M250726084649InsertQimallLinkCategory.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250726084649InsertQimallLinkCategory
  6. */
  7. class M250726084649InsertQimallLinkCategory extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES
  15. ( 'store_goods_data', '门店商品', 0, 0, NULL, 1, 1639814497, 1640312920);";
  16. $this->execute($sql);
  17. $sql = "select * from qimall_link_category where name = 'store_goods_data' and pid = 0";
  18. $list = \Yii::$app->db->createCommand($sql)->queryAll();
  19. if($list){
  20. $sql = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('store_goods_list', '门店商品', ".$list[0]['id'].", 1, NULL, 1, 1639814136, 1639814255);";
  21. $this->execute($sql);
  22. }
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M250726084649InsertQimallLinkCategory cannot be reverted.\n";
  30. return false;
  31. }
  32. /*
  33. // Use up()/down() to run migration code without a transaction.
  34. public function up()
  35. {
  36. }
  37. public function down()
  38. {
  39. echo "M250726084649InsertQimallLinkCategory cannot be reverted.\n";
  40. return false;
  41. }
  42. */
  43. }