diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-29 12:10:29 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 15:08:15 +0200 |
commit | c2efb8acc609eaec799b536412d1f66311aa1cf7 (patch) | |
tree | 43b0976a409796f21c0a50712ddfde7baad90914 /db | |
parent | 945cdf326edcafdcd7a1d2aeaef611d888a4828e (diff) | |
download | gitlab-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.rb | 7 |
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 |