id()->comment('主键'); $table->string('name', 50)->unique()->comment('角色标识'); $table->string('label', 100)->comment('显示名称'); $table->text('description')->nullable()->comment('描述'); $table->timestampsTz(); }); // 种子数据 $now = \Carbon\Carbon::now(); \Hyperf\DbConnection\Db::table('roles')->insert([ ['name' => 'administrator', 'label' => '超级管理员', 'description' => '拥有系统全部权限', 'created_at' => $now, 'updated_at' => $now], ['name' => 'developer', 'label' => '开发者', 'description' => '数据维护者,拥有所维护平台的全部数据权限', 'created_at' => $now, 'updated_at' => $now], ['name' => 'accessor', 'label' => '数据访问者', 'description' => '按授权范围访问数据,可作为 API 调用用户', 'created_at' => $now, 'updated_at' => $now], ]); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('roles'); } };