<?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
    {
        Schema::table('inward_gate_passes', function (Blueprint $table) {
            if (!Schema::hasColumn('inward_gate_passes', 'status')) {
                // 'created_by' may not exist; avoid explicit positioning
                $table->enum('status', ['issued', 'cancelled'])->default('issued');
                $table->index(['status']);
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('inward_gate_passes', function (Blueprint $table) {
            $table->dropIndex(['status']);
            $table->dropColumn('status');
        });
    }
};
