ruby on rails - Advanced usage of add_index -


in ruby on rails project have migration creates case insensitive index string column.

class addcecodetousers < activerecord::migration   def change     add_column :users, :ce_code, :string      execute <<-sql       create unique index index_users_on_lower_ce_code_index         on users using btree (lower(ce_code));     sql   end end 

this works expected want know there way same using rails built_in add_index method?

for mysql try:

add_index "users", "lower(ce_code)", name: "index_users_on_lower_ce_code" 

for pg try:

install gem "schema_plus_pg_indexes"

t.index expression: "lower(ce_code)", name: "index_users_on_lower_ce_code" 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -