Migration generator should add :unique => true for fields declared unique
Reported by Tom Locke | June 23rd, 2009 @ 07:33 PM | in Beyond Hobo 1.0
This should be handled in the DB as well -- doing it just in the app has race conditions.
AFAIK the DB support for policing this can only handle the case where validates_uniqueness_of does not have a scope.
Comments and changes to this ticket
-
Tom Locke October 24th, 2009 @ 06:13 PM
- State changed from new to open
-
Matt Jones October 24th, 2009 @ 10:29 PM
Note that the index generator stuff does this for indexed fields - and some poking around on Google shows that a scoped unique might be possible by doing this:
validates_uniqueness_of :some_field, :scope => :some_other_field TRANSLATE TO: index [:some_field, :some_other_field], :unique => true
Not sure about how allow_blank and allow_nil will interact with this; I've noticed that MySQL unique indexes don't like blanks but are OK with duplicate NULLs.
-
Bryan Larsen October 29th, 2009 @ 11:18 PM
- Tag set to enhancement, migration-generator
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป