1 package FS::queue_depend;
2 use base qw( FS::Record );
5 use FS::Record qw( dbh );
9 FS::queue_depend - Object methods for queue_depend records
15 $record = new FS::queue_depend \%hash;
16 $record = new FS::queue_depend { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::queue_depend object represents an job dependancy. FS::queue_depend
29 inherits from FS::Record. The following fields are currently supported:
33 =item dependnum - primary key
35 =item jobnum - source jobnum (see L<FS::queue>).
37 =item depend_jobnum - dependancy jobnum (see L<FS::queue>)
41 The job specified by B<jobnum> depends on the job specified B<depend_jobnum> -
42 the B<jobnum> job will not be run until the B<depend_jobnum> job has completed
43 successfully (or manually removed).
51 Creates a new dependancy. To add the dependancy to the database, see
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to. You can ask the object for a copy with the I<hash> method.
59 # the new method can be inherited from FS::Record, if a table method is defined
61 sub table { 'queue_depend'; }
65 Adds this record to the database. If there is an error, returns the error,
66 otherwise returns false.
70 # the insert method can be inherited from FS::Record
74 Delete this record from the database.
78 # the delete method can be inherited from FS::Record
80 =item replace OLD_RECORD
82 Replaces the OLD_RECORD with this one in the database. If there is an error,
83 returns the error, otherwise returns false.
87 # the replace method can be inherited from FS::Record
91 Checks all fields to make sure this is a valid dependancy. If there is
92 an error, returns the error, otherwise returns false. Called by the insert
100 $self->ut_numbern('dependnum')
101 || $self->ut_foreign_key('jobnum', 'queue', 'jobnum')
102 || $self->ut_foreign_key('depend_jobnum', 'queue', 'jobnum')
103 || $self->SUPER::check
111 sub _upgrade_schema {
112 my ($class, %opts) = @_;
115 DELETE FROM queue_depend WHERE NOT EXISTS
116 ( SELECT 1 FROM queue WHERE queue.jobnum = queue_depend.jobnum )
119 my $sth = dbh->prepare($sql) or die dbh->errstr;
120 $sth->execute or die $sth->errstr;
128 L<FS::queue>, L<FS::Record>, schema.html from the base documentation.