Files
ulthon_admin/database/migrations/20260527100001_system_timer_log.php
augushong f2f2dcad98 feat(timer): 新增定时任务表的数据库迁移文件
补充 system_timer_config 和 system_timer_log 的数据库迁移,确保全新安装时 migrate:run 能正确建表

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-27 20:22:09 +08:00

50 lines
2.4 KiB
PHP

<?php
use think\migration\Migrator;
class SystemTimerLog extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->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();
}
}