Completed
Branch master (f58c14)
by Andrey
07:50
created

m180508_092223_create_pages_table::safeUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 34
rs 9.568
1
<?php
2
3
use Itstructure\AdminModule\components\MultilanguageMigration;
4
5
/**
6
 * Handles the creation of table `pages`.
7
 */
8 View Code Duplication
class m180508_092223_create_pages_table extends MultilanguageMigration
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createMultiLanguageTable('pages',
16
            [
17
                'title' => $this->string(128)->notNull(),
18
                'description' => $this->text(),
19
                'content' => $this->text(),
20
                'metaKeys' => $this->string(128),
21
                'metaDescription' => $this->string(),
22
            ],
23
            [
24
                'parentId' => $this->integer(),
25
                'active' => $this->tinyInteger()->notNull()->defaultValue(0),
26
                'icon' => $this->string(128),
27
                'alias' => $this->string(128),
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
        $this->createIndex(
44
            'idx-pages-alias',
45
            'pages',
46
            'alias'
47
        );
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function safeDown()
54
    {
55
        $this->dropIndex(
56
            'idx-pages-parentId',
57
            'pages'
58
        );
59
60
        $this->dropIndex(
61
            'idx-pages-active',
62
            'pages'
63
        );
64
65
        $this->dropIndex(
66
            'idx-pages-alias',
67
            'pages'
68
        );
69
70
        $this->dropMultiLanguageTable('pages');
71
    }
72
}
73