# Rake users:merge on former admin account throws error

**URL:** <https://meta.discourse.org/t/rake-users-merge-on-former-admin-account-throws-error/108716>\
**Category:** Product Support\
**Tags:** merge-user\
**Created:** [2월 8, 2019, 8:53오후 UTC](https://meta.discourse.org/t/rake-users-merge-on-former-admin-account-throws-error/108716 "2019-02-08T20:53:57Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2월 8, 2019, 9:21오후 UTC](https://meta.discourse.org/t/rake-users-merge-on-former-admin-account-throws-error/108716/6 "2019-02-08T21:21:54Z")

</div>

You can run the following code in the rails console (`rails c`) to find the offending posts. I’ll leave it up to you what you do with them.

```ruby
source_user = User.find_by_username("<source username>");

Post.with_deleted.
  where(user_id: source_user.id).
  where("NOT EXISTS (SELECT 1 FROM topics WHERE posts.topic_id = topics.id)")

```

---

_[View the full topic](https://meta.discourse.org/t/rake-users-merge-on-former-admin-account-throws-error/108716)._
