Commit 6fbc44b7 authored by Thong Kuah's avatar Thong Kuah

Swap FK ci_build_report_results to projects for LFK

Removes FK for ci_build_report_results to projects

Changelog: changed
parent b5fb1331
# frozen_string_literal: true
class RemoveProjectsCiBuildReportResultsProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_build_report_results, :projects, name: "fk_rails_056d298d48")
end
end
def down
add_concurrent_foreign_key(:ci_build_report_results, :projects, name: "fk_rails_056d298d48", column: :project_id, target_column: :id, on_delete: "cascade")
end
end
774a5ff616663d6d0e002bd04d33747982de10b02cbb9ad7d8abfe0b26a2b441
\ No newline at end of file
......@@ -29951,9 +29951,6 @@ ALTER TABLE ONLY ip_restrictions
ALTER TABLE ONLY terraform_state_versions
ADD CONSTRAINT fk_rails_04f176e239 FOREIGN KEY (terraform_state_id) REFERENCES terraform_states(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_build_report_results
ADD CONSTRAINT fk_rails_056d298d48 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_daily_build_group_report_results
ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
---
dast_site_profiles_pipelines:
- table: ci_pipelines
column: ci_pipeline_id
......@@ -46,6 +47,10 @@ ci_namespace_mirrors:
- table: namespaces
column: namespace_id
on_delete: async_delete
ci_build_report_results:
- table: projects
column: project_id
on_delete: async_delete
ci_builds:
- table: users
column: user_id
......
......@@ -5,6 +5,11 @@ require 'spec_helper'
RSpec.describe Ci::BuildReportResult do
let(:build_report_result) { build(:ci_build_report_result, :with_junit_success) }
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_build_report_result, project: parent) }
end
describe 'associations' do
it { is_expected.to belong_to(:build) }
it { is_expected.to belong_to(:project) }
......
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