Commit 082d4c27 authored by Adam Hegyi's avatar Adam Hegyi

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

Swap FK ci_unit_tests to projects for LFK

See merge request gitlab-org/gitlab!78146
parents 07d68c69 3e4b5984
# frozen_string_literal: true
class RemoveProjectsCiUnitTestsProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_unit_tests, :projects, name: "fk_7a8fabf0a8")
end
end
def down
add_concurrent_foreign_key(:ci_unit_tests, :projects, name: "fk_7a8fabf0a8", column: :project_id, target_column: :id, on_delete: "cascade")
end
end
c528730414c1dcda5d312f03d4e37a0dbb51ebb0b0b87ada786cf686c358daa7
\ No newline at end of file
......@@ -29378,9 +29378,6 @@ ALTER TABLE ONLY analytics_devops_adoption_snapshots
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_7a5553d60f FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_unit_tests
ADD CONSTRAINT fk_7a8fabf0a8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY protected_branches
ADD CONSTRAINT fk_7a9c6d93e7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -79,6 +79,10 @@ ci_project_mirrors:
- table: namespaces
column: namespace_id
on_delete: async_delete
ci_unit_tests:
- table: projects
column: project_id
on_delete: async_delete
merge_requests:
- table: ci_pipelines
column: head_pipeline_id
......
......@@ -3,6 +3,11 @@
require 'spec_helper'
RSpec.describe Ci::UnitTest do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_unit_test, project: parent) }
end
describe 'relationships' do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:unit_test_failures) }
......
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