|
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 worker events |
|
14
|
|
|
* |
|
15
|
|
|
* @author Roman Zhuravlev <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class M171206000000WorkerEvents extends Migration |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @inheritdoc |
|
21
|
|
|
*/ |
|
22
|
|
|
public function up() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->createTable($this->env->workerTableName, [ |
|
25
|
|
|
'id' => $this->primaryKey(), |
|
26
|
|
|
'sender_name' => $this->string(32)->notNull(), |
|
27
|
|
|
'pid' => $this->integer()->notNull(), |
|
28
|
|
|
'started_at' => $this->integer()->notNull(), |
|
29
|
|
|
'finished_at' => $this->integer(), |
|
30
|
|
|
]); |
|
31
|
|
|
$this->createIndex('pid', $this->env->workerTableName, 'pid'); |
|
32
|
|
|
$this->createIndex('finished_at', $this->env->workerTableName, 'finished_at'); |
|
33
|
|
|
|
|
34
|
|
|
$this->addColumn($this->env->execTableName, 'worker_id', $this->integer()->after('push_id')); |
|
35
|
|
|
$this->createIndex('worker_id', $this->env->execTableName, 'worker_id'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @inheritdoc |
|
40
|
|
|
*/ |
|
41
|
|
|
public function down() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->dropIndex('worker_id', $this->env->execTableName); |
|
44
|
|
|
$this->dropColumn($this->env->execTableName, 'worker_id'); |
|
45
|
|
|
|
|
46
|
|
|
$this->dropIndex('finished_at', $this->env->workerTableName); |
|
47
|
|
|
$this->dropIndex('pid', $this->env->workerTableName); |
|
48
|
|
|
$this->dropTable($this->env->workerTableName); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|