class InitCompetitionCertificateModuleData < ActiveRecord::Migration[5.2]
  def change
    Competition.find_each do |competition|
      competition.competition_modules.where(module_type: 'certificate').delete_all

      position = competition.competition_modules.maximum(:position) + 1
      competition.competition_modules.create(module_type: 'certificate', position: position, name: '获奖证书', hidden: true)
    end
  end
end
