Completed
Push — master ( 193986...cdf399 )
by Andrey
11:47
created

m180508_092223_create_pages_table   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 52
c 0
b 0
f 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 30 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(1)->notNull()->defaultValue(0),
20
                'icon' => $this->string(64),
21
                'title' => $this->string(),
22
                'description' => $this->text(),
23
                'content' => $this->text(),
24
                'metaKeys' => $this->string(),
25
                'metaDescription' => $this->string(),
26
                'created_at' => $this->dateTime(),
27
                'updated_at' => $this->dateTime(),
28
            ]
29
        );
30
31
        $this->createIndex(
32
            'idx-pages-parentId',
33
            'pages',
34
            'parentId'
35
        );
36
37
        $this->createIndex(
38
            'idx-pages-active',
39
            'pages',
40
            'active'
41
        );
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function safeDown()
48
    {
49
        $this->dropIndex(
50
            'idx-pages-parentId',
51
            'pages'
52
        );
53
54
        $this->dropIndex(
55
            'idx-pages-active',
56
            'pages'
57
        );
58
59
        $this->dropTable('pages');
60
    }
61
}
62