M250819104649InsertQimallLinkCategory.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250726084649InsertQimallLinkCategory
  6. */
  7. class M250819104649InsertQimallLinkCategory 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 = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('store-commodity-cate', 'O2O商品分类', ".$list[0]['id'].", 1, NULL, 1, 1755571380, 1755571380);";
  18. $this->execute($sql);
  19. }
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. echo "M250726084649InsertQimallLinkCategory 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. }