<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('dberp_admin_menu_shortcuts', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('admin_id')->comment('后台用户 users.id')->constrained('users')->cascadeOnDelete();
            $table->string('shortcut_key', 128)->comment('对应 DberpShortcutRegistry 的 key，不存 URL/权限');
            $table->unsignedInteger('sort')->default(0)->comment('侧栏展示顺序，数值越小越靠前');
            $table->timestamps();

            $table->unique(['admin_id', 'shortcut_key'], 'dberp_admin_menu_shortcuts_admin_key_unique');
            $table->index(['admin_id', 'sort'], 'dberp_admin_menu_shortcuts_admin_sort_idx');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('dberp_admin_menu_shortcuts');
    }
};
