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

M170620000000EventStorage::safeUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 0
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