Commit e024e8e5 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek Committed by Toon Claes

Change constraint on foreign key from cascade to nullify

Add changelog entry

Add cr remarks

Remove rubocop offence

Add cr remarks

Add cr remarks

Add cr remarks

Add cr remarks
parent d58353db
---
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
......@@ -10901,9 +10901,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;
......@@ -11327,6 +11324,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;
......@@ -13512,6 +13512,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200416120128
20200416120354
20200417044453
20200417075843
20200417145946
20200420104303
20200420104323
......
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