From 8f3cdefe7ea2b466c137585f488c30c04a79b134 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Tue, 13 Jan 2026 12:28:56 -0700 Subject: [PATCH] (FEAT): Allow larger serving sizes. Now we can range between 1 and 127. --- .../013_update_recipes_allow_large_servings.sql | 14 ++++++++++++++ .../database/migrations/100_init_database.sh | 2 ++ web/src/hooks/validation.ts | 2 +- web/src/pages/Create.tsx | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 internal/infrastructure/database/migrations/013_update_recipes_allow_large_servings.sql diff --git a/internal/infrastructure/database/migrations/013_update_recipes_allow_large_servings.sql b/internal/infrastructure/database/migrations/013_update_recipes_allow_large_servings.sql new file mode 100644 index 0000000..677150f --- /dev/null +++ b/internal/infrastructure/database/migrations/013_update_recipes_allow_large_servings.sql @@ -0,0 +1,14 @@ +-- Author: Hayden Hargreaves (hhargreaves2006@gmail.com) +-- Desc: Update recipes table to allow larger serving sizes. +-- Date: 01/13/2026 + +BEGIN; + +ALTER TABLE recipes + DROP CONSTRAINT recipes_serves_check; + +ALTER TABLE recipes + ADD CONSTRAINT recipes_serves_check + CHECK (serves >= 0 AND serves <= 127); + +COMMIT; diff --git a/internal/infrastructure/database/migrations/100_init_database.sh b/internal/infrastructure/database/migrations/100_init_database.sh index 203d3fb..e4893c4 100755 --- a/internal/infrastructure/database/migrations/100_init_database.sh +++ b/internal/infrastructure/database/migrations/100_init_database.sh @@ -12,3 +12,5 @@ psql -h "$PSQL_HOST" -U "$PSQL_USERNAME" -d "$PSQL_DATABASE" -f ./internal/infra psql -h "$PSQL_HOST" -U "$PSQL_USERNAME" -d "$PSQL_DATABASE" -f ./internal/infrastructure/database/migrations/010_create_recipe_of_the_week_procedure.sql psql -h "$PSQL_HOST" -U "$PSQL_USERNAME" -d "$PSQL_DATABASE" -f ./internal/infrastructure/database/migrations/011_update_engagement_enum.sql +psql -h "$PSQL_HOST" -U "$PSQL_USERNAME" -d "$PSQL_DATABASE" -f ./internal/infrastructure/database/migrations/013_update_recipes_allow_large_servings.sql + diff --git a/web/src/hooks/validation.ts b/web/src/hooks/validation.ts index 28a4205..9aacb19 100644 --- a/web/src/hooks/validation.ts +++ b/web/src/hooks/validation.ts @@ -34,7 +34,7 @@ export function validateCreateRecipeForm(values: CreateRecipeFormValues, dirty: servingSize: dirty.servingSize ? values.servingSize !== "" && Number(values.servingSize) >= 1 && - Number(values.servingSize) <= 16 + Number(values.servingSize) <= 127 : true, category: dirty.category ? values.category !== "" && isRecipeMeal(values.category) diff --git a/web/src/pages/Create.tsx b/web/src/pages/Create.tsx index d512780..226ac2c 100644 --- a/web/src/pages/Create.tsx +++ b/web/src/pages/Create.tsx @@ -385,7 +385,7 @@ export default function Create() { error="Please enter a serving size." parentClasses="flex-grow w-1/3" min="1" - max="16" + max="127" classes={INPUT_CLASSES} />