add_column allows you to create additional indices on columns that already have an index by providing a custom name for the index, e.g.
Original index: (creates idx_users_on_id)
Second index: (creates index_for_users_on_id)
add_index :users,
:id,
name: "index_for_users_on_id"
Try to remove one:
This gives an error saying that there are multiple indices on the id column so Rails doesn't know which one to remove.
We should have the ability to specify at least the name in remove_index (possibly all the same args as can be given to add_index) so that the generated migration is specific enough to always be able to remove an index even in situations like this
add_columnallows you to create additional indices on columns that already have an index by providing a custom name for the index, e.g.Original index: (creates
idx_users_on_id)Second index: (creates
index_for_users_on_id)Try to remove one:
This gives an error saying that there are multiple indices on the
idcolumn so Rails doesn't know which one to remove.We should have the ability to specify at least the name in
remove_index(possibly all the same args as can be given toadd_index) so that the generated migration is specific enough to always be able to remove an index even in situations like this