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 Schema |
14
|
|
|
* |
15
|
|
|
* @author Roman Zhuravlev <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class M180807000000Schema extends Migration |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @inheritdoc |
21
|
|
|
*/ |
22
|
|
|
public function safeUp() |
23
|
|
|
{ |
24
|
|
|
$this->createTable($this->env->pushTableName, [ |
25
|
|
|
'id' => $this->bigPrimaryKey(), |
26
|
|
|
'parent_id' => $this->bigInteger(), |
27
|
|
|
'sender_name' => $this->string(32)->notNull(), |
28
|
|
|
'job_uid' => $this->string(32)->notNull(), |
29
|
|
|
'job_class' => $this->string()->notNull(), |
30
|
|
|
'job_data' => $this->binary()->notNull(), |
31
|
|
|
'ttr' => $this->integer()->unsigned()->notNull(), |
32
|
|
|
'delay' => $this->integer()->unsigned()->notNull(), |
33
|
|
|
'trace' => $this->text(), |
34
|
|
|
'context' => $this->text(), |
35
|
|
|
'pushed_at' => $this->integer()->unsigned()->notNull(), |
36
|
|
|
'stopped_at' => $this->integer()->unsigned(), |
37
|
|
|
'first_exec_id' => $this->bigInteger(), |
38
|
|
|
'last_exec_id' => $this->bigInteger(), |
39
|
|
|
]); |
40
|
|
|
$this->createIndex('parent_id', $this->env->pushTableName, 'parent_id'); |
41
|
|
|
$this->createIndex('job_uid', $this->env->pushTableName, ['sender_name', 'job_uid']); |
42
|
|
|
$this->createIndex('first_exec_id', $this->env->pushTableName, 'first_exec_id'); |
43
|
|
|
$this->createIndex('last_exec_id', $this->env->pushTableName, 'last_exec_id'); |
44
|
|
|
|
45
|
|
|
$this->createTable($this->env->execTableName, [ |
46
|
|
|
'id' => $this->bigPrimaryKey(), |
47
|
|
|
'push_id' => $this->bigInteger()->notNull(), |
48
|
|
|
'worker_id' => $this->bigInteger(), |
49
|
|
|
'attempt' => $this->integer()->unsigned()->notNull(), |
50
|
|
|
'started_at' => $this->integer()->unsigned()->notNull(), |
51
|
|
|
'finished_at' => $this->integer()->unsigned(), |
52
|
|
|
'memory_usage' => $this->bigInteger()->unsigned(), |
53
|
|
|
'error' => $this->text(), |
54
|
|
|
'retry' => $this->boolean(), |
55
|
|
|
]); |
56
|
|
|
$this->createIndex('push_id', $this->env->execTableName, 'push_id'); |
57
|
|
|
$this->createIndex('worker_id', $this->env->execTableName, 'worker_id'); |
58
|
|
|
|
59
|
|
|
$this->createTable($this->env->workerTableName, [ |
60
|
|
|
'id' => $this->bigPrimaryKey(), |
61
|
|
|
'sender_name' => $this->string(32)->notNull(), |
62
|
|
|
'host' => $this->string(64), |
63
|
|
|
'pid' => $this->integer()->unsigned(), |
64
|
|
|
'started_at' => $this->integer()->unsigned()->notNull(), |
65
|
|
|
'pinged_at' => $this->integer()->unsigned()->notNull(), |
66
|
|
|
'stopped_at' => $this->integer()->unsigned(), |
67
|
|
|
'finished_at' => $this->integer()->unsigned(), |
68
|
|
|
'last_exec_id' => $this->bigInteger(), |
69
|
|
|
]); |
70
|
|
|
$this->createIndex('finished_at', $this->env->workerTableName, 'finished_at'); |
71
|
|
|
$this->createIndex('last_exec_id', $this->env->workerTableName, 'last_exec_id'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @inheritdoc |
76
|
|
|
*/ |
77
|
|
|
public function safeDown() |
78
|
|
|
{ |
79
|
|
|
$this->dropTable($this->env->workerTableName); |
80
|
|
|
$this->dropTable($this->env->execTableName); |
81
|
|
|
$this->dropTable($this->env->pushTableName); |
82
|
|
|
} |
83
|
|
|
} |