<?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('permissions', function (Blueprint $table) {
            //add columns
            $table->string('permission_type')->nullable();
            $table->string('description')->nullable();
            // Add foreign key column and set up the foreign key constraint
            $table->unsignedBigInteger('service_group_id')->nullable();
            $table->foreign('service_group_id')->references('id')
                ->on('iprs_new_service_groups')
                ->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('permissions', function (Blueprint $table) {
            //
            $table->dropColumn('permission_type');
            $table->dropColumn('description');
            $table->dropColumn('service_group_id');
        });
    }
};
