From 1daccb71bece082841abcb41c6eb5f3a9f12fa30 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 4 Jun 2024 12:51:45 +0100 Subject: [PATCH] Bug 36978: (Bug 34029 follow-up) Make update idempotent The update wasn't checking for index pre-existance and as such could fail in certain cases. Signed-off-by: Chris Cormack Signed-off-by: Julian Maurice Signed-off-by: Martin Renvoize --- installer/data/mysql/db_revs/230600007.pl | 27 ++++++++--------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/installer/data/mysql/db_revs/230600007.pl b/installer/data/mysql/db_revs/230600007.pl index 0a6abe77c2..362e6b0908 100755 --- a/installer/data/mysql/db_revs/230600007.pl +++ b/installer/data/mysql/db_revs/230600007.pl @@ -21,13 +21,10 @@ return { ); say $out "Updated deletedbiblioitems.place to text"; - $dbh->do( - q{ - ALTER TABLE `biblioitems` - DROP INDEX `publishercode` + if ( index_exists( 'biblioitems', 'publishercode' ) ) { + $dbh->do(q{ALTER TABLE `biblioitems` DROP INDEX `publishercode`}); + say $out "Remove index on biblioitems.publishercode"; } - ); - say $out "Remove index on biblioitems.publishercode"; $dbh->do( q{ ALTER TABLE `biblioitems` @@ -35,20 +32,14 @@ return { } ); say $out "Updated biblioitems.publishercode to text"; - $dbh->do( - q{ - ALTER TABLE `biblioitems` - ADD INDEX `publishercode` (`publishercode`(191)) - } - ); + + $dbh->do(q{ALTER TABLE `biblioitems` ADD INDEX `publishercode` (`publishercode`(191))}); say $out "Create index on biblioitems.publishercode"; - $dbh->do( - q{ - ALTER TABLE `deletedbiblioitems` - DROP INDEX `publishercode` + + if ( index_exists( 'deletedbiblioitems', 'publishercode' ) ) { + $dbh->do(q{ALTER TABLE `deletedbiblioitems` DROP INDEX `publishercode`}); + say $out "Remove index on deletedbiblioitems.publishercode"; } - ); - say $out "Remove index on deletedbiblioitems.publishercode"; $dbh->do( q{ ALTER TABLE `deletedbiblioitems` -- 2.39.5