Commit c1071d02 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'retain-timelogs-for-deleted-notes' into 'master'

Retain timelogs for deleted notes

See merge request gitlab-org/gitlab!58525
parents 04e63106 690ec1eb
---
title: Prevent loss of timelogs when deleting notes
merge_request: 58525
author: Lee Tickett @leetickett
type: fixed
# frozen_string_literal: true
class RemoveNotesDeleteCascadeTimelogs < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
CONSTRAINT_NAME = 'fk_timelogs_note_id'
disable_ddl_transaction!
def up
add_concurrent_foreign_key :timelogs, :notes, column: :note_id, on_delete: :nullify, name: CONSTRAINT_NAME
with_lock_retries do
remove_foreign_key_if_exists :timelogs, :notes, column: :note_id, on_delete: :cascade
end
end
def down
add_concurrent_foreign_key :timelogs, :notes, column: :note_id, on_delete: :cascade
with_lock_retries do
remove_foreign_key_if_exists :timelogs, :notes, column: :note_id, on_delete: :nullify, name: CONSTRAINT_NAME
end
end
end
c62c2e13bdad42cc1f112f9854fe8d25e1e2aa082cb28341a661c93b8587f1f8
\ No newline at end of file
......@@ -25028,9 +25028,6 @@ ALTER TABLE ONLY issues
ALTER TABLE ONLY protected_branch_merge_access_levels
ADD CONSTRAINT fk_8a3072ccb3 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_8d058cd571 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
ALTER TABLE ONLY releases
ADD CONSTRAINT fk_8e4456f90f FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
......@@ -26885,6 +26882,9 @@ ALTER TABLE ONLY timelogs
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_timelogs_merge_requests_merge_request_id FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_timelogs_note_id FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE SET NULL;
ALTER TABLE ONLY u2f_registrations
ADD CONSTRAINT fk_u2f_registrations_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
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