diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 18:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 18:09:24 +0300 |
commit | 8bcfcd53f3e3fe8df944eea6dab02556976fd4e3 (patch) | |
tree | 6f8cfaf7442b3ab092a107e249689e9049ee4738 /db | |
parent | 0549ffef0d4f862a7354847dd185725cc196eed0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20210403022952_remove_notes_delete_cascade_timelogs.rb | 26 | ||||
-rw-r--r-- | db/schema_migrations/20210403022952 | 1 | ||||
-rw-r--r-- | db/structure.sql | 6 |
3 files changed, 30 insertions, 3 deletions
diff --git a/db/post_migrate/20210403022952_remove_notes_delete_cascade_timelogs.rb b/db/post_migrate/20210403022952_remove_notes_delete_cascade_timelogs.rb new file mode 100644 index 00000000000..832ba584931 --- /dev/null +++ b/db/post_migrate/20210403022952_remove_notes_delete_cascade_timelogs.rb @@ -0,0 +1,26 @@ +# 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 diff --git a/db/schema_migrations/20210403022952 b/db/schema_migrations/20210403022952 new file mode 100644 index 00000000000..581bc5f89c2 --- /dev/null +++ b/db/schema_migrations/20210403022952 @@ -0,0 +1 @@ +c62c2e13bdad42cc1f112f9854fe8d25e1e2aa082cb28341a661c93b8587f1f8
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index db463645810..ad34d16bbda 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -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; |