parent
b039fd5839
commit
bdd02b3dbd
@ -1,13 +1,5 @@
|
||||
class MigrateCourseTaskPosition < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :homework_commons, :position, :integer, :default => 0
|
||||
|
||||
Course.find_each do |course|
|
||||
puts course.id
|
||||
course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC,
|
||||
homework_commons.created_at DESC").reverse.each_with_index do |homework, index|
|
||||
homework.update_columns(position: index + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,11 @@
|
||||
class MigrateCourseShixunHomeworkPosition < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
Course.find_each do |course|
|
||||
puts course.id
|
||||
course.practice_homeworks.order("IF(ISNULL(homework_commons.publish_time),0,1), homework_commons.publish_time DESC,
|
||||
homework_commons.created_at DESC").reverse.each_with_index do |homework, index|
|
||||
homework.update_columns(position: index + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue