# Permanent deletion: Is there a database command?

**URL:** https://meta.discourse.org/t/permanent-deletion-is-there-a-database-command/271554
**Category:** Support
**Created:** [July 13, 2023, 3:47pm UTC](https://meta.discourse.org/t/permanent-deletion-is-there-a-database-command/271554 "2023-07-13T15:47:21Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 13, 2023, 4:10pm UTC](https://meta.discourse.org/t/permanent-deletion-is-there-a-database-command/271554/2 "2023-07-13T16:10:15Z")

</div>

If your wish is to hard-delete all the soft-deleted posts, then you could loop through them with a rails script and use the destroy method.

That might give some info:

> [@How to delete thousands of Personal Messages?](https://meta.discourse.org/t/how-to-delete-thousands-of-private-messages/162747/7):
>
> Revisiting this old topic, since none of the answers are 100% correct. The rake task rake destroy:private\_messages does not hard delete all private messages, it soft deletes them. They can still be seen by an admin and they can be recovered. The Rails code Topic.where(archetype: 'private\_message').where("user\_id \> 0").destroy\_all destroys the topics, but not the actual messages. They are still in the database and can be viewed using for instance the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin. This code will perma…

---

_[View the full topic](https://meta.discourse.org/t/permanent-deletion-is-there-a-database-command/271554)._
