fatkodima/online_migrations

Remove index by name

internethostage opened this issue · 3 comments

First of all thank you for your hard work on this gem!

I noticed that the ability to remove index by name doesn't work as it does using the Rails remove_index method.

example:

class Test < ActiveRecord::Migration[6.0]
  disable_ddl_transaction!

  def up
    add_index :campaigns, :weight, algorithm: :concurrently
  end

  def down
    remove_index :campaigns, name: :index_campaigns_on_weight, algorithm: :concurrently
  end
end

The above, after running migrate (successfully adds index), then rollback results in:

-- remove_index(:campaigns, {:name=>:index_campaigns_on_weight, :algorithm=>:concurrently})
-- [online_migrations] Index was not removed because it does not exist (this may be due to an aborted migration or similar): table_name: campaigns, column_name: []
   -> 0.0040s

As a side note, its quite inconvenient that this sets the migration as completed, though the index was not removed.

Hey @internethostage, thank you for the report! I am glad you find this gem useful.

Which rails version are you using? Are you on the main?

Opened also a PR into rails - rails/rails#46458.

Hey!

Sorry for the lack of context, using Rails 6.0.5.1

@internethostage Released a new version with the fix.