You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/db/migrate/20160408074854_delete_blog_...

22 lines
588 B

class DeleteBlogUserActivity < ActiveRecord::Migration
def up
UserActivity.all.each do |activity|
if activity.act_type == 'BlogComment'
if activity.act
unless activity.act.parent_id.nil?
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='BlogComment'").first
parent_act.created_at = activity.act.parent.children.maximum("created_on")
parent_act.save
activity.destroy
end
else
activity.destroy
end
end
end
end
def down
end
end