diff options
Diffstat (limited to 'db/post_migrate')
6 files changed, 158 insertions, 0 deletions
diff --git a/db/post_migrate/20231016173128_add_temporary_index_to_merge_access_levels.rb b/db/post_migrate/20231016173128_add_temporary_index_to_merge_access_levels.rb new file mode 100644 index 00000000000..0d8fbdfea00 --- /dev/null +++ b/db/post_migrate/20231016173128_add_temporary_index_to_merge_access_levels.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddTemporaryIndexToMergeAccessLevels < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.6' + + INDEX_NAME = 'tmp_idx_protected_branch_merge_access_levels_on_id_with_group' + + def up + # Temporary index to be removed in 16.7 https://gitlab.com/gitlab-org/gitlab/-/issues/430843 + add_concurrent_index( + :protected_branch_merge_access_levels, + %i[id], + where: 'group_id IS NOT NULL', + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name( + :protected_branch_merge_access_levels, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb new file mode 100644 index 00000000000..3f4009d783c --- /dev/null +++ b/db/post_migrate/20231016173129_queue_delete_invalid_protected_branch_merge_access_levels.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class QueueDeleteInvalidProtectedBranchMergeAccessLevels < Gitlab::Database::Migration[2.1] + MIGRATION = "DeleteInvalidProtectedBranchMergeAccessLevels" + DELAY_INTERVAL = 2.minutes + MAX_BATCH_SIZE = 10_000 + BATCH_SIZE = 5_000 + SUB_BATCH_SIZE = 500 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :protected_branch_merge_access_levels, + :id, + job_interval: DELAY_INTERVAL, + queued_migration_version: '20231016173129', + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :protected_branch_merge_access_levels, :id, []) + end +end diff --git a/db/post_migrate/20231016194926_add_temporary_index_to_push_access_levels.rb b/db/post_migrate/20231016194926_add_temporary_index_to_push_access_levels.rb new file mode 100644 index 00000000000..91599051fd4 --- /dev/null +++ b/db/post_migrate/20231016194926_add_temporary_index_to_push_access_levels.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddTemporaryIndexToPushAccessLevels < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.6' + INDEX_NAME = 'tmp_idx_protected_branch_push_access_levels_on_id_with_group' + + def up + # Temporary index to be removed in 16.7 https://gitlab.com/gitlab-org/gitlab/-/issues/430843 + add_concurrent_index( + :protected_branch_push_access_levels, + %i[id], + where: 'group_id IS NOT NULL', + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name( + :protected_branch_push_access_levels, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb new file mode 100644 index 00000000000..6accaa3296b --- /dev/null +++ b/db/post_migrate/20231016194927_queue_delete_invalid_protected_branch_push_access_levels.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class QueueDeleteInvalidProtectedBranchPushAccessLevels < Gitlab::Database::Migration[2.1] + MIGRATION = "DeleteInvalidProtectedBranchPushAccessLevels" + DELAY_INTERVAL = 2.minutes + MAX_BATCH_SIZE = 10_000 + BATCH_SIZE = 5_000 + SUB_BATCH_SIZE = 500 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :protected_branch_push_access_levels, + :id, + job_interval: DELAY_INTERVAL, + queued_migration_version: '20231016194927', + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :protected_branch_push_access_levels, :id, []) + end +end diff --git a/db/post_migrate/20231016194942_add_temporary_index_to_create_access_levels.rb b/db/post_migrate/20231016194942_add_temporary_index_to_create_access_levels.rb new file mode 100644 index 00000000000..d28b664c517 --- /dev/null +++ b/db/post_migrate/20231016194942_add_temporary_index_to_create_access_levels.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddTemporaryIndexToCreateAccessLevels < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.6' + + INDEX_NAME = 'tmp_idx_protected_tag_create_access_levels_on_id_with_group' + + def up + # Temporary index to be removed in 16.7 https://gitlab.com/gitlab-org/gitlab/-/issues/430843 + add_concurrent_index( + :protected_tag_create_access_levels, + %i[id], + where: 'group_id IS NOT NULL', + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name( + :protected_tag_create_access_levels, + INDEX_NAME + ) + end +end diff --git a/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb new file mode 100644 index 00000000000..5880124d0a6 --- /dev/null +++ b/db/post_migrate/20231016194943_queue_delete_invalid_protected_tag_create_access_levels.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class QueueDeleteInvalidProtectedTagCreateAccessLevels < Gitlab::Database::Migration[2.1] + MIGRATION = "DeleteInvalidProtectedTagCreateAccessLevels" + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 10_000 + SUB_BATCH_SIZE = 500 + + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + + def up + queue_batched_background_migration( + MIGRATION, + :protected_tag_create_access_levels, + :id, + job_interval: DELAY_INTERVAL, + queued_migration_version: '20231016194943', + batch_size: BATCH_SIZE, + sub_batch_size: SUB_BATCH_SIZE + ) + end + + def down + delete_batched_background_migration(MIGRATION, :protected_tag_create_access_levels, :id, []) + end +end |