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-07-07 15:08:14 +0200
commit9a32ca409757b4b25520ea9957cdd4c8c97c0e95 (patch)
tree8906704507d8f98d27628bb6abba4d96e551184a /db
parentb7d672328db358690d043aae8b5fc24c358a52ab (diff)
downloadgitlab-ce-9a32ca409757b4b25520ea9957cdd4c8c97c0e95.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