diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-03 03:07:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-03 03:07:15 +0300 |
commit | 25ba0c04e90a470bfdf3fe3a5b044a73157565d2 (patch) | |
tree | 9589a405ba956edeaa6d92a4fedbd3a1b422c793 /db/migrate | |
parent | 3a72ac775065b61bbdb285a8f4f6f152ccb4db49 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate')
3 files changed, 57 insertions, 0 deletions
diff --git a/db/migrate/20231227103059_replace_fk_on_epics_issue_id.rb b/db/migrate/20231227103059_replace_fk_on_epics_issue_id.rb new file mode 100644 index 00000000000..e5dd4e868f0 --- /dev/null +++ b/db/migrate/20231227103059_replace_fk_on_epics_issue_id.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class ReplaceFkOnEpicsIssueId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.8' + + FK_NAME = :fk_epics_issue_id_with_on_delete_nullify + + def up + # This will replace the existing fk_893ee302e5 + add_concurrent_foreign_key(:epics, :issues, column: :issue_id, on_delete: :nullify, validate: false, name: FK_NAME) + end + + def down + with_lock_retries do + remove_foreign_key_if_exists(:epics, column: :issue_id, on_delete: :nullify, name: FK_NAME) + end + end +end diff --git a/db/migrate/20231227104408_validate_fk_epics_issue_id_with_on_delete_nullify.rb b/db/migrate/20231227104408_validate_fk_epics_issue_id_with_on_delete_nullify.rb new file mode 100644 index 00000000000..9f7601a704b --- /dev/null +++ b/db/migrate/20231227104408_validate_fk_epics_issue_id_with_on_delete_nullify.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class ValidateFkEpicsIssueIdWithOnDeleteNullify < Gitlab::Database::Migration[2.2] + milestone '16.8' + + FK_NAME = :fk_epics_issue_id_with_on_delete_nullify + + # foreign key added in db/migrate/20231227103059_replace_fk_on_epics_issue_id.rb + def up + validate_foreign_key(:epics, :issue_id, name: FK_NAME) + end + + def down + # no-op + end +end diff --git a/db/migrate/20231227104711_remove_fk_epics_issue_id.rb b/db/migrate/20231227104711_remove_fk_epics_issue_id.rb new file mode 100644 index 00000000000..29752e8741c --- /dev/null +++ b/db/migrate/20231227104711_remove_fk_epics_issue_id.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveFkEpicsIssueId < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.8' + + FK_NAME = :fk_893ee302e5 + + # new foreign key added in db/migrate/20231227103059_replace_fk_on_epics_issue_id.rb + # and validated in db/migrate/20231227104408_validate_fk_epics_issue_id_with_on_delete_nullify.rb + def up + with_lock_retries do + remove_foreign_key_if_exists(:epics, column: :issue_id, on_delete: :cascade, name: FK_NAME) + end + end + + def down + add_concurrent_foreign_key(:epics, :issues, column: :issue_id, on_delete: :cascade, validate: false, name: FK_NAME) + end +end |