You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/db/migrate/20190909082555_migrate_shix...

14 lines
651 B

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