-- Footer menü (header’dan bağımsız tablo).
-- Tek sefer çalıştırın; tablo varsa CREATE IF NOT EXISTS atlar.
USE faunamix;

CREATE TABLE IF NOT EXISTS footer_menu_items (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  parent_id INT UNSIGNED NULL DEFAULT NULL,
  sort_order INT NOT NULL DEFAULT 0,
  title VARCHAR(128) NOT NULL,
  url VARCHAR(512) NOT NULL,
  open_new_tab TINYINT(1) NOT NULL DEFAULT 0,
  is_active TINYINT(1) NOT NULL DEFAULT 1,
  show_in_footer TINYINT(1) NOT NULL DEFAULT 1,
  variant ENUM('link', 'button') NOT NULL DEFAULT 'link',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_footer_parent_sort (parent_id, sort_order),
  CONSTRAINT fk_footer_menu_parent
    FOREIGN KEY (parent_id) REFERENCES footer_menu_items (id)
    ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
