20260428120014_create_job_locks.php 662 B

123456789101112131415161718192021222324
  1. <?php
  2. declare(strict_types=1);
  3. use App\Infrastructure\Db\Migrations\BaseMigration;
  4. final class CreateJobLocks extends BaseMigration
  5. {
  6. public function change(): void
  7. {
  8. $table = $this->table('job_locks', [
  9. 'id' => false,
  10. 'primary_key' => ['job_name'],
  11. ]);
  12. $table
  13. ->addColumn('job_name', 'string', ['limit' => 64, 'null' => false])
  14. ->addColumn('acquired_by', 'string', ['limit' => 128, 'null' => false]);
  15. $this->addTimestampColumn($table, 'acquired_at');
  16. $this->addTimestampColumn($table, 'expires_at');
  17. $table->addIndex(['expires_at'])->create();
  18. }
  19. }