class MigrateCourseJournals < ActiveRecord::Migration def self.up # 原课程的讨论区数据迁移成新模式 JournalsForMessage.find_all_by_jour_type('Project').each do |journal| project = Project.find_by_id(journal.jour_id) if project && project.project_type == 1 journal.jour_type = 'Course' journal.jour_id = project.course_extra.id journal.save end end end def self.down end end