Commit 5cd90bb9 authored by Adam Hegyi's avatar Adam Hegyi

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

Swap FK ci_daily_build_group_report_results to projects for LFK

See merge request gitlab-org/gitlab!78149
parents 56b6b242 59186e18
# frozen_string_literal: true
class RemoveProjectsCiDailyBuildGroupReportResultsProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
execute('LOCK projects, ci_daily_build_group_report_results IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:ci_daily_build_group_report_results, :projects, name: "fk_rails_0667f7608c")
end
end
def down
add_concurrent_foreign_key(:ci_daily_build_group_report_results, :projects, name: "fk_rails_0667f7608c", column: :project_id, target_column: :id, on_delete: "cascade")
end
end
cbea97a0d067939ba9d713489448cb6e0cc45b2bbd2c717ecf521493cc39d568
\ No newline at end of file
......@@ -29973,9 +29973,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_daily_build_group_report_results
ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_subscriptions_projects
ADD CONSTRAINT fk_rails_0818751483 FOREIGN KEY (downstream_project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -35,6 +35,9 @@ ci_daily_build_group_report_results:
- table: namespaces
column: group_id
on_delete: async_delete
- table: projects
column: project_id
on_delete: async_delete
ci_freeze_periods:
- table: projects
column: project_id
......
......@@ -170,4 +170,10 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
let!(:parent) { model.group }
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:ci_daily_build_group_report_result) }
let!(:parent) { model.project }
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