<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        // SQLite doesn't support ENUM or MODIFY COLUMN — skip on SQLite.
        // The position column is already a string in SQLite and accepts any value.
        if (DB::getDriverName() === 'sqlite') {
            return;
        }

        // Expand position column for MySQL/MariaDB to support all 4 menu positions
        DB::statement("ALTER TABLE navigation_menus MODIFY COLUMN position ENUM('header','mobile','sticky_bar','footer') NOT NULL DEFAULT 'header'");
    }

    public function down(): void
    {
        if (DB::getDriverName() === 'sqlite') {
            return;
        }

        // Revert existing mobile/sticky_bar rows before shrinking the enum
        DB::statement("UPDATE navigation_menus SET position = 'header' WHERE position IN ('mobile','sticky_bar')");
        DB::statement("ALTER TABLE navigation_menus MODIFY COLUMN position ENUM('header','footer') NOT NULL DEFAULT 'header'");
    }
};
