parent
6ff26d06ab
commit
cd3c69af94
@ -0,0 +1,17 @@
|
|||||||
|
class MigrateCourseAttachments < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
# 原课程的资源数据迁移成新模式
|
||||||
|
Attachment.all.each do |attach|
|
||||||
|
if attach.container_type == "Project"
|
||||||
|
project = Project.find_by_id(attach.container_id)
|
||||||
|
if project && project.project_type == 1
|
||||||
|
attach.container_type= 'Course'
|
||||||
|
attach.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue