summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb2
-rw-r--r--spec/migrations/migrate_stage_id_reference_in_background_spec.rb3
2 files changed, 2 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 5b1ff9b8849..f31015d77a3 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
@@ -17,7 +17,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
# It will take around 3 days to process 20M ci_builds.
#
def up
- Build.all.each_batch(of: BATCH_SIZE) do |relation, index|
+ Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index|
relation.each_batch(of: RANGE_SIZE) do |relation|
range = relation.pluck('MIN(id)', 'MAX(id)').first
diff --git a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb b/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
index e829a9238f6..260378adaa7 100644
--- a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
+++ b/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
@@ -51,8 +51,7 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
expect(described_class::MIGRATION).to be_scheduled_migration(2.minutes, 1, 2)
expect(described_class::MIGRATION).to be_scheduled_migration(2.minutes, 3, 3)
expect(described_class::MIGRATION).to be_scheduled_migration(4.minutes, 4, 5)
- expect(described_class::MIGRATION).to be_scheduled_migration(4.minutes, 6, 6)
- expect(BackgroundMigrationWorker.jobs.size).to eq 4
+ expect(BackgroundMigrationWorker.jobs.size).to eq 3
end
end
end