X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b9043da3207903443bc94320b5f5f981f20c3698..772f08d07f41febb13a52e066036d23faa0490fc:/sql/Pg-upgrade2/customer_add_constraints.sql

diff --git a/sql/Pg-upgrade2/customer_add_constraints.sql b/sql/Pg-upgrade2/customer_add_constraints.sql
index 6505efdb1..89ca9d628 100644
--- a/sql/Pg-upgrade2/customer_add_constraints.sql
+++ b/sql/Pg-upgrade2/customer_add_constraints.sql
@@ -4,6 +4,9 @@
 -- @charset: utf-8
 -- @ignore: 0
 
+-- verwaiste Zahlungsbedingungen vorher entfernen:
+update customer set payment_id = NULL where payment_id not in (select id from payment_terms);
+
 ALTER TABLE customer ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id);
 ALTER TABLE customer ADD FOREIGN KEY (language_id) REFERENCES language (id);
 ALTER TABLE customer ADD FOREIGN KEY (business_id) REFERENCES business (id);
