ERROR RecordNotUnique on index_discourse_solved_solved_topics_on_answer_post_id

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?

Delete one of the SolvedTopic records via rails console:

DiscourseSolved::SolvedTopic.where(answer_post_id:201795).last.destroy
1 Like

Thank you. I’ve tried to access those, but I’m getting

NameError: uninitialized constant SolvedTopic

Any other ideas?

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 Like

Hm. discourse-solved was updated recently.

There is a chance, that this error was thrown during database migration.

Yes, this happened during database migration.

Seems to be fixed with this patch:

3 Likes

Excellent! Thanks for the heads up — I’ve marked your post as solution.

2 Likes