Skip to content
代码片段 群组 项目
未验证 提交 1975904d 编辑于 作者: Omar Qunsul's avatar Omar Qunsul 提交者: GitLab
浏览文件

Merge branch...

Merge branch 'backfill-multiple-desired-sharding-key-small-table-snippet_user_mentions' into 'master' 

Add & backfill sharding keys for snippet_user_mentions

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/180836



Merged-by: default avatarOmar Qunsul <oqunsul@gitlab.com>
Approved-by: default avatarOmar Qunsul <oqunsul@gitlab.com>
Co-authored-by: default avatarShubham Kumar <shukumar@gitlab.com>
No related branches found
No related tags found
无相关合并请求
显示
239 个添加0 个删除
---
migration_job_name: BackfillSnippetUserMentionsSnippetOrganizationId
description: Backfills sharding key `snippet_user_mentions.snippet_organization_id` from `snippets`.
feature_category: source_code_management
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/180836
milestone: '17.10'
queued_migration_version: 20250209004158
finalized_by: # version of the migration that finalized this BBM
---
migration_job_name: BackfillSnippetUserMentionsSnippetProjectId
description: Backfills sharding key `snippet_user_mentions.snippet_project_id` from `snippets`.
feature_category: source_code_management
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/180836
milestone: '17.10'
queued_migration_version: 20250209004153
finalized_by: # version of the migration that finalized this BBM
......@@ -29,3 +29,6 @@ desired_sharding_key:
table: snippets
sharding_key: organization_id
belongs_to: snippet
desired_sharding_key_migration_job_name:
- BackfillSnippetUserMentionsSnippetProjectId
- BackfillSnippetUserMentionsSnippetOrganizationId
# frozen_string_literal: true
class AddSnippetProjectIdToSnippetUserMentions < Gitlab::Database::Migration[2.2]
milestone '17.10'
def change
add_column :snippet_user_mentions, :snippet_project_id, :bigint
end
end
# frozen_string_literal: true
class AddSnippetOrganizationIdToSnippetUserMentions < Gitlab::Database::Migration[2.2]
milestone '17.10'
def change
add_column :snippet_user_mentions, :snippet_organization_id, :bigint
end
end
# frozen_string_literal: true
class IndexSnippetUserMentionsOnSnippetProjectId < Gitlab::Database::Migration[2.2]
milestone '17.10'
disable_ddl_transaction!
INDEX_NAME = 'index_snippet_user_mentions_on_snippet_project_id'
def up
add_concurrent_index :snippet_user_mentions, :snippet_project_id, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :snippet_user_mentions, INDEX_NAME
end
end
# frozen_string_literal: true
class AddSnippetUserMentionsSnippetProjectIdFk < Gitlab::Database::Migration[2.2]
milestone '17.10'
disable_ddl_transaction!
def up
add_concurrent_foreign_key :snippet_user_mentions, :projects, column: :snippet_project_id, on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :snippet_user_mentions, column: :snippet_project_id
end
end
end
# frozen_string_literal: true
class AddSnippetUserMentionsSnippetProjectIdTrigger < Gitlab::Database::Migration[2.2]
milestone '17.10'
def up
install_sharding_key_assignment_trigger(
table: :snippet_user_mentions,
sharding_key: :snippet_project_id,
parent_table: :snippets,
parent_sharding_key: :project_id,
foreign_key: :snippet_id
)
end
def down
remove_sharding_key_assignment_trigger(
table: :snippet_user_mentions,
sharding_key: :snippet_project_id,
parent_table: :snippets,
parent_sharding_key: :project_id,
foreign_key: :snippet_id
)
end
end
# frozen_string_literal: true
class QueueBackfillSnippetUserMentionsSnippetProjectId < Gitlab::Database::Migration[2.2]
milestone '17.10'
restrict_gitlab_migration gitlab_schema: :gitlab_main_cell
MIGRATION = "BackfillSnippetUserMentionsSnippetProjectId"
DELAY_INTERVAL = 2.minutes
BATCH_SIZE = 1000
SUB_BATCH_SIZE = 100
def up
queue_batched_background_migration(
MIGRATION,
:snippet_user_mentions,
:id,
:snippet_project_id,
:snippets,
:project_id,
:snippet_id,
job_interval: DELAY_INTERVAL,
batch_size: BATCH_SIZE,
sub_batch_size: SUB_BATCH_SIZE
)
end
def down
delete_batched_background_migration(
MIGRATION,
:snippet_user_mentions,
:id,
[
:snippet_project_id,
:snippets,
:project_id,
:snippet_id
]
)
end
end
# frozen_string_literal: true
class IndexSnippetUserMentionsOnSnippetOrganizationId < Gitlab::Database::Migration[2.2]
milestone '17.10'
disable_ddl_transaction!
INDEX_NAME = 'index_snippet_user_mentions_on_snippet_organization_id'
def up
add_concurrent_index :snippet_user_mentions, :snippet_organization_id, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :snippet_user_mentions, INDEX_NAME
end
end
# frozen_string_literal: true
class AddSnippetUserMentionsSnippetOrganizationIdFk < Gitlab::Database::Migration[2.2]
milestone '17.10'
disable_ddl_transaction!
def up
add_concurrent_foreign_key :snippet_user_mentions, :organizations, column: :snippet_organization_id,
on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :snippet_user_mentions, column: :snippet_organization_id
end
end
end
# frozen_string_literal: true
class AddSnippetUserMentionsSnippetOrganizationIdTrigger < Gitlab::Database::Migration[2.2]
milestone '17.10'
def up
install_sharding_key_assignment_trigger(
table: :snippet_user_mentions,
sharding_key: :snippet_organization_id,
parent_table: :snippets,
parent_sharding_key: :organization_id,
foreign_key: :snippet_id
)
end
def down
remove_sharding_key_assignment_trigger(
table: :snippet_user_mentions,
sharding_key: :snippet_organization_id,
parent_table: :snippets,
parent_sharding_key: :organization_id,
foreign_key: :snippet_id
)
end
end
# frozen_string_literal: true
class QueueBackfillSnippetUserMentionsSnippetOrganizationId < Gitlab::Database::Migration[2.2]
milestone '17.10'
restrict_gitlab_migration gitlab_schema: :gitlab_main_cell
MIGRATION = "BackfillSnippetUserMentionsSnippetOrganizationId"
DELAY_INTERVAL = 2.minutes
BATCH_SIZE = 1000
SUB_BATCH_SIZE = 100
def up
queue_batched_background_migration(
MIGRATION,
:snippet_user_mentions,
:id,
:snippet_organization_id,
:snippets,
:organization_id,
:snippet_id,
job_interval: DELAY_INTERVAL,
batch_size: BATCH_SIZE,
sub_batch_size: SUB_BATCH_SIZE
)
end
def down
delete_batched_background_migration(
MIGRATION,
:snippet_user_mentions,
:id,
[
:snippet_organization_id,
:snippets,
:organization_id,
:snippet_id
]
)
end
end
2b7d3200dbb39701dc29899fa9a91cb8fd6f4524c2dd18fa83809f3986000eb6
\ No newline at end of file
889bd985841d24ba0726a7401e8bc41f8d85469c3c7ab70299eef09121203a9a
\ No newline at end of file
fbdf2c73b97679360386e74734f0be035f64bfc15abe62ff45fb761fb640568f
\ No newline at end of file
ac9d9f71b29435b1283b52cc8bf0f90a1e6ff456fd4003e84152096a17ebfaab
\ No newline at end of file
707bb0c8657cd871427511c75efdc70e8745e8d38b9cf7491cb78e5e132b9452
\ No newline at end of file
b9a499b4bfcd8933f92cf9e1f66da493e615d1cff94233271a280d4506ad6287
\ No newline at end of file
cc669986d1c2e8896173e076c846a65e1bbe7d0fd4c438d80b90d3515d0d036f
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册