<?php

declare(strict_types=1);

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('maestro_modules') || Schema::hasColumn('maestro_modules', 'is_install_enabled')) {
            return;
        }

        Schema::table('maestro_modules', function (Blueprint $table): void {
            $table->boolean('is_install_enabled')->default(false)->after('label');
        });
    }

    public function down(): void
    {
        if (! Schema::hasTable('maestro_modules') || ! Schema::hasColumn('maestro_modules', 'is_install_enabled')) {
            return;
        }

        Schema::table('maestro_modules', function (Blueprint $table): void {
            $table->dropColumn('is_install_enabled');
        });
    }
};
