Migrate in batches of 1000 records

This commit is contained in:
Maximilian Grundke
2018-02-28 10:36:12 +01:00
parent 7b93caf4b3
commit 897950e658

View File

@ -1,8 +1,8 @@
class AddReachedFullScoreToRequestForComment < ActiveRecord::Migration
def up
add_column :request_for_comments, :full_score_reached, :boolean, default: false
RequestForComment.all.each { |rfc|
if (rfc.submission.present? && rfc.submission.exercise.has_user_solved(rfc.user))
RequestForComment.find_each { |rfc|
if rfc.submission.present? and rfc.submission.exercise.has_user_solved(rfc.user)
rfc.full_score_reached = true
rfc.save
end