class UpdateCourseActivityTime < ActiveRecord::Migration def up count = CourseActivity.all.count / 10 + 1 transaction do for i in 1 ... count do i CourseActivity.page(i).per(10).each do |activity| if activity.course_act if activity.course_act.respond_to?("created_at") activity.created_at = activity.course_act.created_at elsif activity.course_act.respond_to?("created_on") activity.created_at = activity.course_act.created_on end activity.save end end end end end def down end end