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

20191002031332_schedule_pages_metadata_migration.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0cd24da50d0c854d3d44d9b5e993ac36233755e7 (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
# frozen_string_literal: true

class SchedulePagesMetadataMigration < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  BATCH_SIZE = 10_000
  MIGRATION = 'MigratePagesMetadata'

  disable_ddl_transaction!

  class Project < ActiveRecord::Base
    include ::EachBatch

    self.table_name = 'projects'
  end

  def up
    say "Scheduling `#{MIGRATION}` jobs"

    # At the time of writing there are ~10_669_292 records to be inserted for GitLab.com,
    # batches of 10_000 with delay interval of 2 minutes gives us an estimate of close to 36 hours.
    queue_background_migration_jobs_by_range_at_intervals(Project, MIGRATION, 2.minutes, batch_size: BATCH_SIZE)
  end

  def down
    # no-op
  end
end