remove old test files
[freeside.git] / FS / FS / pkg_referral.pm
index 333c2bf..0983ff6 100644 (file)
@@ -1,10 +1,8 @@
 package FS::pkg_referral;
+use base qw( FS::Record );
 
 use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-
-@ISA = qw(FS::Record);
+use FS::Record qw( dbh );
 
 =head1 NAME
 
@@ -108,6 +106,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