From 70c00e81d94d27a6b6050d311de51967a9a3fc13 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 20 Oct 2018 11:17:51 +0200 Subject: [PATCH] Cascade changes of stock quantity unit of products to recipe positions (fixes #91) --- migrations/0042.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 migrations/0042.sql diff --git a/migrations/0042.sql b/migrations/0042.sql new file mode 100644 index 00000000..b5fb9498 --- /dev/null +++ b/migrations/0042.sql @@ -0,0 +1,7 @@ +CREATE TRIGGER cascade_change_qu_id_stock AFTER UPDATE ON products +BEGIN + UPDATE recipes_pos + SET qu_id = (SELECT qu_id_stock FROM products WHERE id = NEW.id) + WHERE product_id IN (SELECT id FROM products WHERE id = NEW.id) + AND only_check_single_unit_in_stock = 0; +END;