[freeside-commits] branch master updated. 877a4eb85cb847bd314d6a9192fedb1dc35c5d02

Ivan ivan at 420.am
Tue Feb 14 09:02:49 PST 2017


The branch, master has been updated
       via  877a4eb85cb847bd314d6a9192fedb1dc35c5d02 (commit)
      from  bd5c864f75fd5d4aaddd60d2ba1ebc15f14a9aa8 (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 877a4eb85cb847bd314d6a9192fedb1dc35c5d02
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 14 09:02:48 2017 -0800

    fix FK upgrade for pkg_referral: remove records referencing non-existant customer packages

diff --git a/FS/FS/pkg_referral.pm b/FS/FS/pkg_referral.pm
index 333c2bf..a5ac795 100644
--- a/FS/FS/pkg_referral.pm
+++ b/FS/FS/pkg_referral.pm
@@ -2,7 +2,7 @@ package FS::pkg_referral;
 
 use strict;
 use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( dbh );
 
 @ISA = qw(FS::Record);
 
@@ -108,6 +108,19 @@ sub check {
   $self->SUPER::check;
 }
 
+sub _upgrade_schema {
+  my ($class, %opts) = @_;
+
+  my $sql = '
+    DELETE FROM pkg_referral WHERE NOT EXISTS
+      ( SELECT 1 FROM cust_pkg WHERE cust_pkg.pkgnum = pkg_referral.pkgnum )
+  ';
+
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+  '';
+}
+
 =back
 
 =head1 BUGS

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

Summary of changes:
 FS/FS/pkg_referral.pm |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)




More information about the freeside-commits mailing list