<?php

use App\Database\Migration;

class CreateHomepageSectionsTable extends Migration
{
    public function up(): void
    {
        $this->db->query("
            CREATE TABLE IF NOT EXISTS iw_homepage_sections (
                id INT AUTO_INCREMENT PRIMARY KEY,
                section_key VARCHAR(50) NOT NULL UNIQUE,
                title VARCHAR(255) DEFAULT NULL,
                content LONGTEXT DEFAULT NULL,
                is_active TINYINT(1) NOT NULL DEFAULT 1,
                sort_order INT NOT NULL DEFAULT 0,
                updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
        ");
    }

    public function down(): void
    {
        $this->db->query("DROP TABLE IF EXISTS iw_homepage_sections");
    }
}
