调整数据库表的单复数
This commit is contained in:
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
// 管理员表
|
||||
Schema::create('auth_users', function (Blueprint $table) {
|
||||
Schema::create('auth_user', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('username', 50)->unique()->comment('用户名');
|
||||
$table->string('password')->comment('密码');
|
||||
@@ -32,7 +32,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 部门表
|
||||
Schema::create('auth_departments', function (Blueprint $table) {
|
||||
Schema::create('auth_department', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100)->comment('部门名称');
|
||||
$table->unsignedBigInteger('parent_id')->default(0)->comment('父部门ID');
|
||||
@@ -48,7 +48,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 角色表
|
||||
Schema::create('auth_roles', function (Blueprint $table) {
|
||||
Schema::create('auth_role', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50)->unique()->comment('角色名称');
|
||||
$table->string('code', 50)->unique()->comment('角色编码');
|
||||
@@ -62,7 +62,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 权限表
|
||||
Schema::create('auth_permissions', function (Blueprint $table) {
|
||||
Schema::create('auth_permission', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 100)->comment('权限标题');
|
||||
$table->string('name', 100)->unique()->comment('权限编码');
|
||||
@@ -114,9 +114,9 @@ return new class extends Migration
|
||||
{
|
||||
Schema::dropIfExists('auth_role_permission');
|
||||
Schema::dropIfExists('auth_user_role');
|
||||
Schema::dropIfExists('auth_permissions');
|
||||
Schema::dropIfExists('auth_roles');
|
||||
Schema::dropIfExists('auth_departments');
|
||||
Schema::dropIfExists('auth_users');
|
||||
Schema::dropIfExists('auth_permission');
|
||||
Schema::dropIfExists('auth_role');
|
||||
Schema::dropIfExists('auth_department');
|
||||
Schema::dropIfExists('auth_user');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ return new class extends Migration
|
||||
public function up()
|
||||
{
|
||||
// 系统配置表
|
||||
Schema::create('system_configs', function (Blueprint $table) {
|
||||
Schema::create('system_setting', function (Blueprint $table) {
|
||||
$table->comment('系统配置表');
|
||||
$table->id();
|
||||
$table->string('group')->comment('配置分组');
|
||||
@@ -32,7 +32,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 系统日志表
|
||||
Schema::create('system_logs', function (Blueprint $table) {
|
||||
Schema::create('system_log', function (Blueprint $table) {
|
||||
$table->comment('系统日志表');
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->nullable()->comment('用户ID');
|
||||
@@ -58,7 +58,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 系统字典表
|
||||
Schema::create('system_dictionaries', function (Blueprint $table) {
|
||||
Schema::create('system_dictionary', function (Blueprint $table) {
|
||||
$table->comment('系统字典表');
|
||||
$table->id();
|
||||
$table->string('name')->comment('字典名称');
|
||||
@@ -72,7 +72,7 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 系统字典项表
|
||||
Schema::create('system_dictionary_items', function (Blueprint $table) {
|
||||
Schema::create('system_dictionary_item', function (Blueprint $table) {
|
||||
$table->comment('系统字典项表');
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('dictionary_id')->comment('字典ID');
|
||||
@@ -85,12 +85,12 @@ return new class extends Migration
|
||||
$table->integer('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('dictionary_id')->references('id')->on('system_dictionaries')->onDelete('cascade');
|
||||
$table->foreign('dictionary_id')->references('id')->on('system_dictionary')->onDelete('cascade');
|
||||
$table->index('dictionary_id');
|
||||
});
|
||||
|
||||
// 系统任务表
|
||||
Schema::create('system_tasks', function (Blueprint $table) {
|
||||
Schema::create('system_task', function (Blueprint $table) {
|
||||
$table->comment('系统任务表');
|
||||
$table->id();
|
||||
$table->string('name')->comment('任务名称');
|
||||
@@ -115,32 +115,54 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
// 系统城市表
|
||||
Schema::create('system_cities', function (Blueprint $table) {
|
||||
Schema::create('system_city', function (Blueprint $table) {
|
||||
$table->comment('系统城市表');
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
|
||||
$table->string('name')->comment('城市名称');
|
||||
$table->string('title')->comment('城市名称');
|
||||
$table->string('code')->unique()->comment('城市编码');
|
||||
$table->string('pinyin')->nullable()->comment('拼音');
|
||||
$table->string('pinyin_short')->nullable()->comment('拼音首字母');
|
||||
$table->integer('level')->default(1)->comment('级别:1=省,2=市,3=区/县');
|
||||
$table->integer('sort')->default(0)->comment('排序');
|
||||
$table->boolean('status')->default(true)->comment('状态');
|
||||
$table->string('parent_code')->nullable()->comment('父级编码');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('parent_id');
|
||||
$table->index('code');
|
||||
$table->index('level');
|
||||
$table->index('parent_code');
|
||||
});
|
||||
|
||||
// 系统通知表
|
||||
Schema::create('system_notification', function (Blueprint $table) {
|
||||
$table->comment('系统通知表');
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->comment('用户ID');
|
||||
$table->string('title')->comment('通知标题');
|
||||
$table->text('content')->comment('通知内容');
|
||||
$table->string('type')->default('info')->comment('通知类型:info, success, warning, error, task, system');
|
||||
$table->string('category')->nullable()->comment('通知分类:system, task, message, reminder, announcement');
|
||||
$table->json('data')->nullable()->comment('附加数据(JSON格式)');
|
||||
$table->string('action_type')->nullable()->comment('操作类型:link, modal, none');
|
||||
$table->text('action_data')->nullable()->comment('操作数据');
|
||||
$table->boolean('is_read')->default(false)->comment('是否已读');
|
||||
$table->timestamp('read_at')->nullable()->comment('阅读时间');
|
||||
$table->boolean('sent_via_websocket')->default(false)->comment('是否已通过WebSocket发送');
|
||||
$table->timestamp('sent_at')->nullable()->comment('发送时间');
|
||||
$table->integer('retry_count')->default(0)->comment('重试次数');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('user_id');
|
||||
$table->index('is_read');
|
||||
$table->index('type');
|
||||
$table->index('category');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('system_dictionary_items');
|
||||
Schema::dropIfExists('system_dictionaries');
|
||||
Schema::dropIfExists('system_configs');
|
||||
Schema::dropIfExists('system_logs');
|
||||
Schema::dropIfExists('system_tasks');
|
||||
Schema::dropIfExists('system_cities');
|
||||
Schema::dropIfExists('system_notification');
|
||||
Schema::dropIfExists('system_dictionary_item');
|
||||
Schema::dropIfExists('system_dictionary');
|
||||
Schema::dropIfExists('system_setting');
|
||||
Schema::dropIfExists('system_log');
|
||||
Schema::dropIfExists('system_task');
|
||||
Schema::dropIfExists('system_city');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
// 系统通知表
|
||||
Schema::create('system_notifications', function (Blueprint $table) {
|
||||
$table->comment('系统通知表');
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->comment('用户ID');
|
||||
$table->string('title')->comment('通知标题');
|
||||
$table->text('content')->comment('通知内容');
|
||||
$table->string('type')->default('info')->comment('通知类型:info, success, warning, error, task, system');
|
||||
$table->string('category')->nullable()->comment('通知分类:system, task, message, reminder, announcement');
|
||||
$table->json('data')->nullable()->comment('附加数据(JSON格式)');
|
||||
$table->string('action_type')->nullable()->comment('操作类型:link, modal, none');
|
||||
$table->text('action_data')->nullable()->comment('操作数据');
|
||||
$table->boolean('is_read')->default(false)->comment('是否已读');
|
||||
$table->timestamp('read_at')->nullable()->comment('阅读时间');
|
||||
$table->boolean('sent_via_websocket')->default(false)->comment('是否已通过WebSocket发送');
|
||||
$table->timestamp('sent_at')->nullable()->comment('发送时间');
|
||||
$table->integer('retry_count')->default(0)->comment('重试次数');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('user_id');
|
||||
$table->index('is_read');
|
||||
$table->index('type');
|
||||
$table->index('category');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('system_notifications');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user