Update failed - PG::UniqueViolation: ERROR


#1

Hi guys,

I tried to update Discourse forum to the latest version 2.2.0.beta5 on stage instance, but it failed.

The error is:

I, INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_polls_on_post_id_and_name"
DETAIL:  Key (post_id, name)=(662593, poll) already exists.

I logged into postgresql database and checked that there are no values in polls table, so it is strange why do we receive an error -  "Key (post_id, name)=(662593, poll) already exists.":
=> SELECT * FROM polls;
id | post_id | name | close_at | type | status | results | visibility | min | max | step | anonymous_voters | created_at | updated_at
----+---------+------+----------+------+--------+---------+------------+-----+-----+------+------------------+------------+------------
(0 rows)

=> \d polls_id_seq
        Sequence "public.polls_id_seq"
    Column     |  Type   |        Value
---------------+---------+---------------------
 sequence_name | name    | polls_id_seq
 last_value    | bigint  | 4524
 start_value   | bigint  | 1
 increment_by  | bigint  | 1
 max_value     | bigint  | 9223372036854775807
 min_value     | bigint  | 1
 cache_value   | bigint  | 1
 log_cnt       | bigint  | 24
 is_cycled     | boolean | f
 is_called     | boolean | t
Owned by: public.polls.id

=> select count(id),max(id) from polls;
 count | max
-------+-----
     0 |
(1 row)

Can you, please, help with this issue.
As because of this error we cannot update Discourse forum.