<?php
/**
 * ITSWEBER CMS – Migration 023: Section Types Registry
 *
 * Creates the iw_section_types table that holds all available
 * section types (core + plugin-provided).
 *
 * @author    Benny Weber (ITSWEBER)
 * @copyright © ITSWEBER – www.itsweber.de
 * @contact   kontakt@itsweber.de
 */

use App\Database\Migration;

class CreateSectionTypes extends Migration
{
    public function up(): void
    {
        $this->db->query("
            CREATE TABLE IF NOT EXISTS iw_section_types (
                id              INT AUTO_INCREMENT PRIMARY KEY,
                type_key        VARCHAR(50)  NOT NULL UNIQUE,
                label           VARCHAR(255) NOT NULL,
                description     VARCHAR(500) DEFAULT '',
                category        ENUM('header','content','media','preview','action','global') DEFAULT 'content',
                icon_svg        TEXT         DEFAULT NULL,
                source          ENUM('core','plugin') DEFAULT 'core',
                plugin_slug     VARCHAR(100) DEFAULT NULL,
                allow_multiple  TINYINT(1)   DEFAULT 1,
                is_available    TINYINT(1)   DEFAULT 1,
                sort_order      INT          DEFAULT 0
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
        ");
    }

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