-- Adds the "forgot password" feature (admin/forgot_password.php,
-- admin/reset_password.php). Safe to run on an existing installation;
-- already included in sql/schema.sql for fresh installs.

CREATE TABLE IF NOT EXISTS admin_password_resets (
    id            INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    admin_user_id INT UNSIGNED NOT NULL,
    token_hash    CHAR(64) NOT NULL UNIQUE,
    created_at    DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    expires_at    DATETIME NOT NULL,
    used_at       DATETIME NULL,
    CONSTRAINT fk_password_reset_admin FOREIGN KEY (admin_user_id) REFERENCES admin_users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
