<?php

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

return new class extends Migration {
    public function up()
    {
        Schema::table('ledger_master', function (Blueprint $table) {
            $table->unsignedBigInteger('GT_Id')->nullable()->after('Lg_Id');

            // Foreign Key
            $table->foreign('GT_Id')
                  ->references('GT_Id')
                  ->on('grant_type_master')
                  ->onDelete('cascade');
        });
    }

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