M220906032539QimallAddonsStoreCouponReward.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906032539QimallAddonsStoreCouponReward
  6. */
  7. class M220906032539QimallAddonsStoreCouponReward extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon_reward';
  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. 'reward_type' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('奖励类型,1:转赠奖励,2:使用奖励'),
  24. 'balance' => $this->float('12,2')->notNull()->defaultValue(0)->comment('奖励余额'),
  25. 'score' => $this->float('12,2')->notNull()->defaultValue(0)->comment('奖励积分'),
  26. 'red_packet' => $this->float('12,2')->notNull()->defaultValue(0)->comment('奖励红包'),
  27. 'reward_currency_type' => $this->string(50)->notNull()->defaultValue(0)->comment('奖励货币种类,记录货币 code'),
  28. 'number' => $this->float('12,2')->notNull()->defaultValue(0)->comment('奖励货币数量'),
  29. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  30. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  31. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  32. ]);
  33. $this->addCommentOnTable($table,'优惠券奖励记录表');
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function safeDown()
  39. {
  40. echo "M220906032539QimallAddonsStoreCouponReward cannot be reverted.\n";
  41. return false;
  42. }
  43. /*
  44. // Use up()/down() to run migration code without a transaction.
  45. public function up()
  46. {
  47. }
  48. public function down()
  49. {
  50. echo "M220906032539QimallAddonsStoreCouponReward cannot be reverted.\n";
  51. return false;
  52. }
  53. */
  54. }