2014-06-05 11:01:46 +08:00
|
|
|
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
|
2014-07-01 15:29:16 +08:00
|
|
|
courseinfo.save(:validate => false)
|
2014-06-05 11:01:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|