22 lines
703 B
Ruby
22 lines
703 B
Ruby
|
class UpdateActivitiesData < ActiveRecord::Migration
|
||
|
def up
|
||
|
count = Activity.all.count / 10 + 1
|
||
|
transaction do
|
||
|
for i in 1 ... count do i
|
||
|
Activity.all.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
|