Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210210093901_backfill_updated_at_after_repository_storage_move.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0631cc8095e65a166a5ffe85642d1bff886805d1 (plain)
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
# frozen_string_literal: true

class BackfillUpdatedAtAfterRepositoryStorageMove < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  BATCH_SIZE = 10_000
  INTERVAL = 2.minutes
  MIGRATION_CLASS = 'BackfillProjectUpdatedAtAfterRepositoryStorageMove'

  disable_ddl_transaction!

  class ProjectRepositoryStorageMove < ActiveRecord::Base
    include EachBatch

    self.table_name = 'project_repository_storage_moves'
  end

  def up
    ProjectRepositoryStorageMove.reset_column_information

    ProjectRepositoryStorageMove.select(:project_id).distinct.each_batch(of: BATCH_SIZE, column: :project_id) do |batch, index|
      migrate_in(
        INTERVAL * index,
        MIGRATION_CLASS,
        batch.pluck(:project_id)
      )
    end
  end

  def down
    # No-op
  end
end