From deab5ca89b1d8e7add49e972d555804107090724 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 11 Mar 2015 14:27:31 +0100 Subject: [PATCH] Bug 13068: (follow-up) Remove old files, use C4::Installer The do method does not accept more than 1 sql query. Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/updatedatabase.pl | 74 ++++++++++++++------------ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 01c5544f39..9bfce6b1f3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4942,44 +4942,52 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $DBversion = "3.07.00.029"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { - $dbh->do(qq{ -DROP TABLE IF EXISTS `oai_sets_descriptions`; -DROP TABLE IF EXISTS `oai_sets_mappings`; -DROP TABLE IF EXISTS `oai_sets_biblios`; -DROP TABLE IF EXISTS `oai_sets`; - -CREATE TABLE `oai_sets` ( - `id` int(11) NOT NULL auto_increment, - `spec` varchar(80) NOT NULL UNIQUE, - `name` varchar(80) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;}); + $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;}); + $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;}); + $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;}); -CREATE TABLE `oai_sets_descriptions` ( - `set_id` int(11) NOT NULL, - `description` varchar(255) NOT NULL, - CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + $dbh->do(q{ + CREATE TABLE `oai_sets` ( + `id` int(11) NOT NULL auto_increment, + `spec` varchar(80) NOT NULL UNIQUE, + `name` varchar(80) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + }); -CREATE TABLE `oai_sets_mappings` ( - `set_id` int(11) NOT NULL, - `marcfield` char(3) NOT NULL, - `marcsubfield` char(1) NOT NULL, - `marcvalue` varchar(80) NOT NULL, - CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + $dbh->do(q{ + CREATE TABLE `oai_sets_descriptions` ( + `set_id` int(11) NOT NULL, + `description` varchar(255) NOT NULL, + CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + }); -CREATE TABLE `oai_sets_biblios` ( - `biblionumber` int(11) NOT NULL, - `set_id` int(11) NOT NULL, - PRIMARY KEY (`biblionumber`, `set_id`), - CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + $dbh->do(q{ + CREATE TABLE `oai_sets_mappings` ( + `set_id` int(11) NOT NULL, + `marcfield` char(3) NOT NULL, + `marcsubfield` char(1) NOT NULL, + `marcvalue` varchar(80) NOT NULL, + CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + }); -INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo'); + $dbh->do(q{ + CREATE TABLE `oai_sets_biblios` ( + `biblionumber` int(11) NOT NULL, + `set_id` int(11) NOT NULL, + PRIMARY KEY (`biblionumber`, `set_id`), + CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + }); + + $dbh->do(q{ + INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo'); + }); -}); print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n"; SetVersion($DBversion); } -- 2.39.5