2,0.0.1,2021-05-21,bump version
3,0.0.2,2021-05-24,remove guids
4,0.0.3,2021-05-24,general cleanup
+5,0.0.4,2021-06-17,"add custom foods tables (custom_foods, cf_dat)"
);
-- TODO: enforce FK constraint across two DBs?
-
--
---------------------------------
-- Equations
FOREIGN KEY (bf_eq_id) REFERENCES bf_eqs (id) ON UPDATE CASCADE
);
---
---------------------------------
--- Food costs
---------------------------------
-
-CREATE TABLE food_costs (
- food_id integer NOT NULL,
- profile_id integer NOT NULL,
- cost real NOT NULL,
- PRIMARY KEY (food_id, profile_id),
- FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE ON DELETE CASCADE
-);
-
--
--------------------------------
-- Biometrics
FOREIGN KEY (recipe_id) REFERENCES recipes (id) ON UPDATE CASCADE
);
+--
+--------------------------------
+-- Custom foods
+--------------------------------
+
+CREATE TABLE custom_foods (
+ id integer PRIMARY KEY AUTOINCREMENT,
+ created int DEFAULT (strftime ('%s', 'now')),
+ updated int DEFAULT (strftime ('%s', 'now')),
+ tagname text NOT NULL UNIQUE,
+ name text NOT NULL UNIQUE
+);
+
+CREATE TABLE cf_dat (
+ cf_id int NOT NULL,
+ nutr_id int NOT NULL, -- no FK constraing on usda :[
+ nutr_val real NOT NULL,
+ notes text,
+ PRIMARY KEY (cf_id, nutr_id),
+ FOREIGN KEY (cf_id) REFERENCES custom_foods (id) ON UPDATE CASCADE
+);
+
--
--------------------------------
-- Food (and recipe) logs
);
-- TODO: CREATE TABLE custom_food_log ( ... );
-
--
--------------------------------
-- Custom RDAs
FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE
);
+--
+--------------------------------
+-- Food costs
+--------------------------------
+
+CREATE TABLE food_costs (
+ food_id integer NOT NULL,
+ profile_id integer NOT NULL,
+ cost real NOT NULL,
+ PRIMARY KEY (food_id, profile_id),
+ FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE ON DELETE CASCADE
+);
+