I need to create a case-insensitive index on a column in rails. I did this via SQL:
execute(
\"CREATE UNIQUE INDEX index_users_on_lower_email_index
O
I would suggest (just as an opportunity to consider among others) to use two separate fields:
The first one is always down cased and thus can be uniquely indexed in a database agnostic manner, while the second field keeps verbatim to what user enetered and can have upper characters.
Obviously in User model one then needs to set email based on email_original on each save and prohibit direct mangling with email field.