ActiveRecord::RecordNotUnique on idx_tag_users_ix1:如何修复?

继续讨论 SSO 损坏 - 找不到请求的 URL 或资源

我遇到了类似的问题:

ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "idx_tag_users_ix1"

有什么办法可以删除重复的键吗?

我认为这是因为您有大小写混合的标签(您有 tagTag)。

这是在重建时发生的还是在其他时间发生的?

我认为应该做的是尝试重建索引,然后修复标签的大小写(如果我猜得没错),或者删除其中一个重复的条目。

1 个赞

嗯…… 事实并非如此。

Tag.all.pluck(:name)
=> ["welcome",
 "faq",
 "sysadmin",
 "offdem-0x03",
 "reference",
 "tutorial",
 "local-organization",
 "collective-data",
 "power-relations",
 "offdem-topic",
 "offdem-0x00",
 "offdem-0x01",
 "offdem-0x02",
 "discourse-plugin",
 "page",
 "how-to",
 "about",
 "offdem-0x04"]

据推测,它出现在本月早些时候。我想是在升级之后。

我不知道它是怎么发生的,但我可以删除重复的标签:

TagUser.all.where(user_id: 80, tag_id:2).last.destroy

对于每一个重复项(我是手动完成的)。

谢谢你,Jay!

请注意,症状已清除,但原因尚不清楚。

:thinking: 我怀疑标签上的组通知在追溯应用时,不会检查现有条目 @pfaffman

1 个赞

这些重复的 whatever 问题通常都是这样。

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.