M250902104649InsertQimallLinkCategory.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250902104649InsertQimallLinkCategory
  6. */
  7. class M250902104649InsertQimallLinkCategory extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = "select * from qimall_link_category where name = 'store_steward' and pid = 0";
  15. $list = \Yii::$app->db->createCommand($sql)->queryAll();
  16. if ($list) {
  17. $sql = "update `qimall_link_category` set `name` = 'store_commodity_cate' where `name` = 'store-commodity-cate' and `pid` = ".$list[0]['id'].";";
  18. $this->execute($sql);
  19. }
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. echo "M250902104649InsertQimallLinkCategory cannot be reverted.\n";
  27. return false;
  28. }
  29. /*
  30. // Use up()/down() to run migration code without a transaction.
  31. public function up()
  32. {
  33. }
  34. public function down()
  35. {
  36. echo "M250726084649InsertQimallLinkCategory cannot be reverted.\n";
  37. return false;
  38. }
  39. */
  40. }