-- Panel şifre geçmişi: son N şifrenin tekrar kullanımını engeller (admin_apply_new_password).
-- Bir kez çalıştırın.

USE faunamix;

CREATE TABLE IF NOT EXISTS admin_password_history (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  admin_user_id INT UNSIGNED NOT NULL,
  password_hash VARCHAR(255) NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_admin_pwd_hist_user_id (admin_user_id),
  KEY idx_admin_pwd_hist_user_created (admin_user_id, id),
  CONSTRAINT fk_admin_pwd_hist_user FOREIGN KEY (admin_user_id) REFERENCES admin_users (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
