From 97934ada10143640d4a3aa326cf1c9c8f245c65a Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Thu, 22 Jan 2026 01:29:21 -0500 Subject: [PATCH] add recipe stuff back (wip) --- sql/tables.sql | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/sql/tables.sql b/sql/tables.sql index c6f87a2..746605e 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -77,6 +77,19 @@ CREATE TABLE rda ( FOREIGN KEY (profile_id) REFERENCES profile (id) ON UPDATE CASCADE ON DELETE CASCADE ); +-- +-------------------------------- +-- Custom measures +-------------------------------- +CREATE TABLE measure ( + id integer PRIMARY KEY AUTOINCREMENT, + name text NOT NULL, + unit text NOT NULL, + quantity real NOT NULL, + quantity_text text NOT NULL, + grams real NOT NULL +); + -- TODO: do we want GUID / UUID values on any of these? -- Does that simplify potential CSV imports? Having a GUID / UUID column? -- @@ -102,7 +115,29 @@ CREATE TABLE cf_dat ( -- -------------------------------- --- Food (and recipe) logs +-- Recipes +-------------------------------- + +CREATE TABLE recipe ( + id integer PRIMARY KEY AUTOINCREMENT, + uuid text NOT NULL UNIQUE DEFAULT (hex(randomblob(24))), + name text NOT NULL, + instructions text, + created int DEFAULT (strftime ('%s', 'now')) +); + +CREATE TABLE recipe_ingredient ( + recipe_id int NOT NULL, + food_id int NOT NULL, + amount real NOT NULL, + msre_id int, + FOREIGN KEY (recipe_id) REFERENCES recipe (id) ON DELETE CASCADE, + FOREIGN KEY (msre_id) REFERENCES measure (id) ON UPDATE CASCADE ON DELETE SET NULL +); + +-- +-------------------------------- +-- Custom Logs: Food and Recipe -------------------------------- CREATE TABLE meal_name ( -- predefined, includes standard three, snacks, brunch, and 3 optional/extra meals -- 2.52.0