m160719_135347_addSettingsTables   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 27
dl 0
loc 120
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A initInverter() 0 118 1
1
<?php
2
namespace execut\import\migrations;
3
class m160719_135347_addSettingsTables extends \execut\yii\migration\Migration
4
{
5
    public function initInverter(\execut\yii\migration\Inverter $i)
6
    {
7
        $i->createTable('import_settings', array_merge($this->defaultColumns(), [
8
            'name' => $this->string()->notNull(),
9
            'ignored_lines' => $this->integer()->notNull(),
10
            'email' => $this->string(),
11
            'email_title_match' => $this->string(),
12
            'csv_delimiter' => $this->char(1),
13
            'csv_enclosure' => $this->char(1),
14
        ]));
15
//        $i->createTable('import_files_types', array_merge($this->defaultColumns(), [
16
//            'name' => $this->string()->notNull(),
17
//            'key' => $this->string()->notNull(),
18
//        ]));
19
//        $i->batchInsert('import_files_types', [
20
//            'id',
21
//            'name',
22
//            'key'
23
//        ], [
24
//            [
25
//                'id' => 1,
26
//                'key' => 'auto',
27
//                'name' => 'auto'
28
//            ],
29
//            [
30
//                'id' => 1,
31
//                'name' => 'csv',
32
//                'key' => 'csv',
33
//            ],
34
//            [
35
//                'id' => 2,
36
//                'name' => 'txt',
37
//                'key' => 'txt',
38
//            ],
39
//            [
40
//                'id' => 3,
41
//                'name' => 'xls',
42
//                'key' => 'xls',
43
//            ],
44
//            [
45
//                'id' => 4,
46
//                'name' => 'xlsx',
47
//                'key' => 'xlsx',
48
//            ],
49
//            [
50
//                'id' => 5,
51
//                'name' => 'xlsm',
52
//                'key' => 'xlsm',
53
//            ],
54
//        ]);
55
//        $i->createTable('import_files_encodings', array_merge($this->defaultColumns(), [
56
//            'name' => $this->string()->notNull(),
57
//        ]));
58
//        $i->batchInsert('import_files_encodings', [
59
//            'id',
60
//            'key',
61
//            'name',
62
//        ], [
63
//            [
64
//                'id' => 1,
65
//                'key' => 'auto',
66
//                'name' => 'auto'
67
//            ],
68
//            [
69
//                'id' => 2,
70
//                'key' => 'utf-8',
71
//                'name' => 'utf-8'
72
//            ],
73
//            [
74
//                'id' => 3,
75
//                'key' => 'utf-16',
76
//                'name' => 'utf-16'
77
//            ],
78
//            [
79
//                'id' => 4,
80
//                'key' => 'KOI8-R',
81
//                'name' => 'KOI8-R'
82
//            ],
83
//            [
84
//                'id' => 5,
85
//                'key' => 'KOI8-U',
86
//                'name' => 'KOI8-U'
87
//            ],
88
//            [
89
//                'id' => 6,
90
//                'key' => 'windows-1251',
91
//                'name' => 'windows-1252'
92
//            ],
93
//        ]);
94
        $i->table('import_settings')
95
            ->addForeignColumn('import_files_sources', true);
96
        $i->delete('import_files');
97
        $i->table('import_files')
98
            ->addForeignColumn('import_settings', true);
99
//            ->addForeignColumn('import_files_types')
100
//            ->addForeignColumn('import_files_encodings');
101
        $i->createTable('import_settings_sheets', array_merge($this->defaultColumns(), [
102
            'name' => $this->string()->notNull(),
103
            'order' => $this->integer()->notNull(),
104
        ]));
105
106
        $i->table('import_settings_sheets')->addForeignColumn('import_settings', true);
107
108
        $i->createTable('import_settings_sets', array_merge($this->defaultColumns(), [
109
            'type' => $this->string()->notNull(),
110
        ]));
111
112
        $i->table('import_settings_sets')->addForeignColumn('import_settings_sheets', true);
113
114
        $i->createTable('import_settings_values', array_merge($this->defaultColumns(), [
115
            'type' => $this->string()->notNull(),
116
            'column_nbr' => $this->string(),
117
            'format' => $this->string(),
118
            'value_string' => $this->string(),
119
            'value_option' => $this->string(),
120
        ]));
121
122
        $i->table('import_settings_values')->addForeignColumn('import_settings_sets', true);
123
    }
124
}
125