From 8c355e11b4ec9ac3ade47f55a6a4261e3fce1f1b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 16 Aug 2026 12:21:58 +0200 Subject: [PATCH] Add COMMENT ON for every table and column in the init migration Descriptions pulled from specs/batch-cooking-modele.md's per-table field tables. The two tables not in the original spec (join tables recipe_ingredient, user_profile_allergy) get a comment explaining why they exist. Amends the still-unmerged init migration directly rather than adding a follow-up migration, since it hasn't been applied anywhere but this local dev database. Verified: `prisma migrate reset --force` reapplies cleanly, and a query against pg_description confirms every column of every project table has a comment (only Prisma's own internal _prisma_migrations table is uncommented, out of scope). --- .../20260816100611_init/migration.sql | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/apps/api/prisma/migrations/20260816100611_init/migration.sql b/apps/api/prisma/migrations/20260816100611_init/migration.sql index 41febff..2d429cd 100644 --- a/apps/api/prisma/migrations/20260816100611_init/migration.sql +++ b/apps/api/prisma/migrations/20260816100611_init/migration.sql @@ -6,6 +6,10 @@ CREATE TABLE "house" ( CONSTRAINT "house_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "house" IS 'Foyer regroupant un ou plusieurs profils utilisateurs et leurs plannings.'; +COMMENT ON COLUMN "house"."id" IS 'Identifiant'; +COMMENT ON COLUMN "house"."name" IS 'Nom du foyer'; + -- CreateTable CREATE TABLE "diet" ( "id" SERIAL NOT NULL, @@ -14,6 +18,10 @@ CREATE TABLE "diet" ( CONSTRAINT "diet_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "diet" IS 'Régime alimentaire pouvant être suivi par un profil utilisateur.'; +COMMENT ON COLUMN "diet"."id" IS 'Identifiant'; +COMMENT ON COLUMN "diet"."name" IS 'Nom du régime alimentaire'; + -- CreateTable CREATE TABLE "category" ( "id" SERIAL NOT NULL, @@ -22,6 +30,10 @@ CREATE TABLE "category" ( CONSTRAINT "category_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "category" IS 'Table d''énumération, destinée à grandir au fil du projet (portera notamment les nuances liées aux allergies).'; +COMMENT ON COLUMN "category"."id" IS 'Identifiant'; +COMMENT ON COLUMN "category"."name" IS 'Nom de la catégorie'; + -- CreateTable CREATE TABLE "allergy" ( "id" SERIAL NOT NULL, @@ -30,6 +42,10 @@ CREATE TABLE "allergy" ( CONSTRAINT "allergy_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "allergy" IS 'Allergie, rattachée à une catégorie. Associée à user_profiles en many-to-many (table de jointure simple, sans champ additionnel).'; +COMMENT ON COLUMN "allergy"."id" IS 'Identifiant'; +COMMENT ON COLUMN "allergy"."cat_id" IS 'FK → category'; + -- CreateTable CREATE TABLE "user_profiles" ( "id" SERIAL NOT NULL, @@ -42,6 +58,14 @@ CREATE TABLE "user_profiles" ( CONSTRAINT "user_profiles_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "user_profiles" IS 'Profil utilisateur, rattaché à un foyer et éventuellement à un régime alimentaire.'; +COMMENT ON COLUMN "user_profiles"."id" IS 'Identifiant'; +COMMENT ON COLUMN "user_profiles"."first_name" IS 'Prénom'; +COMMENT ON COLUMN "user_profiles"."last_name" IS 'Nom'; +COMMENT ON COLUMN "user_profiles"."email" IS 'Email'; +COMMENT ON COLUMN "user_profiles"."house_id" IS 'FK → house'; +COMMENT ON COLUMN "user_profiles"."diet_id" IS 'FK → diet'; + -- CreateTable CREATE TABLE "user_profile_allergy" ( "user_profile_id" INTEGER NOT NULL, @@ -50,6 +74,10 @@ CREATE TABLE "user_profile_allergy" ( CONSTRAINT "user_profile_allergy_pkey" PRIMARY KEY ("user_profile_id","allergy_id") ); +COMMENT ON TABLE "user_profile_allergy" IS 'Table de jointure simple pour l''association many-to-many user_profiles ↔ allergy (sans champ additionnel, non présente telle quelle dans la spec d''origine).'; +COMMENT ON COLUMN "user_profile_allergy"."user_profile_id" IS 'FK → user_profiles'; +COMMENT ON COLUMN "user_profile_allergy"."allergy_id" IS 'FK → allergy'; + -- CreateTable CREATE TABLE "planning" ( "id" SERIAL NOT NULL, @@ -60,6 +88,12 @@ CREATE TABLE "planning" ( CONSTRAINT "planning_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "planning" IS 'Planning de repas d''un foyer sur une période donnée.'; +COMMENT ON COLUMN "planning"."id" IS 'Identifiant'; +COMMENT ON COLUMN "planning"."start_date" IS 'Date de début'; +COMMENT ON COLUMN "planning"."finish_date" IS 'Date de fin'; +COMMENT ON COLUMN "planning"."house_id" IS 'FK → house'; + -- CreateTable CREATE TABLE "planning_item" ( "id" SERIAL NOT NULL, @@ -71,6 +105,13 @@ CREATE TABLE "planning_item" ( CONSTRAINT "planning_item_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "planning_item" IS 'Entrée d''un planning : une recette assignée à un jour et un repas donnés.'; +COMMENT ON COLUMN "planning_item"."id" IS 'Identifiant'; +COMMENT ON COLUMN "planning_item"."planning_id" IS 'FK → planning'; +COMMENT ON COLUMN "planning_item"."week_day" IS 'Jour de la semaine'; +COMMENT ON COLUMN "planning_item"."meal" IS 'Repas concerné'; +COMMENT ON COLUMN "planning_item"."recipe_id" IS 'FK → recipe'; + -- CreateTable CREATE TABLE "sources" ( "id" SERIAL NOT NULL, @@ -80,6 +121,11 @@ CREATE TABLE "sources" ( CONSTRAINT "sources_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "sources" IS 'Source d''origine d''une recette (site, livre, etc.), utilisée par le pipeline d''import.'; +COMMENT ON COLUMN "sources"."id" IS 'Identifiant'; +COMMENT ON COLUMN "sources"."name" IS 'Nom de la source'; +COMMENT ON COLUMN "sources"."url" IS 'URL'; + -- CreateTable CREATE TABLE "recipe" ( "id" SERIAL NOT NULL, @@ -91,6 +137,13 @@ CREATE TABLE "recipe" ( CONSTRAINT "recipe_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "recipe" IS 'Recette de cuisine. Associée à ingredients en many-to-many (voir recipe_ingredient).'; +COMMENT ON COLUMN "recipe"."id" IS 'Identifiant'; +COMMENT ON COLUMN "recipe"."name" IS 'Nom de la recette'; +COMMENT ON COLUMN "recipe"."source_id" IS 'FK → sources'; +COMMENT ON COLUMN "recipe"."description" IS 'Description'; +COMMENT ON COLUMN "recipe"."picture" IS 'Image'; + -- CreateTable CREATE TABLE "ingredients" ( "id" SERIAL NOT NULL, @@ -101,6 +154,12 @@ CREATE TABLE "ingredients" ( CONSTRAINT "ingredients_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "ingredients" IS 'Ingrédient pouvant entrer dans la composition d''une ou plusieurs recettes.'; +COMMENT ON COLUMN "ingredients"."id" IS 'Identifiant'; +COMMENT ON COLUMN "ingredients"."name" IS 'Nom'; +COMMENT ON COLUMN "ingredients"."icon" IS 'Icône'; +COMMENT ON COLUMN "ingredients"."alternate_recipe" IS 'FK → recipe (recette alternative, ex: faire soi-même plutôt qu''acheter)'; + -- CreateTable CREATE TABLE "recipe_ingredient" ( "recipe_id" INTEGER NOT NULL, @@ -111,6 +170,12 @@ CREATE TABLE "recipe_ingredient" ( CONSTRAINT "recipe_ingredient_pkey" PRIMARY KEY ("recipe_id","ingredient_id") ); +COMMENT ON TABLE "recipe_ingredient" IS 'Association recipe ↔ ingredients enrichie d''une quantité et d''une unité (non présent dans la spec d''origine, nécessaire pour les listes de courses / le calcul batch-cooking).'; +COMMENT ON COLUMN "recipe_ingredient"."recipe_id" IS 'FK → recipe'; +COMMENT ON COLUMN "recipe_ingredient"."ingredient_id" IS 'FK → ingredients'; +COMMENT ON COLUMN "recipe_ingredient"."quantity" IS 'Quantité de l''ingrédient nécessaire pour la recette'; +COMMENT ON COLUMN "recipe_ingredient"."unit" IS 'Unité de mesure de la quantité (g, ml, pièce...)'; + -- CreateTable CREATE TABLE "tech_step" ( "id" SERIAL NOT NULL, @@ -118,6 +183,9 @@ CREATE TABLE "tech_step" ( CONSTRAINT "tech_step_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "tech_step" IS 'Technique culinaire réutilisable (ex: éplucher, mixer, cuire...), référencée par les étapes de recette.'; +COMMENT ON COLUMN "tech_step"."id" IS 'Identifiant'; + -- CreateTable CREATE TABLE "tech_step_mapping" ( "id" SERIAL NOT NULL, @@ -128,6 +196,12 @@ CREATE TABLE "tech_step_mapping" ( CONSTRAINT "tech_step_mapping_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "tech_step_mapping" IS 'Utilisé par le pipeline d''import de recette pour détecter automatiquement la technique correspondant à une instruction brute (expression = motif texte, weight = score de correspondance).'; +COMMENT ON COLUMN "tech_step_mapping"."id" IS 'Identifiant'; +COMMENT ON COLUMN "tech_step_mapping"."tech_step_id" IS 'FK → tech_step'; +COMMENT ON COLUMN "tech_step_mapping"."expression" IS 'Expression'; +COMMENT ON COLUMN "tech_step_mapping"."weight" IS 'Poids'; + -- CreateTable CREATE TABLE "step" ( "id" SERIAL NOT NULL, @@ -140,6 +214,14 @@ CREATE TABLE "step" ( CONSTRAINT "step_pkey" PRIMARY KEY ("id") ); +COMMENT ON TABLE "step" IS 'Étape d''une recette. Appartient à exactement une recette (one-to-many depuis recipe) : le champ order n''a de sens que dans le contexte d''une recette donnée — voir specs/batch-cooking-modele.md pour la formulation d''origine (many-to-many).'; +COMMENT ON COLUMN "step"."id" IS 'Identifiant'; +COMMENT ON COLUMN "step"."recipe_id" IS 'FK → recipe'; +COMMENT ON COLUMN "step"."description" IS 'Description de l''étape'; +COMMENT ON COLUMN "step"."picture" IS 'Image'; +COMMENT ON COLUMN "step"."order" IS 'Ordre dans la recette'; +COMMENT ON COLUMN "step"."tech_step_id" IS 'FK → tech_step'; + -- CreateIndex CREATE UNIQUE INDEX "user_profiles_email_key" ON "user_profiles"("email");