Commit 181dd06f authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '226985-arguments-for-remove_concurrent_index_by_name-and-remove_concurrent_index' into 'master'

Allow keyword-based name argument for remove_concurrent_index_by_name

See merge request gitlab-org/gitlab!36673
parents e118d7ba b9bc8d2f
......@@ -136,6 +136,10 @@ module Gitlab
'in the body of your migration class'
end
index_name = index_name[:name] if index_name.is_a?(Hash)
raise 'remove_concurrent_index_by_name must get an index name as the second argument' if index_name.blank?
options = options.merge({ algorithm: :concurrently })
unless index_exists_by_name?(table_name, index_name)
......
......@@ -178,6 +178,19 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
model.remove_concurrent_index_by_name(:users, "index_x_by_y")
end
it 'removes the index with keyword arguments' do
expect(model).to receive(:remove_index)
.with(:users, { algorithm: :concurrently, name: "index_x_by_y" })
model.remove_concurrent_index_by_name(:users, name: "index_x_by_y")
end
it 'raises an error if the index is blank' do
expect do
model.remove_concurrent_index_by_name(:users, wrong_key: "index_x_by_y")
end.to raise_error 'remove_concurrent_index_by_name must get an index name as the second argument'
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment