Skip to content

Remove foreign key ci_minutes_additional_packs.namespace_id

What does this MR do and why?

In !77322 (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.

Migrations

Up

== 20220105020514 RemoveCiMinutesAdditionalPacksNamespaceIdForeignKeyConstraint: migrating
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:ci_minutes_additional_packs)
   -> 0.0030s
-- remove_foreign_key(:ci_minutes_additional_packs, :namespaces, {:name=>"fk_rails_e0e0c4e4b1"})
   -> 0.0043s
== 20220105020514 RemoveCiMinutesAdditionalPacksNamespaceIdForeignKeyConstraint: migrated (0.0138s)

Down

== 20220105020514 RemoveCiMinutesAdditionalPacksNamespaceIdForeignKeyConstraint: reverting
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:ci_minutes_additional_packs)
   -> 0.0048s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE ci_minutes_additional_packs\nADD CONSTRAINT fk_rails_e0e0c4e4b1\nFOREIGN KEY (namespace_id)\nREFERENCES namespaces (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0087s
-- execute("ALTER TABLE ci_minutes_additional_packs VALIDATE CONSTRAINT fk_rails_e0e0c4e4b1;")
   -> 0.0071s
== 20220105020514 RemoveCiMinutesAdditionalPacksNamespaceIdForeignKeyConstraint: reverted (0.0291s)

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 to #348269 (closed)

Edited by Dylan Griffith

Merge request reports