Bug 11703: (qa-followup) fix update database entry
[koha_fer] / installer / data / mysql / updatedatabase.pl
index 6d4bc4c..6cda25d 100755 (executable)
@@ -7470,11 +7470,13 @@ if ( CheckVersion($DBversion) ) {
     |);
     my $check_numberpatterns_sth = $dbh->prepare(qq|
         SELECT * FROM subscription_numberpatterns
-        WHERE add1 = ? AND add2 = ? AND add3 = ?
-          AND every1 = ? AND every2 = ? AND every3 = ?
-          AND whenmorethan1 = ? AND whenmorethan2 = ? AND whenmorethan3 = ?
-          AND setto1 = ? AND setto2 = ? AND setto3 = ?
-          AND numberingmethod = ?
+        WHERE (add1 = ? OR (add1 IS NULL AND ? IS NULL)) AND (add2 = ? OR (add2 IS NULL AND ? IS NULL))
+        AND (add3 = ? OR (add3 IS NULL AND ? IS NULL)) AND (every1 = ? OR (every1 IS NULL AND ? IS NULL))
+        AND (every2 = ? OR (every2 IS NULL AND ? IS NULL)) AND (every3 = ? OR (every3 IS NULL AND ? IS NULL))
+        AND (whenmorethan1 = ? OR (whenmorethan1 IS NULL AND ? IS NULL)) AND (whenmorethan2 = ? OR (whenmorethan2 IS NULL AND ? IS NULL))
+        AND (whenmorethan3 = ? OR (whenmorethan3 IS NULL AND ? IS NULL)) AND (setto1 = ? OR (setto1 IS NULL AND ? IS NULL))
+        AND (setto2 = ? OR (setto2 IS NULL AND ? IS NULL)) AND (setto3 = ? OR (setto3 IS NULL AND ? IS NULL))
+        AND (numberingmethod = ? OR (numberingmethod IS NULL AND ? IS NULL))
         LIMIT 1
     |);
     my $update_subscription_sth = $dbh->prepare(qq|
@@ -7487,11 +7489,11 @@ if ( CheckVersion($DBversion) ) {
     my $i = 1;
     while(my $sub = $sth->fetchrow_hashref) {
         $check_numberpatterns_sth->execute(
-            $sub->{add1}, $sub->{add2}, $sub->{add3},
-            $sub->{every1}, $sub->{every2}, $sub->{every3},
-            $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan3},
-            $sub->{setto1}, $sub->{setto2}, $sub->{setto3},
-            $sub->{numberingmethod}
+            $sub->{add1}, $sub->{add1}, $sub->{add2}, $sub->{add2}, $sub->{add3}, $sub->{add3},
+            $sub->{every1}, $sub->{every1}, $sub->{every2}, $sub->{every2}, $sub->{every3}, $sub->{every3},
+            $sub->{whenmorethan1}, $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan2},
+            $sub->{whenmorethan3}, $sub->{whenmorethan3}, $sub->{setto1}, $sub->{setto1}, $sub->{setto2},
+            $sub->{setto2}, $sub->{setto3}, $sub->{setto3}, $sub->{numberingmethod}, $sub->{numberingmethod}
         );
         my $p = $check_numberpatterns_sth->fetchrow_hashref;
         if (defined $p) {
@@ -8374,7 +8376,7 @@ if ( CheckVersion($DBversion) ) {
         INSERT INTO systempreferences (variable,value,explanation,options,type)
         VALUES (
             'BlockExpiredPatronOpacActions',
-            '1',
+            '0',
             'Set whether an expired patron can perform opac actions such as placing holds or renew books, can be overridden on a per patron-type basis',
             NULL,
             'YesNo'
@@ -8385,6 +8387,189 @@ if ( CheckVersion($DBversion) ) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.15.00.046";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE search_history ADD COLUMN type VARCHAR(16) NOT NULL DEFAULT 'biblio' AFTER query_cgi
+    |);
+    print "Upgrade to $DBversion done (Bug 10807 - Add db field search_history.type)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.047";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableSearchHistory','0','','Enable or disable search history','YesNo')
+    |);
+    print "Upgrade to $DBversion done (Bug 10862: Add EnableSearchHistory syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.048";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo')");
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionMessage', '','Display this message on the redirect page for suppressed biblios','70|10','Textarea')");
+    print "Upgrade to $DBversion done (Bug 10195: Records hidden with OpacSuppression can still be accessed)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.049";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("ALTER TABLE biblioitems DROP INDEX isbn");
+    $dbh->do("ALTER TABLE biblioitems DROP INDEX issn");
+    $dbh->do("ALTER TABLE biblioitems
+              CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
+              CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
+    ");
+    $dbh->do("ALTER TABLE biblioitems
+              ADD INDEX isbn ( isbn ( 255 ) ),
+              ADD INDEX issn ( issn ( 255 ) )
+    ");
+
+    $dbh->do("ALTER TABLE deletedbiblioitems DROP INDEX isbn");
+    $dbh->do("ALTER TABLE deletedbiblioitems
+              CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
+              CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
+    ");
+    $dbh->do("ALTER TABLE deletedbiblioitems
+              ADD INDEX isbn ( isbn ( 255 ) )
+    ");
+
+    print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.050";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("
+        INSERT INTO systempreferences (
+            variable,
+            value,
+            explanation,
+            type
+        ) VALUES (
+            'AggressiveMatchOnISBN',
+            '0',
+            'If enabled, attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records when matching on ISBN with the record import tool',
+            'YesNo'
+        )
+    ");
+
+    print "Upgrade to $DBversion done (Bug 10500 - Improve isbn matching when importing records)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.051";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (Koha 3.16 beta)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.052";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (Koha 3.16 RC)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.16.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (3.16.0 release)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.17.00.000';
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (there is no time to rest on our laurels)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.17.00.001';
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("UPDATE systempreferences SET variable = 'AuthoritySeparator' WHERE variable = 'authoritysep'");
+   print "Upgrade to $DBversion done (Bug 10330 - Rename system preference authoritysep to AuthoritySeparator)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.002";
+if (CheckVersion($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('AcqEnableFiles','0','If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo')");
+    $dbh->do("
+CREATE TABLE IF NOT EXISTS `misc_files` (
+  `file_id` int(11) NOT NULL AUTO_INCREMENT,
+  `table_tag` varchar(255) NOT NULL,
+  `record_id` int(11) NOT NULL,
+  `file_name` varchar(255) NOT NULL,
+  `file_type` varchar(255) NOT NULL,
+  `file_description` varchar(255) DEFAULT NULL,
+  `file_content` longblob NOT NULL, -- file content
+  `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`file_id`),
+  KEY `table_tag` (`table_tag`),
+  KEY `record_id` (`record_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    ");
+    print "Upgrade to $DBversion done (Bug 3050 - Add an option to upload scanned invoices)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.003";
+if (CheckVersion($DBversion)) {
+    $dbh->do("UPDATE systempreferences SET type = 'Choice', options = '0|1|force' WHERE variable = 'OPACItemHolds'");
+    print "Upgrade to $DBversion done (Bug 7825 - Changed OPACItemHolds syspref to Choice)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.004";
+if (CheckVersion($DBversion)) {
+    $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER category_type");
+    print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.005";
+if (CheckVersion($DBversion)) {
+    $dbh->do(q|
+        ALTER TABLE issuingrules
+        ADD maxsuspensiondays INT(11) DEFAULT NULL AFTER finedays;
+    |);
+    print "Upgrade to $DBversion done (Bug 12230: Add new issuing rule maxsuspensiondays)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.006";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacLocationBranchToDisplay',  'holding',  'holding|home|both',  'In the OPAC, under location show which branch for Location in the record details.',  'Choice')");
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacLocationBranchToDisplayShelving',  'holding',  'holding|home|both',  'In the OPAC, display the shelving location under which which column',  'Choice')");
+    print "Upgrade to $DBversion done (Bug 7720 - Ambiguity in OPAC Details location.)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.007";
+if (CheckVersion($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free');");
+    print "Upgrade to $DBversion done (Bug 11629 - Add ability to update not for loan status on checkin)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.008";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACAcquisitionDetails','0', '','Show the acquisition details at the OPAC','YesNo')
+    |);
+    print "Upgrade to $DBversion done (Bug 11169 - Add OPACAcquisitionDetails syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DELETE FROM systempreferences WHERE variable = 'UseTablesortForCirc'
+    });
+
+    print "Upgrade to $DBversion done (Bug 11703 - Remove UseTablesortForCirc syspref)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)