From 795e6ab27b19224f9c6f6bc50470d7af07a82b59 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Wed, 8 Feb 2012 15:23:39 +1300 Subject: [PATCH] bug_7509: Added index on items itemcallnumber Content-Type: text/plain; charset="utf-8" I couldn't get this update to fire - I found a small syntax error in the updatedatabase.pl for this, which I corrected with this patch. I also added an atomicupdate to this patch (it was part of my testing, just thought I'd include it? Is there a preference?). Functionally, all of this works as tested (once the typos were fixed), but this probably requires another sign-off. --- .../atomicupdate/add_index_items.itemcallnumber.pl | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++++++++ 3 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add_index_items.itemcallnumber.pl diff --git a/installer/data/mysql/atomicupdate/add_index_items.itemcallnumber.pl b/installer/data/mysql/atomicupdate/add_index_items.itemcallnumber.pl new file mode 100644 index 0000000..c29cf72 --- /dev/null +++ b/installer/data/mysql/atomicupdate/add_index_items.itemcallnumber.pl @@ -0,0 +1,10 @@ +#! /usr/bin/perl +use strict; +use warnings; +use C4::Context; +my $dbh = C4::Context->dbh; + +$dbh->do("ALTER TABLE items ADD KEY (itemcallnumber)"); + +print "Upgrade done (Added index on items.itemcallnumber)\n"; + diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 37113c2..34bf1d6 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1045,6 +1045,7 @@ CREATE TABLE `items` ( -- holdings/item information KEY `itembibnoidx` (`biblionumber`), KEY `homebranch` (`homebranch`), KEY `holdingbranch` (`holdingbranch`), + KEY (itemcallnumber), CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES `biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE, CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON UPDATE CASCADE diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 099dfb9..dc79bd9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4663,6 +4663,14 @@ ENDOFRENEWAL print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n"; SetVersion($DBversion); } + +$DBversion = "3.07.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE items ADD KEY (itemcallnumber)" + print "Upgrade to $DBversion done (Added index on items.itemcallnumber)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) -- 1.7.2.5