<?php

/**
 * Migration 038 – Add frontend enhancement settings
 *
 * Adds settings for sticky header and scroll animations.
 * Both default to OFF (opt-in).
 */

use App\Database\Migration;

class AddFrontendEnhancementSettings extends Migration
{
    public function up(): void
    {
        $settings = [
            ['setting_key' => 'sticky_header_enabled',      'setting_value' => '0', 'setting_group' => 'general'],
            ['setting_key' => 'scroll_animations_enabled',  'setting_value' => '0', 'setting_group' => 'general'],
        ];

        foreach ($settings as $s) {
            $existing = $this->db->fetch(
                "SELECT id FROM iw_settings WHERE setting_key = :key LIMIT 1",
                ['key' => $s['setting_key']]
            );
            if (!$existing) {
                $this->db->insert('iw_settings', $s);
            }
        }
    }

    public function down(): void
    {
        $this->db->query("DELETE FROM iw_settings WHERE setting_key IN ('sticky_header_enabled', 'scroll_animations_enabled')");
    }
}
