<?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
    {
        Schema::table('import_templates', function (Blueprint $table) {
            if (! Schema::hasColumn('import_templates', 'reactivate')) {
                $table->boolean('reactivate')->default(false)->after('is_active');
            }
        });
        Schema::table('imports', function (Blueprint $table) {
            if (! Schema::hasColumn('imports', 'reactivate')) {
                $table->boolean('reactivate')->default(false)->after('status');
            }
        });
    }

    public function down(): void
    {
        Schema::table('import_templates', function (Blueprint $table) {
            if (Schema::hasColumn('import_templates', 'reactivate')) {
                $table->dropColumn('reactivate');
            }
        });
        Schema::table('imports', function (Blueprint $table) {
            if (Schema::hasColumn('imports', 'reactivate')) {
                $table->dropColumn('reactivate');
            }
        });
    }
};
