Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change column index in rails 3 migration?

I have a table 'users' with column 'email'. It used to be unique (with index), but a new requirement is to allow nils there.

Is there a better solution than:

  remove_index :users, :email   add_index :users, :email 

?

Initially it was added with option unique:

add_index :users, :email, :unique => true 
like image 326
santuxus Avatar asked Jun 05 '13 17:06

santuxus


1 Answers

I would say that you have the correct solution there as the index will need to be regenerated, hence why there is no update_index.

like image 101
ChuckJHardy Avatar answered Oct 11 '22 11:10

ChuckJHardy