Skip to content

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

Description

@Tabby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions