20260710140000_create_cron_job_log.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. 'id' => false,
  13. 'primary_key' => ['id'],
  14. ]);
  15. $table->addColumn('id', 'biginteger', [
  16. 'identity' => true,
  17. 'signed' => false,
  18. 'comment' => '主键'
  19. ])->addColumn('name', 'string', [
  20. 'limit' => 100,
  21. 'null' => false,
  22. 'comment' => '任务名称'
  23. ])->addColumn('rule', 'string', [
  24. 'limit' => 50,
  25. 'null' => false,
  26. 'comment' => 'cron规则'
  27. ])->addColumn('duration', 'decimal', [
  28. 'precision' => 10,
  29. 'scale' => 4,
  30. 'default' => 0,
  31. 'comment' => '执行耗时(秒)'
  32. ])->addColumn('success', 'boolean', [
  33. 'default' => true,
  34. 'comment' => '是否成功'
  35. ])->addTimestamps('create_time', false)
  36. ->addIndex(['name', 'id'], [
  37. 'name' => 'idx_name_id'
  38. ])->create();
  39. }
  40. }