+=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;
+
+ '';
+}
+