26 lines
1.0 KiB
PL/PgSQL
26 lines
1.0 KiB
PL/PgSQL
-- 008_diet_draft_meal_ingredients.sql
|
|
-- Scaled ingredient amounts per diet generator draft meal (portions applied at plan time).
|
|
-- Apply after script 006.
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS diet."DietGeneratorDraftMealIngredients" (
|
|
"Id" serial PRIMARY KEY,
|
|
"DraftMealId" int NOT NULL
|
|
REFERENCES diet."DietGeneratorDraftMeals"("Id") ON DELETE CASCADE,
|
|
"SourceIngredientId" int NULL
|
|
REFERENCES diet."Ingredients"("Id") ON DELETE SET NULL,
|
|
"Name" varchar(255) NOT NULL,
|
|
"AmountGrams" numeric(8,2) NULL,
|
|
"Unit" varchar(50) NULL,
|
|
"SortOrder" int NOT NULL DEFAULT 0
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "IX_DietGeneratorDraftMealIngredients_DraftMealId"
|
|
ON diet."DietGeneratorDraftMealIngredients" ("DraftMealId");
|
|
|
|
COMMENT ON TABLE diet."DietGeneratorDraftMealIngredients" IS
|
|
'Ingredient weights recalculated for the planned portion size of each draft meal.';
|
|
|
|
COMMIT;
|