diff options
| author | Christopher Burger <burgerc@freeside.biz> | 2017-03-21 10:29:20 -0400 |
|---|---|---|
| committer | Christopher Burger <burgerc@freeside.biz> | 2017-03-21 10:29:20 -0400 |
| commit | d22004dc0909c8a7fca5a44aa596c4d4f590b558 (patch) | |
| tree | 1dfc8da36fd8f65480ab9308ac0bd8f7836af35e /FS/FS | |
| parent | 76d2898fee82437debaffbd95a120df20ce8023f (diff) | |
| parent | d0b9bf2f18ea8c5b6a4267f7498df954bfaeafde (diff) | |
Merge branch 'master' of ssh://git.freeside.biz/home/git/freeside
Diffstat (limited to 'FS/FS')
| -rw-r--r-- | FS/FS/Upgrade.pm | 1 | ||||
| -rw-r--r-- | FS/FS/cust_main_invoice.pm | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index da74555a5..6edec9072 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -575,6 +575,7 @@ sub upgrade_schema_data { 'cust_event_fee' => [], 'radius_attr' => [], 'queue_depend' => [], + 'cust_main_invoice' => [], #update records referencing removed things with their FKs 'cust_pkg' => [], ; diff --git a/FS/FS/cust_main_invoice.pm b/FS/FS/cust_main_invoice.pm index 6c155aca6..31a07bcff 100644 --- a/FS/FS/cust_main_invoice.pm +++ b/FS/FS/cust_main_invoice.pm @@ -2,7 +2,7 @@ package FS::cust_main_invoice; use base qw( FS::Record ); use strict; -use FS::Record qw( qsearchs ); +use FS::Record qw( qsearchs dbh ); use FS::Conf; use FS::svc_acct; use FS::Msgcat qw(gettext); @@ -167,6 +167,22 @@ Returns the parent customer object (see L<FS::cust_main>). =back +=cut + +sub _upgrade_schema { + my ($class, %opts) = @_; + + # delete records where custnum points to a nonexistent customer + my $sql = 'DELETE FROM cust_main_invoice + WHERE NOT EXISTS ( + SELECT 1 FROM cust_main WHERE cust_main.custnum = cust_main_invoice.custnum + )'; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + + ''; +} + =head1 BUGS =head1 SEE ALSO |
