From 993ac23a3693e93a78bd45fbe12b49527b4e5010 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 1 Jul 2014 15:29:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB=E6=97=B6=E4=B8=8D=E5=86=8D=E5=81=9A?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=EF=BC=8C=E4=BB=A5=E5=85=BC=E5=AE=B9=E8=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0140603033359_add_boards_type_to_boards.rb | 2 +- .../20140603042015_stored_course_procedure.rb | 4 +- ...3081801_add_courseid_to_enabled_modules.rb | 3 +- ...140604011630_add_courseid_to_to_members.rb | 2 +- ...name_project_id_to_homework_for_courses.rb | 2 +- .../20140605025300_create_course_infos.rb | 2 +- .../20140605025303_migrate_course_tags.rb | 2 +- .../20140606027403_migrate_course_journals.rb | 2 +- db/migrate/20140606028512_add_course_roles.rb | 2 +- .../20140611161801_add_courseid_to_news.rb | 2 +- ...18020535_remove_data_to_homework_attach.rb | 2 +- .../20140618105213_migrate_course_students.rb | 2 +- ...20140618155324_migrate_course_file_type.rb | 2 +- .../20140626012511_modify_student_roles.rb | 2 +- db/schema.rb | 64 ++----------------- 15 files changed, 21 insertions(+), 74 deletions(-) diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb index fcef8b11..85b3723f 100644 --- a/db/migrate/20140603033359_add_boards_type_to_boards.rb +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -11,7 +11,7 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration if project && project.project_type == 1 board.course_id = project.course_extra.id board.project_id = -1 - board.save + board.save(:validate => false) end end diff --git a/db/migrate/20140603042015_stored_course_procedure.rb b/db/migrate/20140603042015_stored_course_procedure.rb index 5dd6bc38..40cb87e2 100644 --- a/db/migrate/20140603042015_stored_course_procedure.rb +++ b/db/migrate/20140603042015_stored_course_procedure.rb @@ -14,7 +14,7 @@ class StoredCourseProcedure < ActiveRecord::Migration course.attachmenttype = 2 #course.lft = project.lft #course.rgt = project.rgt - course.save + course.save(:validate => false) # 更新状态表 projectstatus = ProjectStatus.find_by_project_id(project.id) @@ -25,7 +25,7 @@ class StoredCourseProcedure < ActiveRecord::Migration courseStatus.watchers_count = projectstatus.watchers_count courseStatus.grade = projectstatus.grade courseStatus.course_ac_para = projectstatus.course_ac_para - courseStatus.save + courseStatus.save(:validate => false) end end end diff --git a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb index be4fe7e6..61484481 100644 --- a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb +++ b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb @@ -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(project_id: -1) + EnabledModule.all.each do |enablemodule| project = Project.find_by_id(enablemodule.project_id) if project && project.project_type == 1 enablemodule.course_id = project.course_extra.id enablemodule.project_id = -1 - enablemodule.save + enablemodule.save(:validate => false) end end end diff --git a/db/migrate/20140604011630_add_courseid_to_to_members.rb b/db/migrate/20140604011630_add_courseid_to_to_members.rb index 583e3a2d..1fb547d6 100644 --- a/db/migrate/20140604011630_add_courseid_to_to_members.rb +++ b/db/migrate/20140604011630_add_courseid_to_to_members.rb @@ -15,7 +15,7 @@ class AddCourseidToToMembers < ActiveRecord::Migration if project && project.project_type == 1 member.course_id = project.course_extra.id member.project_id = -1 - member.save + member.save(:validate => false) end end end diff --git a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb index 613f141c..e9cf6ee1 100644 --- a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb +++ b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb @@ -7,7 +7,7 @@ class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration project = Project.find_by_id(work.course_id) if project && project.project_type == 1 work.course_id = project.course_extra.id - work.save + work.save(:validate => false) end end end diff --git a/db/migrate/20140605025300_create_course_infos.rb b/db/migrate/20140605025300_create_course_infos.rb index b1947f3d..daf9f953 100644 --- a/db/migrate/20140605025300_create_course_infos.rb +++ b/db/migrate/20140605025300_create_course_infos.rb @@ -16,7 +16,7 @@ class CreateCourseInfos < ActiveRecord::Migration courseinfo = CourseInfos.new courseinfo.course_id = course.id courseinfo.user_id = projinfo.user_id - courseinfo.save + courseinfo.save(:validate => false) end end end diff --git a/db/migrate/20140605025303_migrate_course_tags.rb b/db/migrate/20140605025303_migrate_course_tags.rb index 6e95839e..83926ae8 100644 --- a/db/migrate/20140605025303_migrate_course_tags.rb +++ b/db/migrate/20140605025303_migrate_course_tags.rb @@ -7,7 +7,7 @@ class MigrateCourseTags < ActiveRecord::Migration if project && project.project_type == 1 tagging.taggable_type= 'Course' tagging.taggable_id = project.course_extra.id - tagging.save + tagging.save(:validate => false) end end end diff --git a/db/migrate/20140606027403_migrate_course_journals.rb b/db/migrate/20140606027403_migrate_course_journals.rb index 4a13ef38..b601483a 100644 --- a/db/migrate/20140606027403_migrate_course_journals.rb +++ b/db/migrate/20140606027403_migrate_course_journals.rb @@ -6,7 +6,7 @@ class MigrateCourseJournals < ActiveRecord::Migration if project && project.project_type == 1 journal.jour_type = 'Course' journal.jour_id = project.course_extra.id - journal.save + journal.save(:validate => false) end # 将自动设置的更新日期还原 sql = ActiveRecord::Base.connection() diff --git a/db/migrate/20140606028512_add_course_roles.rb b/db/migrate/20140606028512_add_course_roles.rb index 7b84b92a..3435dd25 100644 --- a/db/migrate/20140606028512_add_course_roles.rb +++ b/db/migrate/20140606028512_add_course_roles.rb @@ -47,7 +47,7 @@ class AddCourseRoles < ActiveRecord::Migration role.permissions.append(:view_course_files ) role.permissions.append(:view_course_journals_for_messages ) role.permissions.append(:view_course_messages ) - role.save + role.save(:validate => false) end end diff --git a/db/migrate/20140611161801_add_courseid_to_news.rb b/db/migrate/20140611161801_add_courseid_to_news.rb index 5ca62a6a..b1a34938 100644 --- a/db/migrate/20140611161801_add_courseid_to_news.rb +++ b/db/migrate/20140611161801_add_courseid_to_news.rb @@ -12,7 +12,7 @@ class AddCourseidToNews < ActiveRecord::Migration if project && project.project_type == 1 news.course_id = project.course_extra.id news.project_id = -1 - news.save + news.save(:validate => false) end end diff --git a/db/migrate/20140618020535_remove_data_to_homework_attach.rb b/db/migrate/20140618020535_remove_data_to_homework_attach.rb index 16a1b491..9067e406 100644 --- a/db/migrate/20140618020535_remove_data_to_homework_attach.rb +++ b/db/migrate/20140618020535_remove_data_to_homework_attach.rb @@ -11,7 +11,7 @@ class RemoveDataToHomeworkAttach < ActiveRecord::Migration homework.description = biding.description homework.user_id = biding.user_id homework.state = 0 - homework.save + homework.save(:validate => false) end end diff --git a/db/migrate/20140618105213_migrate_course_students.rb b/db/migrate/20140618105213_migrate_course_students.rb index ef037682..9eb43e4b 100644 --- a/db/migrate/20140618105213_migrate_course_students.rb +++ b/db/migrate/20140618105213_migrate_course_students.rb @@ -5,7 +5,7 @@ class MigrateCourseStudents < ActiveRecord::Migration project = Project.find_by_id(student.course_id) if project && project.course_extra student.course_id = project.course_extra.id - student.save + student.save(:validate => false) end end end diff --git a/db/migrate/20140618155324_migrate_course_file_type.rb b/db/migrate/20140618155324_migrate_course_file_type.rb index 6cbf3b87..a91b1461 100644 --- a/db/migrate/20140618155324_migrate_course_file_type.rb +++ b/db/migrate/20140618155324_migrate_course_file_type.rb @@ -4,7 +4,7 @@ class MigrateCourseFileType < ActiveRecord::Migration Attachment.all.each do |attach| if attach.container_type == "Course" && attach.attachtype == 1 attach.attachtype = 4 - attach.save + attach.save(:validate => false) end end end diff --git a/db/migrate/20140626012511_modify_student_roles.rb b/db/migrate/20140626012511_modify_student_roles.rb index 1db0a734..18274871 100644 --- a/db/migrate/20140626012511_modify_student_roles.rb +++ b/db/migrate/20140626012511_modify_student_roles.rb @@ -6,7 +6,7 @@ class ModifyStudentRoles < ActiveRecord::Migration role = Role.find_by_name('学生') if role role.permissions.append(:add_messages) - role.save + role.save(:validate => false) end end diff --git a/db/schema.rb b/db/schema.rb index cc3d68cb..67ea26a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -175,58 +175,6 @@ ActiveRecord::Schema.define(:version => 20140626012511) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -1041,13 +989,11 @@ ActiveRecord::Schema.define(:version => 20140626012511) do end create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "user_id" + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "activity" end create_table "user_statuses", :force => true do |t| From cf00942261c8392c08ae15d7e4b1baa9fff4b658 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 1 Jul 2014 16:19:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140603042015_stored_course_procedure.rb | 16 ++++-- db/schema.rb | 52 +++++++++++++++++++ 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/db/migrate/20140603042015_stored_course_procedure.rb b/db/migrate/20140603042015_stored_course_procedure.rb index 40cb87e2..2f5faf5c 100644 --- a/db/migrate/20140603042015_stored_course_procedure.rb +++ b/db/migrate/20140603042015_stored_course_procedure.rb @@ -8,13 +8,19 @@ class StoredCourseProcedure < ActiveRecord::Migration 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 + sql = "update courses set name='" + project.name.to_s + "',description='" + sql += project.description.to_s + "',status=" + project.status.to_s + sql += ",attachmenttype=2 where id=" +course.id.to_s + execute(sql) + + # 以下方式保存,描述等经常不能成功 + #course.name = project.name + #course.description = project.description + #course.status = project.status + #course.attachmenttype = 2 #course.lft = project.lft #course.rgt = project.rgt - course.save(:validate => false) + #course.save(:validate => false) # 更新状态表 projectstatus = ProjectStatus.find_by_project_id(project.id) diff --git a/db/schema.rb b/db/schema.rb index 67ea26a2..9962892d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -175,6 +175,58 @@ ActiveRecord::Schema.define(:version => 20140626012511) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false