+sub _upgrade_schema {
+ my ($class, %opts) = @_;
+
+ # fix records where jobnum points to a nonexistent queue job
+ my $sql = 'UPDATE cust_pay_pending SET jobnum = NULL
+ WHERE NOT EXISTS (
+ SELECT 1 FROM queue WHERE queue.jobnum = cust_pay_pending.jobnum
+ )';
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+
+ # fix records where custnum points to a nonexistent customer
+ $sql = 'UPDATE cust_pay_pending SET custnum = NULL
+ WHERE NOT EXISTS (
+ SELECT 1 FROM cust_main WHERE cust_main.custnum = cust_pay_pending.custnum
+ )';
+ $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+
+
+ '';
+}
+