Completed
Push — master ( 1037b2...772018 )
by Loban
03:18
created

m151220_112320_lang::safeUp()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 26
rs 8.8571
cc 2
eloc 18
nc 2
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
class m151220_112320_lang extends Migration
1 ignored issue
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...
6
{
7
    public function safeUp()
8
    {
9
        $tableOptions = null;
10
        if ($this->db->driverName === 'mysql') {
11
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
12
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
13
        }
14
15
        $this->createTable('{{%lang}}', [
16
            'id' => $this->string(2)->notNull(),
17
            'locale' => $this->string(8)->notNull(),
18
            'name' => $this->string(32)->notNull(),
19
            'status' => $this->smallInteger(),
20
            'PRIMARY KEY (id)',
21
        ], $tableOptions);
22
23
        $this->createIndex('lang_name_idx', 'lang', 'name', true);
24
        $this->createIndex('lang_status_idx', 'lang', 'status');
25
26
        $this->insert('lang', [
27
            'id' => 'en',
28
            'locale' => 'en-US',
29
            'name' => 'ENG',
30
            'status' => 10,
31
        ]);
32
    }
33
34
    public function safeDown()
35
    {
36
        $this->dropTable('lang');
37
    }
38
}
39