Swap FK vulnerability_occurrence_pipelines to ci_pipelines for LFK

Swaps FK for vulnerability_occurrence_pipelines.pipeline_id to ci_pipelines

Changelog: changed
parent df3cecdc
# frozen_string_literal: true
class RemoveCiPipelinesVulnerabilityOccurrencePipelinesPipelineIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
execute('LOCK ci_pipelines, vulnerability_occurrence_pipelines IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:vulnerability_occurrence_pipelines, :ci_pipelines, name: "fk_rails_6421e35d7d")
end
end
def down
add_concurrent_foreign_key(:vulnerability_occurrence_pipelines, :ci_pipelines, name: "fk_rails_6421e35d7d", column: :pipeline_id, target_column: :id, on_delete: :cascade)
end
end
c0f29fd7f960ffd92a65a00e8dce123b91a604f4d89b7cf0bc419fa80495e2e5
\ No newline at end of file
......@@ -30632,9 +30632,6 @@ ALTER TABLE ONLY evidences
ALTER TABLE ONLY jira_imports
ADD CONSTRAINT fk_rails_63cbe52ada FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerability_occurrence_pipelines
ADD CONSTRAINT fk_rails_6421e35d7d FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;
ALTER TABLE ONLY group_deploy_tokens
ADD CONSTRAINT fk_rails_6477b01f6b FOREIGN KEY (deploy_token_id) REFERENCES deploy_tokens(id) ON DELETE CASCADE;
......@@ -15,4 +15,11 @@ RSpec.describe Vulnerabilities::FindingPipeline do
it { is_expected.to validate_presence_of(:pipeline) }
it { is_expected.to validate_uniqueness_of(:pipeline_id).scoped_to(:occurrence_id) }
end
context 'loose foreign key on vulnerability_occurrence_pipelines.pipeline_id' do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:ci_pipeline) }
let!(:model) { create(:vulnerabilities_finding_pipeline, pipeline: parent) }
end
end
end
......@@ -45,7 +45,6 @@ RSpec.describe 'cross-database foreign keys' do
dast_site_profiles_pipelines.ci_pipeline_id
external_pull_requests.project_id
vulnerability_feedback.pipeline_id
vulnerability_occurrence_pipelines.pipeline_id
vulnerability_statistics.latest_pipeline_id
).freeze
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