Commit 0c7e5b94 authored by Thong Kuah's avatar Thong Kuah Committed by Adam Hegyi

Swap FK vulnerability_feedback to ci_pipelines for LFK

Swaps FK for vulnerability_feedback.pipeline_id to ci_pipelines

Changelog: changed
parent 76706f64
# frozen_string_literal: true
class RemoveCiPipelinesVulnerabilityFeedbackPipelineIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
return unless foreign_key_exists?(:vulnerability_feedback, :ci_pipelines, name: "fk_rails_20976e6fd9")
with_lock_retries do
execute('LOCK ci_pipelines, vulnerability_feedback IN ACCESS EXCLUSIVE MODE') if transaction_open?
remove_foreign_key_if_exists(:vulnerability_feedback, :ci_pipelines, name: "fk_rails_20976e6fd9")
end
end
def down
add_concurrent_foreign_key(:vulnerability_feedback, :ci_pipelines, name: "fk_rails_20976e6fd9", column: :pipeline_id, target_column: :id, on_delete: :nullify)
end
end
75eb050fc789eb5775a5d3a88c2573dca5c38e16b63cd342bf46dca55d1adaef
\ No newline at end of file
...@@ -30197,9 +30197,6 @@ ALTER TABLE ONLY boards_epic_lists ...@@ -30197,9 +30197,6 @@ ALTER TABLE ONLY boards_epic_lists
ALTER TABLE ONLY approval_merge_request_rules_groups ALTER TABLE ONLY approval_merge_request_rules_groups
ADD CONSTRAINT fk_rails_2020a7124a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_2020a7124a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerability_feedback
ADD CONSTRAINT fk_rails_20976e6fd9 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
ALTER TABLE ONLY work_item_types ALTER TABLE ONLY work_item_types
ADD CONSTRAINT fk_rails_20f694a960 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_20f694a960 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
...@@ -351,4 +351,11 @@ RSpec.describe Vulnerabilities::Feedback do ...@@ -351,4 +351,11 @@ RSpec.describe Vulnerabilities::Feedback do
it { is_expected.to eq(finding) } it { is_expected.to eq(finding) }
end end
end end
context 'loose foreign key on vulnerability_feedback.pipeline_id' do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:ci_pipeline) }
let!(:model) { create(:vulnerability_feedback, project: parent.project, pipeline: parent) }
end
end
end end
...@@ -32,7 +32,6 @@ RSpec.describe 'cross-database foreign keys' do ...@@ -32,7 +32,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_sources_projects.source_project_id ci_sources_projects.source_project_id
ci_stages.project_id ci_stages.project_id
ci_unit_tests.project_id ci_unit_tests.project_id
vulnerability_feedback.pipeline_id
).freeze ).freeze
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