Class: Gitlab::BackgroundMigration::BackfillProjectWikiRepositories

Inherits:
BatchedMigrationJob show all
Defined in:
lib/gitlab/background_migration/backfill_project_wiki_repositories.rb

Overview

Backfill project_wiki_repositories table 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

#backfill_project_wiki_repositories(relation) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/background_migration/backfill_project_wiki_repositories.rb', line 22

def backfill_project_wiki_repositories(relation)
  connection.execute(
    <<~SQL
    INSERT INTO project_wiki_repositories (project_id, created_at, updated_at)
      SELECT projects.id, now(), now()
      FROM projects
      WHERE projects.id IN(#{relation.select(:id).to_sql})
    ON CONFLICT (project_id) DO NOTHING;
  SQL
  )
end

#performObject



16
17
18
19
20
# File 'lib/gitlab/background_migration/backfill_project_wiki_repositories.rb', line 16

def perform
  each_sub_batch do |sub_batch|
    backfill_project_wiki_repositories(sub_batch)
  end
end