From 66c1d648b71c7fd5a31d22f699ed4c8a0e7bc3a6 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 31 Aug 2020 08:21:34 +0000 Subject: [PATCH] Bug 21066: (QA follow-up) Check for field existence in dbrev Content-Type: text/plain; charset=utf-8 Test plan: Run the upgrade twice. Signed-off-by: Marcel de Rooy --- installer/data/mysql/atomicupdate/bug_21066.perl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_21066.perl b/installer/data/mysql/atomicupdate/bug_21066.perl index 3a9780f78d..630f6d270b 100644 --- a/installer/data/mysql/atomicupdate/bug_21066.perl +++ b/installer/data/mysql/atomicupdate/bug_21066.perl @@ -1,9 +1,16 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do(q| - ALTER TABLE opac_news - CHANGE COLUMN timestamp publicationdate date DEFAULT NULL, - ADD COLUMN updated_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - |); + if( column_exists( 'opac_news', 'timestamp' ) ) { + $dbh->do(q| + ALTER TABLE opac_news + CHANGE COLUMN timestamp publicationdate date DEFAULT NULL + |); + } + if( !column_exists( 'opac_news', 'updated_on' ) ) { + $dbh->do(q| + ALTER TABLE opac_news + ADD COLUMN updated_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER publicationdate + |); + } NewVersion( $DBversion, 21066, "Update table opac_news"); } -- 2.11.0