M220906034739QimallAddonsStoreCouponUseLog.php 1.9 KB

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