class AddStatisticsToCourseModule < ActiveRecord::Migration[5.2]
  def change
    Course.includes(:course_modules).all.each do |course|
      CourseModule.create!(course_id: course.id, module_type: "statistics", hidden:0, module_name: "统计", position: course.course_modules.pluck(:position).max + 1)
    end
  end
end
