socialforge/db/migrate/20150911064528_alter_user_a...

22 lines
577 B
Ruby
Raw Normal View History

2015-09-11 16:45:50 +08:00
class AlterUserActivities < ActiveRecord::Migration
def up
2015-09-11 17:19:40 +08:00
UserActivity.all.each do |activity|
2015-09-11 17:15:05 +08:00
if activity.act_type == 'Message'
if activity.act
unless activity.act.parent_id.nil?
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='Message'").first
parent_act.created_at = activity.act.parent.children.maximum("created_on")
parent_act.save
activity.destroy
2015-09-11 16:45:50 +08:00
end
2015-09-11 17:15:05 +08:00
else
activity.destroy
2015-09-11 16:45:50 +08:00
end
end
end
end
def down
end
end