[Koha-patches] [PATCH] 6536: Z3950 Enhancements (DB Revision)
Marcel de Rooy
M.de.Rooy at rijksmuseum.nl
Thu Jun 30 15:01:12 CEST 2011
This patch contains db revision for Z3950 enhancements: SRU search targets, MARC conversion and additional XSLT processing.
It also contains a few additional lines of code for updatedatabase routines SetVersion and TransformToNum in order to facilitate testing new db revisions which are still marked XXX.
---
installer/data/mysql/kohastructure.sql | 10 ++++++----
installer/data/mysql/updatedatabase.pl | 20 +++++++++++++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index e3c6f42..1b0be0e 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1985,21 +1985,23 @@ CREATE TABLE `virtualshelfcontents` (
DROP TABLE IF EXISTS `z3950servers`;
CREATE TABLE `z3950servers` (
- `host` varchar(255) default NULL,
+ `host` varchar(255) NOT NULL,
`port` int(11) default NULL,
`db` varchar(255) default NULL,
`userid` varchar(255) default NULL,
`password` varchar(255) default NULL,
- `name` mediumtext,
+ `name` mediumtext NOT NULL,
`id` int(11) NOT NULL auto_increment,
`checked` smallint(6) default NULL,
`rank` int(11) default NULL,
- `syntax` varchar(80) default NULL,
+ `syntax` varchar(80) NOT NULL,
`icon` text,
`position` enum('primary','secondary','') NOT NULL default 'primary',
`type` enum('zed','opensearch') NOT NULL default 'zed',
- `encoding` text default NULL,
+ `encoding` text NOT NULL,
`description` text NOT NULL,
+ `srufields` text,
+ `add_xslt` varchar(255),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 3c7d043..bbd8140 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4354,6 +4354,18 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.05.00.XXX";
+if (C4::Context->preference("Version") lt TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE z3950servers MODIFY COLUMN `host` varchar(255) NOT NULL;");
+ $dbh->do("ALTER TABLE z3950servers MODIFY COLUMN `name` mediumtext NOT NULL;");
+ $dbh->do("ALTER TABLE z3950servers MODIFY COLUMN `syntax` varchar(80) NOT NULL;");
+ $dbh->do("ALTER TABLE z3950servers MODIFY COLUMN `encoding` text NOT NULL;");
+ $dbh->do("ALTER TABLE z3950servers ADD COLUMN `srufields` text;");
+ $dbh->do("ALTER TABLE z3950servers ADD COLUMN `add_xslt` varchar(255);");
+ print "Upgrade to $DBversion done (Bug 6536: Z3950 enhancements)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)
@@ -4396,6 +4408,10 @@ sub TransformToNum {
my $version = shift;
# remove the 3 last . to have a Perl number
$version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
+ # three X's at the end indicate that you are testing patch with dbrev
+ # change it into 999
+ # prevents error on a < comparison between strings (should be: lt)
+ $version =~ s/XXX$/999/;
return $version;
}
@@ -4406,7 +4422,9 @@ set the DBversion in the systempreferences
=cut
sub SetVersion {
- my $kohaversion = TransformToNum(shift);
+ return if $_[0]=~ /XXX$/;
+ #you are testing a patch with a db revision; do not change version
+ my $kohaversion = TransformToNum($_[0]);
if (C4::Context->preference('Version')) {
my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
$finish->execute($kohaversion);
--
1.6.0.6
More information about the Koha-patches
mailing list