M250514144436AlterLinkCategory.php 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * 添加一个o2o分类链接数据
  6. * Class M250514144436AlterLinkCategory
  7. */
  8. class M250514144436AlterLinkCategory extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $table = 'qimall_link_category';
  16. $sql = "select id from {$table} where name = 'goods' and pid=0 and status = 1";
  17. $res = $this->db->createCommand($sql)->queryOne();
  18. if (empty($res)) return '';
  19. $sql = <<<SQL
  20. INSERT INTO `qimall_link_category`(`name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('store_renov_goods', 'O2O门店商品', {$res['id']}, 1, '', 1, 1747206336, 1747206336);
  21. SQL;
  22. $this->execute($sql);
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M250514144436AlterLinkCategory cannot be reverted.\n";
  30. return false;
  31. }
  32. }