Bug 15108: (QA followup) Fix atomic update file
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 5 May 2017 14:38:31 +0000 (11:38 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 8 May 2017 13:27:20 +0000 (09:27 -0400)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
installer/data/mysql/atomicupdate/Bug15108-OAI-PMH_provider_improvements.perl

index 9a252cf..4cd702c 100644 (file)
@@ -1,11 +1,18 @@
-$DBversion = 'XXX';  # will be replaced by the RM
+$DBversion = 'XXX';
 if( CheckVersion( $DBversion ) ) {
-    $dbh->do("ALTER TABLE biblioitems ADD KEY `timestamp` (`timestamp`);");
-    $dbh->do("ALTER TABLE deletedbiblioitems ADD KEY `timestamp` (`timestamp`);");
-    $dbh->do("ALTER TABLE items ADD KEY `timestamp` (`timestamp`);");
-    $dbh->do("ALTER TABLE deleteditems ADD KEY `timestamp` (`timestamp`);");
+    if ( !index_exists( 'biblioitems', 'timestamp' ) ) {
+        $dbh->do("ALTER TABLE biblioitems ADD KEY `timestamp` (`timestamp`);");
+    }
+    if ( !index_exists( 'deletedbiblioitems', 'timestamp' ) ) {
+        $dbh->do("ALTER TABLE deletedbiblioitems ADD KEY `timestamp` (`timestamp`);");
+    }
+    if ( !index_exists( 'items', 'timestamp' ) ) {
+        $dbh->do("ALTER TABLE items ADD KEY `timestamp` (`timestamp`);");
+    }
+    if ( !index_exists( 'deleteditems', 'timestamp' ) ) {
+        $dbh->do("ALTER TABLE deleteditems ADD KEY `timestamp` (`timestamp`);");
+    }
 
-    # Always end with this (adjust the bug info)
     SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 15108 - OAI-PMH provider improvements)\n";
+    print "Upgrade to $DBversion done (Bug 15108: OAI-PMH provider improvements)\n";
 }