You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/db/migrate/20140618105213_migrate_cour...

14 lines
400 B

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