socialforge/db/migrate/20151231012634_add_last_ter...

18 lines
432 B
Ruby

class AddLastTermToCourse < ActiveRecord::Migration
def change
add_column :courses, :end_time, :integer
add_column :courses, :end_term, :string
count = Course.all.count / 30 + 2
transaction do
for i in 1 ... count do
Course.page(i).per(30).each do |course|
course.end_time = course.time
course.end_term = course.term
course.save
end
end
end
end
end