class AddCommitTimeToStudentWork < ActiveRecord::Migration
  def change
    add_column :student_works, :commit_time, :datetime

    count = StudentWork.all.count / 30 + 2
    transaction do
      for i in 1 ... count do i
        StudentWork.page(i).per(30).each do |work|
          if work.work_status != 0
            work.update_column("commit_time", work.created_at)
          end
        end
      end
    end
  end
end
