修改迁移文件

guange_homework
cxt 10 years ago
parent 86f0889f5b
commit 9dc3f43af1

@ -1,21 +1,16 @@
class AlterUserActivities < ActiveRecord::Migration class AlterUserActivities < ActiveRecord::Migration
def up def up
count = UserActivity.all.count / 30 + 3 UserActivity.each do |activity|
transaction do if activity.act_type == 'Message'
for i in 1 ... count do i if activity.act
UserActivity.page(i).per(30).each do |activity| unless activity.act.parent_id.nil?
if activity.act_type == 'Message' parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='Message'").first
if activity.act parent_act.created_at = activity.act.parent.children.maximum("created_on")
unless activity.act.parent_id.nil? parent_act.save
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='Message'").first activity.destroy
parent_act.created_at = activity.act.parent.children.maximum("created_on")
parent_act.save
activity.destroy
end
else
activity.destroy
end
end end
else
activity.destroy
end end
end end
end end

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save