From c5a758d9a06dba412a8564c8574c68eebf0b6ff8 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 13 Jan 2017 14:00:55 +0000 Subject: [PATCH] Bug 17196 - DBRev 16.12.00.004 Signed-off-by: Kyle M Hall --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_17196.sql | 29 ----------- installer/data/mysql/updatedatabase.pl | 48 +++++++++++++++++++ 3 files changed, 49 insertions(+), 30 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_17196.sql diff --git a/Koha.pm b/Koha.pm index 2214ab1404..27a8fcc6bc 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "16.12.00.003"; +$VERSION = "16.12.00.004"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_17196.sql b/installer/data/mysql/atomicupdate/bug_17196.sql deleted file mode 100644 index 58373fe70d..0000000000 --- a/installer/data/mysql/atomicupdate/bug_17196.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE biblio_metadata ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `biblionumber` INT(11) NOT NULL, - `format` VARCHAR(16) NOT NULL, - `marcflavour` VARCHAR(16) NOT NULL, - `metadata` LONGTEXT NOT NULL, - PRIMARY KEY(id), - UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`), - CONSTRAINT `biblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -CREATE TABLE deletedbiblio_metadata ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `biblionumber` INT(11) NOT NULL, - `format` VARCHAR(16) NOT NULL, - `marcflavour` VARCHAR(16) NOT NULL, - `metadata` LONGTEXT NOT NULL, - PRIMARY KEY(id), - UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`), - CONSTRAINT `deletedbiblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - -INSERT INTO biblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM biblioitems; -INSERT INTO deletedbiblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM deletedbiblioitems; -UPDATE biblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour"); -UPDATE deletedbiblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour"); -ALTER TABLE biblioitems DROP COLUMN marcxml; -ALTER TABLE deletedbiblioitems DROP COLUMN marcxml; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 91cda76b20..d024b1207b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -13788,6 +13788,54 @@ if ( CheckVersion($DBversion) ) { print "Upgrade to $DBversion done (Bug 17486 - Remove 'Mozilla Persona' as an authentication method)\n"; } +$DBversion = '16.12.00.004'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + CREATE TABLE biblio_metadata ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `biblionumber` INT(11) NOT NULL, + `format` VARCHAR(16) NOT NULL, + `marcflavour` VARCHAR(16) NOT NULL, + `metadata` LONGTEXT NOT NULL, + PRIMARY KEY(id), + UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`), + CONSTRAINT `biblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + }); + $dbh->do(q{ + CREATE TABLE deletedbiblio_metadata ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `biblionumber` INT(11) NOT NULL, + `format` VARCHAR(16) NOT NULL, + `marcflavour` VARCHAR(16) NOT NULL, + `metadata` LONGTEXT NOT NULL, + PRIMARY KEY(id), + UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`), + CONSTRAINT `deletedbiblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + }); + $dbh->do(q{ + INSERT INTO biblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM biblioitems; + }); + $dbh->do(q{ + INSERT INTO deletedbiblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM deletedbiblioitems; + }); + $dbh->do(q{ + UPDATE biblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour"); + }); + $dbh->do(q{ + UPDATE deletedbiblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour"); + }); + $dbh->do(q{ + ALTER TABLE biblioitems DROP COLUMN marcxml; + }); + $dbh->do(q{ + ALTER TABLE deletedbiblioitems DROP COLUMN marcxml; + }); + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 17196 - Move marcxml out of the biblioitems table)\n"; +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5