From 4bb08755b6c0193b830f83588ff5666622b951d7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 2 Jan 2020 11:41:13 +0800 Subject: [PATCH 1/3] 1 --- db/migrate/20200102030945_modify_course_group_for_courses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200102030945_modify_course_group_for_courses.rb b/db/migrate/20200102030945_modify_course_group_for_courses.rb index f613023c8..6e71af35b 100644 --- a/db/migrate/20200102030945_modify_course_group_for_courses.rb +++ b/db/migrate/20200102030945_modify_course_group_for_courses.rb @@ -10,7 +10,7 @@ class ModifyCourseGroupForCourses < ActiveRecord::Migration[5.2] cg.homework_group_reviews.update_all(course_group_id: g.id) cg.homework_group_settings.update_all(course_group_id: g.id) cg.teacher_course_groups.update_all(course_group_id: g.id) - cg.destory! + cg.destroy! end end end From b1ca2286a10b1f61dfd33e3f7b946bab532b15f1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 2 Jan 2020 11:48:33 +0800 Subject: [PATCH 2/3] fixbug --- ...s.rb => 20200102030946_modify_course_group_for_courses.rb} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename db/migrate/{20200102030945_modify_course_group_for_courses.rb => 20200102030946_modify_course_group_for_courses.rb} (86%) diff --git a/db/migrate/20200102030945_modify_course_group_for_courses.rb b/db/migrate/20200102030946_modify_course_group_for_courses.rb similarity index 86% rename from db/migrate/20200102030945_modify_course_group_for_courses.rb rename to db/migrate/20200102030946_modify_course_group_for_courses.rb index 6e71af35b..e36bc9e0b 100644 --- a/db/migrate/20200102030945_modify_course_group_for_courses.rb +++ b/db/migrate/20200102030946_modify_course_group_for_courses.rb @@ -4,7 +4,9 @@ class ModifyCourseGroupForCourses < ActiveRecord::Migration[5.2] ActiveRecord::Base.transaction do groups.each do |g| CourseGroup.where(name: g.name).where.not(id: g.id).each do |cg| - cg.course_members.update_all(course_group_id: g.id) + cg.course_members.each do |cm| + cm.update_attributes!(course_group_id: g.id) + end cg.exercise_group_settings.update_all(course_group_id: g.id) cg.attachment_group_settings.update_all(course_group_id: g.id) cg.homework_group_reviews.update_all(course_group_id: g.id) From 000585cf126b02c208b89e7ff4b5840aefaabd6b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 2 Jan 2020 11:50:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E5=88=86=E7=8F=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20200102030946_modify_course_group_for_courses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200102030946_modify_course_group_for_courses.rb b/db/migrate/20200102030946_modify_course_group_for_courses.rb index e36bc9e0b..8df0943b3 100644 --- a/db/migrate/20200102030946_modify_course_group_for_courses.rb +++ b/db/migrate/20200102030946_modify_course_group_for_courses.rb @@ -1,6 +1,6 @@ class ModifyCourseGroupForCourses < ActiveRecord::Migration[5.2] def change - groups = CourseGroup.where(course_id:3128).order("created_at desc").group(:name) + groups = CourseGroup.where(course_id:3429).order("created_at desc").group(:name) ActiveRecord::Base.transaction do groups.each do |g| CourseGroup.where(name: g.name).where.not(id: g.id).each do |cg|