Skip to content

Add partitioned FK from p_ci_pipeline_variables to ci_pipelines

Marius Bobin requested to merge 436529-p_ci_pipeline_variables-1 into master

What does this MR do and why?

Add partitioned FK from p_ci_pipeline_variables to ci_pipelines. This is the first step for replacing the regular FK with a partitioned one which is needed for partitioning ci_pipelines.

Changelog: other

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

./scripts/regenerate-schema
RAILS_ENV=test bin/rails runner 'Feature.enable(:database_async_foreign_key_validation)'
RAILS_ENV=test bin/rails gitlab:db:validate_async_constraints:all
RAILS_ENV=test bin/rails db:schema:dump
git diff db/structure.sql

The new constraint is valid:

diff --git a/db/structure.sql b/db/structure.sql
index 5107aa43be6f..813763d34a79 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -32912,7 +32912,7 @@ ALTER TABLE p_ci_pipeline_variables
     ADD CONSTRAINT fk_f29c5f4380 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;

 ALTER TABLE ONLY ci_pipeline_variables
-    ADD CONSTRAINT fk_f29c5f4380_p FOREIGN KEY (partition_id, pipeline_id) REFERENCES ci_pipelines(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE NOT VALID;
+    ADD CONSTRAINT fk_f29c5f4380_p FOREIGN KEY (partition_id, pipeline_id) REFERENCES ci_pipelines(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE;

 ALTER TABLE ONLY zoekt_indices
     ADD CONSTRAINT fk_f34800a202 FOREIGN KEY (zoekt_node_id) REFERENCES zoekt_nodes(id) ON DELETE CASCADE;

Related to #436529 (closed)

Edited by Marius Bobin

Merge request reports