Alex Rivera | Logout

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

Asked 2013-06-05T17:03:02.323
54

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
Edit
Report

1 Answer

49

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.

answered 2013-06-05T17:07:07.297

Your Answer