class ModifyChallnegeScoreForChoose < ActiveRecord::Migration[5.2]
  def change
    challenges = Challenge.where(st: 1)
    challenges.find_each do |c|
      puts(c.id)
      score = c.challenge_chooses.sum(:score)
      c.update_column(:score, score)
    end
  end
end
