<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (Schema::hasTable('countries')) {
            Schema::table('countries', function (Blueprint $table) {
                // Check if the column does not already exist
                if (!Schema::hasColumn('countries', 'status')) {
                    $table->integer('status')->default(0)->comment('0: Inactive, 1: Active');
                }
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasTable('countries')) {
            Schema::table('countries', function (Blueprint $table) {
                // Check if the column exists before dropping
                if (Schema::hasColumn('countries', 'status')) {
                    $table->dropColumn('status');
                }
            });
        }
    }
};
