Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions db/migrate/20260629000001_fix_probe_result_duration_precision.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class FixProbeResultDurationPrecision < ActiveRecord::Migration[8.0]
# `t.decimal :duration` with no precision becomes DECIMAL(10,0) on MySQL,
# which rounds every duration to a whole second on write. Probe durations
# are sub-second floats from a monotonic clock, so they were all stored as
# 0. SQLite preserved the fractional value, which is why this only surfaced
# after the MySQL migration. Give the column microsecond precision.
def up
change_column :upright_probe_results, :duration, :decimal, precision: 10, scale: 6
end

def down
change_column :upright_probe_results, :duration, :decimal
end
end
4 changes: 2 additions & 2 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.1].define(version: 2025_01_14_000001) do
ActiveRecord::Schema[8.1].define(version: 2026_06_29_000001) do
create_table "active_storage_attachments", force: :cascade do |t|
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
Expand Down Expand Up @@ -41,7 +41,7 @@

create_table "upright_probe_results", force: :cascade do |t|
t.datetime "created_at", null: false
t.decimal "duration"
t.decimal "duration", precision: 10, scale: 6
t.string "probe_name"
t.string "probe_service"
t.string "probe_target"
Expand Down