2016-05-13 20:07:43 +08:00
|
|
|
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|
|
2016-05-13 20:12:56 +08:00
|
|
|
homework = HomeworkCommon.where("id = ?",ah.homework_common_id)
|
|
|
|
if homework.empty?
|
2016-05-13 20:07:43 +08:00
|
|
|
ah.destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
end
|
|
|
|
end
|