<?php
declare(strict_types=1);

use App\Core\Database;

return function (Database $db): void {
    $db->raw("
        CREATE TABLE news_articles (
            id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            title_ar VARCHAR(300) NOT NULL,
            body_ar TEXT NOT NULL,
            category ENUM('match','facility','announcement','schedule','general') NOT NULL DEFAULT 'general',
            cover_image_path VARCHAR(500) NULL,
            related_match_id BIGINT UNSIGNED NULL,
            related_facility_id BIGINT UNSIGNED NULL,
            is_published TINYINT(1) NOT NULL DEFAULT 0,
            published_at DATETIME NULL,
            created_by BIGINT UNSIGNED NULL,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            INDEX idx_news_published (is_published, published_at)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ");
};
