Skip to content

Commit

Permalink
refactor: optimise task comment update
Browse files Browse the repository at this point in the history
  • Loading branch information
satikaj committed Sep 26, 2024
1 parent b0e2321 commit 58b3d52
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 58b3d52

Please sign in to comment.