Completed
Push — master ( 3364e5...5b352d )
by Loban
02:12
created

m151220_112320_lang::safeUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 21
rs 9.3143
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
use yii\db\Migration;
4
use lav45\translate\models\Lang;
5
6
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...
7
{
8
    public function safeUp()
9
    {
10
        $this->createTable('lang', [
11
            'id' => $this->string(2)->notNull(),
12
            'locale' => $this->string(8)->notNull(),
13
            'name' => $this->string(32)->notNull(),
14
            'status' => $this->smallInteger()
15
        ]);
16
17
        $this->addPrimaryKey('lang_pk', 'lang', 'id');
18
19
        $this->createIndex('lang_name_idx', 'lang', 'name', true);
20
        $this->createIndex('lang_status_idx', 'lang', 'status');
21
22
        $this->batchInsert('lang', [
23
            'id', 'locale', 'name', 'status'
24
        ], [
25
            ['en', 'en-US', 'ENG', Lang::STATUS_ACTIVE],
26
            ['ru', 'ru-RU', 'RUS', Lang::STATUS_ACTIVE]
27
        ]);
28
    }
29
30
    public function safeDown()
31
    {
32
        $this->dropTable('lang');
33
    }
34
}
35