Bug 35687: Upgrade to 23.06.00.013 may fail

There are reports that this update triggers the error Cannot change column 'itemnumber': used in a foreign key constraint 'tmp_holdsqueue_ibfk_1'

Test Plan:
1) Upgrade to post 23.06.00.013
2) Note the failure
3) Apply this patch set
4) Run updatedatabase.pl
5) Update should succeed!

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Kyle Hall 2024-01-03 14:07:49 +00:00 committed by Katrin Fischer
parent aadb617235
commit a644f41a92
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -0,0 +1,24 @@
use Modern::Perl;
return {
bug_number => "35687",
description => "Upgrade to 23.06.00.013 may fail, drop fk and recreate after adding the pk to tmp_holdsqueue",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
unless ( primary_key_exists( 'tmp_holdsqueue', 'itemnumber' ) ) {
$dbh->do(q{ALTER TABLE tmp_holdsqueue DROP CONSTRAINT `tmp_holdsqueue_ibfk_1`});
$dbh->do(q{ALTER TABLE tmp_holdsqueue ADD PRIMARY KEY (itemnumber)});
$dbh->do(
q{
ALTER TABLE tmp_holdsqueue ADD CONSTRAINT `tmp_holdsqueue_ibfk_1`
FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
ON DELETE CASCADE ON UPDATE CASCADE
}
);
}
say $out "Set primary key for table 'tmp_holdsqueue' to 'itemnumber'";
},
};