class UpdateActivitiesData < ActiveRecord::Migration def up count = Activity.all.count / 20 + 1 transaction do for i in 1 ... count do i 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 elsif type=='Contestnotification' || type=='HomeworkCommon' || type=='Poll' activity.created_at = activity.act.created_at if activity.act end activity.save end end end end def down end end