Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank
commit
5f410d5bb6
@ -0,0 +1,18 @@
|
|||||||
|
class ModifyCourseGroupForCourses < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
groups = CourseGroup.where(course_id:3128).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.update_all(course_group_id: g.id)
|
||||||
|
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