add new_core.rake task for updating bs_id field

This commit is contained in:
Vokhmin Alexey V 2012-12-26 00:15:21 +04:00
parent 960af73ff3
commit e2ec09f8f8
1 changed files with 17 additions and 0 deletions

17
lib/tasks/new_core.rake Normal file
View File

@ -0,0 +1,17 @@
namespace :new_core do
desc 'Sets bs_id field for all BuildList which use new_core'
task :update_bs_id => :environment do
say "[#{Time.zone.now}] Starting to update bs_id..."
BuildList.select(:id).
where(:new_core => true, :bs_id => nil).
find_in_batches(:batch_size => 500) do | bls |
puts "[#{Time.zone.now}] - where build_lists.id from #{bls.first.id} to #{bls.last.id}"
BuildList.where(:id => bls.map(&:id), :bs_id => nil).
update_all("bs_id = id")
end
say "[#{Time.zone.now}] done"
end
end