<?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('leadership_ranks')) {
            return;
        }

        Schema::table('leadership_ranks', function (Blueprint $table) {
            $table->boolean('include_level2_verified')->default(false)->after('need_verified_members');
            $table->boolean('include_level3_verified')->default(false)->after('include_level2_verified');
            $table->integer('need_level3_members')->default(0)->after('include_level3_verified');
        });
    }

    public function down(): void
    {
        if (!Schema::hasTable('leadership_ranks')) {
            return;
        }

        Schema::table('leadership_ranks', function (Blueprint $table) {
            if (Schema::hasColumn('leadership_ranks','need_level3_members')) {
                $table->dropColumn('need_level3_members');
            }
            if (Schema::hasColumn('leadership_ranks','include_level3_verified')) {
                $table->dropColumn('include_level3_verified');
            }
            if (Schema::hasColumn('leadership_ranks','include_level2_verified')) {
                $table->dropColumn('include_level2_verified');
            }
        });
    }
};
