X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_svc.pm;fp=FS%2FFS%2Fcust_svc.pm;h=13e2e0f2670943849f44abd7a4702dc3f08964a5;hb=fc951f6ed5fab5c3b36f79f9f413556f76e75e0c;hp=0223f934bbaf77c6ca1175c655338f4292e812e3;hpb=6a8cfb9dfdc9a48b840623fdf878cd4001482a57;p=freeside.git diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 0223f934b..13e2e0f26 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -1300,13 +1300,19 @@ sub _upgrade_data { my $svcdb = $cust_svc->part_svc->svcdb; $h_search{'hashref'}{'svcnum'} = $svcnum; $h_search{'table'} = "h_$svcdb"; - my $h_svc_x = qsearchs(\%h_search) - or next; - my $class = "FS::$svcdb"; - my $new_svc_x = $class->new({ $h_svc_x->hash }); - my $error = $new_svc_x->insert; - warn "error repairing svcnum $svcnum ($svcdb) from history:\n$error\n" - if $error; + my $h_svc_x = qsearchs(\%h_search); + if ( $h_svc_x ) { + my $class = "FS::$svcdb"; + my $new_svc_x = $class->new({ $h_svc_x->hash }); + my $error = $new_svc_x->insert; + warn "error repairing svcnum $svcnum ($svcdb) from history:\n$error\n" + if $error; + } else { + # can't be fixed, so remove the dangling cust_svc to avoid breaking + # stuff + my $error = $cust_svc->delete; + warn "error cleaning up missing svcnum $svcnum ($svcdb):\n$error\n"; + } } '';