1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/zhuravljov/yii2-queue-monitor |
4
|
|
|
* @copyright Copyright (c) 2017 Roman Zhuravlev |
5
|
|
|
* @license http://opensource.org/licenses/BSD-3-Clause |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace zhuravljov\yii\queue\monitor\migrations; |
9
|
|
|
|
10
|
|
|
use zhuravljov\yii\queue\monitor\base\Migration; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Storage of job events |
14
|
|
|
* |
15
|
|
|
* @author Roman Zhuravlev <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class M170620000000EventStorage extends Migration |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @inheritdoc |
21
|
|
|
*/ |
22
|
|
|
public function safeUp() |
23
|
|
|
{ |
24
|
|
|
$this->createTable($this->env->pushTableName, [ |
25
|
|
|
'id' => $this->primaryKey(), |
26
|
|
|
'sender_name' => $this->string(32)->notNull(), |
27
|
|
|
'job_uid' => $this->string(32)->notNull(), |
28
|
|
|
'job_class' => $this->string()->notNull(), |
29
|
|
|
'job_object' => $this->binary()->notNull(), |
30
|
|
|
'ttr' => $this->integer()->notNull(), |
31
|
|
|
'delay' => $this->integer()->notNull(), |
32
|
|
|
'pushed_at' => $this->integer()->notNull(), |
33
|
|
|
'stopped_at' => $this->integer(), |
34
|
|
|
'first_exec_id' => $this->integer(), |
35
|
|
|
'last_exec_id' => $this->integer(), |
36
|
|
|
]); |
37
|
|
|
$this->createIndex('job_uid', $this->env->pushTableName, ['sender_name', 'job_uid']); |
38
|
|
|
$this->createIndex('first_exec_id', $this->env->pushTableName, 'first_exec_id'); |
39
|
|
|
$this->createIndex('last_exec_id', $this->env->pushTableName, 'last_exec_id'); |
40
|
|
|
|
41
|
|
|
$this->createTable($this->env->execTableName, [ |
42
|
|
|
'id' => $this->primaryKey(), |
43
|
|
|
'push_id' => $this->integer()->notNull(), |
44
|
|
|
'attempt' => $this->integer()->notNull(), |
45
|
|
|
'reserved_at' => $this->integer()->notNull(), |
46
|
|
|
'done_at' => $this->integer(), |
47
|
|
|
'error' => $this->text(), |
48
|
|
|
'retry' => $this->boolean(), |
49
|
|
|
]); |
50
|
|
|
$this->createIndex('push_id', $this->env->execTableName, 'push_id'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritdoc |
55
|
|
|
*/ |
56
|
|
|
public function safeDown() |
57
|
|
|
{ |
58
|
|
|
$this->dropTable($this->env->execTableName); |
59
|
|
|
$this->dropTable($this->env->pushTableName); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|