m000000_000020_module   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 89
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 4 1
A up() 0 75 2
1
<?php
2
3
use yii\db\Schema;
4
5
/**
6
 * Class m000000_000020_module
7
 *
8
 * @author Agiel K. Saputra <[email protected]>
9
 * @since 0.2.0
10
 */
11
class m000000_000020_module extends \yii\db\Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function up()
17
    {
18
        $tableOptions = null;
19
20
        if ($this->db->driverName === 'mysql') {
21
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
22
        }
23
24
        $this->createTable('{{%module}}', [
25
            'id' => Schema::TYPE_PK,
26
            'name' => Schema::TYPE_STRING . '(64) NOT NULL',
27
            'title' => Schema::TYPE_TEXT . ' NOT NULL',
28
            'description' => Schema::TYPE_TEXT,
29
            'config' => Schema::TYPE_TEXT . ' NOT NULL',
30
            'status' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0',
31
            'directory' => Schema::TYPE_STRING . '(128) NOT NULL',
32
            'backend_bootstrap' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0',
33
            'frontend_bootstrap' => Schema::TYPE_SMALLINT . '(1) NOT NULL DEFAULT 0',
34
            'date' => Schema::TYPE_DATETIME . ' NOT NULL',
35
            'modified' => Schema::TYPE_DATETIME . ' NOT NULL',
36
        ], $tableOptions);
37
38
        /**
39
         * Insert data module
40
         */
41
        $this->batchInsert('{{%module}}', [
42
            'name',
43
            'title',
44
            'description',
45
            'config',
46
            'status',
47
            'directory',
48
            'backend_bootstrap',
49
            'frontend_bootstrap',
50
            'date',
51
            'modified',
52
        ], [
53
            [
54
                'toolbar',
55
                'Toolbar',
56
                null,
57
                '{"frontend":{"class":"modules\\\\toolbar\\\\frontend\\\\Module"}}',
58
                0,
59
                'toolbar',
60
                0,
61
                1,
62
                '2015-09-11 03:14:57',
63
                '2015-09-11 03:14:57',
64
            ],
65
            [
66
                'sitemap',
67
                'Sitemap',
68
                'Module for sitemap',
69
                '{"backend":{"class":"modules\\\\sitemap\\\\backend\\\\Module"},"frontend":{"class":"modules\\\\sitemap\\\\frontend\\\\Module"}}',
70
                0,
71
                'sitemap',
72
                0,
73
                1,
74
                '2015-09-11 03:38:25',
75
                '2015-09-11 03:38:25',
76
            ],
77
            [
78
                'feed',
79
                'RSS Feed',
80
                null,
81
                '{"frontend":{"class":"modules\\\\feed\\\\frontend\\\\Module"}}',
82
                0,
83
                'feed',
84
                0,
85
                0,
86
                '2015-09-11 03:38:53',
87
                '2015-09-11 03:38:53',
88
            ],
89
        ]);
90
    }
91
92
    /**
93
     * @inheritdoc
94
     */
95
    public function down()
96
    {
97
        $this->dropTable('{{%module}}');
98
    }
99
}
100