Commit 1d2df5a4 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'remove_fk_ci_running_builds_to_projects' into 'master'

Swap ci_running_builds FK to projects for LFK

See merge request gitlab-org/gitlab!78027
parents afb61c6d 5e0a4b23
# frozen_string_literal: true
class RemoveProjectsCiRunningBuildsFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
execute('LOCK projects, ci_running_builds IN ACCESS EXCLUSIVE MODE')
remove_foreign_key_if_exists(:ci_running_builds, :projects, name: "fk_rails_dc1d0801e8")
end
end
def down
add_concurrent_foreign_key(:ci_running_builds, :projects, name: "fk_rails_dc1d0801e8", column: :project_id, target_column: :id, on_delete: "cascade")
end
end
e4417c3367115d6adba023e18657d8aecd476b8d1c4227c73e06f97d05af07ad
\ No newline at end of file
......@@ -31338,9 +31338,6 @@ ALTER TABLE ONLY issues_prometheus_alert_events
ALTER TABLE ONLY board_user_preferences
ADD CONSTRAINT fk_rails_dbebdaa8fe FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_running_builds
ADD CONSTRAINT fk_rails_dc1d0801e8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerability_occurrence_pipelines
ADD CONSTRAINT fk_rails_dc3ae04693 FOREIGN KEY (occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE;
......@@ -57,6 +57,10 @@ ci_runner_namespaces:
- table: namespaces
column: namespace_id
on_delete: async_delete
ci_running_builds:
- table: projects
column: project_id
on_delete: async_delete
ci_namespace_mirrors:
- table: namespaces
column: namespace_id
......
......@@ -49,4 +49,9 @@ RSpec.describe Ci::RunningBuild do
end
end
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_running_build, project: parent) }
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