Commit 1ea8e187 authored by Toon Claes's avatar Toon Claes

Merge branch 'recreate_foreign_key_with_nullify' into 'master'

Change constraint on foreign key from cascade to nullify

See merge request gitlab-org/gitlab!29767
parents 7df11dac e024e8e5
---
title: Recreate foreign key in project settings to use nullify instead of cascade
merge_request: 29767
author:
type: changed
# frozen_string_literal: true
class RemoveAndAddForeignKeyToProjectSettings < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
CONSTRAINT_NAME = 'fk_project_settings_push_rule_id'
disable_ddl_transaction!
def up
add_concurrent_foreign_key :project_settings, :push_rules, column: :push_rule_id, name: CONSTRAINT_NAME, on_delete: :nullify
remove_foreign_key_if_exists :project_settings, column: :push_rule_id, on_delete: :cascade
end
def down
add_concurrent_foreign_key :project_settings, :push_rules, column: :push_rule_id, on_delete: :cascade
remove_foreign_key_if_exists :project_settings, column: :push_rule_id, name: CONSTRAINT_NAME, on_delete: :nullify
end
end
......@@ -10927,9 +10927,6 @@ ALTER TABLE ONLY public.epics
ALTER TABLE ONLY public.ci_pipelines
ADD CONSTRAINT fk_3d34ab2e06 FOREIGN KEY (pipeline_schedule_id) REFERENCES public.ci_pipeline_schedules(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.project_settings
ADD CONSTRAINT fk_413a953e20 FOREIGN KEY (push_rule_id) REFERENCES public.push_rules(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.ci_pipeline_schedule_variables
ADD CONSTRAINT fk_41c35fda51 FOREIGN KEY (pipeline_schedule_id) REFERENCES public.ci_pipeline_schedules(id) ON DELETE CASCADE;
......@@ -11353,6 +11350,9 @@ ALTER TABLE ONLY public.path_locks
ALTER TABLE ONLY public.personal_access_tokens
ADD CONSTRAINT fk_personal_access_tokens_user_id FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.project_settings
ADD CONSTRAINT fk_project_settings_push_rule_id FOREIGN KEY (push_rule_id) REFERENCES public.push_rules(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.protected_branch_merge_access_levels
ADD CONSTRAINT fk_protected_branch_merge_access_levels_user_id FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
......@@ -13543,6 +13543,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200416120128
20200416120354
20200417044453
20200417075843
20200417145946
20200420092011
20200420094444
......
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