M220906031357QimallAddonsStoreCouponGoodStatistics.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906031357QimallAddonsStoreCouponGoodStatistics
  6. */
  7. class M220906031357QimallAddonsStoreCouponGoodStatistics extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function safeUp()
  16. {
  17. $table = 'qimall_addons_store_coupon_good_statistics';
  18. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  19. $res = $this->db->createCommand($sql)->execute();
  20. if(!empty($res)) return '';
  21. $this->createTable($table, [
  22. 'id' => $this->primaryKey(),
  23. 'mall_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商城ID'),
  24. 'coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券id'),
  25. 'good_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商品id'),
  26. 'booking_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('该商品使用该优惠券下单的总数量'),
  27. 'payed_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('使用该优惠券已支付的该商品数量'),
  28. 'booking_user_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('该商品使用该优惠券下单的总人数'),
  29. 'buyed_user_number' => $this->integer(11)->notNull()->defaultValue(0)->comment('使用该优惠券已购买该商品人数'),
  30. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  31. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  32. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  33. ]);
  34. $this->addCommentOnTable($table,'使用优惠券购买的商品的相关数据统计');
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M220906031357QimallAddonsStoreCouponGoodStatistics cannot be reverted.\n";
  42. return false;
  43. }
  44. /*
  45. // Use up()/down() to run migration code without a transaction.
  46. public function up()
  47. {
  48. }
  49. public function down()
  50. {
  51. echo "M220906031357QimallAddonsStoreCouponGoodStatistics cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }