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

m151220_112320_lang   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 21 1
A safeDown() 0 4 1
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