16 lines
490 B
Ruby
16 lines
490 B
Ruby
|
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
|