summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-29 12:10:29 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-07 15:08:15 +0200
commitc2efb8acc609eaec799b536412d1f66311aa1cf7 (patch)
tree43b0976a409796f21c0a50712ddfde7baad90914 /db
parent945cdf326edcafdcd7a1d2aeaef611d888a4828e (diff)
downloadgitlab-ce-c2efb8acc609eaec799b536412d1f66311aa1cf7.tar.gz
Use ActiveRecord 5 batching to schedule bg migration
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
index a73456af386..9e95216b35a 100644
--- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
+++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
@@ -13,10 +13,9 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
def up
Build.where(stage_id: nil)
- .find_in_batches(batch_size: BATCH_SIZE)
- .with_index do |builds, batch|
- builds.each do |build|
- schedule = (batch - 1) * 5.minutes
+ .in_batches(of: BATCH_SIZE) do |relation, index|
+ schedule = index * 5.minutes
+ relation.each do |build|
BackgroundMigrationWorker.perform_at(schedule, MIGRATION, [build.id])
end
end