summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-28 12:21:25 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-28 12:21:25 +0200
commit02bb40e2acd7b1838e47e1a2f8b9288e42e6ca53 (patch)
tree96ad606eced04aa327cce17aa7adc7942a98106c /db
parent6209ff671fdd025be31f9dcaf208a71b6ec2907d (diff)
downloadgitlab-ce-02bb40e2acd7b1838e47e1a2f8b9288e42e6ca53.tar.gz
Find builds that require a migration in batches
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb9
1 files changed, 6 insertions, 3 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 44bac4a8cc7..6b326bc0b69 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
@@ -2,6 +2,8 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
+ BATCH_SIZE = 10000
+ MIGRATION = 'MigrateBuildStageIdReference'.freeze
disable_ddl_transaction!
@@ -10,9 +12,10 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
end
def up
- Build.find_each do |build|
- BackgroundMigrationWorker
- .perform_async('MigrateBuildStageIdReference', [build.id])
+ Build.find_in_batches(batch_size: BATCH_SIZE).with_index do |builds, batch|
+ migrations = builds.map { |build| [MIGRATION, [build.id]] }
+
+ BackgroundMigrationWorker.perform_bulk(*migrations)
end
end