Convenient use of concurrent migration helpers
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?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together -
End-to-end tests pass ( package-and-qa
manual pipeline job)
What are the relevant issue numbers?
Closes #43887 (closed).