ACL for hardware class config, RT#85057
[freeside.git] / FS / FS / queue_depend.pm
index bc910d8..f21ed99 100644 (file)
@@ -1,11 +1,8 @@
 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
 
@@ -43,7 +40,7 @@ inherits from FS::Record.  The following fields are currently supported:
 
 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
 
@@ -109,6 +106,21 @@ sub 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