package FS::queue_depend;
+use base qw( FS::Record );
use strict;
-use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
-use FS::queue;
-
-@ISA = qw(FS::Record);
+use FS::Record qw( dbh );
=head1 NAME
The job specified by B<jobnum> depends on the job specified B<depend_jobnum> -
the B<jobnum> job will not be run until the B<depend_jobnum> job has completed
-sucessfully (or manually removed).
+successfully (or manually removed).
=head1 METHODS
$self->ut_numbern('dependnum')
|| $self->ut_foreign_key('jobnum', 'queue', 'jobnum')
|| $self->ut_foreign_key('depend_jobnum', 'queue', 'jobnum')
+ || $self->SUPER::check
;
}
=back
+=cut
+
+sub _upgrade_schema {
+ my ($class, %opts) = @_;
+
+ my $sql = '
+ DELETE FROM queue_depend WHERE NOT EXISTS
+ ( SELECT 1 FROM queue WHERE queue.jobnum = queue_depend.jobnum )
+ ';
+
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ '';
+}
+
=head1 BUGS
=head1 SEE ALSO