From 62acc69c719049ddf36e39b1b29b1fa061b6ab54 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 db rev Test plan: Run the upgrade twice. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- .../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.20.1