[freeside-commits] branch FREESIDE_4_BRANCH updated. 1115cbfe4ba825c46be63a46bd2b5c34e910eab1

Ivan ivan at 420.am
Fri Mar 10 12:02:34 PST 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  1115cbfe4ba825c46be63a46bd2b5c34e910eab1 (commit)
      from  65cb2bea6e8e93e268d45b523efe1a6666c521f6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1115cbfe4ba825c46be63a46bd2b5c34e910eab1
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Mar 10 12:02:33 2017 -0800

    fix upgrade of cust_pay_pending for deleted customers, RT#75118

diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm
index d108341..8f313f4 100644
--- a/FS/FS/cust_pay_pending.pm
+++ b/FS/FS/cust_pay_pending.pm
@@ -504,6 +504,16 @@ sub _upgrade_schema {
     )';
   my $sth = dbh->prepare($sql) or die dbh->errstr;
   $sth->execute or die $sth->errstr;
+
+  # fix records where custnum points to a nonexistent customer
+  $sql = 'UPDATE cust_pay_pending SET custnum = NULL
+    WHERE NOT EXISTS (
+      SELECT 1 FROM cust_main WHERE cust_main.custnum = cust_pay_pending.custnum
+    )';
+  $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+
+
   '';
 }
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_pay_pending.pm |   10 ++++++++++
 1 file changed, 10 insertions(+)




More information about the freeside-commits mailing list