USE mjpos_db;

CREATE TABLE IF NOT EXISTS `password_resets` (
  `id`         int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id`    int(10) unsigned NOT NULL,
  `token`      varchar(64)      NOT NULL,
  `expires_at` datetime         NOT NULL,
  `used`       tinyint(1)       NOT NULL DEFAULT 0,
  `created_at` timestamp        NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `token` (`token`),
  KEY `idx_pwreset_user` (`user_id`),
  CONSTRAINT `fk_pwreset_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
