-- Mağaza müşterisi şifre sıfırlama (e-posta + 6 haneli kod). idempotent

CREATE TABLE IF NOT EXISTS shop_password_resets (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  shop_customer_id BIGINT UNSIGNED NOT NULL,
  code_hash VARCHAR(255) NOT NULL,
  expires_at DATETIME NOT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_shop_pwd_reset_customer (shop_customer_id),
  KEY idx_shop_pwd_reset_expires (expires_at),
  CONSTRAINT fk_shop_pwd_reset_customer FOREIGN KEY (shop_customer_id) REFERENCES shop_customers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
