commit
2b72b5794b
@ -0,0 +1,20 @@
|
||||
class ModifyCourseGroupForCourses < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
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|
|
||||
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)
|
||||
cg.homework_group_settings.update_all(course_group_id: g.id)
|
||||
cg.teacher_course_groups.update_all(course_group_id: g.id)
|
||||
cg.destroy!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue