20 lines
496 B
Ruby
20 lines
496 B
Ruby
class UpdateCourseName < ActiveRecord::Migration
|
|
def up
|
|
count = Course.all.count / 30 + 2
|
|
transaction do
|
|
for i in 1 ... count do i
|
|
Course.page(i).per(30).each do |course|
|
|
if course.syllabus && !course.syllabus.title.nil?
|
|
if course.name.index(course.syllabus.title) != 0
|
|
course.update_column("name", course.syllabus.title+course.name)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def down
|
|
end
|
|
end
|