From f355322dd83ef5efac9164f935ceff214fff6ba6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Jul 2021 13:52:02 +0200 Subject: [PATCH] Bug 20472: Make DB rev idempotent --- .../data/mysql/atomicupdate/bug_20472a.perl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_20472a.perl b/installer/data/mysql/atomicupdate/bug_20472a.perl index a789245112b..66f7590d240 100644 --- a/installer/data/mysql/atomicupdate/bug_20472a.perl +++ b/installer/data/mysql/atomicupdate/bug_20472a.perl @@ -1,9 +1,16 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do(q| - ALTER TABLE article_requests - ADD COLUMN `format` enum('PHOTOCOPY', 'SCAN') NOT NULL DEFAULT 'PHOTOCOPY' AFTER notes, - ADD COLUMN `urls` MEDIUMTEXT AFTER format - |); + unless ( column_exists('article_requests', 'format') ) { + $dbh->do(q| + ALTER TABLE article_requests + ADD COLUMN `format` enum('PHOTOCOPY', 'SCAN') NOT NULL DEFAULT 'PHOTOCOPY' AFTER notes + |); + } + unless ( column_exists('article_requests', 'urls') ) { + $dbh->do(q| + ALTER TABLE article_requests + ADD COLUMN `urls` MEDIUMTEXT AFTER format + |); + } NewVersion( $DBversion, 20472, "Add columns format and urls in article_requests table"); } -- 2.20.1