Persist Quantity :depth instead of computing it on the fly

This commit is contained in:
2025-01-16 17:14:52 +01:00
parent 30686dd1fc
commit c908063212
3 changed files with 45 additions and 15 deletions

View File

@@ -5,6 +5,7 @@ class CreateQuantities < ActiveRecord::Migration[7.2]
t.string :name, null: false, limit: 31
t.text :description
t.references :parent, foreign_key: {to_table: :quantities}
t.integer :depth, null: false, default: 0
t.timestamps null: false
end

View File

@@ -16,6 +16,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_01_04_194343) do
t.string "name", limit: 31, null: false
t.text "description"
t.bigint "parent_id"
t.integer "depth", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["parent_id"], name: "index_quantities_on_parent_id"