DB rev 116 - finish fixing default value of OrderPdfFormat
[koha.git] / installer / data / mysql / updatedatabase.pl
index 4512943..08169ab 100755 (executable)
@@ -2705,14 +2705,6 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
-$DBversion = '3.01.00.064';
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
-    $dbh->do('ALTER TABLE issuingrules DROP FOREIGN KEY issuingrules_ibfk_1');
-    $dbh->do('ALTER TABLE issuingrules DROP FOREIGN KEY issuingrules_ibfk_2');
-    SetVersion ($DBversion);
-    print "Upgrade to $DBversion done (deleting contraints in issuingrules)\n";
-}
-
 $DBversion = '3.01.00.065';
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
@@ -2734,7 +2726,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
 $DBversion = '3.01.00.066';
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
-
+    
     my $maxreserves = C4::Context->preference('maxreserves');
     $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
     $sth->execute($maxreserves);
@@ -2752,23 +2744,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
     $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
     print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
+    SetVersion ($DBversion);
 }
 
 $DBversion = "3.01.00.068";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
-       $dbh->do("ALTER TABLE issuingrules ADD
-                       COLUMN `finedays` int(11) default NULL AFTER `fine`,
-                       ADD COLUMN `renewalsallowed` smallint(6) default NULL, 
-                       ADD COLUMN `reservesallowed` smallint(6) default NULL;
-                       ");
-       my $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
-    $sth->execute();
-       my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
-       while(my $row = $sth->fetchrow_hashref){
-                 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
-       }
-       $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
-       print "Upgrade done (Adding finedays renewalsallowed, and reservesallowed fields in issuingrules table)\n";
+       $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
+       print "Upgrade done (Adding finedays in issuingrules table)\n";
+    SetVersion ($DBversion);
 }
 
 
@@ -2884,7 +2867,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
                          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
     $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
     $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
-    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::example','Controls what script is used for printing (basketgroups)','','free')");
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
     print "Upgrade to $DBversion done (adding basketgroups)\n";
     SetVersion ($DBversion);
 }
@@ -2924,7 +2907,7 @@ ADDPERIODS
 
 
     $dbh->do(<<BUDGETNAME);
-ALTER TABLE aqbudget RENAME`aqbudgets`
+ALTER TABLE aqbudget RENAME `aqbudgets`
 BUDGETNAME
     my $maxbudgetid=$dbh->selectcol_arrayref(<<IDsBUDGET);
 SELECT MAX(aqbudgetid) from aqbudgets
@@ -2985,11 +2968,9 @@ BUDGETCONSTRAINTS
     $dbh->do(<<BUDGETDROPDATES);
 ALTER TABLE `aqbudgets`
    DROP startdate,
-   DROP enddate,
-   DROP bookfundid
+   DROP enddate
 BUDGETDROPDATES
 
-    $dbh->do("DROP TABLE aqbookfund ");
 
     $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
     $dbh->do("CREATE TABLE  `aqbudgets_planning` (
@@ -3010,6 +2991,8 @@ BUDGETDROPDATES
                     ADD COLUMN  `sort1_authcat` varchar(10) default NULL,
                     ADD COLUMN  `sort2_authcat` varchar(10) default NULL" );
 
+                # cannot do until aqorderbreakdown removed
+#    $dbh->do("DROP TABLE aqbookfund ");
 
 
 
@@ -3093,6 +3076,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     );
 
     $dbh->do(qq| DROP TABLE aqorderbreakdown |);
+    $dbh->do('DROP TABLE aqbookfund');
     print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
     SetVersion ($DBversion);
 }
@@ -3148,14 +3132,6 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
-$DBversion = "3.01.00.089";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
-    $dbh->do(  qq# ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib` #);
-
-    print "Upgrade to $DBversion done (opac authorised values added)\n";
-    SetVersion ($DBversion);
-}
-
 $DBversion = "3.01.00.090";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
 $dbh->do("
@@ -3291,13 +3267,6 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
-$DBversion = "3.01.00.100";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
-       $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('casAuthentication', '1', '', 'Enable or disable CAS authentication', 'YesNo'), ('casLogout', '1', '', 'Does a logout from Koha should also log out of CAS ?', 'YesNo'), ('casServerUrl', 'https://localhost:8443/cas', '', 'URL of the cas server', 'Free')");
-       print "Upgrade done (added CAS authentication system preferences)\n";
-    SetVersion ($DBversion);
-}
-
 $DBversion = "3.01.00.101";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
        $dbh->do(
@@ -3313,7 +3282,9 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
 }
 $DBversion = "3.01.00.102";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
-       $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)')");
+    $dbh->do(
+    "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
+    );
        print "Upgrade done (fixed spelling error in edit_catalogue permission)\n";
     SetVersion ($DBversion);
 }
@@ -3369,7 +3340,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("
         INSERT INTO permissions (module_bit, code, description) 
         VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
-       print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotataing collection functionnality)\n";
+       print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
     SetVersion ($DBversion);
 }
 $DBversion = "3.01.00.106";
@@ -3387,6 +3358,86 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.01.00.108';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do(qq{
+       ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
+       ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
+       ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator` 
+       });
+       print "Upgrade done (added separators for csv export)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.109";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do(qq{
+       ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
+       });
+       print "Upgrade done (added encoding for csv export)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.110';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
+    print "Upgrade done (Add enrolment period date support)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.111';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    print "Upgrade done (mark DBrev for 3.2-alpha release)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.112';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('SpineLabelShowPrintOnBibDetails', '0', '', 'If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.', 'YesNo');");
+       print "Upgrade done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.113';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    my $value = C4::Context->preference("XSLTResultsDisplay");
+    $dbh->do(
+        "INSERT INTO systempreferences (variable,value,type)
+         VALUES('OPACXSLTResultsDisplay',$value,'YesNo')");
+    $value = C4::Context->preference("XSLTDetailsDisplay");
+    $dbh->do(
+        "INSERT INTO systempreferences (variable,value,type)
+         VALUES('OPACXSLTDetailsDisplay',$value,'YesNo')");
+    print "Upgrade done (added two new syspref: OPACXSLTResultsDisplay and OPACXSLTDetailDisplay). You may have to go in Admin > System preference to tweak XSLT related syspref both in OPAC and Search tabs.\n     ";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.114';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('AutoSelfCheckAllowed', '0', 'For corporate and special libraries which want web-based self-check available from any PC without the need for a manual staff login. Most libraries will want to leave this turned off. If on, requires self-check ID and password to be entered in AutoSelfCheckID and AutoSelfCheckPass sysprefs.', '', 'YesNo')");
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoSelfCheckID','','Staff ID with circulation rights to be used for automatic web-based self-check. Only applies if AutoSelfCheckAllowed syspref is turned on.','','free')");
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoSelfCheckPass','','Password to be used for automatic web-based self-check. Only applies if AutoSelfCheckAllowed syspref is turned on.','','free')");
+       print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.115';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
+    $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
+       print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.116';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
+               $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
+       }
+       print "Upgrade done ( corrected default OrderPdfFormat value if still set wrong )\n";
+    SetVersion ($DBversion);
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table