diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-28 12:23:00 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-28 12:23:00 +0200 |
commit | 5292eb651e1e3595e409a4c216eb0be3445a9319 (patch) | |
tree | 31ff994016ce45f8211bf90050e86d7c20459d71 /db | |
parent | 02bb40e2acd7b1838e47e1a2f8b9288e42e6ca53 (diff) | |
download | gitlab-ce-5292eb651e1e3595e409a4c216eb0be3445a9319.tar.gz |
Schedule background migration only when it is needed
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb | 10 |
1 files changed, 6 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 6b326bc0b69..bfeb09f6da1 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 @@ -12,11 +12,13 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration end def up - Build.find_in_batches(batch_size: BATCH_SIZE).with_index do |builds, batch| - migrations = builds.map { |build| [MIGRATION, [build.id]] } + Build.where(stage_id: nil) + .find_in_batches(batch_size: BATCH_SIZE) + .with_index do |builds, batch| + migrations = builds.map { |build| [MIGRATION, [build.id]] } - BackgroundMigrationWorker.perform_bulk(*migrations) - end + BackgroundMigrationWorker.perform_bulk(*migrations) + end end def down |