socialforge/db/migrate/20150619060110_homework_com...

19 lines
515 B
Ruby

class HomeworkCommonTime < ActiveRecord::Migration
def up
count = StudentWork.all.count / 100 + 1
transaction do
for i in 1 ... count do i
StudentWork.page(i).per(100).each do |homework|
old_homework = HomeworkAttach.where(:user_id => homework.user_id, :name => homework.name, :description => homework.description).first
if old_homework
homework.update_column('created_at', old_homework.created_at)
end
end
end
end
end
def down
end
end