Files
FendxPHP/database/migrations/2024_01_15_000003_create_permissions_table.php
Lawson 2782d765fb feat(database): 添加用户角色权限系统及相关监控功能
- 创建用户表(users)包含基本信息和认证字段
- 创建角色表(roles)用于权限控制
- 创建权限表(permissions)定义系统权限
- 创建用户角色关联表(user_roles)建立用户与角色关系
- 创建角色权限关联表(role_permissions)建立角色与权限关系
- 创建迁移记录表(migrations)追踪数据库变更
- 添加AdminController提供管理员面板功能
- 实现系统监控、配置管理、缓存清理等功能
- 添加AOP切面编程支持的各种通知类型
- 实现告警管理AlertManager支持多渠道告警
- 添加文档注解接口规范
2026-04-08 17:00:28 +08:00

40 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use Fendx\Database\Schema\Schema;
use Fendx\Database\Migration;
/**
* 创建权限表
*/
class CreatePermissionsTable extends Migration
{
public function up(): void
{
Schema::create('permissions', function (Schema\Table $table) {
$table->id('id')->primary()->autoIncrement();
$table->string('name', 100)->unique()->comment('权限名称');
$table->string('display_name', 100)->comment('显示名称');
$table->text('description')->nullable()->comment('权限描述');
$table->string('guard_name', 50)->default('web')->comment('守卫名称');
$table->string('group_name', 50)->nullable()->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('group_name');
$table->index('is_active');
$table->index('sort_order');
});
}
public function down(): void
{
Schema::dropIfExists('permissions');
}
}