Skip to content

Renaming column name with index generates wrong migrations #259

Closed
@jeroen11dijk

Description

@jeroen11dijk

I had a resource with a start_date with an index but I renamed it to date and while generating the migration it switched the order around by first adding an index before renaming the column which will result in a crash.

def up do
    drop_if_exists index(:events, [:start_date])

    create index(:events, [:date])

    rename table(:events), :start_date, to: :date

    alter table(:events) do
      modify :date, :date
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions