# 批量将一个分类下的主题转换为群组私信

**URL:** <https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811>\
**Category:** Product Support\
**Tags:** rails-console\
**Created:** [2022 年2 月 19 日 13:32 UTC](https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811 "2022-02-19T13:32:31Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)\
发布日期： [2022 年2 月 19 日 13:32 UTC](https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811/1 "2022-02-19T13:32:31Z")

</div>

我计划将一系列主题转换为群组 PM，以弃用一些很少使用的类别。我们无法通过用户界面执行此操作（一次只能一个），也找不到批量执行的方法。

据我所知，这应该可以通过控制台完成：

1. 按类别识别主题
2. 将 topic.archetype 更改为 `private_message`
3. 将 topic.subtype 更改为 ‘user\_to\_user’
4. 将 topic.category 设为 `Null`
5. 在 topic\_groups（或可能是 topic\_allowed\_groups）中，添加一行包含相关 group\_id 和 topic\_id

这种方法有意义吗？当然，我需要先弄清楚这些 topic/groups 表之间的区别。并且首先在沙盒中进行！！

---

_[View the full topic](https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811)._
