20260710140000_create_cron_job_log.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class CreateCronJobLog extends AbstractMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('cron_job_log', [
  9. 'comment' => '定时任务执行日志',
  10. 'engine' => 'InnoDB',
  11. 'collation' => 'utf8mb4_general_ci',
  12. ]);
  13. $table->addColumn('name', 'string', [
  14. 'limit' => 100,
  15. 'null' => false,
  16. 'comment' => '任务名称'
  17. ])->addColumn('rule', 'string', [
  18. 'limit' => 50,
  19. 'null' => false,
  20. 'comment' => 'cron规则'
  21. ])->addColumn('duration', 'decimal', [
  22. 'precision' => 10,
  23. 'scale' => 4,
  24. 'default' => 0,
  25. 'comment' => '执行耗时(秒)'
  26. ])->addColumn('success', 'boolean', [
  27. 'default' => true,
  28. 'comment' => '是否成功'
  29. ])->addTimestamps('create_time', false)
  30. ->addIndex(['name', 'id'], [
  31. 'name' => 'idx_name_id'
  32. ])->create();
  33. }
  34. }