Fix updatedatabase.pl mess coming from last merge?
[srvgit] / installer / data / mysql / updatedatabase.pl
index 901f98d..9f4c149 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`,
-                       COLUMN `renewalsallowed` smallint(6) default NULL,
-                       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);
 }
 
 
@@ -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);
 }
@@ -3126,7 +3110,7 @@ ALTER table suggestions
     ADD rejectedby INT(11) default NULL,
     ADD rejecteddate date default NULL,
     ADD collectiontitle text default NULL,
-    ADD itemtype VARCHAR(30) default NULL,
+    ADD itemtype VARCHAR(30) default NULL
     ;
 SUGGESTIONS
     print "Upgrade to $DBversion done Suggestions";
@@ -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("
@@ -3286,12 +3262,95 @@ if (C4::Context->preference("Version") < TransformToNum($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')");
+       $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('casAuthentication', '0', '', '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';
+$DBversion = "3.01.00.101";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do(
+        "INSERT INTO systempreferences 
+           (variable, value, options, explanation, type)
+         VALUES (
+            'OverdueNoticeBcc', '', '', 
+            'Email address to Bcc outgoing notices sent by email',
+            'free')
+         ");
+       print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
+    SetVersion ($DBversion);
+}
+$DBversion = "3.01.00.102";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $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);
+}
+
+$DBversion = "3.01.00.103";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
+       print "Upgrade done (adding patron permissions for tags tool)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.104";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+
+    my ($maninv_count, $borrnotes_count);
+    eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
+    if ($maninv_count == 0) {
+        $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
+    }
+    eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
+    if ($borrnotes_count == 0) {
+        $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
+    }
+    
+    $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
+    $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
+
+       print "Upgrade to $DBversion done ( add defaults to authorized values for MANUAL_INV and BOR_NOTES and add new default LOC authorized values for shelf to cart processing )\n";
+       SetVersion ($DBversion);
+}
+
+
+$DBversion = "3.01.00.105";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("
+      CREATE TABLE `collections` (
+        `colId` int(11) NOT NULL auto_increment,
+        `colTitle` varchar(100) NOT NULL default '',
+        `colDesc` text NOT NULL,
+        `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
+        PRIMARY KEY  (`colId`)
+      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    ");
+       
+    $dbh->do("
+      CREATE TABLE `collections_tracking` (
+        `ctId` int(11) NOT NULL auto_increment,
+        `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
+        `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
+        PRIMARY KEY  (`ctId`)
+      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    ");
+    $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";
+    SetVersion ($DBversion);
+}
+$DBversion = "3.01.00.106";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ( 'OpacAddMastheadLibraryPulldown', '0', '', 'Adds a pulldown menu to select the library to search on the opac masthead.', 'YesNo' )");
+       print "Upgrade done (added OpacAddMastheadLibraryPulldown system preferences)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.107';
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
     system("perl $upgrade_script");
@@ -3299,6 +3358,33 @@ 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);
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table