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

m180508_092223_create_pages_table   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
c 0
b 0
f 0
dl 0
loc 64
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 35 1
A safeDown() 0 18 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `pages`.
7
 */
8
class m180508_092223_create_pages_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createTable('pages',
16
            [
17
                'id' => $this->primaryKey(),
18
                'parentId' => $this->integer(),
19
                'active' => $this->tinyInteger()->notNull()->defaultValue(0),
20
                'icon' => $this->string(128),
21
                'title' => $this->string(128)->notNull(),
22
                'description' => $this->text(),
23
                'content' => $this->text(),
24
                'metaKeys' => $this->string(128),
25
                'metaDescription' => $this->string(),
26
                'alias' => $this->string(128),
27
                'created_at' => $this->dateTime(),
28
                'updated_at' => $this->dateTime(),
29
            ]
30
        );
31
32
        $this->createIndex(
33
            'idx-pages-parentId',
34
            'pages',
35
            'parentId'
36
        );
37
38
        $this->createIndex(
39
            'idx-pages-active',
40
            'pages',
41
            'active'
42
        );
43
44
        $this->createIndex(
45
            'idx-pages-alias',
46
            'pages',
47
            'alias'
48
        );
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function safeDown()
55
    {
56
        $this->dropIndex(
57
            'idx-pages-parentId',
58
            'pages'
59
        );
60
61
        $this->dropIndex(
62
            'idx-pages-active',
63
            'pages'
64
        );
65
66
        $this->dropIndex(
67
            'idx-pages-alias',
68
            'pages'
69
        );
70
71
        $this->dropTable('pages');
72
    }
73
}
74