|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use yii\db\Migration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class m180310_090057_chg_proxy |
|
7
|
|
|
*/ |
|
8
|
|
|
class m180310_090057_chg_proxy extends Migration |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* {@inheritdoc} |
|
12
|
|
|
*/ |
|
13
|
|
|
public function safeUp() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->alterColumn('proxy', 'ip', $this->string()->notNull()); |
|
16
|
|
|
$this->alterColumn('proxy', 'port', $this->integer()->notNull()); |
|
17
|
|
|
$this->alterColumn('proxy', 'active', $this->boolean()->notNull()->defaultValue(1)); |
|
18
|
|
|
|
|
19
|
|
|
$this->addColumn('proxy', 'default_for_accounts', $this->boolean()->notNull()->defaultValue('0')); |
|
20
|
|
|
$this->addColumn('proxy', 'default_for_tags', $this->boolean()->notNull()->defaultValue('0')); |
|
21
|
|
|
|
|
22
|
|
|
$this->dropColumn('proxy', 'type'); |
|
23
|
|
|
|
|
24
|
|
|
$this->addColumn('account', 'proxy_tag_id', $this->integer()->after('proxy_id')); |
|
25
|
|
|
$this->addForeignKey('fk_account_proxy_tag', 'account', 'proxy_tag_id', 'tag', 'id', 'SET NULL'); |
|
26
|
|
|
|
|
27
|
|
|
$this->addColumn('tag', 'proxy_tag_id', $this->integer()->after('proxy_id')); |
|
28
|
|
|
$this->addForeignKey('fk_tag_proxy_tag', 'tag', 'proxy_tag_id', 'tag', 'id', 'SET NULL'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function safeDown() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->dropForeignKey('fk_account_proxy_tag', 'account'); |
|
37
|
|
|
$this->dropColumn('account', 'proxy_tag_id'); |
|
38
|
|
|
|
|
39
|
|
|
$this->dropForeignKey('fk_tag_proxy_tag', 'tag'); |
|
40
|
|
|
$this->dropColumn('tag', 'proxy_tag_id'); |
|
41
|
|
|
|
|
42
|
|
|
$this->addColumn('proxy', 'type', $this->string()); |
|
43
|
|
|
|
|
44
|
|
|
$this->dropColumn('proxy', 'default_for_accounts'); |
|
45
|
|
|
$this->dropColumn('proxy', 'default_for_tags'); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|