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