Skip to content

Convenient use of concurrent migration helpers

Andreas Brandl requested to merge ab-43887-concurrent-migration-helpers into master

What does this MR do?

This makes it more convenient to use concurrent migration helpers #add_concurrent_index, #remove_concurrent_index and #add_concurrent_foreign_key.

Those helpers have in common that they can only be used in migrations that have transactions disabled due to their "concurrent" nature. That is, if the process fails in the middle of the migration, it may leave back an inconsistent state where some indexes/foreign keys have been created.

It is good practice to guard calls to those methods with checks for existence of the desired objects. For example:

  add_concurrent_index :table1, :a unless index_exists?(:table1, :a)

This gets a little bulky with more than one index/foreign key in a migration. Confusingly, the methods to check existence have a slightly different signature than the ones to create the object.

This MR addresses this and adds the guarding checks inside the above mentioned helper methods.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #43887 (closed).

Edited by Yorick Peterse

Merge request reports

Loading