socialforge/db/migrate/20160715091215_delete_none_...

18 lines
355 B
Ruby
Raw Normal View History

2016-07-15 17:38:32 +08:00
class DeleteNoneCourseHomework < ActiveRecord::Migration
def up
count = HomeworkCommon.all.count / 30 + 2
transaction do
for i in 1 ... count do i
HomeworkCommon.page(i).per(30).each do |h|
if h.course_id.nil? || h.course.nil?
h.destroy
end
end
end
end
end
def down
end
end