# Error on restore: could not create unique index

**URL:** <https://meta.discourse.org/t/error-on-restore-could-not-create-unique-index/220816>\
**Category:** Self-hosting\
**Created:** [March 12, 2022, 9:49pm UTC](https://meta.discourse.org/t/error-on-restore-could-not-create-unique-index/220816 "2022-03-12T21:49:23Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

[slackmoehrle](/t/-/220816/1) is migrating their Discourse community to a new provider but is blocked by a restore error: `could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"`. The error indicates a duplicate key exists for the path `/m/search` and `incoming_domain_id` 989, yet a direct query on the `incoming_referers` table returned zero rows, suggesting the data might be hidden or the index is corrupted. [pfaffman](/t/-/220816/2) suggests the issue is likely a corrupt index requiring the removal or fixing of duplicate entries. They recommend using [amcheck to check PostgreSQL index integrity](https://meta.discourse.org/t/how-to-use-amcheck-to-check-postgresql-index-integrity-corruption/153207) and reference a related thread on [dealing with corrupt indexes during restore](https://meta.discourse.org/t/cant-restore-due-to-corrupt-indexes-with-some-clues-on-how-to-deal-with-corrupt-indexes/137400) for further solutions.

<div class="post-metadata">

**Author:** ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)\
**Post date:** [March 12, 2022, 9:49pm UTC](https://meta.discourse.org/t/error-on-restore-could-not-create-unique-index/220816/1 "2022-03-12T21:49:23Z")

</div>

I am moving our community to a new provider.

```sql
CREATE INDEX
CREATE INDEX
ERROR: could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"
DETAIL: Key (path, incoming_domain_id)=(/m/search, 989) is duplicated.
CONTEXT: parallel worker
EXCEPTION: psql failed: CONTEXT: parallel worker
/var/www/discourse/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:51:in `run'
script/discourse:149:in `restore'

```

I tried some previous thoughts on this error:

```sh
discourse=# select * from incoming_referers where path LIKE '%/search/' ORDER BY incoming_domain_id;
 id | path | incoming_domain_id
----+------+--------------------
(0 rows)

```

can anyone help me solve this error?

---

<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:** [March 12, 2022, 10:01pm UTC](https://meta.discourse.org/t/error-on-restore-could-not-create-unique-index/220816/2 "2022-03-12T22:01:07Z")

</div>

It’s likely a corrupt index. Someone will need to remove or fix the duplicate entries. [How to Use amcheck to Check PostgreSQL Index Integrity (Corruption)](https://meta.discourse.org/t/how-to-use-amcheck-to-check-postgresql-index-integrity-corruption/153207)might help. See also [Can't restore due to corrupt indexes (with some clues on how to deal with corrupt indexes)](https://meta.discourse.org/t/cant-restore-due-to-corrupt-indexes-with-some-clues-on-how-to-deal-with-corrupt-indexes/137400).
