M220906030417QimallAddonsStoreCouponCatRelate.php 1.6 KB

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