修改迁移文件

This commit is contained in:
cxt 2015-09-11 17:15:05 +08:00
parent 86f0889f5b
commit 9dc3f43af1
2 changed files with 10 additions and 1709 deletions

View File

@ -1,21 +1,16 @@
class AlterUserActivities < ActiveRecord::Migration
def up
count = UserActivity.all.count / 30 + 3
transaction do
for i in 1 ... count do i
UserActivity.page(i).per(30).each do |activity|
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
end
else
activity.destroy
end
UserActivity.each do |activity|
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
end
else
activity.destroy
end
end
end

File diff suppressed because it is too large Load Diff