bigdir/db/migrate/20140605025302_migrate_cour...

18 lines
450 B
Ruby

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