socialforge/db/migrate/20140603042015_stored_cours...

38 lines
1.2 KiB
Ruby
Raw Normal View History

2014-05-30 10:48:06 +08:00
class StoredCourseProcedure < ActiveRecord::Migration
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|
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
course.save
# 更新状态表
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
courseStatus.save
2014-05-30 10:48:06 +08:00
end
end
end
end
end
def self.down
2014-05-30 10:48:06 +08:00
end
end