AlexMl
2018 年 12 月 7 日午前 8:51
1
こんにちは、皆さん。
ステージインスタンスで Discourse フォーラムを最新バージョン 2.2.0.beta5 に更新しようとしましたが、失敗しました。
エラー内容は以下の通りです:
I, INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
StandardError: エラーが発生しました。このマイグレーションおよび以降のすべてのマイグレーションはキャンセルされました。
PG::UniqueViolation: エラー: 重複するキー値が一意制約 "index_polls_on_post_id_and_name" に違反しています。
DETAIL: キー (post_id, name)=(662593, poll) は既に存在します。
PostgreSQL データベースにログインして polls テーブルを確認したところ、値が存在しませんでした。そのため、「キー (post_id, name)=(662593, poll) は既に存在します」というエラーが発生するのは奇妙です:
= > SELECT * FROM polls;
id | post_id | name | close_at | type | status | results | visibility | min | max | step | anonymous_voters | created_at | updated_at
----+---------+------+----------+------+--------+---------+------------+-----+-----+------+------------------+------------+------------
(0 行)
= > \d polls_id_seq
シーケンス "public.polls_id_seq"
カラム名 | 型 | 値
---------------+---------+---------------------
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
所有権: public.polls.id
= > select count(id),max(id) from polls;
count | max
-------+-----
0 |
(1 行)
この問題についてお手伝いいただけますでしょうか。
このエラーのため、Discourse フォーラムの更新ができません。
AlexMl
2018 年 12 月 10 日午前 8:28
2
Hi,
Can someone from development team take a look to this question ?
We are blocked with update of Discourse forum to the latest version, because of this error.
And also we cannot install additional plugin, as docker container is not compiled and as a result is not running.
The error indicates that the post (id: 662593) has more than one polls named “poll”.
Can you share the raw of that post? You can find it by going to https://your.discourse/posts/662593/raw
Also, can you share the results of this command when ran in the rails console?
PostCustomField.where(post_id: 662593, name: "polls")
「いいね!」 3
AlexMl
2018 年 12 月 11 日午前 11:52
5
Unfortunately, I cannot share the raw of post from https://your.discourse/posts/662593/raw , as it is not running now because of error.
The output from rail`s console:
[1] pry(main)> PostCustomField.where(post_id: 662593, name: "polls")
=> [#<PostCustomField:0x00005641ffca5f48
id: 376790,
post_id: 662593,
name: "polls",
value:
"{\"poll\":{\"options\":[{\"id\":\"4d8a15e3cc35750f016ce15a43937620\",\"html\":\"1\",\"votes\":1,\"voter_ids\":[9160]},{\"id\":\"cd314db7dfbac2b10687b6f39abfdf41\",\"html\":\"2\",\"votes\":0,\"voter_ids\":[]}],\"voters\":1,\"status\":\"open\",\"type\":\"regular\",\"public\":\"true\",\"name\":\"poll\"},\"\":{\"options\":[{\"id\":\"4d8a15e3cc35750f016ce15a43937620\",\"html\":\"1\",\"votes\":0},{\"id\":\"cd314db7dfbac2b10687b6f39abfdf41\",\"html\":\"2\",\"votes\":0}],\"voters\":0,\"status\":\"open\",\"type\":\"regular\",\"public\":\"true\"}}",
created_at: Thu, 26 Apr 2018 01:56:00 UTC +00:00,
updated_at: Thu, 26 Apr 2018 01:56:00 UTC +00:00>]
the data looks fine.
Can you try to clean all the polls related tables and then try to run the migration again?
AlexMl
2018 年 12 月 11 日午後 2:43
7
There are 3 poll related tables.
I tried to delete rows, but these tables are empty.
=> DELETE FROM poll_options;
DELETE 0
=> DELETE FROM poll_votes;
DELETE 0
=> DELETE FROM polls;
DELETE 0
Then ran the migration again, but it failed with the same error as earlier.
pfaffman
(Jay Pfaffman)
2018 年 12 月 20 日午後 10:13
8
It turns out that the problem was that the poll had been duplicated in a quote block, and the migration didn’t know to ignore it. It was in a PM, apparently as an example of how polls worked. I deleted the duplicate and the migration ran fine.
「いいね!」 6
Weird, I’ll have to test that…
「いいね!」 2