<?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('dsg_pay_map', function (Blueprint $table) {
            $table->unsignedBigInteger('PRB_id')->nullable()->after('PL_Id');

            $table->foreign('PRB_id', 'fk_dsg_payroll_bill')
                ->references('PRB_id')
                ->on('payroll_bills')
                ->cascadeOnUpdate()
                ->restrictOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('dsg_pay_map', function (Blueprint $table) {
            $table->dropForeign('fk_dsg_payroll_bill');
            $table->dropColumn('PRB_id');
        });
    }
};
