fhe
(Florian)
2025 年 3 月 26 日午前 6:39
1
I’m getting this error when trying to update via
./launcher rebuild app
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: could not create unique index "index_discourse_solved_solved_topics_on_answer_post_id" (ActiveRecord::RecordNotUnique)
DETAIL: Key (answer_post_id)=(201795) is duplicated.
Any ideas on how to resolve this issue?
thoka
(Thomas Kalka)
2025 年 3 月 26 日午前 8:00
3
Delete one of the SolvedTopic
records via rails console:
DiscourseSolved::SolvedTopic.where(answer_post_id:201795).last.destroy
「いいね!」 1
fhe
(Florian)
2025 年 3 月 26 日午前 9:16
4
Thank you. I’ve tried to access those, but I’m getting
NameError: uninitialized constant SolvedTopic
Any other ideas?
fhe
(Florian)
2025 年 3 月 26 日午前 9:32
5
I’ve now connected to the database directly and deleted the record with the duplicate answer_post_id
from discourse_solved_solved_topics
.
All good now. Thanks again for your quick reply!
「いいね!」 1
thoka
(Thomas Kalka)
2025 年 3 月 26 日午後 12:59
6
Hm. discourse-solved was updated recently .
There is a chance, that this error was thrown during database migration.
fhe
(Florian)
2025 年 3 月 26 日午後 2:19
7
Yes, this happened during database migration.
thoka
(Thomas Kalka)
2025 年 3 月 26 日午後 5:04
8
Seems to be fixed with this patch:
committed 02:21PM - 26 Mar 25 UTC
We are seeing some errors when migrating and adding indexes on `answer_post_id`.…
```
#<StandardError:"An error has occurred, all later migrations canceled:\n\nPG::UniqueViolation: ERROR: could not create unique index \"index_discourse_solved_solved_topics_on_answer_post_id\"\nDETAIL: Key (answer_post_id)=(13006) is duplicated.\n">
```
This PR modifies the earlier migration, and also adds one before the addition of indexes to remove duplicates.
「いいね!」 4
fhe
(Florian)
2025 年 3 月 26 日午後 5:07
9
Excellent! Thanks for the heads up — I’ve marked your post as solution.
「いいね!」 2
nat
(Natalie T)
クローズされました:
2025 年 4 月 9 日午前 7:25
10
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.