1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
# frozen_string_literal: true
# On .com partitions are not created on application startup,
# they are created by the PartitionManagementWorker cron worker
# which is executed several times per day. If a partition must be present
# on startup, it could be created using a regular migration.
# https://gitlab.com/gitlab-com/gl-infra/production/-/issues/2446
Gitlab::Database::Partitioning.register_models(
[
AuditEvent,
AuditEvents::UserAuditEvent,
AuditEvents::GroupAuditEvent,
AuditEvents::ProjectAuditEvent,
AuditEvents::InstanceAuditEvent,
BatchedGitRefUpdates::Deletion,
Ci::BuildMetadata,
Ci::BuildExecutionConfig,
Ci::BuildName,
Ci::BuildTag,
Ci::BuildTraceMetadata,
Ci::BuildSource,
Ci::Catalog::Resources::Components::Usage,
Ci::Catalog::Resources::SyncEvent,
Ci::FinishedPipelineChSyncEvent,
Ci::JobAnnotation,
Ci::JobArtifact,
Ci::JobArtifactReport,
Ci::Pipeline,
Ci::PipelineConfig,
Ci::PipelineVariable,
Ci::RunnerManagerBuild,
Ci::Stage,
CommitStatus,
Gitlab::Database::BackgroundMigration::BatchedJobTransitionLog,
LooseForeignKeys::DeletedRecord,
Users::GroupVisit,
Users::ProjectVisit,
WebHookLog
])
if Gitlab.ee?
Gitlab::Database::Partitioning.register_models(
[
IncidentManagement::PendingEscalations::Alert,
IncidentManagement::PendingEscalations::Issue,
Security::Finding,
Analytics::ValueStreamDashboard::Count,
Ci::FinishedBuildChSyncEvent,
Search::Zoekt::Task,
Ai::CodeSuggestionEvent
])
else
Gitlab::Database::Partitioning.register_tables(
[
{
limit_connection_names: %i[main],
table_name: 'incident_management_pending_alert_escalations',
partitioned_column: :process_at, strategy: :monthly
},
{
limit_connection_names: %i[main],
table_name: 'incident_management_pending_issue_escalations',
partitioned_column: :process_at, strategy: :monthly
}
])
end
# The following tables are already defined as models
unless Gitlab.jh?
Gitlab::Database::Partitioning.register_tables(
[
# This should be synchronized with the following model:
# https://jihulab.com/gitlab-cn/gitlab/-/blob/main-jh/jh/app/models/phone/verification_code.rb
{
limit_connection_names: %i[main],
table_name: 'verification_codes',
partitioned_column: :created_at, strategy: :monthly
}
])
end
# Enable partition management for the backfill table during merge_request_diff_commits partitioning.
# This way new partitions will be created as the trigger syncs new rows across to this table.
#
Gitlab::Database::Partitioning.register_tables(
[
{
limit_connection_names: %i[main],
table_name: 'merge_request_diff_commits_b5377a7a34',
partitioned_column: :merge_request_diff_id, strategy: :int_range, partition_size: 200_000_000
}
]
)
# Enable partition management for the backfill table during merge_request_diff_files partitioning.
# This way new partitions will be created as the trigger syncs new rows across to this table.
#
Gitlab::Database::Partitioning.register_tables(
[
{
limit_connection_names: %i[main],
table_name: 'merge_request_diff_files_99208b8fac',
partitioned_column: :merge_request_diff_id, strategy: :int_range, partition_size: 200_000_000
}
]
)
Gitlab::Database::Partitioning.sync_partitions_ignore_db_error
|