dev_forum
cxt 5 years ago
parent c1835bd5ff
commit aaf492e34a

@ -4,7 +4,7 @@ class MigrateCourseMembers < ActiveRecord::Migration[5.2]
Course.find_each do |course| Course.find_each do |course|
position = 1 position = 1
course.course_groups.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").find_each do |group| course.course_groups.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each do |group|
group.update_attribute(:position, position) group.update_attribute(:position, position)
position += 1 position += 1
end end

@ -1,11 +0,0 @@
class MigrateCourseGroupsPosition < ActiveRecord::Migration[5.2]
def change
Course.find_each do |course|
position = 1
course.course_groups.unscoped.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each do |group|
group.update_attribute(:position, position)
position += 1
end
end
end
end
Loading…
Cancel
Save