Add migration 0018 with unique indexes on recipe_ingredients and recipe_steps (recipe_id, position), so a recipe can never hold two ingredients or two steps at one position. The dinner detail read now orders by position alone and drops its read-time duplicate check; a database already holding a duplicate fails the migration. Maestro task 75bb8cc1-fd30-4050-90d2-a1627a865b22 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 lines
561 B
SQL
10 lines
561 B
SQL
-- 0018_recipe_item_position_unique: position is the only record of recipe
|
|
-- order, so a recipe never has two ingredients or two steps at one
|
|
-- position. Writers replace a recipe's items whole, numbered from 0, and
|
|
-- the detail read orders by position alone. A database already holding a
|
|
-- duplicate fails this migration rather than keep an order nobody can
|
|
-- trust.
|
|
|
|
CREATE UNIQUE INDEX recipe_ingredients_recipe_position ON recipe_ingredients (recipe_id, position);
|
|
CREATE UNIQUE INDEX recipe_steps_recipe_position ON recipe_steps (recipe_id, position);
|