Bug 22899: (QA follow-up) Change accessor name
[koha.git] / installer / data / mysql / atomicupdate / bug_22899_add_items_constraint_to_tmpholdsqueue.perl
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' ) ) {
5         $dbh->do(q{
6             DELETE t FROM tmp_holdsqueue t
7             LEFT JOIN items i ON t.itemnumber=i.itemnumber
8             WHERE i.itemnumber IS NULL
9         });
10         $dbh->do(q{
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
14         });
15     }
16     SetVersion( $DBversion );
17     print "Upgrade to $DBversion done (Bug XXXXX - Add items constraint to tmp_holdsqueue)\n";
18 }