Remove FK requirements_management_test_reports.build_id as we have LFK

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77908 we
already added a ["loose foreign key"](
https://docs.gitlab.com/ee/development/database/loose_foreign_keys.html)
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.

Changelog: other
parent eccefaed
# frozen_string_literal: true
class RemoveRequirementsManagementTestReportsBuildIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
CONSTRAINT_NAME = 'fk_rails_e67d085910'
def up
with_lock_retries do
remove_foreign_key_if_exists(:requirements_management_test_reports, :ci_builds, name: CONSTRAINT_NAME)
end
end
def down
add_concurrent_foreign_key(:requirements_management_test_reports, :ci_builds, column: :build_id, on_delete: :nullify, name: CONSTRAINT_NAME)
end
end
768f97a38c0b741f7de99082ce7c8efb1578ac6600c3af4b30019bc987968bc9
\ No newline at end of file
......@@ -31332,9 +31332,6 @@ ALTER TABLE ONLY approval_merge_request_rule_sources
ALTER TABLE ONLY prometheus_alerts
ADD CONSTRAINT fk_rails_e6351447ec FOREIGN KEY (prometheus_metric_id) REFERENCES prometheus_metrics(id) ON DELETE CASCADE;
ALTER TABLE ONLY requirements_management_test_reports
ADD CONSTRAINT fk_rails_e67d085910 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE SET NULL;
ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_rails_e6d7c24d1b FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment