# Import failing with \`could not create unique index\`

**URL:** <https://meta.discourse.org/t/import-failing-with-could-not-create-unique-index/154693>\
**Category:** Self-hosting\
**Created:** [12 ביוני,‏ 2020,‏ 7:10pm UTC](https://meta.discourse.org/t/import-failing-with-could-not-create-unique-index/154693 "2020-06-12T19:10:16Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Paulus\_Schoutsen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paulus_schoutsen/32/183883_2.png) [@Paulus\_Schoutsen](https://meta.discourse.org/u/Paulus_Schoutsen)\
**Post date:** [13 ביוני,‏ 2020,‏ 9:29pm UTC](https://meta.discourse.org/t/import-failing-with-could-not-create-unique-index/154693/7 "2020-06-13T21:29:27Z")

</div>

One last tip for people debugging data corruption issues. Initially when our import failed on duplicate data I jumped into the Rails console and searched by the data that caused the index to fail to be created.

However, by querying using the indexed fields, Postgres was using the broken index to generate the results! So my initial query showed 1 result, and later when deleting that entry it showed 0 results.

Queries that do full table scans for the win 🙂

---

_[View the full topic](https://meta.discourse.org/t/import-failing-with-could-not-create-unique-index/154693)._
