1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3 # you can use $dbh here like:
4 unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) {
6 DELETE t FROM tmp_holdsqueue t
7 LEFT JOIN items i ON t.itemnumber=i.itemnumber
8 WHERE i.itemnumber IS NULL
11 ALTER TABLE tmp_holdsqueue
12 ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)
13 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
16 SetVersion( $DBversion );
17 print "Upgrade to $DBversion done (Bug XXXXX - Add items constraint to tmp_holdsqueue)\n";