db/migrate/20111202135732_fill_session_start_and_end_time.rb
class FillSessionStartAndEndTime < ActiveRecord::Migration[4.2]
def up
execute 'UPDATE sessions s SET start_time=(SELECT MIN(time) FROM measurements WHERE session_id=s.id), end_time=(SELECT MAX(time) FROM measurements WHERE session_id=s.id)'
end
def down; end
end