Upgrade.php 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. echo "<?php\n";
  3. ?>
  4. namespace addons\<?= $model->name;?>;
  5. use Yii;
  6. use common\components\Migration;
  7. use common\interfaces\AddonWidget;
  8. /**
  9. * 升级数据库
  10. *
  11. * Class Upgrade
  12. * @package addons\<?= $model->name . "\r";?>
  13. */
  14. class Upgrade extends Migration implements AddonWidget
  15. {
  16. /**
  17. * @var array
  18. */
  19. public $versions = [
  20. '1.0.0', // 默认版本
  21. '1.0.1',
  22. '1.0.2',
  23. ];
  24. /**
  25. * @param $addon
  26. * @return mixed|void
  27. * @throws \yii\db\Exception
  28. */
  29. public function run($addon)
  30. {
  31. switch ($addon->version) {
  32. case '1.0.2' :
  33. // 删除测试 - 冗余的字段
  34. // $this->dropColumn('{{%addon_example_curd}}', 'redundancy_field');
  35. break;
  36. case '1.0.1' :
  37. // 增加测试 - 冗余的字段
  38. // $this->addColumn('{{%addon_example_curd}}', 'redundancy_field', 'varchar(48)');
  39. break;
  40. }
  41. }
  42. }
粤ICP备19079148号