<?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('leave_application', function (Blueprint $table) {

            // FK Column
            $table->unsignedBigInteger('R_Status')->nullable()->after('your_existing_column');

            // Status Remark
            $table->text('Status_Remark')->nullable()->after('R_Status');

            // Foreign Key Constraint
            $table->foreign('R_Status')
                  ->references('Act_Id')
                  ->on('action_master')
                  ->onDelete('set null');
        });
    }

    public function down(): void
    {
        Schema::table('leave_application', function (Blueprint $table) {

            $table->dropForeign(['R_Status']);
            $table->dropColumn(['R_Status', 'Status_Remark']);
        });
    }
};
