[freeside-commits] branch FREESIDE_4_BRANCH updated. 07dee094cc143a19acc4bc16b00361b1e23a739f
Ivan
ivan at 420.am
Tue Feb 14 09:02:50 PST 2017
The branch, FREESIDE_4_BRANCH has been updated
via 07dee094cc143a19acc4bc16b00361b1e23a739f (commit)
from 2b2111e072ce91322705e21215c55652d271e4ba (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 07dee094cc143a19acc4bc16b00361b1e23a739f
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Feb 14 09:02:49 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