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.
11 lines
518 B
11 lines
518 B
5 years ago
|
class MigrateExerciseShixunAnswerComment < ActiveRecord::Migration[5.2]
|
||
|
def change
|
||
|
ExerciseAnswerComment.where.not(exercise_shixun_answer_id: ExerciseShixunAnswer.all).where("exercise_shixun_answer_id is not null and exercise_answer_id is not null").each do |answer|
|
||
|
exercise_shixun_answer = ExerciseShixunAnswer.find_by(id: answer.exercise_answer_id)
|
||
|
if exercise_shixun_answer.present?
|
||
|
answer.update_columns(exercise_shixun_answer_id: exercise_shixun_answer&.id)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|