From b6b874ce361928afd95dc49486b2fe748c854a54 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 1 May 2014 15:07:12 +0200 Subject: [PATCH] Bug 6536: Dbrev for Z3950 search improvements Content-Type: text/plain; charset=utf-8 Adjusts table z3950servers: Drops unused columns icon, description and position. Moves id column to first position. Renames name to servername, and type to servertype. (This is not only more clear but may eliminate some problems too with DBIx.) Changes recordtype from varchar(45) to enumeration with two members. [The upgrade replaces unknown record types with biblio, although it is very unlikely to find such records.] Adds SRU as servertype enumeration member. Removes opensearch, since it is not used/supported. [The upgrade replaces unknown server types with zed (z3950) (in exceptional cases).] Adds new columns: sru_options, sru_fields, add_xslt. Test plan: Run database update via webinstaller. Check your z3950servers table. --- installer/data/mysql/kohastructure.sql | 14 +++++++------- installer/data/mysql/updatedatabase.pl | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b46dc6a..0e54234 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2334,23 +2334,23 @@ CREATE TABLE `virtualshelfshares` ( -- shared private lists DROP TABLE IF EXISTS `z3950servers`; CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets used in cataloging + `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha `host` varchar(255) default NULL, -- target's host name `port` int(11) default NULL, -- port number used to connect to target `db` varchar(255) default NULL, -- target's database name `userid` varchar(255) default NULL, -- username needed to log in to target `password` varchar(255) default NULL, -- password needed to log in to target - `name` mediumtext, -- name given to the target by the library - `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha + `servername` mediumtext NOT NULL, -- name given to the target by the library `checked` smallint(6) default NULL, -- whether this target is checked by default (1 for yes, 0 for no) `rank` int(11) default NULL, -- where this target appears in the list of targets `syntax` varchar(80) default NULL, -- marc format provided by this target `timeout` int(11) NOT NULL DEFAULT '0', -- number of seconds before Koha stops trying to access this server - `icon` text, -- unused in Koha - `position` enum('primary','secondary','') NOT NULL default 'primary', - `type` enum('zed','opensearch') NOT NULL default 'zed', + `servertype` enum('zed','sru') NOT NULL default 'zed', -- zed means z39.50 server `encoding` text default NULL, -- characters encoding provided by this target - `description` text NOT NULL, -- unused in Koha - `recordtype` varchar(45) NOT NULL default 'biblio', -- server contains bibliographic or authority records + `recordtype` enum('authority','biblio') NOT NULL default 'biblio', -- server contains bibliographic or authority records + `sru_options` varchar(255) default NULL, -- options like sru=get, sru_version=1.1; will be passed to the server via ZOOM + `sru_fields` mediumtext default NULL, -- contains the mapping between the Z3950 search fields and the specific SRU server indexes + `add_xslt` mediumtext default NULL, -- zero or more paths to XSLT files to be processed on the search results PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 1030454..fcc7cab 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8570,6 +8570,35 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } + +$DBversion = "3.17.00.XXX"; +if ( CheckVersion($DBversion) ) { + # Correct invalid recordtypes (should be very exceptional) + $dbh->do(q{ + UPDATE z3950servers set recordtype='biblio' WHERE recordtype NOT IN ('authority','biblio') + }); + # Correct invalid server types (should also be very exceptional) + $dbh->do(q{ + UPDATE z3950servers set type='zed' WHERE type <> 'zed' + }); + # Adjust table + $dbh->do(q{ + ALTER TABLE z3950servers + DROP COLUMN icon, + DROP COLUMN description, + DROP COLUMN position, + MODIFY COLUMN id int NOT NULL AUTO_INCREMENT FIRST, + MODIFY COLUMN recordtype enum('authority','biblio') NOT NULL DEFAULT 'biblio', + CHANGE COLUMN name servername mediumtext NOT NULL, + CHANGE COLUMN type servertype enum('zed','sru') NOT NULL DEFAULT 'zed', + ADD COLUMN sru_options varchar(255) default NULL, + ADD COLUMN sru_fields mediumtext default NULL, + ADD COLUMN add_xslt mediumtext default NULL + }); + print "Upgrade to $DBversion done (Bug 6536: Z3950 improvements)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.7.6