|
1
|
|
|
<?php |
|
2
|
|
|
namespace execut\import\migrations; |
|
3
|
|
|
class m160929_071905_addFtpFieldsToSettings extends \execut\yii\migration\Migration |
|
4
|
|
|
{ |
|
5
|
|
|
public function initInverter(\execut\yii\migration\Inverter $i) |
|
6
|
|
|
{ |
|
7
|
|
|
$is = $i->table('import_settings'); |
|
8
|
|
|
|
|
9
|
|
|
$is->addColumn('ftp_host', $this->string()) |
|
10
|
|
|
->addColumn('ftp_ssl', $this->boolean()) |
|
11
|
|
|
->addColumn('ftp_port', $this->integer()) |
|
12
|
|
|
->addColumn('ftp_timeout', $this->integer()) |
|
13
|
|
|
->addColumn('ftp_login', $this->string()) |
|
14
|
|
|
->addColumn('ftp_password', $this->string()) |
|
15
|
|
|
->addColumn('ftp_dir', $this->string()) |
|
16
|
|
|
->addColumn('ftp_file_name', $this->string()) |
|
17
|
|
|
->alterColumnSetDefault('ftp_timeout', 60) |
|
18
|
|
|
->update([ |
|
19
|
|
|
'ftp_timeout' => 60, |
|
20
|
|
|
'ftp_ssl' => false, |
|
21
|
|
|
'ftp_port' => 21, |
|
22
|
|
|
]) |
|
23
|
|
|
->alterColumnSetNotNull('ftp_timeout') |
|
24
|
|
|
->alterColumnSetDefault('ftp_ssl', 'false') |
|
25
|
|
|
->alterColumnSetNotNull('ftp_ssl') |
|
26
|
|
|
->alterColumnSetDefault('ftp_port', 21) |
|
27
|
|
|
->alterColumnSetNotNull('ftp_port'); |
|
28
|
|
|
$i->table('import_files_sources')->batchInsert([ |
|
29
|
|
|
'id', |
|
30
|
|
|
'name', |
|
31
|
|
|
'key', |
|
32
|
|
|
], [ |
|
33
|
|
|
[ |
|
34
|
|
|
3, |
|
35
|
|
|
'FTP', |
|
36
|
|
|
'ftp', |
|
37
|
|
|
], |
|
38
|
|
|
[ |
|
39
|
|
|
4, |
|
40
|
|
|
'Сайт', |
|
41
|
|
|
'site', |
|
42
|
|
|
], |
|
43
|
|
|
]); |
|
44
|
|
|
$is->update([ |
|
45
|
|
|
'import_files_source_id' => 2, |
|
46
|
|
|
], [ |
|
47
|
|
|
'import_files_source_id' => [3,4], |
|
48
|
|
|
]); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|