This commit is contained in:
z9hang 2014-07-01 16:33:26 +08:00
commit 37acecae61
15 changed files with 31 additions and 26 deletions

View File

@ -11,7 +11,7 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration
if project && project.project_type == 1 if project && project.project_type == 1
board.course_id = project.course_extra.id board.course_id = project.course_extra.id
board.project_id = -1 board.project_id = -1
board.save board.save(:validate => false)
end end
end end

View File

@ -8,13 +8,19 @@ class StoredCourseProcedure < ActiveRecord::Migration
if project.project_type == 1 if project.project_type == 1
course = Course.find_by_extra(project.identifier) course = Course.find_by_extra(project.identifier)
if course if course
course.name = project.name sql = "update courses set name='" + project.name.to_s + "',description='"
course.description = project.description sql += project.description.to_s + "',status=" + project.status.to_s
course.status = project.status sql += ",attachmenttype=2 where id=" +course.id.to_s
course.attachmenttype = 2 execute(sql)
# 以下方式保存,描述等经常不能成功
#course.name = project.name
#course.description = project.description
#course.status = project.status
#course.attachmenttype = 2
#course.lft = project.lft #course.lft = project.lft
#course.rgt = project.rgt #course.rgt = project.rgt
course.save #course.save(:validate => false)
# 更新状态表 # 更新状态表
projectstatus = ProjectStatus.find_by_project_id(project.id) projectstatus = ProjectStatus.find_by_project_id(project.id)
@ -25,7 +31,7 @@ class StoredCourseProcedure < ActiveRecord::Migration
courseStatus.watchers_count = projectstatus.watchers_count courseStatus.watchers_count = projectstatus.watchers_count
courseStatus.grade = projectstatus.grade courseStatus.grade = projectstatus.grade
courseStatus.course_ac_para = projectstatus.course_ac_para courseStatus.course_ac_para = projectstatus.course_ac_para
courseStatus.save courseStatus.save(:validate => false)
end end
end end
end end

View File

@ -6,12 +6,13 @@ class AddCourseidToEnabledModules < ActiveRecord::Migration
#EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") #EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
#EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) #EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
EnabledModule.all.each do |enablemodule| EnabledModule.all.each do |enablemodule|
project = Project.find_by_id(enablemodule.project_id) project = Project.find_by_id(enablemodule.project_id)
if project && project.project_type == 1 if project && project.project_type == 1
enablemodule.course_id = project.course_extra.id enablemodule.course_id = project.course_extra.id
enablemodule.project_id = -1 enablemodule.project_id = -1
enablemodule.save enablemodule.save(:validate => false)
end end
end end
end end

View File

@ -15,7 +15,7 @@ class AddCourseidToToMembers < ActiveRecord::Migration
if project && project.project_type == 1 if project && project.project_type == 1
member.course_id = project.course_extra.id member.course_id = project.course_extra.id
member.project_id = -1 member.project_id = -1
member.save member.save(:validate => false)
end end
end end
end end

View File

@ -7,7 +7,7 @@ class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration
project = Project.find_by_id(work.course_id) project = Project.find_by_id(work.course_id)
if project && project.project_type == 1 if project && project.project_type == 1
work.course_id = project.course_extra.id work.course_id = project.course_extra.id
work.save work.save(:validate => false)
end end
end end
end end

View File

@ -16,7 +16,7 @@ class CreateCourseInfos < ActiveRecord::Migration
courseinfo = CourseInfos.new courseinfo = CourseInfos.new
courseinfo.course_id = course.id courseinfo.course_id = course.id
courseinfo.user_id = projinfo.user_id courseinfo.user_id = projinfo.user_id
courseinfo.save courseinfo.save(:validate => false)
end end
end end
end end

View File

@ -7,7 +7,7 @@ class MigrateCourseTags < ActiveRecord::Migration
if project && project.project_type == 1 if project && project.project_type == 1
tagging.taggable_type= 'Course' tagging.taggable_type= 'Course'
tagging.taggable_id = project.course_extra.id tagging.taggable_id = project.course_extra.id
tagging.save tagging.save(:validate => false)
end end
end end
end end

View File

@ -6,7 +6,7 @@ class MigrateCourseJournals < ActiveRecord::Migration
if project && project.project_type == 1 if project && project.project_type == 1
journal.jour_type = 'Course' journal.jour_type = 'Course'
journal.jour_id = project.course_extra.id journal.jour_id = project.course_extra.id
journal.save journal.save(:validate => false)
end end
# 将自动设置的更新日期还原 # 将自动设置的更新日期还原
sql = ActiveRecord::Base.connection() sql = ActiveRecord::Base.connection()

View File

@ -47,7 +47,7 @@ class AddCourseRoles < ActiveRecord::Migration
role.permissions.append(:view_course_files ) role.permissions.append(:view_course_files )
role.permissions.append(:view_course_journals_for_messages ) role.permissions.append(:view_course_journals_for_messages )
role.permissions.append(:view_course_messages ) role.permissions.append(:view_course_messages )
role.save role.save(:validate => false)
end end
end end

View File

@ -12,7 +12,7 @@ class AddCourseidToNews < ActiveRecord::Migration
if project && project.project_type == 1 if project && project.project_type == 1
news.course_id = project.course_extra.id news.course_id = project.course_extra.id
news.project_id = -1 news.project_id = -1
news.save news.save(:validate => false)
end end
end end

View File

@ -11,7 +11,7 @@ class RemoveDataToHomeworkAttach < ActiveRecord::Migration
homework.description = biding.description homework.description = biding.description
homework.user_id = biding.user_id homework.user_id = biding.user_id
homework.state = 0 homework.state = 0
homework.save homework.save(:validate => false)
end end
end end

View File

@ -5,7 +5,7 @@ class MigrateCourseStudents < ActiveRecord::Migration
project = Project.find_by_id(student.course_id) project = Project.find_by_id(student.course_id)
if project && project.course_extra if project && project.course_extra
student.course_id = project.course_extra.id student.course_id = project.course_extra.id
student.save student.save(:validate => false)
end end
end end
end end

View File

@ -4,7 +4,7 @@ class MigrateCourseFileType < ActiveRecord::Migration
Attachment.all.each do |attach| Attachment.all.each do |attach|
if attach.container_type == "Course" && attach.attachtype == 1 if attach.container_type == "Course" && attach.attachtype == 1
attach.attachtype = 4 attach.attachtype = 4
attach.save attach.save(:validate => false)
end end
end end
end end

View File

@ -6,7 +6,7 @@ class ModifyStudentRoles < ActiveRecord::Migration
role = Role.find_by_name('学生') role = Role.find_by_name('学生')
if role if role
role.permissions.append(:add_messages) role.permissions.append(:add_messages)
role.save role.save(:validate => false)
end end
end end

View File

@ -1041,13 +1041,11 @@ ActiveRecord::Schema.define(:version => 20140626012511) do
end end
create_table "user_scores", :force => true do |t| create_table "user_scores", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id"
t.integer "collaboration" t.integer "collaboration"
t.integer "influence" t.integer "influence"
t.integer "skill" t.integer "skill"
t.integer "active" t.integer "activity"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end end
create_table "user_statuses", :force => true do |t| create_table "user_statuses", :force => true do |t|