From f2f2dcad98757cd47a6a30b5a90971fe9c55451f Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 27 May 2026 20:22:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(timer):=20=E6=96=B0=E5=A2=9E=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E8=A1=A8=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补充 system_timer_config 和 system_timer_log 的数据库迁移,确保全新安装时 migrate:run 能正确建表 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../20260527100000_system_timer_config.php | 44 +++++++++++++++++ .../20260527100001_system_timer_log.php | 49 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 database/migrations/20260527100000_system_timer_config.php create mode 100644 database/migrations/20260527100001_system_timer_log.php diff --git a/database/migrations/20260527100000_system_timer_config.php b/database/migrations/20260527100000_system_timer_config.php new file mode 100644 index 0000000..d45edf8 --- /dev/null +++ b/database/migrations/20260527100000_system_timer_config.php @@ -0,0 +1,44 @@ +table('system_timer_config') + ->setComment('定时任务协调配置表') + ->addColumn('task_name', 'string', ['limit' => 100, 'null' => false, 'comment' => '任务名称']) + ->addColumn('run_type', 'string', ['limit' => 20, 'default' => 'auto', 'comment' => '运行类型:main/auto/all/manual']) + ->addColumn('status', 'integer', ['limit' => 4, 'null' => false, 'default' => 1, 'comment' => '状态:0=停用,1=启用']) + ->addColumn('is_synced', 'integer', ['limit' => 4, 'null' => false, 'default' => 0, 'comment' => '是否已同步:0=未同步,1=已同步']) + ->addColumn('last_execute_node', 'string', ['limit' => 100, 'null' => true, 'comment' => '最后执行节点ID']) + ->addColumn('last_execute_time', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '最后执行时间戳', 'signed' => false]) + ->addColumn('manual_trigger', 'integer', ['limit' => 4, 'null' => false, 'default' => 0, 'comment' => '手动触发标记:0=未触发,1=已触发']) + ->addColumn('create_time', 'integer', ['limit' => 11, 'comment' => '创建时间', 'signed' => false]) + ->addColumn('update_time', 'integer', ['limit' => 11, 'comment' => '更新时间', 'signed' => false]) + ->addIndex('task_name', ['unique' => true]) + ->create(); + } +} diff --git a/database/migrations/20260527100001_system_timer_log.php b/database/migrations/20260527100001_system_timer_log.php new file mode 100644 index 0000000..7a4fa05 --- /dev/null +++ b/database/migrations/20260527100001_system_timer_log.php @@ -0,0 +1,49 @@ +table('system_timer_log') + ->setComment('定时器执行日志表') + ->addColumn('task_name', 'string', ['limit' => 100, 'null' => false, 'comment' => '任务名称']) + ->addColumn('node_id', 'string', ['limit' => 100, 'null' => false, 'comment' => '执行节点ID']) + ->addColumn('run_type', 'string', ['limit' => 20, 'null' => true, 'comment' => '运行类型']) + ->addColumn('start_time', 'integer', ['limit' => 11, 'null' => false, 'comment' => '开始时间戳', 'signed' => false]) + ->addColumn('end_time', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '结束时间戳', 'signed' => false]) + ->addColumn('duration', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '耗时(毫秒)', 'signed' => false]) + ->addColumn('status', 'string', ['limit' => 20, 'default' => 'running', 'comment' => '状态:running/success/error']) + ->addColumn('error_message', 'text', ['null' => true, 'comment' => '错误信息']) + ->addColumn('result', 'text', ['null' => true, 'comment' => '执行结果(任务返回值)']) + ->addColumn('concurrency_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '并发分片ID']) + ->addColumn('create_time', 'integer', ['limit' => 11, 'comment' => '创建时间', 'signed' => false]) + ->addIndex('task_name', ['name' => 'idx_task_name']) + ->addIndex('node_id', ['name' => 'idx_node_id']) + ->addIndex('start_time', ['name' => 'idx_start_time']) + ->addIndex('status', ['name' => 'idx_status']) + ->create(); + } +}