From 88b4baceeee7cb820a3aa08f319e4f8ed7e98072 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 13 Oct 2016 10:49:17 +0200 Subject: [PATCH] Bug 8835: New db rev for issn_idx This db rev reapplies dbrev 3.15.00.049 in case that one failed due to existence of issn_idx. Test plan: If you do not have index issn_idx, recreate it: ALTER TABLE biblioitems ADD INDEX issn_idx (issn (255)) Run this db rev. You should see: Removed issn_idx. Rerun the dbrev. You should see: Everything is fine. Signed-off-by: Nicolas Legrand Signed-off-by: Jonathan Druart --- .../data/mysql/atomicupdate/8835_dbrev.perl | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/8835_dbrev.perl diff --git a/installer/data/mysql/atomicupdate/8835_dbrev.perl b/installer/data/mysql/atomicupdate/8835_dbrev.perl new file mode 100644 index 0000000000..eee4e7585a --- /dev/null +++ b/installer/data/mysql/atomicupdate/8835_dbrev.perl @@ -0,0 +1,23 @@ +$DBversion = "16.06.00.XXX"; +if ( CheckVersion($DBversion) ) { + + # If index issn_idx still exists, we assume that dbrev 3.15.00.049 failed, + # and we repeat it (partially). + # Note: the db rev only pertains to biblioitems and is not needed for + # deletedbiblioitems. + + my $temp = $dbh->selectall_arrayref( "SHOW INDEXES FROM biblioitems WHERE key_name = 'issn_idx'" ); + + if( @$temp > 0 ) { + $dbh->do( "ALTER TABLE biblioitems DROP INDEX isbn" ); + $dbh->do( "ALTER TABLE biblioitems DROP INDEX issn" ); + $dbh->do( "ALTER TABLE biblioitems DROP INDEX issn_idx" ); + $dbh->do( "ALTER TABLE biblioitems CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL, CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL" ); + $dbh->do( "ALTER TABLE biblioitems ADD INDEX isbn ( isbn ( 255 ) ), ADD INDEX issn ( issn ( 255 ) )" ); + print "Upgrade to $DBversion done (Bug 8835). Removed issn_idx.\n"; + } else { + print "Upgrade to $DBversion done (Bug 8835). Everything is fine.\n"; + } + + SetVersion($DBversion); +} -- 2.39.5