NutritionLogs table
The NutritionLogs table in the FitStack - V2 schema has 33 columns, keyed by Id, with 5 foreign keys to Users, Products, Meals, MealPlans and 1 more. 1 column in ScheduledItems references it.
THE ONLY TABLE IN THE `nutrition` SCHEMA. Everything else nutrition-related is in `public`. The split buys nothing and costs a schema qualifier on every query — either move it to `public` or move MealLogs and Meals in with it.
Columns (33)
| Column | Type | Constraints | Description |
|---|---|---|---|
| Id | uuid | primary key, not null | |
| UserId | character varying(450) | not null, references Users.Id | CASCADE. |
| ProductId | uuid | not null, references Products.Id | RESTRICT. Required. |
| MealId | uuid | references Meals.Id | SET NULL. |
| MealPlanId | uuid | references MealPlans.Id | SET NULL. |
| RecipeId | uuid | references Recipes.Id | SET NULL. |
| StartTime | timestamp with time zone | not null | The C# `ConsumedAt` is a computed alias of this. |
| EndTime | timestamp with time zone | ||
| SourcePlatform | integer | not null | |
| Source | integer | not null | |
| RecordingMethod | integer | not null | |
| SourceIdentifier | character varying(200) | ||
| MealType | character varying(50) | not null | Stored as TEXT here, unlike MealLogs.MealType which is an integer. Same enum, two encodings. |
| ServingsConsumed | numeric(10,4) | not null | |
| Confidence | numeric(5,2) | ||
| TotalCalories | numeric(10,2) | ||
| TotalProtein | numeric(10,2) | ||
| TotalCarbohydrates | numeric(10,2) | ||
| TotalFat | numeric(10,2) | ||
| TotalFiber | numeric(10,2) | ||
| TotalSugar | numeric(10,2) | ||
| TotalSodium | numeric(10,2) | ||
| TotalCholesterol | numeric(10,2) | ||
| TotalSaturatedFat | numeric(10,2) | ||
| IsSnack | boolean | not null | |
| IsBeverage | boolean | not null | |
| TimeOfDay | interval | ||
| Metadata | text | ||
| Notes | character varying(1000) | ||
| CreatedAt | timestamp with time zone | not null | |
| ModifiedAt | timestamp with time zone | ||
| IsDeleted | boolean | not null | |
| DeletedAt | timestamp with time zone |
Indexes (6)
(UserId)(IX_NutritionLogs_UserId)(ProductId)(IX_NutritionLogs_ProductId)(MealId)(IX_NutritionLogs_MealId)(MealPlanId)(IX_NutritionLogs_MealPlanId)(RecipeId)(IX_NutritionLogs_RecipeId)(MealType)(IX_NutritionLogs_MealType)
Relationships
NutritionLogs.UserIdreferencesUsers.IdNutritionLogs.ProductIdreferencesProducts.IdNutritionLogs.MealIdreferencesMeals.IdNutritionLogs.MealPlanIdreferencesMealPlans.IdNutritionLogs.RecipeIdreferencesRecipes.IdScheduledItems.NutritionLogIdreferencesNutritionLogs