Commit bc330910 authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch...

Merge branch '348274-remove-foreign-key-requirements_management_test_reports-build_id' into 'master'

LFK: Remove foreign key requirements_management_test_reports.build_id

See merge request gitlab-org/gitlab!77912
parents a7879405 144b082b
# 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
execute('LOCK ci_builds, requirements_management_test_reports IN ACCESS EXCLUSIVE MODE')
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
......@@ -31404,9 +31404,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;
......@@ -168,4 +168,9 @@ RSpec.describe RequirementsManagement::TestReport do
end
end
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:test_report) }
let(:parent) { model.build }
end
end
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