From 539af7bd5afedb5b1749e05c084fb9ef2ec44a7f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 15 Feb 2021 11:01:46 +0000 Subject: [PATCH] Bug 27598: DBRev 20.12.00.012 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- ...default_upload_authorised_value_category.perl | 16 ---------------- installer/data/mysql/updatedatabase.pl | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_27598_add_default_upload_authorised_value_category.perl diff --git a/Koha.pm b/Koha.pm index 265c2fc3d1..16782c147d 100644 --- 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 = "20.12.00.011"; +$VERSION = "20.12.00.012"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_27598_add_default_upload_authorised_value_category.perl b/installer/data/mysql/atomicupdate/bug_27598_add_default_upload_authorised_value_category.perl deleted file mode 100644 index 05f59c1386..0000000000 --- a/installer/data/mysql/atomicupdate/bug_27598_add_default_upload_authorised_value_category.perl +++ /dev/null @@ -1,16 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - $sth = $dbh->prepare("SELECT category_name FROM authorised_value_categories WHERE category_name='UPLOAD'"); - $sth->execute; - my ($value) = $sth->fetchrow; - if( $value ){ - print "The UPLOAD authorized value category exists. Update the 'is_system' value to 1.\n"; - $dbh->do( "UPDATE authorised_value_categories SET is_system = 1 WHERE category_name = 'UPLOAD'" ); - } else { - print "The UPLOAD authorized value category does not exist. Create it.\n"; - $dbh->do( "INSERT IGNORE INTO authorised_value_categories (category_name, is_system) VALUES ('UPLOAD', 1)" ); - } - - # Always end with this (adjust the bug info) - NewVersion( $DBversion, 27598, "Add UPLOAD as a built-in system authorized value category"); -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 1d973704d5..79b4d1ae68 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -23505,6 +23505,21 @@ if ( CheckVersion($DBversion) ) { NewVersion( $DBversion, 18506, "Add OPACShibOnly and staffShibOnly system preferences" ); } +$DBversion = '20.12.00.012'; +if( CheckVersion( $DBversion ) ) { + my $category_exists = $dbh->selectrow_array("SELECT count(category_name) FROM authorised_value_categories WHERE category_name='UPLOAD'"); + my $description; + if( $category_exists ){ + $description = "The UPLOAD authorized value category exists. Update the 'is_system' value to 1."; + $dbh->do( "UPDATE authorised_value_categories SET is_system = 1 WHERE category_name = 'UPLOAD'" ); + } else { + $description = "The UPLOAD authorized value category does not exist. Create it."; + $dbh->do( "INSERT IGNORE INTO authorised_value_categories (category_name, is_system) VALUES ('UPLOAD', 1)" ); + } + + NewVersion( $DBversion, 27598, ["Add UPLOAD as a built-in system authorized value category", $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/'; -- 2.39.5