提升迁移文件效率

This commit is contained in:
sw 2015-08-15 19:47:24 +08:00
parent 8d30bec8a4
commit 0ba9cfe5dd
1 changed files with 2 additions and 2 deletions

View File

@ -1,9 +1,9 @@
class UpdateActivitiesData < ActiveRecord::Migration
def up
count = Activity.all.count / 10 + 1
count = Activity.all.count / 20 + 1
transaction do
for i in 1 ... count do i
Activity.all.each do |activity|
Activity.page(i).per(20).each do |activity|
type = activity.act_type
if type=='Contest' || type=='Message' || type=='News'|| type=='Journal'|| type=='Issue'|| type=='Principal'||type=='JournalsForMessage'
activity.created_at = activity.act.created_on if activity.act