batchCooking/apps/api/prisma/migrations/20260819192851_recipe_portions/migration.sql
Nicolas 0cb1dccd92 feat(recipes): ajouter le nombre de portions couvertes par une recette
Ajoute Recipe.portions (combien de portions la recette produit telle
qu'écrite) — formulaire de création/édition, fiche détail, migration
Prisma (backfill à 4, même pattern que planning_item.portions).

Le sélecteur de recette du planning pré-remplit désormais son propre
champ "portions" depuis cette valeur au lieu de toujours démarrer à 1
(RecipeSummaryView.portions), tout en gardant PlanningItem.portions
indépendant (une recette peut être mise à l'échelle pour un créneau).

Couverture : tests API (création/édition/validation), scénarios
cypress (formulaire + préchargement en édition).
2026-08-19 21:44:01 +02:00

10 lines
700 B
SQL

-- Adds how many portions a recipe yields as written (`Recipe.portions`) —
-- the planning recipe picker now pre-fills its own "how many portions?"
-- step from this (see `RecipePickerDialog`), closing the gap noted on
-- `PlanningItem.portions`'s own migration ("no such default exists ... on
-- `Recipe` either"). Backfills any pre-existing row with 4 portions (a
-- reasonable default recipe yield) via a transient DEFAULT, then drops it
-- so it isn't implicitly reused for new inserts going forward — same
-- pattern as `20260819064721_planning_item_portions`.
ALTER TABLE "recipe" ADD COLUMN "portions" INTEGER NOT NULL DEFAULT 4;
ALTER TABLE "recipe" ALTER COLUMN "portions" DROP DEFAULT;