Commit a9671246 authored by Marius Bobin's avatar Marius Bobin

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

Swap FK ci_sources_pipelines to projects for LFK

See merge request gitlab-org/gitlab!79062
parents ab913702 11b4ece6
# frozen_string_literal: true
class RemoveProjectsCiSourcesPipelinesProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
return unless foreign_key_exists?(:ci_sources_pipelines, :projects, name: "fk_1e53c97c0a")
with_lock_retries do
execute('LOCK projects, ci_sources_pipelines IN ACCESS EXCLUSIVE MODE') if transaction_open?
remove_foreign_key_if_exists(:ci_sources_pipelines, :projects, name: "fk_1e53c97c0a")
end
end
def down
add_concurrent_foreign_key(:ci_sources_pipelines, :projects, name: "fk_1e53c97c0a", column: :project_id, target_column: :id, on_delete: :cascade)
end
end
90115936ede32bbf9a299582409cb0686e8072c204c4f91364dfb13195155929
\ No newline at end of file
...@@ -29240,9 +29240,6 @@ ALTER TABLE ONLY agent_project_authorizations ...@@ -29240,9 +29240,6 @@ ALTER TABLE ONLY agent_project_authorizations
ALTER TABLE ONLY vulnerabilities ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_1d37cddf91 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL; ADD CONSTRAINT fk_1d37cddf91 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_sources_pipelines
ADD CONSTRAINT fk_1e53c97c0a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY boards ALTER TABLE ONLY boards
ADD CONSTRAINT fk_1e9a074a35 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; ADD CONSTRAINT fk_1e9a074a35 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
...@@ -177,6 +177,9 @@ ci_sources_pipelines: ...@@ -177,6 +177,9 @@ ci_sources_pipelines:
- table: projects - table: projects
column: source_project_id column: source_project_id
on_delete: async_delete on_delete: async_delete
- table: projects
column: project_id
on_delete: async_delete
ci_triggers: ci_triggers:
- table: users - table: users
column: owner_id column: owner_id
......
...@@ -31,7 +31,6 @@ RSpec.describe 'cross-database foreign keys' do ...@@ -31,7 +31,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_runner_namespaces.namespace_id ci_runner_namespaces.namespace_id
ci_runner_projects.project_id ci_runner_projects.project_id
ci_running_builds.project_id ci_running_builds.project_id
ci_sources_pipelines.project_id
ci_sources_projects.source_project_id ci_sources_projects.source_project_id
ci_stages.project_id ci_stages.project_id
ci_subscriptions_projects.downstream_project_id ci_subscriptions_projects.downstream_project_id
......
...@@ -24,4 +24,11 @@ RSpec.describe Ci::Sources::Pipeline do ...@@ -24,4 +24,11 @@ RSpec.describe Ci::Sources::Pipeline do
let!(:model) { create(:ci_sources_pipeline, source_project: parent) } let!(:model) { create(:ci_sources_pipeline, source_project: parent) }
end end
end end
context 'loose foreign key on ci_sources_pipelines.project_id' do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_sources_pipeline, project: parent) }
end
end
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