Artur-Sulej / excellent_migrations

An Elixir tool for checking safety of database migrations.
MIT License
232 stars 25 forks source link

Safety of rolling back non-concurrent drops #38

Closed ding-an-sich closed 5 months ago

ding-an-sich commented 5 months ago

excellent_migrations won't complain about things like these:

def change do
  drop_if_exists index(:my_table, [:my_column])
end

Even though rolling back such a migration will recreate the index non-concurrently.

Changing this to:

def change do
  drop_if_exists index(:my_table, [:my_column], concurrently: true)
end

Will recreate the index concurrently when rolling back.

Since dropping an index by itself will acquire an ACCESS EXCLUSIVE lock on the table, I'm thinking maybe we should enforce the dropping of indexes to be concurrent to err on the side of caution.

Curious what others think of this.

ding-an-sich commented 5 months ago

Sorry, this was actually misconfiguration on my part.

Artur-Sulej commented 5 months ago

@ding-an-sich Ok, great that you found the solution 🙂