<?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('trans_demand', function (Blueprint $table) {
            $table->unsignedBigInteger('Approved_By')->nullable()->after('Status');

            $table->foreign('Approved_By')
                  ->references('Usr_Id')
                  ->on('user_master')
                  ->onDelete('set null')
                  ->onUpdate('cascade');
        });
    }

    public function down(): void
    {
        Schema::table('trans_demand', function (Blueprint $table) {
            $table->dropForeign(['Approved_By']);
            $table->dropColumn('Approved_By');
        });
    }
};
