X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b67471a15a2334cd0ce4f617c962819889c487f9..9c5f94c0359a8f2c0dba93b5e9bdef99f332fcc8:/sql/Pg-upgrade2/vendor_add_constraints.sql?ds=inline

diff --git a/sql/Pg-upgrade2/vendor_add_constraints.sql b/sql/Pg-upgrade2/vendor_add_constraints.sql
index 7b707c0fa..bddd627f4 100644
--- a/sql/Pg-upgrade2/vendor_add_constraints.sql
+++ b/sql/Pg-upgrade2/vendor_add_constraints.sql
@@ -1,9 +1,13 @@
 -- @tag: vendor_add_constraints
 -- @description: ZusÃ¤tzliche FremdschlÃ¼ssel fÃ¼r Sprache, Lieferantentyp und Zahlungskonditionen
 -- @depends: release_2_6_3
--- @charset: utf-8
 -- @ignore: 0
 
+-- verwaiste EintrÃ¤ge vorher entfernen
+UPDATE vendor SET payment_id  = NULL WHERE payment_id  NOT IN (SELECT id FROM payment_terms);
+UPDATE vendor SET language_id = NULL WHERE language_id NOT IN (SELECT id FROM language);
+UPDATE vendor SET business_id = NULL WHERE business_id NOT IN (SELECT id FROM business);
+
 ALTER TABLE vendor ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id);
 ALTER TABLE vendor ADD FOREIGN KEY (language_id) REFERENCES language (id);
 ALTER TABLE vendor ADD FOREIGN KEY (business_id) REFERENCES business (id);
