projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bd5c864
)
fix FK upgrade for pkg_referral: remove records referencing non-existant customer...
author
Ivan Kohler
<ivan@freeside.biz>
Tue, 14 Feb 2017 17:02:48 +0000
(09:02 -0800)
committer
Ivan Kohler
<ivan@freeside.biz>
Tue, 14 Feb 2017 17:02:48 +0000
(09:02 -0800)
FS/FS/pkg_referral.pm
patch
|
blob
|
history
diff --git
a/FS/FS/pkg_referral.pm
b/FS/FS/pkg_referral.pm
index
333c2bf
..
a5ac795
100644
(file)
--- 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 strict;
use vars qw( @ISA );
-use FS::Record qw(
qsearch qsearchs
);
+use FS::Record qw(
dbh
);
@ISA = qw(FS::Record);
@ISA = qw(FS::Record);
@@
-108,6
+108,19
@@
sub check {
$self->SUPER::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
=back
=head1 BUGS