开发者

How to triage this MySQL duplicate entry error after running Rails migration?

开发者 https://www.devze.com 2023-01-01 18:40 出处:网络
I get the following error when I try to run this migration: ==AddUniquenessConstraintOnAwards: migrating ================================

I get the following error when I try to run this migration:

==  AddUniquenessConstraintOnAwards: migrating ================================
-- add_ind开发者_开发问答ex(:awards, [:badge_id, :game_week_id], {:unique=>true, :name=>:game_badge_index})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Duplicate entry '35-8192' for key 'game_badge_index': CREATE UNIQUE INDEX `game_badge_index` ON `awards` (`badge_id`, `game_week_id`)

Has anyone encountered? What's the error telling me? How did you troubleshoot it and ultimately fix it?


The error is telling you that there is at least two records in your awards table that have the same values for badge_id and game_week_id (entry 35-8192), and such duplicate entries aren't permitted for a Unique index

To fix it, you eliminate the duplicate records

0

精彩评论

暂无评论...
验证码 换一张
取 消