14 lines
356 B
Ruby
14 lines
356 B
Ruby
|
class MigrateCourseStudents < ActiveRecord::Migration
|
||
|
def change
|
||
|
# 原课程的学生数据迁移成新模式
|
||
|
StudentsForCourse.all.each do |student|
|
||
|
project = Project.find_by_id(student.course_id)
|
||
|
if project
|
||
|
student.course_id = project.course_extra.id
|
||
|
student.save
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|