Bug 22899: (QA follow-up) Ensure constraint is created

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 49a6aac8b6)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-05-14 13:17:01 +01:00
parent 8e4ea14f93
commit 07738ea63b
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,11 @@ $DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
# you can use $dbh here like:
unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) {
$dbh->do(q{
DELETE t FROM tmp_holdsqueue t
LEFT JOIN items i ON t.itemnumber=i.itemnumber
WHERE i.itemnumber IS NULL
});
$dbh->do(q{
ALTER TABLE tmp_holdsqueue
ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)