Deleting all topics in a category


(David Taylor) #1

To delete all topics from a category, you will need access SSH access to your server. If you use managed Discourse hosting, get in touch with your provider and ask them to help. If you run your own server, here are the steps you need to take to delete all topics in a category:

:warning: This is a destructive action. Make sure to back up your forum before continuing

  1. Find the “slug” of your category. This is the name of category used in the URL.

  2. SSH into the server

  3. cd /var/discourse
    
  4. ./launcher enter app
    
  5. rake destroy:topics["mycategory"]
    

    (replace “mycategory” with the slug of your category)

  6. Wait… this may take some time, depending how many topics you have

Subcategories

To delete topics in a subcategory, you need to supply the parent category slug as well. For example, if “childcategory” is a subcategory of “parentcategory”, the command would look like

rake destroy:topics["childcategory","parentcategory"]

:warning: All categories

To delete all topics in all categories, you can use the command:

rake destroy:topics_all_categories

(Ultra Noob) #2

Thanks, this was a brilliant tip.

How long Discourse stores deleted topics? I see it still become accessible with direct link.


(David Taylor) #3

The topics remain in the database forever

Only staff can see deleted topics.