<?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('requisition_masters', function (Blueprint $table) {
            $table->unsignedBigInteger('contact_person_id')->nullable()->after('department_id');
            $table->foreign('contact_person_id')->references('id')->on('client_contact_persons')->onDelete('set null');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('requisition_masters', function (Blueprint $table) {
            $table->dropForeign(['contact_person_id']);
            $table->dropColumn('contact_person_id');
        });
    }
};
