From 6f266e929ff3eaefc84c34b46fa452c50eecbcf4 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 15 Jan 2013 14:46:30 +0100 Subject: [PATCH] =?utf8?q?Vor=20Fremdschl=C3=BCsselzuweisung=20trans=5Fid?= =?utf8?q?=20verwaiste=20Eintr=C3=A4ge=20in=20orderitems=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../orderitems_delivery_order_items_invoice_foreign_keys.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/Pg-upgrade2/orderitems_delivery_order_items_invoice_foreign_keys.sql b/sql/Pg-upgrade2/orderitems_delivery_order_items_invoice_foreign_keys.sql index 0de00c5d3..ed1b01795 100644 --- a/sql/Pg-upgrade2/orderitems_delivery_order_items_invoice_foreign_keys.sql +++ b/sql/Pg-upgrade2/orderitems_delivery_order_items_invoice_foreign_keys.sql @@ -10,6 +10,8 @@ UPDATE orderitems SET project_id = NULL WHERE project_id NOT IN (SELEC UPDATE delivery_order_items SET project_id = NULL WHERE project_id NOT IN (SELECT id FROM project); UPDATE invoice SET project_id = NULL WHERE project_id NOT IN (SELECT id FROM project); +DELETE FROM orderitems WHERE trans_id NOT IN (SELECT id FROM oe); + ALTER TABLE orderitems ADD FOREIGN KEY (trans_id) REFERENCES oe (id); ALTER TABLE orderitems ADD FOREIGN KEY (project_id) REFERENCES project (id); ALTER TABLE orderitems ADD FOREIGN KEY (pricegroup_id) REFERENCES pricegroup (id); -- 2.20.1