From ad91d8f732dd2d92a9d0b2bcbf4050ea5d9574b5 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 20 Dec 2017 12:25:32 +0100 Subject: [PATCH] Bug 19724: DBRev 17.05.06.001 --- Koha.pm | 2 +- installer/data/mysql/updatedatabase.pl | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Koha.pm b/Koha.pm index 8722d1ed8a..0d1f280846 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 = "17.05.06.000"; +$VERSION = "17.05.06.001"; sub version { return $VERSION; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index df5b6594c4..bc2e64db58 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -14601,6 +14601,28 @@ if ( CheckVersion($DBversion) ) { print "Upgrade to $DBversion done (Koha 17.05.06)\n"; } +$DBversion = '17.05.06.001'; +if( CheckVersion( $DBversion ) ) { + foreach my $table (qw(biblio_metadata deletedbiblio_metadata)) { + if (!column_exists($table, 'timestamp')) { + $dbh->do(qq{ + ALTER TABLE `$table` + ADD COLUMN `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `metadata`, + ADD KEY `timestamp` (`timestamp`) + }); + $dbh->do(qq{ + UPDATE $table metadata + LEFT JOIN biblioitems ON (biblioitems.biblionumber = metadata.biblionumber) + LEFT JOIN biblio ON (biblio.biblionumber = metadata.biblionumber) + SET metadata.timestamp = GREATEST(biblioitems.timestamp, biblio.timestamp); + }); + } + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 19724 - Add [deleted]biblio_metadata.timestamp)\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