<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void {
		Schema::create('system_logs', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->unsignedBigInteger('user_id')->comment('用户ID');
			$table->string('title')->comment('日志标题');
			$table->string('name')->comment('日志名称');
			$table->string('url')->comment('请求地址');
			$table->string('method')->comment('请求方法');
			$table->string('client_ip')->nullable()->comment('请求IP');
			$table->text('data')->nullable()->comment('请求数据');
			$table->text('remark')->nullable()->comment('备注');
			$table->text('browser')->nullable()->comment('浏览器');
			$table->tinyInteger('status')->default(1)->comment('状态码');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统日志表');
		});
		Schema::create('system_configs', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('title')->comment('配置标题');
			$table->string('name')->comment('配置名称');
			$table->string('values')->nullable()->comment('配置值');
			$table->string('type')->comment('配置类型');
			$table->string('group')->comment('配置分组');
			$table->jsonb('option')->nullable()->comment('配置选项');
			$table->string('remark')->nullable()->comment('配置备注');
			$table->string('sort')->default(0)->comment('排序');
			$table->tinyInteger('status')->default(1)->comment('状态');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统配置表');
		});
		Schema::create('system_dicts', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('title')->comment('字典标题');
			$table->string('values')->comment('字典值');
			$table->string('group_id')->comment('字典分组');
			$table->string('group_name')->comment('字典分组标识');
			$table->string('sort')->default(0)->comment('排序');
			$table->tinyInteger('status')->default(1)->comment('状态');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统字典表');
		});
		Schema::create('system_dict_groups', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('parent_id')->default(0)->comment('父级id');
			$table->string('title')->comment('字典分组标题');
			$table->string('name')->comment('字典分组名称');
			$table->string('sort')->default(0)->comment('排序');
			$table->tinyInteger('status')->default(1)->comment('状态');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统字典分组表');
		});
		Schema::create('system_areas', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('code')->comment('城市编码');
			$table->string('parent_code')->default(0)->comment('父级id');
			$table->string('title')->comment('城市名称');
			$table->tinyInteger('status')->default(1)->comment('状态');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统城市数据表');
		});

		Schema::create('system_messages', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->unsignedBigInteger('send_uid')->comment('发送人uid');
			$table->string('receive_uid')->comment('接受人uid');
			$table->string('receive_group')->nullable()->comment('接受组');
			$table->string('type')->default(1)->comment('消息类型 1系统消息 2用户消息');
			$table->string('title')->comment('消息标题');
			$table->text('content')->comment('消息内容');
			$table->text('params')->nullable()->comment('消息参数');
			$table->string('url')->nullable()->comment('消息链接');
			$table->string('status')->default(1)->comment('状态 1未读 2已读');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');
			$table->timestamp('read_at')->nullable()->comment('已读时间');
			$table->timestamp('deleted_at')->nullable()->comment('删除时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统消息表');
		});

		Schema::create('system_tasks', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->unsignedBigInteger('user_id')->default(0)->comment('用户id');
			$table->string('title')->comment('任务名称');
			$table->string('file')->comment('文件路径');
			$table->string('type')->default('export')->comment('任务类型 import export');
			$table->string('status')->default(1)->comment('状态 1正常 2禁用');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统excel任务表');
		});
		Schema::create('system_crontabs', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('title')->comment('定时任务标题');
			$table->string('command')->comment('定时任务命令');
			$table->string('expression')->comment('定时任务表达式');
			$table->string('status')->default(1)->comment('状态 1正常 2禁用');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统定时任务表');
		});
		Schema::create('system_client', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('title')->comment('客户端名称');
			$table->string('app_id')->comment('客户端ID');
			$table->string('secret')->comment('客户端密钥');
			$table->string('redirect')->comment('回调地址');
			$table->string('status')->default(1)->comment('状态 1正常 2禁用');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统客户端表');
		});
		Schema::create('system_client_menu', function (Blueprint $table) {
			$table->id()->uniqid()->comment('主键id');
			$table->string('client_id')->comment('客户端ID');
			$table->unsignedBigInteger('parent_id')->default(0)->comment('父级id');
			$table->string('position')->comment('菜单位置');
			$table->string('name')->nullable()->comment('菜单名称标识');
			$table->string('title')->comment('菜单标题');
			$table->string('url')->comment('菜单链接');
			$table->string('cover')->nullable()->comment('菜单图片');
			$table->string('icon')->nullable()->comment('菜单图标');
			$table->string('sort')->default(0)->comment('排序');
			$table->tinyInteger('is_show')->default(1)->comment('是否显示 1显示 2不显示');
			$table->tinyInteger('is_blank')->default(1)->comment('是否新窗口打开 1是 2否');
			$table->string('status')->default(1)->comment('状态 1正常 2禁用');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');

			$table->engine = 'InnoDB';
			$table->charset = 'utf8mb4';
			$table->collation = 'utf8mb4_unicode_ci';
			$table->comment('系统客户端菜单表');
		});

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void {
		Schema::dropIfExists('system_logs');
		Schema::dropIfExists('system_configs');
		Schema::dropIfExists('system_dicts');
		Schema::dropIfExists('system_dict_groups');
		Schema::dropIfExists('system_areas');
		Schema::dropIfExists('system_messages');
		Schema::dropIfExists('system_tasks');
		Schema::dropIfExists('system_crontabs');
		Schema::dropIfExists('system_client');
		Schema::dropIfExists('system_client_menu');
    }
};
