<?php

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('permissions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('parent_id')->default(0)->comment('上级权限');
            $table->string('name', 50)->comment('权限名称');
            $table->string('code', 100)->unique()->comment('权限标识 如 crm.lead.create');
            $table->string('module', 50)->nullable()->comment('所属模块');
            $table->tinyInteger('type')->default(1)->comment('1菜单 2按钮 3接口');
            $table->string('description', 255)->nullable();
            $table->integer('sort')->default(0);
            $table->timestamps();
        });
    }

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