summaryrefslogtreecommitdiff
path: root/FS/FS/pkg_referral.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/pkg_referral.pm')
-rw-r--r--FS/FS/pkg_referral.pm15
1 files changed, 14 insertions, 1 deletions
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