Class: Gitlab::BackgroundMigration::BackfillProjectNamespaceDetails
- Inherits:
-
BatchedMigrationJob
- Object
- BatchedMigrationJob
- Gitlab::BackgroundMigration::BackfillProjectNamespaceDetails
- Defined in:
- lib/gitlab/background_migration/backfill_project_namespace_details.rb
Overview
Backfill project namespace_details for a range of projects
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
9 10 11 12 13 |
# File 'lib/gitlab/background_migration/backfill_project_namespace_details.rb', line 9 def perform each_sub_batch do |sub_batch| upsert_project_namespace_details(sub_batch) end end |
#upsert_project_namespace_details(relation) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/background_migration/backfill_project_namespace_details.rb', line 15 def upsert_project_namespace_details(relation) connection.execute( <<~SQL INSERT INTO namespace_details (description, description_html, cached_markdown_version, created_at, updated_at, namespace_id) SELECT projects.description, projects.description_html, projects.cached_markdown_version, now(), now(), projects.project_namespace_id FROM projects WHERE projects.id IN(#{relation.select(:id).to_sql}) ON CONFLICT (namespace_id) DO NOTHING; SQL ) end |