2014-06-06 08:50:46 +08:00
|
|
|
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'
|
2014-06-18 11:08:44 +08:00
|
|
|
journal.jour_id = project.course_extra.id
|
2014-06-06 08:50:46 +08:00
|
|
|
journal.save
|
|
|
|
end
|
2014-06-18 15:18:30 +08:00
|
|
|
# 将自动设置的更新日期还原
|
|
|
|
sql = ActiveRecord::Base.connection()
|
|
|
|
sql.insert "update journals_for_messages set updated_on=created_on where jour_type='Course'"
|
2014-06-06 08:50:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
end
|
|
|
|
end
|