M240612084212InsertQimallLinkCategory.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240612084212InsertQimallLinkCategory
  6. */
  7. class M240612084212InsertQimallLinkCategory extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $f_sql = "SELECT * FROM qimall_link_category where name = 'wechat_video_account';";
  15. $res = \Yii::$app->db->createCommand($f_sql)->queryOne();
  16. if(!$res){
  17. $sql = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'wechat_video_account', '微信视频号跳转', 9, 0, '此功能仅支持小程序端跳转。直播类型需要小程序和视频号的主体相关联', 1, 1630564778, 1630564778);";
  18. $this->execute($sql);
  19. }
  20. $res = \Yii::$app->db->createCommand($f_sql)->queryOne();
  21. $cat_id = $res['id'];
  22. $sql = "INSERT INTO `qimall_link` ( `name`, `title`, `cat_id`, `open_type`, `route`, `icon`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'jumpType', '跳转类型', {$cat_id}, 'wechat_video_account', 'channelsUserProfile', NULL, '', 1, 1718248695, 1718248695);
  23. INSERT INTO `qimall_link` ( `name`, `title`, `cat_id`, `open_type`, `route`, `icon`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'finderUserName', '视频号id', {$cat_id}, 'wechat_video_account', '', NULL, '以\'sph\'开头的id,登录视频号助手,在首页可以查看自己的视频号ID', 1, 1718248695, 1718248695);
  24. INSERT INTO `qimall_link` ( `name`, `title`, `cat_id`, `open_type`, `route`, `icon`, `remark`, `status`, `created_at`, `updated_at`) VALUES ( 'feedId', '视频id', {$cat_id}, 'wechat_video_account', '', NULL, '跳转类型为\'视频\'时必填。\\n获取视频的feedId需要登录视频号助手,在「内容管理」模块可以复制自己发表的每个视频对应的feedId。', 1, 1718248695, 1718248695);
  25. ";
  26. $this->execute($sql);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function safeDown()
  32. {
  33. echo "M240612084212InsertQimallLinkCategory cannot be reverted.\n";
  34. return false;
  35. }
  36. /*
  37. // Use up()/down() to run migration code without a transaction.
  38. public function up()
  39. {
  40. }
  41. public function down()
  42. {
  43. echo "M240612084212InsertQimallLinkCategory cannot be reverted.\n";
  44. return false;
  45. }
  46. */
  47. }