m220830_025931_user_level_upgrade_condition.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. *
  6. * Class m220830_025931_user_level_upgrade_condition
  7. */
  8. class m220830_025931_user_level_upgrade_condition extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $tableName = 'qimall_user_level_upgrade_condition';
  16. $table = \Yii::$app->db->getTableSchema($tableName, true);
  17. $column_cate_ids = $table->getColumn('cate_ids');
  18. $column_buy_cate_type = $table->getColumn('buy_cate_type');
  19. if(!$column_cate_ids){
  20. $this->execute("ALTER TABLE qimall_user_level_upgrade_condition add `cate_ids` varchar(3000) NOT NULL DEFAULT '' COMMENT '商品分类id集合'");
  21. }
  22. if(!$column_buy_cate_type){
  23. $this->execute("ALTER TABLE qimall_user_level_upgrade_condition add `buy_cate_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '订单完成0;支付完成:1';");
  24. }
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function safeDown()
  30. {
  31. echo "m220830_025931_user_level_upgrade_condition cannot be reverted.\n";
  32. return false;
  33. }
  34. /*
  35. // Use up()/down() to run migration code without a transaction.
  36. public function up()
  37. {
  38. }
  39. public function down()
  40. {
  41. echo "m220830_025931_user_level_upgrade_condition cannot be reverted.\n";
  42. return false;
  43. }
  44. */
  45. }