<?php
/**
 * ITSWEBER CMS – Migration 025: Plugin Settings
 *
 * Creates the iw_plugin_settings table for section/plugin
 * configuration storage (e.g. Site Notice settings).
 *
 * @author    Benny Weber (ITSWEBER)
 * @copyright © ITSWEBER – www.itsweber.de
 * @contact   kontakt@itsweber.de
 */

use App\Database\Migration;

class CreatePluginSettings extends Migration
{
    public function up(): void
    {
        $this->db->query("
            CREATE TABLE IF NOT EXISTS iw_plugin_settings (
                id              INT AUTO_INCREMENT PRIMARY KEY,
                plugin_slug     VARCHAR(100) NOT NULL,
                setting_key     VARCHAR(100) NOT NULL,
                setting_value   LONGTEXT     DEFAULT NULL,
                created_at      DATETIME     DEFAULT CURRENT_TIMESTAMP,
                updated_at      DATETIME     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                UNIQUE KEY plugin_setting (plugin_slug, setting_key)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
        ");
    }

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