Drop Readout.value decimal type in favor of float

This commit is contained in:
2026-04-25 16:39:54 +02:00
parent 97e7bfedf7
commit 3ac3a6f13c
5 changed files with 45 additions and 6 deletions

View File

@@ -3,8 +3,10 @@ class CreateReadouts < ActiveRecord::Migration[7.2]
create_table :readouts do |t|
t.references :user, null: false, foreign_key: true
t.references :quantity, null: false, foreign_key: true
# :category + :value + :unit as a separate table? (NumericValue, TextValue)
t.integer :category, null: false, default: 0
t.float :value, null: false, limit: Float::MANT_DIG
t.references :unit, foreign_key: true
t.decimal :value, null: false, precision: 30, scale: 15
#t.references :collector, foreign_key: true
#t.references :device, foreign_key: true

View File

@@ -28,8 +28,9 @@ ActiveRecord::Schema[7.2].define(version: 2025_01_21_230456) do
create_table "readouts", charset: "utf8mb4", collation: "utf8mb4_0900_as_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "quantity_id", null: false
t.integer "category", default: 0, null: false
t.float "value", limit: 53, null: false
t.bigint "unit_id"
t.decimal "value", precision: 30, scale: 15, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["quantity_id", "created_at"], name: "index_readouts_on_quantity_id_and_created_at", unique: true