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

            $table->unsignedBigInteger('Role_Id')->nullable()->after('Menu_Id');

            $table->foreign('Role_Id')
                  ->references('Role_Id')
                  ->on('role_master')
                  ->onDelete('set null')
                  ->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('dept_menu_map', function (Blueprint $table) {

            $table->dropForeign(['Role_Id']);
            $table->dropColumn('Role_Id');

        });
    }
};