测验历史数据的题号迁移
This commit is contained in:
parent
c3671baa6e
commit
10884221b5
|
|
@ -0,0 +1,17 @@
|
|||
class MigrateExerciseQuestionNum < ActiveRecord::Migration
|
||||
def up
|
||||
count = Exercise.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
Exercise.page(i).per(30).each do |exercise|
|
||||
exercise.exercise_questions.reorder("created_at asc").each_with_index do |question, j|
|
||||
question.update_column('question_number', j + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue