Delete merge_request_metrics -> ci_pipelines FK
What does this MR do and why?
This MR removes the foreign key between the merge_request_metrics
and ci_pipelines
tables. This is needed for CI DB decomposition.
Within this MR, I add a new shared example that can test the loose FK cleanup behaviour.
Related epic: #348272 (closed)
Migration
Up:
== 20211213102111 DropCiPipelinesMrMetricsFk: migrating =======================
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:merge_request_metrics)
-> 0.0045s
-- remove_foreign_key(:merge_request_metrics, :ci_pipelines, {:name=>"fk_rails_33ae169d48"})
-> 0.0068s
== 20211213102111 DropCiPipelinesMrMetricsFk: migrated (0.0227s) ==============
Down:
== 20211213102111 DropCiPipelinesMrMetricsFk: reverting =======================
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:merge_request_metrics)
-> 0.0026s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE merge_request_metrics\nADD CONSTRAINT fk_rails_33ae169d48\nFOREIGN KEY (pipeline_id)\nREFERENCES ci_pipelines (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0026s
-- execute("SET statement_timeout TO 0")
-> 0.0007s
-- execute("ALTER TABLE merge_request_metrics VALIDATE CONSTRAINT fk_rails_33ae169d48;")
-> 0.0057s
-- execute("RESET statement_timeout")
-> 0.0006s
== 20211213102111 DropCiPipelinesMrMetricsFk: reverted (0.0254s) ==============
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 Adam Hegyi