parent
12c05c262b
commit
803d9d5d7d
@ -0,0 +1,17 @@
|
|||||||
|
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
|
Loading…
Reference in new issue