M220906032843QimallAddonsStoreCouponShareLog.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906032843QimallAddonsStoreCouponShareLog
  6. */
  7. class M220906032843QimallAddonsStoreCouponShareLog extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon_share_log';
  15. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if(!empty($res)) return '';
  18. $this->createTable($table, [
  19. 'id' => $this->primaryKey(),
  20. 'mall_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商城id'),
  21. 'coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券id'),
  22. 'store_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('门店id'),
  23. 'user_coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('赠送者coupon_user_relate表的id'),
  24. 'get_user_coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('领取者coupon_user_relate表的id'),
  25. 'giving_user_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('转出会员id,值为 0 说明是平台赠送的优惠券'),
  26. 'receive_user_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('受赠会员id,尚未被领取此字段值为0'),
  27. 'giving_status' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('转赠状态,1:转赠中(已分享出去,未被领取),2:已被领取'),
  28. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  29. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  30. ]);
  31. $this->addCommentOnTable($table,'优惠券分享记录表');
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function safeDown()
  37. {
  38. echo "M220906032843QimallAddonsStoreCouponShareLog cannot be reverted.\n";
  39. return false;
  40. }
  41. /*
  42. // Use up()/down() to run migration code without a transaction.
  43. public function up()
  44. {
  45. }
  46. public function down()
  47. {
  48. echo "M220906032843QimallAddonsStoreCouponShareLog cannot be reverted.\n";
  49. return false;
  50. }
  51. */
  52. }