I am trying to remove some categories in favor of using tags, but I end up with one system created topic that I cannot delete (it is Technical in the screenshot, notice the -1 replies). If I try to visit this topic the page freezes and I have to close the tab and start over. Any idea how to delete this, possibly in rails?
cd /var/discourse ./launcher enter app rails c Topic.find(id).destroy
You will find the
id placing the mouse over the topic title
Thanks Daniela, that worked to delete the topic, but now when I try to delete the category it still thinks there is one topic and won’t allow me to delete the category. Similar function to delete the category?
Take a full backup of your site, then try with
cd /var/discourse ./launcher enter app rails c rake destroy:topics["Gear","Discussions"]
where Gear is your subcategory and Discussions is your parent category.
This should be enough to destroy all the topics in that subcategory. After that you should be able to delete the subcategory.
Unfortunately this is the result…
NameError: undefined local variable or method `topics' for main:Object from (pry):1:in `__pry__'  pry(main)>
My mistake, try only
cd /var/discourse ./launcher enter app rake destroy:topics["Gear","Discussions"]
There are 0 topics to delete in discussions/gear category yet I still can’t delete the category
Can't delete this category because topic count is 1.
Can you see your logs to see if there are specific errors?
No I don’t see anything in the logs related to this…
Can you try updating the category counters, and see if that helps.
cd /var/discourse ./launcher enter app rails c Category.ensure_consistency!
And then try deleting the category again
I was able to reset the topic count using
Category.find_by(name: 'Gear').update(topic_count: 0)
And then was able to delete the category, thanks David!