<?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('archive_settings') && ! Schema::hasColumn('archive_settings', 'reactivate')) {
            Schema::table('archive_settings', function (Blueprint $table): void {
                $table->boolean('reactivate')->default(false)->after('soft');
                $table->index('reactivate');
            });
        }
    }

    public function down(): void
    {
        if (Schema::hasTable('archive_settings') && Schema::hasColumn('archive_settings', 'reactivate')) {
            Schema::table('archive_settings', function (Blueprint $table): void {
                $table->dropIndex(['reactivate']);
                $table->dropColumn('reactivate');
            });
        }
    }
};
