2015-08-29 17:09:44 +08:00
|
|
|
class UpdateMessageTime < ActiveRecord::Migration
|
|
|
|
def up
|
2015-09-02 21:33:03 +08:00
|
|
|
# course_count = CourseMessage.all.count / 30 + 1
|
|
|
|
# transaction do
|
|
|
|
# for i in 1 ... course_count do i
|
|
|
|
# CourseMessage.page(i).per(30).each do |cmessage|
|
|
|
|
# if cmessage.course_message
|
|
|
|
# if cmessage.course_message.respond_to?("created_at")
|
|
|
|
# cmessage.created_at = cmessage.course_message.created_at
|
|
|
|
# elsif cmessage.course_message.respond_to?("created_on")
|
|
|
|
# cmessage.created_at = cmessage.course_message.created_on
|
|
|
|
# end
|
|
|
|
# cmessage.save
|
|
|
|
# puts cmessage.id
|
|
|
|
#
|
|
|
|
# course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first
|
|
|
|
# course_all_message.created_at = cmessage.created_at
|
|
|
|
# course_all_message.save
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
2015-08-29 17:09:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
end
|
|
|
|
end
|