Passed
Push — master ( e0e6c6...849d03 )
by Roman
02:16
created

M171206000000WorkerEvents::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 2
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