Files
FendxPHP/database/migrations/2024_01_15_000002_create_roles_table.php

38 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Fendx\Database\Schema\Schema;
use Fendx\Database\Migration;
/**
* 创建角色表
*/
class CreateRolesTable extends Migration
{
public function up(): void
{
Schema::create('roles', function (Schema\Table $table) {
$table->id('id')->primary()->autoIncrement();
$table->string('name', 50)->unique()->comment('角色名称');
$table->string('display_name', 100)->comment('显示名称');
$table->text('description')->nullable()->comment('角色描述');
$table->string('guard_name', 50)->default('web')->comment('守卫名称');
$table->boolean('is_active')->default(true)->comment('是否激活');
$table->integer('sort_order')->default(0)->comment('排序');
$table->timestamp('created_at')->useCurrent()->comment('创建时间');
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate()->comment('更新时间');
// 索引
$table->index('name');
$table->index('guard_name');
$table->index('is_active');
$table->index('sort_order');
});
}
public function down(): void
{
Schema::dropIfExists('roles');
}
}