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

20180405101928_reschedule_builds_stages_migration.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e19387bce1ee9a874155ffb28eccd72a629948db (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
class RescheduleBuildsStagesMigration < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  ##
  # Rescheduled `20180212101928_schedule_build_stage_migration.rb`
  #

  DOWNTIME = false
  MIGRATION = 'MigrateBuildStage'.freeze
  BATCH_SIZE = 500

  disable_ddl_transaction!

  class Build < ActiveRecord::Base
    include EachBatch
    self.table_name = 'ci_builds'
  end

  def up
    disable_statement_timeout

    Build.where('stage_id IS NULL').tap do |relation|
      queue_background_migration_jobs_by_range_at_intervals(relation,
                                                            MIGRATION,
                                                            5.minutes,
                                                            batch_size: BATCH_SIZE)
    end
  end

  def down
    # noop
  end
end