Bug 1861: DBRev 3.19.00.003
[srvgit] / installer / data / mysql / updatedatabase.pl
index 3542685..5dab69d 100755 (executable)
@@ -7205,7 +7205,7 @@ $DBversion = "3.13.00.029";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
         INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type )
-        VALUES ( "issues to claim", "efault CSV export for serial issue claims",
+        VALUES ( "issues to claim", "Default CSV export for serial issue claims",
                 "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate",
                 ",", "sql" )
     });
@@ -9439,7 +9439,7 @@ if ( CheckVersion($DBversion) ) {
 }
 
 $DBversion = "3.17.00.053";
-if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
         INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)');
     });
@@ -9481,7 +9481,7 @@ if (CheckVersion($DBversion)) {
 }
 
 $DBversion = "3.17.00.055";
-if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+if ( CheckVersion($DBversion) ) {
     $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEnable', '0', NULL, 'Enable communication with the Norwegian national patron database.', 'YesNo')");
     $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEndpoint', '', NULL, 'Which NL endpoint to use.', 'Free')");
     $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBUsername', '', NULL, 'Username for communication with the Norwegian national patron database.', 'Free')");
@@ -9505,6 +9505,129 @@ CREATE TABLE borrower_sync (
     SetVersion($DBversion);
 }
 
+$DBversion = "3.17.00.056";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'pubdate,itemtype,language,sorting,location' WHERE variable='OpacAdvSearchOptions'
+    });
+
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'pubdate,itemtype,language,subtype,sorting,location' WHERE variable='OpacAdvSearchMoreOptions'
+    });
+
+    print "Upgrade to $DBversion done (Bug 9043 - Update the values for OpacAdvSearchOptions and OpacAdvSearchOptions)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.057";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (Koha 3.18 beta)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.058";
+if( CheckVersion($DBversion) ){
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueChargeValue','Charge a lost item to the borrower account when the LOST value of the item changes to n',  'integer')");
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueLostValue', 'Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.', 'integer')");
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueDays', 'Set the LOST value of an item when the item has been overdue for more than n days.',  'integer')");
+    print "Upgrade to $DBversion done (Bug 8337: System preferences for longoverdue cron)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.059";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE permissions SET description = "Add and delete budgets (but can't modifiy budgets)" WHERE description = "Add and delete budgets (but cant modify budgets)";
+    });
+    print "Upgrade to $DBversion done (Bug 10749: Fix typo in budget_add_del permission description)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.060";
+if ( CheckVersion($DBversion) ) {
+    my $count_l = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
+    |);
+    my $count_mq = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
+    |);
+    my $count_ott = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
+    |);
+    my $count_mt = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
+    |);
+    my $count_bmtp = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
+    |);
+
+    my $deleted = 0;
+    if ( $count_l->[0] == 0 and $count_mq->[0] == 0 and $count_ott->[0] == 0 and $count_mt->[0] == 0 and $count_bmtp->[0] == 0 ) {
+        $deleted = $dbh->do(q|
+            DELETE FROM message_transport_types where message_transport_type='feed'
+        |);
+        $deleted = $deleted ne '0E0' ? 1 : 0;
+    }
+
+    print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.18.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (3.18.0 release)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (there's life after 3.18)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.001";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("
+        UPDATE systempreferences
+        SET options = 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription'
+        WHERE variable = 'UsageStatsLibraryType'
+    ");
+    if ( C4::Context->preference("UsageStatsLibraryType") eq "university" ) {
+        C4::Context->set_preference("UsageStatsLibraryType", "academic")
+    }
+    print "Upgrade to $DBversion done (Bug 13436: Add more options to UsageStatsLibraryType)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.002";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        UPDATE suggestions SET branchcode="" WHERE branchcode="__ANY__"
+    |);
+    print "upgrade to $DBversion done (Bug 10753: replace __ANY__ with empty string in suggestions.branchcode)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.003";
+if ( CheckVersion($DBversion) ) {
+    my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1");
+
+    if ( $count ) {
+        print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n";
+        print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n";
+        print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)";
+    } else {
+        $dbh->do(q{
+            ALTER TABLE borrowers
+                DROP INDEX userid ,
+                ADD UNIQUE userid (userid)
+        });
+        print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n";
+    }
+
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)