26 lines
691 B
Ruby
26 lines
691 B
Ruby
|
class CreateCourseInfos < ActiveRecord::Migration
|
||
|
def change
|
||
|
create_table :course_infos do |t|
|
||
|
t.integer :course_id
|
||
|
t.integer :user_id
|
||
|
t.timestamps
|
||
|
end
|
||
|
|
||
|
#迁移课程管理员数据
|
||
|
Project.all.each do |project|
|
||
|
if project.project_type == 1
|
||
|
course = Course.find_by_extra(project.identifier)
|
||
|
if course
|
||
|
projectinfos = ProjectInfo.find_all_by_project_id(project.id)
|
||
|
projectinfos.each do |projinfo|
|
||
|
courseinfo = CourseInfos.new
|
||
|
courseinfo.course_id = course.id
|
||
|
courseinfo.user_id = projinfo.user_id
|
||
|
courseinfo.save
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|