class UpdateMemoMessageTime < ActiveRecord::Migration def up # memo_count = Memo.all.count / 30 + 1 # transaction do # for i in 1 ... memo_count do i # MemoMessage.page(i).per(30).each do |memo_message| # if memo_message.memo # if memo_message.memo.respond_to?("created_at") # memo_message.created_at = memo_message.memo.created_at # elsif memo_message.memo.respond_to?("created_on") # memo_message.created_at = memo_message.memo.created_on # end # memo_message.save # puts memo_message.id # # memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first # memo_messages.created_at = memo_message.created_at # memo_messages.save # end # end # end # end end def down end end