M220906031723QimallAddonsStoreCouponMemberRelate.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M220906031723QimallAddonsStoreCouponMemberRelate
  6. */
  7. class M220906031723QimallAddonsStoreCouponMemberRelate extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_coupon_member_relate';
  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. 'coupon_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('优惠券id'),
  21. 'store_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('门店id'),
  22. 'member_level' => $this->integer(11)->notNull()->defaultValue(0)->comment('会员等级'),
  23. 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
  24. 'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('添加时间'),
  25. 'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
  26. ]);
  27. $this->addCommentOnTable($table,'会员等级下优惠券表');
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function safeDown()
  33. {
  34. echo "M220906031723QimallAddonsStoreCouponMemberRelate cannot be reverted.\n";
  35. return false;
  36. }
  37. /*
  38. // Use up()/down() to run migration code without a transaction.
  39. public function up()
  40. {
  41. }
  42. public function down()
  43. {
  44. echo "M220906031723QimallAddonsStoreCouponMemberRelate cannot be reverted.\n";
  45. return false;
  46. }
  47. */
  48. }