socialforge/db/migrate/20150820025358_about_user_a...

38 lines
1.2 KiB
Ruby
Raw Normal View History

class AboutUserActivities < ActiveRecord::Migration
def up
forge_count = ForgeActivity.all.count / 30 + 2
transaction do
for i in 1 ... forge_count do i
ForgeActivity.page(i).per(30).each do |activity|
user_activity = UserActivity.new
2015-08-25 17:54:29 +08:00
user_activity.act_id = activity.forge_act_id
user_activity.act_type = activity.forge_act_type
user_activity.container_type = "Project"
user_activity.container_id = activity.project_id
user_activity.created_at = activity.created_at
user_activity.save
end
end
end
# course_count = CourseActivity.all.count / 30 + 2
# transaction do
# for i in 1 ... course_count do i
# CourseActivity.page(i).per(30).each do |activity|
# user_activity = UserActivity.new
# user_activity.act_id = activity.course_act_id
# user_activity.act_type = activity.course_act_type
# user_activity.container_type = "Course"
# user_activity.container_id = activity.course_id
# user_activity.created_at = activity.created_at
# user_activity.save
# end
# end
# end
end
def down
# UserActivity.destroy_all
end
end