bigdir/db/migrate/20140605025300_create_cours...

26 lines
711 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(:validate => false)
end
end
end
end
end
end