From 43c9ab77342c53daa21156e12571986e971436ba Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 5 Jan 2019 20:28:21 +0100 Subject: [PATCH] Fixed a problem with newer SQLite versions (references and fixes #133) --- migrations/0045.sql | 9 +++++++++ migrations/0047.sql | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 migrations/0047.sql diff --git a/migrations/0045.sql b/migrations/0045.sql index 1723f6c6..ba5fdcf6 100644 --- a/migrations/0045.sql +++ b/migrations/0045.sql @@ -29,6 +29,15 @@ FROM recipes_pos_old; DROP TABLE recipes_pos_old; +DROP TRIGGER cascade_change_qu_id_stock; +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; + DROP VIEW recipes_fulfillment; CREATE VIEW recipes_fulfillment AS diff --git a/migrations/0047.sql b/migrations/0047.sql new file mode 100644 index 00000000..3cc73950 --- /dev/null +++ b/migrations/0047.sql @@ -0,0 +1,12 @@ +DROP TRIGGER cascade_change_qu_id_stock; +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; + +UPDATE recipes_pos +SET qu_id = (SELECT qu_id_stock FROM products WHERE id = recipes_pos.product_id) +WHERE only_check_single_unit_in_stock = 0;