Require user names and emails to be case insensitively unique

Any existing clashes are allowed to remain for now, byt any new
accounts, or changes to names on existing accounts, must be unique
without regard to case.
This commit is contained in:
Tom Hughes 2011-12-12 19:11:06 +00:00
parent ebf597971f
commit af2b13c2c1
3 changed files with 22 additions and 3 deletions

View file

@ -198,7 +198,13 @@ module ActiveRecord
else
index_type = options
end
quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ")
quoted_column_names = column_names.map { |e| quote_column_name(e) }
if Hash === options and options[:lowercase]
quoted_column_names = quoted_column_names.map { |e| "LOWER(#{e})" }
end
quoted_column_names = quoted_column_names.join(", ")
execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})"
end
end