|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use yii\db\Migration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Handles the creation of table `queue`. |
|
7
|
|
|
*/ |
|
8
|
|
|
class m180305_014442_create_queue_table extends Migration |
|
9
|
|
|
{ |
|
10
|
|
|
public $tableName = '{{%queue}}'; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* {@inheritdoc} |
|
14
|
|
|
*/ |
|
15
|
|
|
public function safeUp() |
|
16
|
|
|
{ |
|
17
|
|
|
$tableOptions = null; |
|
18
|
|
|
if ($this->db->driverName === 'mysql') { |
|
19
|
|
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
|
20
|
|
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
$this->createTable($this->tableName, [ |
|
24
|
|
|
'id' => $this->bigPrimaryKey(), |
|
25
|
|
|
'channel' => $this->string()->notNull(), |
|
26
|
|
|
'job' => $this->binary()->notNull(), |
|
27
|
|
|
'pushed_at' => $this->integer()->unsigned()->notNull(), |
|
28
|
|
|
'ttr'=>$this->integer()->notNull()->unsigned(), |
|
29
|
|
|
'delay' => $this->integer()->unsigned()->defaultValue(0)->notNull(), |
|
30
|
|
|
'priority'=>$this->integer()->unsigned()->notNull()->defaultValue(1024), |
|
31
|
|
|
'reserved_at' => $this->integer()->unsigned(), |
|
32
|
|
|
'attempt'=>$this->integer()->unsigned(), |
|
33
|
|
|
'done_at' => $this->integer()->unsigned(), |
|
34
|
|
|
], $tableOptions); |
|
35
|
|
|
|
|
36
|
|
|
$this->createIndex('channel', $this->tableName, 'channel'); |
|
37
|
|
|
$this->createIndex('reserved_at', $this->tableName, 'reserved_at'); |
|
38
|
|
|
$this->createIndex('priority', $this->tableName, 'priority'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function safeDown() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->dropTable($this->tableName); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|