You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
775 B
18 lines
775 B
class MigrateCompetitionModuleContent < ActiveRecord::Migration[5.2]
|
|
def change
|
|
Competition.all.each do |competition|
|
|
competition.informs.each do |inform|
|
|
if inform.status == 1
|
|
com_module = competition.competition_modules.find_by(module_type: "inform")
|
|
elsif inform.status == 2
|
|
com_module = competition.competition_modules.find_by(name: "参赛手册")
|
|
end
|
|
if com_module
|
|
new_md = CompetitionModuleMdContent.create!(competition_module_id: com_module.id, content: inform.description, name: inform.name)
|
|
Attachment.where(container_id: inform.id, container_type: "Inform").update_all(container_id: new_md.id, container_type: "CompetitionModuleMdContent")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|