diff --git a/lib/tasks/new_core.rake b/lib/tasks/new_core.rake new file mode 100644 index 000000000..f61689b96 --- /dev/null +++ b/lib/tasks/new_core.rake @@ -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 \ No newline at end of file