Commit 56c85af4 authored by Fabio Pitino's avatar Fabio Pitino

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

Add LFK ci_pipeline_artifacts to projects on project_id

See merge request gitlab-org/gitlab!78058
parents 88848ff8 5e3f68fc
# frozen_string_literal: true
class RemoveProjectsCiPipelineArtifactsProjectIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
execute('LOCK projects, ci_pipeline_artifacts IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:ci_pipeline_artifacts, :projects, name: "fk_rails_4a70390ca6")
end
end
def down
add_concurrent_foreign_key(:ci_pipeline_artifacts, :projects, name: "fk_rails_4a70390ca6", column: :project_id, target_column: :id, on_delete: :cascade)
end
end
faa30b386af9adf3e9f54a0e8e2880310490e4dc1378eae68b346872d0bb8bfd
\ No newline at end of file
......@@ -30484,9 +30484,6 @@ ALTER TABLE ONLY user_custom_attributes
ALTER TABLE ONLY upcoming_reconciliations
ADD CONSTRAINT fk_rails_497b4938ac FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_pipeline_artifacts
ADD CONSTRAINT fk_rails_4a70390ca6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_job_token_project_scope_links
ADD CONSTRAINT fk_rails_4b2ee3290b FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -154,3 +154,7 @@ ci_secure_files:
- table: projects
column: project_id
on_delete: async_delete
ci_pipeline_artifacts:
- table: projects
column: project_id
on_delete: async_delete
......@@ -23,7 +23,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_job_token_project_scope_links.target_project_id
ci_pending_builds.namespace_id
ci_pending_builds.project_id
ci_pipeline_artifacts.project_id
ci_pipeline_schedules.owner_id
ci_pipeline_schedules.project_id
ci_pipelines.merge_request_id
......
......@@ -215,4 +215,11 @@ RSpec.describe Ci::PipelineArtifact, type: :model do
end
end
end
context 'loose foreign key on ci_pipeline_artifacts.project_id' do
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_pipeline_artifact, project: parent) }
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