Enable setting to allow admins to permanently delete data

As of 2.8.0.beta7: Security Release, Fast Edits, Topic Bookmarks, and more there is a hidden site setting to allow admins to permanently delete data. To enable it, you’d set the SiteSetting at the Rails console like this:

cd /var/discourse
./launcher enter app
rails c
SiteSetting.can_permanently_delete=true
exit
exit

This change takes effect immediately. No further action is necessary.

Another way to accomplish this would be to add it to app.yml in the env: section. To do that you would add in the env: section (say, under DISCOURSE_HOSTNAME)

  DISCOURSE_CAN_PERMANENTLY_DELETE: true

To have this change take effect, you need to ./launcher rebuild app to have that setting applied.

19 Likes

A clarification on this feature. If a post is permanently deleted, what happens to other posts which have quoted the deleted post? Would it display the quoted post?

1 Like

If those posts have copied the contents of the post in question, then I’m fairly certain that this isn’t going to find them and edit them. But I haven’t tested or looked at the code.

This topic was intended to be more about how to enable the feature than explaining what it does, but perhaps that was short-sighted.

2 Likes

Hi @pfaffman,
I have a large number of ‘deleted posts’ under system user. They’re done by migration script, I’m not sure if they’re ‘deleted by admins’. I then execute above commands, does this setting apply to my case? After few mins, I can still see ‘deleted posts’ under system user. What else can I do to permanently delete data?

Thanks!

There is a PostDestroyer method that could be used. If it’s not too late, I’d update the migration script to not import the data.

Sounds like there’s no easy way to delete posts belongs to system user, right? It has to be under a ‘admin’ users.

The import script I use has below line, which I suppose moving deleted post to system user. But I have to re-import the data and changes made early I have to redo manually.

PostDestroyer.new(Discourse.system_user, action_post).perform_delete

No, that is destroying the post and making a note that the system user is asking that it be deleted.

My suggestion is that you find the place in the script that is creating the post and skipping it so that it is never created and you don’t need to delete it. Ideally, you can wipe the database and run the script again from the beginning, but if your site is live already then you can’t do that and you’ll need to delete the messages. But it’s probably easiest to do nothing and pretend that the messages don’t exist.

1 Like

Does this setting still work in the latest stable version (3.0.3)? I tried both methods, but when I edit a post and hide the revision, there is no Delete revisions button.

Ah, I hadn’t realised you were on the Stable version. The Delete Revision option is fairly new so won’t be included until the next Stable release in a couple of months. Sorry to get your hopes up prematurely. :slight_smile:

2 Likes

3 posts were split to a new topic: Where to find the ‘permanently delete’ function?

Hi, none of the methods you mention works. I only have the delete option but no permanent delete. Was this feature removed?