Class: Gitlab::BackgroundMigration::BackfillNamespaceDetails
- Inherits:
-
BatchedMigrationJob
- Object
- BatchedMigrationJob
- Gitlab::BackgroundMigration::BackfillNamespaceDetails
- Defined in:
- lib/gitlab/background_migration/backfill_namespace_details.rb
Overview
Backfill namespace_details for a range of namespaces
Constant Summary
Constants inherited from BatchedMigrationJob
Gitlab::BackgroundMigration::BatchedMigrationJob::DEFAULT_FEATURE_CATEGORY
Constants included from Database::DynamicModelHelpers
Database::DynamicModelHelpers::BATCH_SIZE
Instance Method Summary collapse
Methods inherited from BatchedMigrationJob
#batch_metrics, feature_category, #filter_batch, generic_instance, #initialize, job_arguments, job_arguments_count, operation_name, scope_to
Methods included from Database::DynamicModelHelpers
#define_batchable_model, #each_batch, #each_batch_range
Constructor Details
This class inherits a constructor from Gitlab::BackgroundMigration::BatchedMigrationJob
Instance Method Details
#perform ⇒ Object
10 11 12 13 14 |
# File 'lib/gitlab/background_migration/backfill_namespace_details.rb', line 10 def perform each_sub_batch do |sub_batch| upsert_namespace_details(sub_batch) end end |
#upsert_namespace_details(relation) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/background_migration/backfill_namespace_details.rb', line 16 def upsert_namespace_details(relation) connection.execute( <<~SQL INSERT INTO namespace_details (description, description_html, cached_markdown_version, created_at, updated_at, namespace_id) SELECT namespaces.description, namespaces.description_html, namespaces.cached_markdown_version, now(), now(), namespaces.id FROM namespaces WHERE namespaces.id IN(#{relation.select(:id).to_sql}) AND namespaces.type <> 'Project' ON CONFLICT (namespace_id) DO NOTHING; SQL ) end |