class DeleteNullAtMessages < ActiveRecord::Migration def up count = AtMessage.all.count / 30 + 2 transaction do for i in 1 ... count do i AtMessage.page(i).per(30).each do |am| if am.at_message.nil? am.destroy end end end end end def down end end