|
1
|
|
|
<?php |
|
2
|
|
|
namespace execut\import\migrations; |
|
3
|
|
|
class m160713_140416_addImportFilesTable extends \execut\yii\migration\Migration |
|
4
|
|
|
{ |
|
5
|
|
|
public function initInverter(\execut\yii\migration\Inverter $i) |
|
6
|
|
|
{ |
|
7
|
|
|
$i = $this->inverter; |
|
8
|
|
|
$i->createTable('import_files', array_merge($this->defaultColumns(), [ |
|
9
|
|
|
'name' => $this->string()->notNull(), |
|
10
|
|
|
'extension' => $this->string()->notNull(), |
|
11
|
|
|
'mime_type' => $this->string()->notNull(), |
|
12
|
|
|
'content' => $this->data()->notNull(), |
|
13
|
|
|
'md5' => $this->string(64)->notNull(), |
|
14
|
|
|
])); |
|
15
|
|
|
$i->createTable('import_files_sources', array_merge($this->defaultColumns(), [ |
|
16
|
|
|
'name' => $this->string()->notNull(), |
|
17
|
|
|
'key' => $this->string()->notNull(), |
|
18
|
|
|
])); |
|
19
|
|
|
$i->batchInsert('import_files_sources', [ |
|
20
|
|
|
'id', |
|
21
|
|
|
'name', |
|
22
|
|
|
'key', |
|
23
|
|
|
], [ |
|
24
|
|
|
[ |
|
25
|
|
|
'id' => 1, |
|
26
|
|
|
'name' => 'Email', |
|
27
|
|
|
'key' => 'email', |
|
28
|
|
|
], |
|
29
|
|
|
[ |
|
30
|
|
|
'id' => 2, |
|
31
|
|
|
'name' => 'Вручную', |
|
32
|
|
|
'key' => 'manual', |
|
33
|
|
|
], |
|
34
|
|
|
]); |
|
35
|
|
|
|
|
36
|
|
|
$i->createTable('import_files_statuses', array_merge($this->defaultColumns(), [ |
|
37
|
|
|
'name' => $this->string()->notNull(), |
|
38
|
|
|
'key' => $this->string()->notNull(), |
|
39
|
|
|
])); |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$i->table('import_files') |
|
43
|
|
|
->addForeignColumn('import_files_sources', true) |
|
44
|
|
|
->addForeignColumn('user') |
|
45
|
|
|
->addForeignColumn('import_files_statuses', true); |
|
46
|
|
|
$i->batchInsert('import_files_statuses', [ |
|
47
|
|
|
'id', |
|
48
|
|
|
'name', |
|
49
|
|
|
'key', |
|
50
|
|
|
], [ |
|
51
|
|
|
[ |
|
52
|
|
|
'id' => 1, |
|
53
|
|
|
'name' => 'New', |
|
54
|
|
|
'key' => 'new', |
|
55
|
|
|
], |
|
56
|
|
|
[ |
|
57
|
|
|
'id' => 2, |
|
58
|
|
|
'name' => 'Reload', |
|
59
|
|
|
'key' => 'reload', |
|
60
|
|
|
], |
|
61
|
|
|
[ |
|
62
|
|
|
'id' => 3, |
|
63
|
|
|
'name' => 'Delete', |
|
64
|
|
|
'key' => 'delete', |
|
65
|
|
|
], |
|
66
|
|
|
[ |
|
67
|
|
|
'id' => 4, |
|
68
|
|
|
'name' => 'Loaded', |
|
69
|
|
|
'key' => 'loaded', |
|
70
|
|
|
], |
|
71
|
|
|
[ |
|
72
|
|
|
'id' => 5, |
|
73
|
|
|
'name' => 'Loading', |
|
74
|
|
|
'key' => 'loading', |
|
75
|
|
|
], |
|
76
|
|
|
[ |
|
77
|
|
|
'id' => 6, |
|
78
|
|
|
'name' => 'Deleting', |
|
79
|
|
|
'key' => 'deleting', |
|
80
|
|
|
] |
|
81
|
|
|
]); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|