| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace addons\Store\console\migrations;
- use addons\Store\common\models\StoreGoodsCate;
- use addons\Store\common\models\StoreScoreStoreApply;
- use yii\db\Migration;
- /**
- * Class M241206074356NewAlterScoreRulesField
- */
- class M241206074356NewAlterScoreRulesField extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- $goods_cate_field = StoreGoodsCate::getTableSchema()->getColumnNames();
- $score_store_apply_feild = StoreScoreStoreApply::getTableSchema()->getColumnNames();
- if (!in_array('mall_goods_cate_id', $goods_cate_field) && !in_array('score_method', $score_store_apply_feild)) {
- $sql = <<<SQL
- ALTER TABLE `qimall_addons_store_goods_cate` ADD COLUMN `mall_goods_cate_id` int(11) DEFAULT '0' COMMENT '关联主商城商品分类ID' AFTER `sort`;
- ALTER TABLE `qimall_addons_store_score_store_apply` ADD COLUMN `score_method` tinyint(1) DEFAULT '1' COMMENT '积分操作,1积分赠送,2积分抵扣,默认1' AFTER `store_c_id`;
- SQL;
- $this->execute($sql);
- }
- }catch (\Exception $e){}
- return true;
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M241206074356NewAlterScoreRulesField cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M241206074356NewAlterScoreRulesField cannot be reverted.\n";
- return false;
- }
- */
- }
|