<?php

use App\Models\User;
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('grns', function (Blueprint $table) {
            $table->enum('status', ['draft', 'confirmed'])->default('draft')->after('reference');
            $table->foreignId('confirmed_by')->nullable()->constrained('users')->nullOnDelete()->after('updated_by');
            $table->timestamp('confirmed_at')->nullable()->after('confirmed_by');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('grns', function (Blueprint $table) {
            $table->dropColumn('status');
            $table->dropForeignIdFor(User::class, 'confirmed_by');
            $table->dropColumn('confirmed_at');
        });
    }
};
