From: Shane Jaroch Date: Thu, 22 Jan 2026 06:29:21 +0000 (-0500) Subject: add recipe stuff back (wip) X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=97934ada10143640d4a3aa326cf1c9c8f245c65a;p=nutratech%2Fnt-sqlite.git add recipe stuff back (wip) --- 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