Skip to content

LFK: Remove foreign key dast_site_profiles_builds.ci_build_id

What does this MR do and why?

In !77908 (merged) we already added a "loose foreign key" to replace this foreign key. Now that this has been running fine in production we should be OK to remove the foreign key altogether.

This was added in a post-deployment migration as we want to ensure that they have the correct code running with the loose foreign key in place before we remove the foreign key to ensure that there isn't any lost deletes.

Migration output

Up

== 20220110233155 RemoveDastSiteProfilesBuildsCiBuildIdFk: migrating ==========
-- transaction_open?()
   -> 0.0000s
-- execute("LOCK ci_builds, dast_site_profiles_builds IN ACCESS EXCLUSIVE MODE")
   -> 0.0015s
-- foreign_keys(:dast_site_profiles_builds)
   -> 0.0042s
-- remove_foreign_key(:dast_site_profiles_builds, :ci_builds, {:name=>"fk_a325505e99"})
   -> 0.0038s
== 20220110233155 RemoveDastSiteProfilesBuildsCiBuildIdFk: migrated (0.0117s) =

Down

== 20220110233155 RemoveDastSiteProfilesBuildsCiBuildIdFk: reverting ==========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:dast_site_profiles_builds)
   -> 0.0038s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE dast_site_profiles_builds\nADD CONSTRAINT fk_a325505e99\nFOREIGN KEY (ci_build_id)\nREFERENCES ci_builds (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0024s
-- execute("SET statement_timeout TO 0")
   -> 0.0006s
-- execute("ALTER TABLE dast_site_profiles_builds VALIDATE CONSTRAINT fk_a325505e99;")
   -> 0.0077s
-- execute("RESET statement_timeout")
   -> 0.0007s
== 20220110233155 RemoveDastSiteProfilesBuildsCiBuildIdFk: reverted (0.0235s) =

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related issues

Related to #348274 (closed)

Edited by Kamil Trzciński

Merge request reports