Permanently deleting posts from the db for privacy reasons

I want to nightly delete posts that are in an autoclosed status in a specific category on a regular basis for privacy reasons

as discussed here:

Would this be the rails command?

Topic.where(closed: true).where(category_id: <your category id here>).destroy_all

Is there any risk to my site if I was to run this command every night?

2 Likes

So I went ahead and set this up and it’s working.

For anyone that’s interested I created a bash script that I run daily from cron:

#!/bin/bash
# Script to permanently delete discourse posts from a specific category that are closed

expect -c "

# This may be $ or # or something else dependent on host environment. Change accordingly.

set prompt \"root@ip-172-31-31-39-app:/var/www/discourse# \"
spawn sudo /var/discourse/launcher enter app
expect $prompt
send \"echo 'Topic.where(closed: true).where(category_id: 11).destroy_all' | rails c > /dev/null\r\"
send \"exit\r\"
"
3 Likes