Bug 33051: Make 22600075.pl idempotent
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 23 Feb 2023 10:56:31 +0000 (07:56 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 24 Feb 2023 19:40:05 +0000 (16:40 -0300)
As there is no check, this dbrev could cause trouble if run twice. It
doesn't look like it is going to get backported to 22.05, but just in
case...

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/db_revs/220600075.pl

index df2dbb2..279284a 100755 (executable)
@@ -1,12 +1,17 @@
 use Modern::Perl;
 
 return {
-    bug_number => "31948",
+    bug_number  => "31948",
     description => "Add timestamp to tmp_holdsqueue table",
     up => sub {
         my ($args) = @_;
         my ($dbh, $out) = @$args{qw(dbh out)};
 
-        $dbh->do(q{ALTER TABLE `tmp_holdsqueue` ADD `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER item_level_request});
+        unless ( column_exists( 'tmp_holdsqueue', 'timestamp' ) ) {
+            $dbh->do(q{
+                ALTER TABLE `tmp_holdsqueue`
+                    ADD `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER item_level_request
+            });
+        }
     },
 };