class DeleteEmptyApplyHomework < ActiveRecord::Migration
  def up
    count = ApplyHomework.all.count / 30 + 2
    transaction do
      for i in 1 ... count do i
        ApplyHomework.page(i).per(30).each do |ah|
          homework = HomeworkCommon.where("id = ?",ah.homework_common_id)
          if homework.empty?
            ah.destroy
          end
        end
      end
    end
  end

  def down
  end
end
