2014-05-30 10:48:06 +08:00
|
|
|
class StoredCourseProcedure < ActiveRecord::Migration
|
2014-05-30 11:01:20 +08:00
|
|
|
def self.up
|
2014-05-30 10:48:06 +08:00
|
|
|
# 需要完成的数据导入:
|
|
|
|
# project中所有的课程导入至course
|
|
|
|
# Project_status导入至course_status
|
|
|
|
#
|
2014-06-03 09:39:33 +08:00
|
|
|
Project.all.each do |project|
|
2014-05-30 11:01:20 +08:00
|
|
|
if project.project_type == 1
|
|
|
|
course = Course.find_by_extra(project.identifier)
|
|
|
|
if course
|
|
|
|
course.name = project.name
|
|
|
|
course.description = project.description
|
|
|
|
course.status = project.status
|
|
|
|
course.attachmenttype = 2
|
2014-06-16 14:42:48 +08:00
|
|
|
#course.lft = project.lft
|
|
|
|
#course.rgt = project.rgt
|
2014-07-01 15:29:16 +08:00
|
|
|
course.save(:validate => false)
|
2014-05-30 11:01:20 +08:00
|
|
|
|
|
|
|
# 更新状态表
|
|
|
|
projectstatus = ProjectStatus.find_by_project_id(project.id)
|
|
|
|
if projectstatus
|
|
|
|
courseStatus = CourseStatus.new
|
|
|
|
courseStatus.course_id = course.id
|
|
|
|
courseStatus.changesets_count = projectstatus.changesets_count
|
|
|
|
courseStatus.watchers_count = projectstatus.watchers_count
|
|
|
|
courseStatus.grade = projectstatus.grade
|
|
|
|
courseStatus.course_ac_para = projectstatus.course_ac_para
|
2014-07-01 15:29:16 +08:00
|
|
|
courseStatus.save(:validate => false)
|
2014-05-30 10:48:06 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-30 11:01:20 +08:00
|
|
|
def self.down
|
2014-05-30 10:48:06 +08:00
|
|
|
end
|
|
|
|
end
|