Bulk convert topics to PMs

I plan to convert a bunch of topics to group PMs in order to depreciate some barely used categories. We can’t do that via the UI (only one by one), nor can I find a bulk way to do it.

As far as I can tell this should work via the console:

  1. Identify the topics by their category
  2. Change topic.archetype to private_message
  3. Change topic.subtype to ‘user_to_user’
  4. Make topic.category Null
  5. In topic_groups (or maybe topic_allowed_groups), add a line with the relevant group_id and topic_id

Does this approach make sense? I need to work out the difference between those topic/groups tables first of course. And do it in a sandbox for starters!!

1 Like

That could work. Also, if you don’t know you can do something like

 topics = Topic.where(category: 10)

  topics.update_all(archetype: xxx, topic_category: nil)

Or something like that. If you knew about update_all, this isn’t news.


Thanks Jay! That would be nice and fast for the first half. However, I also have to ensure that they end up as Group PMs.

Any idea what I have to do with the topic_groups / topic_allowed_groups tables? I don’t think that I can get away with an update_all for them.

1 Like