<?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) {
            // Scope identifies the sub-resource (tab/section) this permission applies to.
            // NULL = menu-level (legacy), non-null = scoped (e.g. 'general', 'login-security').
            $table->string('scope')->nullable()->after('name')->index();
        });
    }

    public function down(): void
    {
        Schema::table('permissions', function (Blueprint $table) {
            $table->dropColumn('scope');
        });
    }
};
