parent
5cf6b7e76a
commit
35d6c76a8e
@ -1,22 +0,0 @@
|
||||
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
|
@ -0,0 +1,13 @@
|
||||
class ChangeAttachmentTime < ActiveRecord::Migration
|
||||
def up
|
||||
Attachment.where("container_type = 'Course'").each do |attachment|
|
||||
if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i
|
||||
attachment.created_on = attachment.container.created_at + 3600 * 24
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
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
|
Loading…
Reference in new issue