2014-06-05 14:07:44 +08:00
|
|
|
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'
|
2014-06-18 11:08:44 +08:00
|
|
|
attach.container_id = project.course_extra.id
|
2014-06-05 14:07:44 +08:00
|
|
|
attach.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
end
|
|
|
|
end
|