dev_forum
parent
4a86b86021
commit
5e484022b3
@ -1,11 +0,0 @@
|
|||||||
class MigrateCourseGroupPosition < ActiveRecord::Migration[5.2]
|
|
||||||
def change
|
|
||||||
Course.find_each do |course|
|
|
||||||
position = 1
|
|
||||||
course.course_groups.reorder("CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").find_each do |group|
|
|
||||||
group.update_attribute(:position, position)
|
|
||||||
position += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -0,0 +1,11 @@
|
|||||||
|
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…
Reference in new issue