Files

9 lines
1022 B
Markdown
Raw Permalink Normal View History

# Units are data: built-in ones plus the cook's own
Units used to be a fixed list in code. The cook wants to add their own (e.g. "Würfel"), choose which ones the picker offers directly and in what order, so units now live in a `units` table (schema version 2). The 27 built-in units are seeded from the `Unit` enum and keep their keys and localized names; the cook's own units get an `own-<uuid>` key and a stored name. Ingredient Lines keep storing just the unit's key, so existing recipes and version 1 Recipe Bundles stay valid.
## Consequences
- Recipe Bundles are version 2: they carry the cook's own units (`units`), and an import creates the ones that are missing. Version 1 bundles (the Excel converter's) still import.
- Built-in units cannot be renamed or deleted: their keys are shared by every bundle and by the Excel converter.
- Deleting an own unit rewrites the Ingredient Lines that used it ("2 Würfel Brühe": the name moves into the ingredient), so no recipe points at a unit that no longer exists.