<?php
declare(strict_types=1);
require __DIR__ . '/../../config/bootstrap.php';

use App\Core\Database;

$db = Database::getInstance();

$db->exec("
CREATE TABLE IF NOT EXISTS conference_homepage_blocks (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  conference_id BIGINT UNSIGNED NOT NULL,
  block_type ENUM('hero_slide','panel','topic','section_html','important_date','committee') NOT NULL,
  block_key VARCHAR(120) DEFAULT NULL,
  title_en VARCHAR(255) DEFAULT NULL,
  title_ar VARCHAR(255) DEFAULT NULL,
  body_en LONGTEXT DEFAULT NULL,
  body_ar LONGTEXT DEFAULT NULL,
  image_path VARCHAR(255) DEFAULT NULL,
  link_url VARCHAR(500) DEFAULT NULL,
  sort_order INT NOT NULL DEFAULT 0,
  is_active TINYINT(1) NOT NULL DEFAULT 1,
  created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_conf (conference_id),
  KEY idx_type (block_type),
  KEY idx_active (is_active),
  CONSTRAINT fk_chb_conf FOREIGN KEY (conference_id) REFERENCES conferences(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");

echo "OK: conference_homepage_blocks ready\n";
