Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple indices can be created on a single column, but then can't be removed #131

Open
Tabby opened this issue Mar 9, 2023 · 0 comments

Comments

@Tabby
Copy link

Tabby commented Mar 9, 2023

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)

  add_index :users,
            :id

Second index: (creates index_for_users_on_id)

  add_index :users,
            :id,
            name: "index_for_users_on_id"

Try to remove one:

  remove_index :users,
               :id

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant