# Completely remove user data from the system

**URL:** <https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629>\
**Category:** Self-hosting\
**Tags:** rails-console\
**Created:** [June 5, 2024, 8:54am UTC](https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629 "2024-06-05T08:54:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [June 5, 2024, 3:35pm UTC](https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629/3 "2024-06-05T15:35:41Z")

</div>

Could you just delete them?

```plaintext
u=User.find_by_username('byebye')
posts=Post.where(user_id: u.id)

```

and then call PostDestroyer on all of the posts. (I don’t remember exactly how to do that offhand.)

If you really want to replace their posts with “deleted by…” then you’d do something like

```plaintext
posts.update_all(raw: "deleted by user request")

```

And then you’d need to wipe stuff from the PostRevision model, maybe

```plaintext
posts.each do |p|
  bad=PostRevision.where(post_id: p.id)
  bad.destroy_all
end

```

You’d want to do a couple of those by hand as a test, or on a staging site if you’re really careful.

---

_[View the full topic](https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629)._
