Passed
Branch master (3c33c7)
by Andrey
04:31
created

m180530_133910_create_feedback_table::safeUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 30
nc 1
nop 0
dl 0
loc 42
c 0
b 0
f 0
cc 1
rs 9.44
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `feedback`.
7
 */
8
class m180530_133910_create_feedback_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createTable('feedback', [
16
            'id' => $this->primaryKey(),
17
            'name' => $this->string(64)->notNull(),
18
            'email' => $this->string(64)->notNull(),
19
            'phone' => $this->string(32),
20
            'subject' => $this->string()->notNull(),
21
            'message' => $this->text()->notNull(),
22
            'read' => $this->tinyInteger()->notNull()->defaultValue(0),
23
            'created_at' => $this->dateTime(),
24
            'updated_at' => $this->dateTime(),
25
        ]);
26
27
        $this->createIndex(
28
            'idx-feedback-read',
29
            'feedback',
30
            'read'
31
        );
32
33
        $this->createIndex(
34
            'idx-feedback-name',
35
            'feedback',
36
            'name'
37
        );
38
39
        $this->createIndex(
40
            'idx-feedback-email',
41
            'feedback',
42
            'email'
43
        );
44
45
        $this->createIndex(
46
            'idx-feedback-phone',
47
            'feedback',
48
            'phone'
49
        );
50
51
        $this->createIndex(
52
            'idx-feedback-subject',
53
            'feedback',
54
            'subject'
55
        );
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function safeDown()
62
    {
63
        $this->dropIndex(
64
            'idx-feedback-read',
65
            'feedback'
66
        );
67
68
        $this->dropIndex(
69
            'idx-feedback-name',
70
            'feedback'
71
        );
72
73
        $this->dropIndex(
74
            'idx-feedback-email',
75
            'feedback'
76
        );
77
78
        $this->dropIndex(
79
            'idx-feedback-phone',
80
            'feedback'
81
        );
82
83
        $this->dropIndex(
84
            'idx-feedback-subject',
85
            'feedback'
86
        );
87
88
        $this->dropTable('feedback');
89
    }
90
}
91