<?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::create('ms_access_menu', function (Blueprint $table) {
            $table->id('MsAccessMenuId');
            $table->foreignId('ms_group_id')->comment('FK ms group');
            $table->string('module', 150)->nullable();
            $table->foreignId('ms_menu_id')->comment('FK tb_menu');
            $table->string('menu_group', 20)->nullable()->default('adminsidebar');
            $table->boolean('is_create')->default(false);
            $table->boolean('is_read')->default(false);
            $table->boolean('is_update')->default(false);
            $table->boolean('is_delete')->default(false);
            $table->boolean('is_verify')->default(false);
            $table->boolean('is_approve')->default(false);
            $table->boolean('is_download')->default(false);
            $table->json('access')->nullable();
            $table->timestamps();
            $table->foreign('ms_menu_id')->references('MsMenuId')->on('ms_menu')->cascadeOnDelete();
            $table->foreign('ms_group_id')->references('MsGroupId')->on('ms_group')->cascadeOnDelete();
            $table->comment('Master hak akses role/group user');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('access_menus');
    }
};
