diff --git a/db/migrate/20240601103707_add_polymorphic_association_to_comment.rb b/db/migrate/20240601103707_add_polymorphic_association_to_comment.rb index bea8d90ab..f6828c0b2 100644 --- a/db/migrate/20240601103707_add_polymorphic_association_to_comment.rb +++ b/db/migrate/20240601103707_add_polymorphic_association_to_comment.rb @@ -5,11 +5,7 @@ def change add_column :task_comments, :commentable_type, :string rename_column :task_comments, :overseer_assessment_id, :commentable_id - TaskComment.find_each do |comment| - if comment.commentable_id.present? - comment.update(commentable_type: 'OverseerAssessment') - end - end + TaskComment.where('NOT commentable_id IS NULL').in_batches.update_all(commentable_type: 'OverseerAssessment') add_index :task_comments, [:commentable_type, :commentable_id] end