2014-06-18 11:08:44 +08:00
|
|
|
class MigrateCourseStudents < ActiveRecord::Migration
|
|
|
|
def change
|
|
|
|
# 原课程的学生数据迁移成新模式
|
|
|
|
StudentsForCourse.all.each do |student|
|
|
|
|
project = Project.find_by_id(student.course_id)
|
2014-06-26 10:01:44 +08:00
|
|
|
if project && project.course_extra
|
2014-06-18 11:08:44 +08:00
|
|
|
student.course_id = project.course_extra.id
|
2014-07-01 15:29:16 +08:00
|
|
|
student.save(:validate => false)
|
2014-06-18 11:08:44 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|