python:
- '3.6'
script:
-- python sql/__init__.py
+- make
+- make test
+- make clean
notifications:
slack:
secure: TCGuxW6k2tewO6JUm1BXy5NIEUh6QwjrkMLpdFCpZZwMz49UVO+i8fQKQWB9jTvGyq9Ya+NbW6jfxgJUYfFtmUmfXNCZ/LsKVu3hMPQ5/0yAIsGJayXxCPhIQYmEnA6BZnfnhoYt5R6U5NfLy8WyDwqS3b7uDUWfyxmllunWPNMY5IptrZmOXVSs5s7zqp1pqm9hjN28WiaEzOifsEygai2ZMsmxRUMhrzncRxyhOmw3APyMAvAsHgJw/nbdF1ux7lmvvbFQpOwzDkPdZXcbRdmfruvphaKfHT5TS48Aml81KdKDnk+VMoxD/U/wSW+nnOM0ZcWyYfFuh7/vndF2aMAP/PDq7iAESyFN3YIGXNhGTtHUPLRw7eWoO1CGJqvpkFl2oDj6GbzkO9zsoLg+qxoM7bX+P/ynAQ22M3e/VeSTuC1t8mrHnJZoDTMYrqQRQJDOT0QflZpMRlW5Du/SAkijGURaxGcpR5dt8KP19bd+Sm9k77509nQ576BNaHPn/rJOqdi3LYInMr0VTin/fghfTiPqy4hB3jzV7tl/0jTYAVsbAW73U2KFS95d7r9/BOQptYcCZgpGZu8iT2Q8iQVlUaWGDnGMzo1lWmsdwrEWpofBwC7jeYFDSwRfkdojQfVM4JBKpT5mbqHavRjMKCYWtDk7X6nQIWs32YaWbGQ=
--- /dev/null
+.DEFAULT_GOAL := build
+
+clean:
+ find sql/ -name __pycache__ | xargs rm -rf
+ rm -f sql/nt.sqlite
+
+build:
+ python sql/__init__.py
+
+test:
+ sqlite3 sql/nt.sqlite \
+ 'SELECT * FROM bf_eqs;' \
+ 'SELECT * FROM biometrics;' \
+ 'SELECT * FROM bmr_eqs;' \
+ 'SELECT * FROM meal_name;' \
+ 'SELECT * FROM version;' \
Building the database
#########################
-1. If you are committing database changes, add a line to :code:`data/version.csv` (e.g. :code:`id=4` is the latest in this case),
+1. If you are committing database changes, add a line to ``data/version.csv`` (e.g. ``id=4`` is the latest in this case),
+-----+----------+-------------+------------------+
| id | version | created | notes |
.. code-block:: bash
- python sql/__init__.py
+ make
-3. Verify the tables (again inside the SQL shell :code:`sqlite3 nutra.sqlite`),
+3. Verify the tables were populated and exist,
-.. code-block:: sql
+.. code-block:: bash
- .tables
- SELECT * FROM versions;
- .exit
+ make test
4. If everything looks good, commit and update submodules in the ``cli`` (python) and ``nt-android`` (java) repos.
Tables (Relational Design)
##########################
-See :code:`sql/tables.sql` for details.
+Note: functions are kept in ``sql/functions.sql``.
+
+See ``sql/tables.sql`` for details.
-This is frequently updated, see :code:`docs/` for more info.
+This is frequently updated, see ``docs/`` for more info.
.. image:: docs/nt.svg
-id,profile_id,created,updated,date,tags,notes
-1,1,1601977400,1601977400,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,
-2,2,1601977400,1601977400,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,
-3,1,1601977400,1601977400,Sun 28 Jun 2020 02:38:20 PM EDT,,
-4,2,1601977400,1601977400,Sun 28 Jun 2020 02:38:20 PM EDT,,
-5,1,1601977400,1601977400,Sun 28 Jun 2020 10:05:26 PM EDT,exercise,
-6,2,1601977400,1601977400,Thu 02 Jul 2020 12:12:54 PM EDT,,doctor's office
-7,1,1601977400,1601977400,Sat 04 Jul 2020 03:50:13 PM EDT,,
-8,2,1601977400,1601977400,Sat 04 Jul 2020 03:54:27 PM EDT,,
-9,2,1601977400,1601977400,Sun 05 Jul 2020 01:30:44 PM EDT,no THC,
-10,1,1601977400,1601977400,Mon 06 Jul 2020 06:54:49 AM EDT,,
-11,2,1601977400,1601977400,Sun 12 Jul 2020 12:29:11 PM EDT,THC,
-12,2,1601977400,1601977400,Sun 12 Jul 2020 02:44:25 PM EDT,THC,
-13,1,1601977400,1601977400,Sun 12 Jul 2020 02:44:25 PM EDT,THC,
-14,3,1601977400,1601977400,Mon 13 Jul 2020 03:30:46 PM EDT,,
-15,2,1601977400,1601977400,Fri 17 Jul 2020 02:02:12 PM EDT,,
-16,2,1601977400,1601977400,Fri 17 Jul 2020 03:14:37 PM EDT,THC,
-17,1,1601977400,1601977400,Fri 17 Jul 2020 03:14:37 PM EDT,,
-18,2,1601977400,1601977400,Sat 08 Aug 2020 01:53:25 PM EDT,,
-19,3,1601977400,1601977400,Thu 27 Aug 2020 12:44:37 PM EDT,,
-20,2,1601977400,1601977400,Fri 28 Aug 2020 03:40:56 PM EDT,,
-21,1,1601977400,1601977400,Fri 28 Aug 2020 03:40:56 PM EDT,THC,1st dabs/2 weeks
-22,2,1601977400,1601977400,Sun 06 Sep 2020 11:49:47 AM EDT,,
-23,1,1601977400,1601977400,Sun 06 Sep 2020 11:53:21 AM EDT,,
-24,2,1601977400,1601977400,Sat 12 Sep 2020 12:15:53 PM EDT,,
-25,2,1601977400,1601977400,Sun 06 Sep 2020,,
-26,1,1601977400,1601977400,Sun 06 Sep 2020,,
-27,2,1601977400,1601977400,Sat 12 Sep 2020,,
-28,1,1601977400,1601977400,Sat 12 Sep 2020,,
-29,1,1601977400,1601977400,Sun 13 Sep 2020,,
-30,1,1601977400,1601977400,Mon 14 Sep 2020,,
-31,1,1601977400,1601977400,Fri 18 Sep 2020 09:04:38 PM EDT,exercise,
-32,2,1601977400,1601977400,Thu 24 Sep 2020 05:05:51 PM EDT,illness,
-33,1,1601977400,1601977400,Thu 24 Sep 2020 05:05:51 PM EDT,,
-34,2,1601977400,1601977400,Thu 24 Sep 2020,,
-35,1,1601977400,1601977400,Fri 25 Sep 2020,gym scale,
-36,2,1601977400,1601977400,Sat 26 Sep 2020,,
-37,2,1601977400,1601977400,Sat 26 Sep 2020 11:54:17 AM EDT,,
-38,1,1601977400,1601977400,Tue 29 Sep 2020 03:40:37 PM EDT,nude,
+id,profile_id,date,tags,notes,created
+1,1,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,,1601977400
+2,2,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,,1601977400
+3,1,Sun 28 Jun 2020 02:38:20 PM EDT,,,1601977400
+4,2,Sun 28 Jun 2020 02:38:20 PM EDT,,,1601977400
+5,1,Sun 28 Jun 2020 10:05:26 PM EDT,exercise,,1601977400
+6,2,Thu 02 Jul 2020 12:12:54 PM EDT,,doctor's office,1601977400
+7,1,Sat 04 Jul 2020 03:50:13 PM EDT,,,1601977400
+8,2,Sat 04 Jul 2020 03:54:27 PM EDT,,,1601977400
+9,2,Sun 05 Jul 2020 01:30:44 PM EDT,,,1601977400
+10,1,Mon 06 Jul 2020 06:54:49 AM EDT,,,1601977400
+11,2,Sun 12 Jul 2020 12:29:11 PM EDT,,,1601977400
+12,2,Sun 12 Jul 2020 02:44:25 PM EDT,,,1601977400
+13,1,Sun 12 Jul 2020 02:44:25 PM EDT,,,1601977400
+14,3,Mon 13 Jul 2020 03:30:46 PM EDT,,,1601977400
+15,2,Fri 17 Jul 2020 02:02:12 PM EDT,,,1601977400
+16,2,Fri 17 Jul 2020 03:14:37 PM EDT,,,1601977400
+17,1,Fri 17 Jul 2020 03:14:37 PM EDT,,,1601977400
+18,2,Sat 08 Aug 2020 01:53:25 PM EDT,,,1601977400
+19,3,Thu 27 Aug 2020 12:44:37 PM EDT,,,1601977400
+20,2,Fri 28 Aug 2020 03:40:56 PM EDT,,,1601977400
+21,1,Fri 28 Aug 2020 03:40:56 PM EDT,,,1601977400
+22,2,Sun 06 Sep 2020 11:49:47 AM EDT,,,1601977400
+23,1,Sun 06 Sep 2020 11:53:21 AM EDT,,,1601977400
+24,2,Sat 12 Sep 2020 12:15:53 PM EDT,,,1601977400
+25,2,Sun 06 Sep 2020,,,1601977400
+26,1,Sun 06 Sep 2020,,,1601977400
+27,2,Sat 12 Sep 2020,,,1601977400
+28,1,Sat 12 Sep 2020,,,1601977400
+29,1,Sun 13 Sep 2020,,,1601977400
+30,1,Mon 14 Sep 2020,,,1601977400
+31,1,Fri 18 Sep 2020 09:04:38 PM EDT,exercise,,1601977400
+32,2,Thu 24 Sep 2020 05:05:51 PM EDT,illness,,1601977400
+33,1,Thu 24 Sep 2020 05:05:51 PM EDT,,,1601977400
+34,2,Thu 24 Sep 2020,,,1601977400
+35,1,Fri 25 Sep 2020,gym scale,,1601977400
+36,2,Sat 26 Sep 2020,,,1601977400
+37,2,Sat 26 Sep 2020 11:54:17 AM EDT,,,1601977400
+38,1,Tue 29 Sep 2020 03:40:37 PM EDT,nude,,1601977400
-id,created,updated,name,unit
-1,1580336088,1580336088,Height,cm
-2,1580336088,1580336088,Weight,kg
-3,1580336088,1580336088,Wrist,cm
-4,1580336088,1580336088,Ankle,cm
-5,1580336088,1580336088,Chest,cm
-6,1580336088,1580336088,Upper Arm,cm
-7,1580336088,1580336088,Thigh,cm
-8,1580336088,1580336088,Calf,cm
-9,1580336088,1580336088,Shoulders,cm
-10,1580336088,1580336088,Waist,cm
-11,1580336088,1580336088,Hips,cm
-12,1580336088,1580336088,Neck,cm
-13,1580336088,1580336088,Forearm,cm
-14,1580336088,1580336088,Pectoral,mm
-15,1580336088,1580336088,Abdominal,mm
-16,1580336088,1580336088,Quadricep,mm
-17,1580336088,1580336088,Midaxillary,mm
-18,1580336088,1580336088,Subscapular,mm
-19,1580336088,1580336088,Tricep,mm
-20,1580336088,1580336088,Suprailiac,mm
-21,1580336088,1580336088,Body Fat (Custom),
-22,1580336088,1580336088,Pulse,bpm
-23,1580336088,1580336088,Systolic Blood Pressure,mmHg
-24,1580336088,1580336088,Diastolic Blood Pressure,mmHg
-25,1580336088,1580336088,Blood Glucose,mg/dL
-26,1580336088,1580336088,Total Cholesterol,mg/dL
-27,1580336088,1580336088,LDL Cholesterol,mg/dL
-28,1580336088,1580336088,HDL Cholesterol,mg/dL
-29,1580336088,1580336088,Triglycerides,mg/dL
+id,name,unit,created
+1,Height,cm,1580336088
+2,Weight,kg,1580336088
+3,Wrist,cm,1580336088
+4,Ankle,cm,1580336088
+5,Chest,cm,1580336088
+6,Upper Arm,cm,1580336088
+7,Thigh,cm,1580336088
+8,Calf,cm,1580336088
+9,Shoulders,cm,1580336088
+10,Waist,cm,1580336088
+11,Hips,cm,1580336088
+12,Neck,cm,1580336088
+13,Forearm,cm,1580336088
+14,Pectoral,mm,1580336088
+15,Abdominal,mm,1580336088
+16,Quadricep,mm,1580336088
+17,Midaxillary,mm,1580336088
+18,Subscapular,mm,1580336088
+19,Tricep,mm,1580336088
+20,Suprailiac,mm,1580336088
+21,Body Fat (Custom),,1580336088
+22,Pulse,bpm,1580336088
+23,Systolic Blood Pressure,mmHg,1580336088
+24,Diastolic Blood Pressure,mmHg,1580336088
+25,Blood Glucose,mg/dL,1580336088
+26,Total Cholesterol,mg/dL,1580336088
+27,LDL Cholesterol,mg/dL,1580336088
+28,HDL Cholesterol,mg/dL,1580336088
+29,Triglycerides,mg/dL,1580336088
-id,profile_id,created,updated,date,meal_id,food_id,msre_id,amt
-1,1,1601977400,1601977400,2020-09-20,1,13047,-1,100
-2,1,1601977400,1601977400,2020-09-20,1,1270,-1,28
-3,1,1601977400,1601977400,2020-09-20,1,9038,-1,55
-4,1,1601977400,1601977400,2020-09-20,1,11251,-1,20
-5,1,1601977400,1601977400,2020-09-20,1,11529,-1,35
-6,1,1601977400,1601977400,2020-09-20,1,11282,-1,15
-7,1,1601977400,1601977400,2020-09-20,1,11828,-1,210
-8,1,1601977400,1601977400,2020-09-20,1,28313,-1,40
-9,1,1601977400,1601977400,2020-09-20,1,9112,-1,100
-10,1,1601977400,1601977400,2020-09-20,2,20137,-1,140
-11,1,1601977400,1601977400,2020-09-20,2,5062,-1,100
-12,1,1601977400,1601977400,2020-09-20,2,12136,-1,45
-13,1,1601977400,1601977400,2020-09-20,2,11821,-1,50
-14,1,1601977400,1601977400,2020-09-20,2,44005,-1,15
-15,1,1601977400,1601977400,2020-09-20,3,20545,-1,150
-16,1,1601977400,1601977400,2020-09-20,3,16146,-1,85
-17,1,1601977400,1601977400,2020-09-20,3,1270,-1,40
-18,1,1601977400,1601977400,2020-09-20,3,9037,-1,60
-19,1,1601977400,1601977400,2020-09-20,3,15076,-1,100
-20,1,1601977400,1601977400,2020-09-20,3,11090,-1,60
-21,1,1601977400,1601977400,2020-09-20,3,11938,-1,35
-22,1,1601977400,1601977400,2020-09-20,3,11282,-1,25
+id,profile_id,date,meal_id,food_id,msre_id,amt,created
+1,1,2020-09-20,1,13047,-1,100,1601977400
+2,1,2020-09-20,1,1270,-1,28,1601977400
+3,1,2020-09-20,1,9038,-1,55,1601977400
+4,1,2020-09-20,1,11251,-1,20,1601977400
+5,1,2020-09-20,1,11529,-1,35,1601977400
+6,1,2020-09-20,1,11282,-1,15,1601977400
+7,1,2020-09-20,1,11828,-1,210,1601977400
+8,1,2020-09-20,1,28313,-1,40,1601977400
+9,1,2020-09-20,1,9112,-1,100,1601977400
+10,1,2020-09-20,2,20137,-1,140,1601977400
+11,1,2020-09-20,2,5062,-1,100,1601977400
+12,1,2020-09-20,2,12136,-1,45,1601977400
+13,1,2020-09-20,2,11821,-1,50,1601977400
+14,1,2020-09-20,2,44005,-1,15,1601977400
+15,1,2020-09-20,3,20545,-1,150,1601977400
+16,1,2020-09-20,3,16146,-1,85,1601977400
+17,1,2020-09-20,3,1270,-1,40,1601977400
+18,1,2020-09-20,3,9037,-1,60,1601977400
+19,1,2020-09-20,3,15076,-1,100,1601977400
+20,1,2020-09-20,3,11090,-1,60,1601977400
+21,1,2020-09-20,3,11938,-1,35,1601977400
+22,1,2020-09-20,3,11282,-1,25,1601977400
-id,name,created,updated,eula,gender,dob,act_lvl,goal_wt,goal_bf,bmr_id,bf_id
-1,Shane,1601067725,1601067725,,MALE,1993-01-01,2,78,0.12,1,1
-2,Mark,1601068574,1601068574,,MALE,1957-01-01,2,72,0.14,1,1
-3,Rocky,1601068718,1601068718,,DOG,2007-08-01,2,7.3,,1,1
+id,name,eula,gender,dob,act_lvl,goal_wt,goal_bf,bmr_id,bf_id,created
+1,Shane,,MALE,1993-01-01,2,78,0.12,1,1,1601067725
+2,Mark,,MALE,1957-01-01,2,72,0.14,1,1,1601068574
+3,Rocky,,DOG,2007-08-01,2,7.3,,1,1,1601068718
-recipe_id,food_id,grams,notes
-1,20045,180,white rice
-1,16042,25,pinto beans
-1,11282,45,onions
-1,11260,45,mushrooms
-1,11821,35,bell peppers
-1,11233,25,kale
-1,23293,85,"beef (grass-fed, 85/15)"
-1,11529,40,tomatoes
-1,9037,40,avocados
-1,1009,20,cheese (cheddar)
-2,18351,55,roll (mixed-grain)
-2,23293,85,"beef (grass-fed, 85/15)"
-2,1009,20,cheddar cheese
-2,11251,25,lettuce (romaine)
-2,11529,40,tomatoes
-2,11282,20,onions
-2,9037,40,avocados
-3,11355,300,potatoes (red)
-3,4053,30,olive oil
-3,11297,30,parsley (fresh)
-4,20011,60,flour (buckwheat)
-4,20140,30,flour (spelt)
-4,20080,30,flour (whole wheat)
-4,1123,56,egg
-4,1079,244,milk (2%)
-4,19911,25,syrup (maple)
-4,16122,20,protein (soy or whey)
-4,2047,1.5,salt
-4,18372,1.5,baking soda
-4,18370,0.75,baking powder
-5,12061,50,almonds
-5,12220,30,flaxseed
-5,12012,20,hemp (seed/protein)
-5,16122,28,protein (soy or whey)
-5,9050,50,blueberries
-5,9040,80,bananas
-5,9176,40,mangos
-5,1289,140,kefir
+recipe_id,food_id,grams,notes,created
+1,20045,180,white rice,
+1,16042,25,pinto beans,
+1,11282,45,onions,
+1,11260,45,mushrooms,
+1,11821,35,bell peppers,
+1,11233,25,kale,
+1,23293,85,"beef (grass-fed, 85/15)",
+1,11529,40,tomatoes,
+1,9037,40,avocados,
+1,1009,20,cheese (cheddar),
+2,18351,55,roll (mixed-grain),
+2,23293,85,"beef (grass-fed, 85/15)",
+2,1009,20,cheddar cheese,
+2,11251,25,lettuce (romaine),
+2,11529,40,tomatoes,
+2,11282,20,onions,
+2,9037,40,avocados,
+3,11355,300,potatoes (red),
+3,4053,30,olive oil,
+3,11297,30,parsley (fresh),
+4,20011,60,flour (buckwheat),
+4,20140,30,flour (spelt),
+4,20080,30,flour (whole wheat),
+4,1123,56,egg,
+4,1079,244,milk (2%),
+4,19911,25,syrup (maple),
+4,16122,20,protein (soy or whey),
+4,2047,1.5,salt,
+4,18372,1.5,baking soda,
+4,18370,0.75,baking powder,
+5,12061,50,almonds,
+5,12220,30,flaxseed,
+5,12012,20,hemp (seed/protein),
+5,16122,28,protein (soy or whey),
+5,9050,50,blueberries,
+5,9040,80,bananas,
+5,9176,40,mangos,
+5,1289,140,kefir,
-id,profile_id,created,updated,date,meal_id,recipe_id,grams
-1,1,1601977400,1601977400,2020-09-26,1,1,315
+id,profile_id,date,meal_id,recipe_id,grams,created
+1,1,2020-09-26,1,1,315,1601977400
-id,created,updated,tagname,name
-1,1601235568,1601235568,burrito-bowl,Burrito bowl (Everyday)
-2,1601235568,1601235568,burger,"Burger (Grass fed, Beef)"
-3,1601235568,1601235568,potato-wedges,Baked potato wedges
-4,1601235568,1601235568,buckwheat-pancake,Buckwheat pancake (w/ syrup)
-5,1601235568,1601235568,blueberry-hemp-smoothie,Blueberry-hemp Smoothie
+id,tagname,name,created
+1,burrito-bowl,Burrito bowl (Everyday),1601235568
+2,burger,"Burger (Grass fed, Beef)",1601235568
+3,potato-wedges,Baked potato wedges,1601235568
+4,buckwheat-pancake,Buckwheat pancake (w/ syrup),1601235568
+5,blueberry-hemp-smoothie,Blueberry-hemp Smoothie,1601235568
CREATE TABLE profiles (
id integer PRIMARY KEY AUTOINCREMENT,
name text NOT NULL UNIQUE,
- created int DEFAULT (strftime ('%s', 'now')),
- updated int DEFAULT (strftime ('%s', 'now')),
eula int DEFAULT 0,
gender text,
dob date,
goal_bf real,
bmr_eq_id int DEFAULT 1,
bf_eq_id int DEFAULT 1,
+ created int DEFAULT (strftime ('%s', 'now')),
+ -- last_active timestamp?
FOREIGN KEY (bmr_eq_id) REFERENCES bmr_eqs (id) ON UPDATE CASCADE,
FOREIGN KEY (bf_eq_id) REFERENCES bf_eqs (id) ON UPDATE CASCADE
);
CREATE TABLE biometrics (
-- TODO: support custom biometrics and sync?
id integer PRIMARY KEY AUTOINCREMENT,
- created int DEFAULT (strftime ('%s', 'now')),
- updated int DEFAULT (strftime ('%s', 'now')),
name text NOT NULL UNIQUE,
- unit text
+ unit text,
+ created int DEFAULT (strftime ('%s', 'now'))
);
CREATE TABLE biometric_log (
id integer PRIMARY KEY AUTOINCREMENT,
profile_id int NOT NULL,
- created int DEFAULT (strftime ('%s', 'now')),
- updated int DEFAULT (strftime ('%s', 'now')),
date int DEFAULT (strftime ('%s', 'now')),
tags text,
notes text,
+ created int DEFAULT (strftime ('%s', 'now')),
FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE
);
CREATE TABLE recipes (
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
+ name text NOT NULL UNIQUE,
+ created int DEFAULT (strftime ('%s', 'now'))
);
CREATE TABLE recipe_dat (
food_id int NOT NULL,
grams real NOT NULL,
notes text,
+ created int DEFAULT (strftime ('%s', 'now')),
PRIMARY KEY (recipe_id, food_id),
FOREIGN KEY (recipe_id) REFERENCES recipes (id) ON UPDATE CASCADE
);
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
+ name text NOT NULL UNIQUE,
+ created int DEFAULT (strftime ('%s', 'now'))
);
CREATE TABLE cf_dat (
nutr_id int NOT NULL, -- no FK constraining on usda :[
nutr_val real NOT NULL,
notes text,
+ created int DEFAULT (strftime ('%s', 'now')),
PRIMARY KEY (cf_id, nutr_id),
FOREIGN KEY (cf_id) REFERENCES custom_foods (id) ON UPDATE CASCADE
);
CREATE TABLE food_log (
id integer PRIMARY KEY AUTOINCREMENT,
profile_id int NOT NULL,
- created int DEFAULT (strftime ('%s', 'now')),
- updated int DEFAULT (strftime ('%s', 'now')),
date int DEFAULT (strftime ('%s', 'now')),
meal_id int NOT NULL,
food_id int NOT NULL,
msre_id int NOT NULL,
amt real NOT NULL,
+ created int DEFAULT (strftime ('%s', 'now')),
FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE,
FOREIGN KEY (meal_id) REFERENCES meal_name (id) ON UPDATE CASCADE
);
CREATE TABLE recipe_log (
id integer PRIMARY KEY AUTOINCREMENT,
profile_id int NOT NULL,
- created int DEFAULT (strftime ('%s', 'now')),
- updated int DEFAULT (strftime ('%s', 'now')),
date int DEFAULT (strftime ('%s', 'now')),
meal_id int NOT NULL,
recipe_id int NOT NULL,
grams real NOT NULL,
+ created int DEFAULT (strftime ('%s', 'now')),
FOREIGN KEY (profile_id) REFERENCES profiles (id) ON UPDATE CASCADE,
FOREIGN KEY (meal_id) REFERENCES meal_name (id) ON UPDATE CASCADE,
FOREIGN KEY (recipe_id) REFERENCES recipes (id) ON UPDATE CASCADE
-- Food costs
--------------------------------
+-- Case for no FK? e.g. points to food OR custom_food?
+-- Leave edge cases potentially dangling (should never happen)
+-- Does this simplify imports with a potential `guid` column?
CREATE TABLE food_costs (
food_id integer NOT NULL,
profile_id integer NOT NULL,