Created
January 16, 2014 21:10
-
-
Save mperham/8463495 to your computer and use it in GitHub Desktop.
Using #join with a Sidekiq::Batch in Rails to parallelize data migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MoveInventoryUpdatesToS3 < ActiveRecord::Migration | |
def up | |
batch = Sidekiq::Batch.new | |
batch.jobs do | |
InventoryUpdate.where("content is not null").pluck(:id).each do |iuid| | |
InventoryUpdate.delay.send_to_s3(iuid) | |
end | |
end | |
# wait for all jobs to finish | |
batch.status.join | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That might be a case where you have a two-step migration or populate the column with a SQL UPDATE statement.