# 2.7.0.beta2 upgrade failed with ERROR: duplicate key

**URL:** <https://meta.discourse.org/t/2-7-0-beta2-upgrade-failed-with-error-duplicate-key/176980>\
**Category:** Self-hosting\
**Created:** [January 22, 2021, 8:25pm UTC](https://meta.discourse.org/t/2-7-0-beta2-upgrade-failed-with-error-duplicate-key/176980 "2021-01-22T20:25:45Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![Gunnar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gunnar/32/119647_2.png) [@Gunnar](https://meta.discourse.org/u/Gunnar)\
**Post date:** [January 26, 2021, 7:22pm UTC](https://meta.discourse.org/t/2-7-0-beta2-upgrade-failed-with-error-duplicate-key/176980/27 "2021-01-26T19:22:52Z")

</div>

> [@omarfilip](#):
>
> a better way to do it

In my case, the problem was duplicate users. So, focusing on that, one way of finding them that worked well for me, was this:

`SELECT username_lower, count(*) from users GROUP by username_lower HAVING count(*) > 1;`

This gave me a list of the duplicates, with the count for each.

```
 username_lower | count 
----------------+-------
 jagger | 2
 richards | 2
 patrick | 2
 peter | 2
 jagman | 2
(5 rows)

```

After fixing those, I was able to run a successful reindex, and after that, a successful rebuild.

---

_[View the full topic](https://meta.discourse.org/t/2-7-0-beta2-upgrade-failed-with-error-duplicate-key/176980)._
