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 <nicolas.legrand@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
This commit is contained in:
Marcel de Rooy 2016-10-13 10:49:17 +02:00 committed by Kyle M Hall
parent 0fee84690e
commit 88b4baceee

View file

@ -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);
}