class MigrateShixunWorkComment < ActiveRecord::Migration[5.2]
  def change
    StudentWorksScore.where(is_ultimate: 0, score: nil).where("created_at > '2019-09-04 00:00:00'").each do |work_score|
      if work_score.student_work && work_score.student_work.homework_common&.shixuns
        if work_score.is_hidden
          ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, hidden_comment: work_score.comment)
        else
          ShixunWorkComment.create!(student_work_id: work_score.student_work_id, user_id: work_score.user_id, comment: work_score.comment)
        end
      end
    end
  end
end