Bug 22887: DBRev 19.12.00.071
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 14 Apr 2020 16:21:25 +0000 (17:21 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 14 Apr 2020 16:24:42 +0000 (17:24 +0100)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha.pm
installer/data/mysql/atomicupdate/bug_22887.perl [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index 41f77b1..b626d6e 100644 (file)
--- a/Koha.pm
+++ b/Koha.pm
@@ -29,7 +29,7 @@ use vars qw{ $VERSION };
 # - #4 : the developer version. The 4th number is the database subversion.
 #        used by developers when the database changes. updatedatabase take care of the changes itself
 #        and is automatically called by Auth.pm when needed.
-$VERSION = "19.12.00.070";
+$VERSION = "19.12.00.071";
 
 sub version {
     return $VERSION;
diff --git a/installer/data/mysql/atomicupdate/bug_22887.perl b/installer/data/mysql/atomicupdate/bug_22887.perl
deleted file mode 100644 (file)
index f3dca7d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-    unless ( index_exists('authorised_values', 'av_uniq') ) {
-        $dbh->do(q|
-            DELETE FROM authorised_values
-            WHERE category="COUNTRY" AND authorised_value="CC" AND lib="Keeling"
-        |);
-        my $duplicates = $dbh->selectall_arrayref(q|
-            SELECT category, authorised_value, COUNT(concat(category, ':', authorised_value)) AS c
-            FROM authorised_values
-            GROUP BY category, authorised_value
-            HAVING c > 1
-        |, { Slice => {} });
-        if ( @$duplicates ) {
-            warn "WARNING - Cannot create unique constraint on authorised_value(category, authorised_value)\n";
-            warn "The following entries are duplicated: " . join (', ', map { sprintf "%s:%s (%s)", $_->{category}, $_->{authorised_value}, $_->{c} } @$duplicates);
-        } else {
-            $dbh->do( q{ALTER TABLE `authorised_values` ADD CONSTRAINT `av_uniq` UNIQUE (category, authorised_value)} );
-        }
-    }
-
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 22887 - Add unique constraint to authorised_values)\n";
-}
index f3d927c..4590ead 100755 (executable)
@@ -21565,6 +21565,40 @@ if( CheckVersion( $DBversion ) ) {
     NewVersion( $DBversion, 22774, "Limit purchase suggestion in a specified time period");
 }
 
+$DBversion = '19.12.00.071';
+if( CheckVersion( $DBversion ) ) {
+    my @description = ("Add unique constraint to authorised_values");
+    unless ( index_exists('authorised_values', 'av_uniq') ) {
+        $dbh->do(q|
+            DELETE FROM authorised_values
+            WHERE category="COUNTRY" AND authorised_value="CC" AND lib="Keeling"
+        |);
+        my $duplicates = $dbh->selectall_arrayref(q|
+            SELECT category, authorised_value, COUNT(concat(category, ':', authorised_value)) AS c
+            FROM authorised_values
+            GROUP BY category, authorised_value
+            HAVING c > 1
+        |, { Slice => {} });
+        if ( @$duplicates ) {
+            push @description, "WARNING - Cannot create unique constraint on authorised_value(category, authorised_value)";
+            push @description, "The following entries are duplicated: " . join(
+                ', ',
+                map {
+                    sprintf "%s:%s (%s)", $_->{category},
+                      $_->{authorised_value}, $_->{c}
+                } @$duplicates
+            );
+            for my $error (@description) {
+                warn $error . "\n";
+            }
+        } else {
+            $dbh->do( q{ALTER TABLE `authorised_values` ADD CONSTRAINT `av_uniq` UNIQUE (category, authorised_value)} );
+        }
+    }
+
+    NewVersion( $DBversion, 22887, \@description );
+}
+
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';