Refactor add_concurrent_partitioned_foreign_key migration helper
Ref: #382033 (closed)
What does this MR do and why?
It refactors add_concurrent_partitioned_foreign_key
migration helper to allow multiple column references.
It also alows to skip adding the FK on the parent table
for async validation. Example of usage:
First migration to add the FK on all partitions:
add_concurrent_partitioned_foreign_key(
:p_ci_builds_metadata,
:ci_builds,
column: [:partition_id, :build_id],
target_column: [:partition_id, :id],
name: :fk_multiple_columns,
validate: false
)
Second migration to asynchronously validate the constraints on partitions:
prepare_partitioned_async_foreign_key_validation(
:p_ci_builds_metadata,
name: fk_multiple_columns
)
Third migration to add the FK on the parent table and on any new partitions that might have been created:
add_concurrent_partitioned_foreign_key(
:p_ci_builds_metadata,
:ci_builds,
column: [:partition_id, :build_id],
target_column: [:partition_id, :id],
name: :fk_multiple_columns,
validate: true
)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Marius Bobin