From f2a74a7f13f236ade27d62275a0dfe51c5aa97e1 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 14 Dec 2017 12:03:10 +0000 Subject: [PATCH] Bug 19724: DBRev 17.11.00.001 Signed-off-by: Nick Clemens --- installer/data/mysql/updatedatabase.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index fb278a7eba..f37d3ad076 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -15064,6 +15064,28 @@ foreach my $file ( sort readdir $dirh ) { } } +$DBversion = '17.11.00.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"; +} + =head1 FUNCTIONS =head2 TableExists($table) -- 2.39.5