<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        if (Schema::hasTable('block_registry_template_assignments')) {
            Schema::table('block_registry_template_assignments', function (Blueprint $table) {
                if (!Schema::hasColumn('block_registry_template_assignments', 'is_default')) {
                    $table->boolean('is_default')->default(false);
                }
                if (!Schema::hasColumn('block_registry_template_assignments', 'order_index')) {
                    $table->integer('order_index')->default(0);
                }
                if (!Schema::hasColumn('block_registry_template_assignments', 'created_at')) {
                    $table->timestamps();
                }
            });
        }
    }

    public function down(): void
    {
        // Not reversing
    }
};
