A bit of a late answer, but I just ran into the same issue so I am writing this answer in the hopes it will help others in the future.
The issue that the original asker ran into led to the solution. It appears that in Rails 3.x, the implementation of index_name_for_remove
was flawed so that it sometimes did not accept named indexes. Instead, it raised an ArgumentError
claiming the index does not exist.
In Rails 4.x, the implementation was changed so that passing a hash with the index name was handled correctly (I think, I do not have a Rails 4 app at the moment to test with).
If you need to handle this in Rails 3.x, looking at the source of remove index
leads to the solution - using the remove_index!
method.
remove_index!
takes two arguments - the table name and the index name. So in the case of the original poster's question, this command should do the job:
remove_index! :users, :index_users_on_email
Update: After posting the answer I noticed that the original poster was asking about Rails 4, so it would seem that in certain cases there are still problems with the implementation of index_name_for_remove
not detecting the correct index name. However, since the name of the index is known and we don't need to actually find out what the name is (which is what index_name_for_remove
does internally), we can still use the remove_index!
method to remove it.