mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Delete QU conversions when deleting QU (theoretical problem, closes #1796)
This commit is contained in:
10
migrations/0171.sql
Normal file
10
migrations/0171.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TRIGGER remove_conversions AFTER DELETE ON quantity_units
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM quantity_unit_conversions
|
||||||
|
WHERE from_qu_id = OLD.id
|
||||||
|
OR to_qu_id = OLD.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
DELETE FROM quantity_unit_conversions
|
||||||
|
WHERE NOT EXISTS(SELECT 1 FROM quantity_units WHERE id = quantity_unit_conversions.from_qu_id)
|
||||||
|
OR NOT EXISTS(SELECT 1 FROM quantity_units WHERE id = quantity_unit_conversions.to_qu_id);
|
Reference in New Issue
Block a user