Commit 96637f48 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'remove-projects_ci_build_report_results_project_id-fk' into 'master'

Swap FK ci_build_report_results to projects for LFK

See merge request gitlab-org/gitlab!78157
parents 5f617d55 6fbc44b7
# 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
...@@ -29939,9 +29939,6 @@ ALTER TABLE ONLY ip_restrictions ...@@ -29939,9 +29939,6 @@ ALTER TABLE ONLY ip_restrictions
ALTER TABLE ONLY terraform_state_versions ALTER TABLE ONLY terraform_state_versions
ADD CONSTRAINT fk_rails_04f176e239 FOREIGN KEY (terraform_state_id) REFERENCES terraform_states(id) ON DELETE CASCADE; 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 ALTER TABLE ONLY ci_daily_build_group_report_results
ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
...@@ -58,6 +58,10 @@ ci_namespace_mirrors: ...@@ -58,6 +58,10 @@ ci_namespace_mirrors:
- table: namespaces - table: namespaces
column: namespace_id column: namespace_id
on_delete: async_delete on_delete: async_delete
ci_build_report_results:
- table: projects
column: project_id
on_delete: async_delete
ci_builds: ci_builds:
- table: users - table: users
column: user_id column: user_id
......
...@@ -5,6 +5,11 @@ require 'spec_helper' ...@@ -5,6 +5,11 @@ require 'spec_helper'
RSpec.describe Ci::BuildReportResult do RSpec.describe Ci::BuildReportResult do
let(:build_report_result) { build(:ci_build_report_result, :with_junit_success) } 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 describe 'associations' do
it { is_expected.to belong_to(:build) } it { is_expected.to belong_to(:build) }
it { is_expected.to belong_to(:project) } 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