Skip to content

Commit

Permalink
Add db migration (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
aphraoh committed Apr 16, 2024
1 parent c6b76d3 commit 12428e7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^5.20"
},
"suggest": {
"yiisoft/db": "For using with Yii Database",
"yiisoft/db-migration": "For automating schema migration"
},
"autoload": {
"psr-4": {
"Yiisoft\\Queue\\Db\\": "src"
Expand Down
40 changes: 40 additions & 0 deletions migrations/M240409200600CreateQueueTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

use Yiisoft\Db\Migration\MigrationBuilder;
use Yiisoft\Db\Migration\RevertibleMigrationInterface;
use Yiisoft\Db\Migration\TransactionalMigrationInterface;

final class M240409200600CreateQueueTable implements RevertibleMigrationInterface, TransactionalMigrationInterface
{
private const QUEUE_TABLE = 'queue';

public function up(MigrationBuilder $b): void
{
$b->createTable(
self::QUEUE_TABLE,
[
'id' => 'int NOT NULL AUTO_INCREMENT',
'channel' => 'varchar(255) NOT NULL',
'job' => 'blob NOT NULL',
'pushed_at' => 'int NOT NULL',
'ttr' => 'int NOT NULL',
'delay' => 'int NOT NULL DEFAULT 0',
'priority' => 'int UNSIGNED NOT NULL DEFAULT 1024',
'reserved_at' => 'int DEFAULT NULL',
'attempt' => 'int DEFAULT NULL',
'done_at' => 'int DEFAULT NULL',
'PRIMARY KEY ([[id]])',
'KEY channel ([[channel]])',
'KEY reserved_at ([[reserved_at]])',
'KEY priority ([[priority]])',
],
);
}

public function down(MigrationBuilder $b): void
{
$b->dropTable(self::QUEUE_TABLE);
}
}

0 comments on commit 12428e7

Please sign in to comment.