20260713000000_create_queue_job_log.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. use Phinx\Migration\AbstractMigration;
  4. class CreateQueueJobLog extends AbstractMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('queue_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' => 200,
  21. 'null' => false,
  22. 'comment' => '任务类名'
  23. ])->addColumn('connection', 'string', [
  24. 'limit' => 50,
  25. 'null' => false,
  26. 'comment' => '队列连接'
  27. ])->addColumn('queue', 'string', [
  28. 'limit' => 255,
  29. 'null' => false,
  30. 'comment' => '队列名称'
  31. ])->addColumn('attempts', 'integer', [
  32. 'default' => 1,
  33. 'signed' => false,
  34. 'comment' => '当前第几次尝试'
  35. ])->addColumn('duration', 'decimal', [
  36. 'precision' => 10,
  37. 'scale' => 4,
  38. 'default' => 0,
  39. 'comment' => '执行耗时(秒)'
  40. ])->addColumn('success', 'boolean', [
  41. 'default' => true,
  42. 'comment' => '是否成功'
  43. ])->addColumn('exception', 'text', [
  44. 'null' => true,
  45. 'comment' => '异常信息'
  46. ])->addTimestamps('create_time', false)
  47. ->addIndex(['name', 'id'], [
  48. 'name' => 'idx_name_id'
  49. ])->addIndex(['create_time'], [
  50. 'name' => 'idx_create_time'
  51. ])->create();
  52. }
  53. }