m160801_142638_addEncodingsTable::initInverter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 44
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 27
c 0
b 0
f 0
dl 0
loc 44
rs 9.488
cc 1
nc 1
nop 1
1
<?php
2
namespace execut\import\migrations;
3
class m160801_142638_addEncodingsTable extends \execut\yii\migration\Migration
4
{
5
    // Use safeUp/safeDown to run migration code within a transaction
6
    public function initInverter(\execut\yii\migration\Inverter $i)
7
    {
8
        $i->createTable('import_files_encodings', array_merge($this->defaultColumns(), [
9
            'name' => $this->string()->notNull(),
10
            'key' => $this->string()->notNull(),
11
        ]));
12
        $i->batchInsert('import_files_encodings', [
13
            'id',
14
            'key',
15
            'name',
16
        ], [
17
            [
18
                'id' => 1,
19
                'key' => 'UTF-8',
20
                'name' => 'UTF-8'
21
            ],
22
            [
23
                'id' => 2,
24
                'key' => 'UTF-16',
25
                'name' => 'UTF-16'
26
            ],
27
            [
28
                'id' => 3,
29
                'key' => 'KOI8-R',
30
                'name' => 'KOI8-R'
31
            ],
32
            [
33
                'id' => 4,
34
                'key' => 'KOI8-U',
35
                'name' => 'KOI8-U'
36
            ],
37
            [
38
                'id' => 5,
39
                'key' => 'Windows-1251',
40
                'name' => 'Windows-1251'
41
            ],
42
            [
43
                'id' => 6,
44
                'key' => 'Windows-1252',
45
                'name' => 'Windows-1252'
46
            ],
47
        ]);
48
        $i->table('import_settings')
49
            ->addForeignColumn('import_files_encodings', true, 1);
50
    }
51
}
52