M231212062704AlterQimallAddonsCouponUserRelate.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace addons\Coupon\console\migrations;
  3. use addons\Coupon\common\models\AddonsCouponUserRelate;
  4. use yii\db\Migration;
  5. /**
  6. * Class M231212062704AlterQimallAddonsCouponUserRelate
  7. */
  8. class M231212062704AlterQimallAddonsCouponUserRelate extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $this->execute("alter table qimall_addons_coupon_user_relate add `mch_id` varchar(3000) not null default ''");
  16. $this->execute("UPDATE `qimall_addons_coupon` set `mch_id` = '' where `mch_id` = '0';");
  17. AddonsCouponUserRelate::fixMchId();
  18. }
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function safeDown()
  23. {
  24. echo "M231212062704AlterQimallAddonsCouponUserRelate cannot be reverted.\n";
  25. return false;
  26. }
  27. /*
  28. // Use up()/down() to run migration code without a transaction.
  29. public function up()
  30. {
  31. }
  32. public function down()
  33. {
  34. echo "M231212062704AlterQimallAddonsCouponUserRelate cannot be reverted.\n";
  35. return false;
  36. }
  37. */
  38. }