CREATE TABLE `password_reset` (
    `id`         BINARY(16)  NOT NULL,
    `user_id`    BINARY(16)  NOT NULL,
    `token_hash` BINARY(32)  NOT NULL,
    `created_at` DATETIME    NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `expires_at` DATETIME    NOT NULL,
    `used_at`    DATETIME    NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uniq_token_hash` (`token_hash`),
    KEY `idx_user_created` (`user_id`, `created_at`),
    CONSTRAINT `fk_password_reset_user`
        FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
