migration "MoveStylesToContent" fails

Support Ticket


When attempting upgrade from 1.11.7 to 1.12.5, wagn:migrate successfully applies AddStyleCards and then crashes in MoveStylesToContent with:


==  MoveStylesToContent: migrating ============================================
rake aborted!
An error has occurred, this and all later migrations canceled:

Validation failed: Codename codename  already in use


By running commands in a rails console, it's clear that the update_attributes! call fails for all of the style cards when trying to set :codename to nil. My suspicion -- which I haven't verified -- is that a validation was added sometime after that card migration was created, so it used to work fine in some intermediate version.


To work around this, I changed the migration so that it only sets :content (which worked fine) and then eliminated codename for those records directly in the database ('update cards set codename = null where id in (...)'). This worked fine, but is probably a little bit too invasive to expect everyone who's gotten a few releases behind to do.

expand_less +discussion

Hi Brett,


Sorry for the slow reply; I was away for Thanksgiving.


Your diagnosis is exactly correct. There is a new validation of codename uniqueness that mishandling nil codenames. I've just added a fix and will try to get that pushed and deployed soon, but you shouldn't need it. Your workaround looks fine to me (though of course you're right: most wouldn't be able -- and shouldn't need -- to figure that out!).

--Ethan McCutchen.....2013-12-02 18:19:56 +0000