Fixed meal plan did not load when a containing recipe was deleted (closes #361)

This commit is contained in:
Bernd Bestel
2019-09-21 09:18:40 +02:00
parent ab44566890
commit 327c1f4fb3
4 changed files with 24 additions and 2 deletions

9
migrations/0089.sql Normal file
View File

@@ -0,0 +1,9 @@
CREATE TRIGGER remove_recipe_from_meal_plans AFTER DELETE ON recipes
BEGIN
DELETE FROM meal_plan
WHERE recipe_id = OLD.id;
END;
-- Delete all recipes from the meal plan which doesn't exist anymore
DELETE FROM meal_plan
WHERE recipe_id NOT IN (SELECT id FROM recipes);