socialforge/db/migrate/20161117060138_add_column_t...

16 lines
490 B
Ruby
Raw Normal View History

2016-11-17 17:04:00 +08:00
class AddColumnToExerciseUsers < ActiveRecord::Migration
def change
add_column :exercise_users, :commit_status, :integer, :default => 0
count = ExerciseUser.all.count / 30 + 2
transaction do
for i in 1 ... count do i
ExerciseUser.page(i).per(30).each do |eu|
if eu.exercise && eu.exercise.end_time < Time.now && eu.exercise.end_time > eu.created_at
eu.update_column('commit_status', 1)
end
end
end
end
end
end