45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 文件功能:创建职务表迁移
|
|||
|
|
* 职务属于某个部门,包含 rank 位阶、对应 user_level、人数上限、奖励上限和展示图标
|
|||
|
|
*
|
|||
|
|
* @author ChatRoom Laravel
|
|||
|
|
*
|
|||
|
|
* @version 1.0.0
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
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('positions', function (Blueprint $table) {
|
|||
|
|
$table->id();
|
|||
|
|
$table->foreignId('department_id')->constrained('departments')->cascadeOnDelete()->comment('所属部门');
|
|||
|
|
$table->string('name', 50)->comment('职务名称');
|
|||
|
|
$table->string('icon', 10)->nullable()->comment('职务图标(emoji),展示在聊天室用户列表');
|
|||
|
|
$table->unsignedTinyInteger('rank')->default(0)->comment('职务位阶(0~99,跨全局排序,99 最高)');
|
|||
|
|
$table->tinyInteger('level')->default(1)->comment('对应 user_level,任命后同步写入 users.user_level');
|
|||
|
|
$table->unsignedTinyInteger('max_persons')->nullable()->comment('人数上限(null=不限)');
|
|||
|
|
$table->unsignedInteger('max_reward')->nullable()->comment('单次奖励上限金币(null=不限)');
|
|||
|
|
$table->tinyInteger('sort_order')->default(0)->comment('后台列表排序');
|
|||
|
|
$table->timestamps();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 回滚:删除职务表
|
|||
|
|
*/
|
|||
|
|
public function down(): void
|
|||
|
|
{
|
|||
|
|
Schema::dropIfExists('positions');
|
|||
|
|
}
|
|||
|
|
};
|