-- Site sayfaları (panelden yönetim, path = vitrin URL’i; max 1 alt seviye parent_id).
-- Tek sefer çalıştırın.
USE faunamix;

CREATE TABLE IF NOT EXISTS site_pages (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  parent_id INT UNSIGNED NULL DEFAULT NULL,
  sort_order INT NOT NULL DEFAULT 0,
  path VARCHAR(255) NOT NULL,
  title VARCHAR(255) NOT NULL,
  short_title VARCHAR(255) NULL DEFAULT NULL,
  excerpt TEXT NULL,
  image_url VARCHAR(512) NULL DEFAULT NULL,
  cover_url VARCHAR(512) NULL DEFAULT NULL,
  body_html MEDIUMTEXT NULL,
  meta_title VARCHAR(255) NULL DEFAULT NULL,
  meta_keywords VARCHAR(512) NULL DEFAULT NULL,
  meta_description TEXT NULL,
  is_active TINYINT(1) NOT NULL DEFAULT 1,
  legal_review_confirmed TINYINT(1) NOT NULL DEFAULT 0,
  legal_review_note VARCHAR(1024) NOT NULL DEFAULT '',
  legal_review_confirmed_at DATETIME NULL DEFAULT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  UNIQUE KEY uq_site_pages_path (path),
  KEY idx_site_pages_parent_sort (parent_id, sort_order),
  CONSTRAINT fk_site_pages_parent FOREIGN KEY (parent_id) REFERENCES site_pages(id)
    ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
