forked from jianyan74/TinyShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgrade.php
44 lines (40 loc) · 975 Bytes
/
Upgrade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace addons\TinyShop;
use Yii;
use yii\db\Migration;
use common\interfaces\AddonWidget;
/**
* 升级数据库
*
* Class Upgrade
* @package addons\TinyShop */
class Upgrade extends Migration implements AddonWidget
{
/**
* @var array
*/
public $versions = [
'1.0.0', // 默认版本
'1.0.1',
'1.0.2',
];
/**
* @param $addon
* @return mixed|void
* @throws \yii\db\Exception
*/
public function run($addon)
{
switch ($addon->version) {
case '1.0.1' :
// 增加测试 - 冗余的字段
// $this->addColumn('{{%addon_example_curd}}', 'redundancy_field', 'varchar(48)');
break;
case '1.0.2' :
// 删除测试 - 冗余的字段
// $this->dropColumn('{{%addon_example_curd}}', 'redundancy_field');
break;
}
}
}