blob: b33127140bb5f9e1d75e7c5a88b1698411c1fbfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
class ScheduleBuildStageMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
MIGRATION = 'MigrateBuildStage'.freeze
BATCH = 1000
class Build < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_builds'
end
def change
Build.where('stage_id IS NULL').each_batch(of: BATCH) do |builds, index|
builds.pluck(:id).map { |id| [MIGRATION, [id]] }.tap do |migrations|
BackgroundMigrationWorker.bulk_perform_in(index.minutes, migrations)
end
end
end
end
|