# Upgrade failed with "duplicate key value violates unique constraint" error

**URL:** https://meta.discourse.org/t/upgrade-failed-with-duplicate-key-value-violates-unique-constraint-error/142767
**Category:** Self-hosting
**Created:** [February 27, 2020, 10:54am UTC](https://meta.discourse.org/t/upgrade-failed-with-duplicate-key-value-violates-unique-constraint-error/142767 "2020-02-27T10:54:22Z")
**Posts on this page:** 1
**Showing post:** 19

<div class="post-metadata">

### Author: ![morevnaproject](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/morevnaproject/32/171168_2.png) [@morevnaproject](https://meta.discourse.org/u/morevnaproject)
#### Post date: [February 29, 2020, 7:19am UTC](https://meta.discourse.org/t/upgrade-failed-with-duplicate-key-value-violates-unique-constraint-error/142767/19 "2020-02-29T07:19:13Z")

</div>

Okay, I did the following from `pgsql`:

```plaintext
SELECT *
	FROM post_custom_fields
	WHERE name = 'polls'
	AND value LIKE '%399fc6670871474cd7ce0458401fd299%';

```

It displayed me one row. So, I removed it:

```plaintext
DELETE FROM post_custom_fields
	WHERE name = 'polls'
	AND value LIKE '%399fc6670871474cd7ce0458401fd299%';

```

Note: The proper way would be to remove by row id, but since it returned just a single row I did just that. 🙂

After that I re-started upgrade and it completed successfully. Thanks to everyone who posted their hints! 🙂

---

_[View the full topic](https://meta.discourse.org/t/upgrade-failed-with-duplicate-key-value-violates-unique-constraint-error/142767)._
