Removing unconditionnal warning
[koha.git] / installer / data / mysql / updatedatabase.pl
index 2b9df4a..1183375 100755 (executable)
@@ -15,7 +15,7 @@
 # NOTE: Please keep the version in kohaversion.pl up-to-date!
 
 use strict;
-use warnings;
+use warnings;
 
 # CPAN modules
 use DBI;
@@ -742,7 +742,6 @@ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,ty
 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACViewOthersSuggestions',0,'If ON, allows all suggestions to be displayed in the OPAC',NULL,'YesNo')");
 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACURLOpenInNewWindow',0,'If ON, URLs in the OPAC open in a new window',NULL,'YesNo')");
 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
-$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('emailPurchaseSuggestions',0,'If ON, patron suggestions are emailed rather than managed in Acquisitions',NULL,'YesNo')");
 
     print "Upgrade to $DBversion done (adding additional system preference)\n";
     SetVersion ($DBversion);
@@ -812,7 +811,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('uppercasesurnames',0,'If ON, surnames are converted to upper case in patron entry form',NULL,'YesNo')");
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('CircControl','ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','PickupLibrary|PatronLibrary|ItemHomeLibrary','Choice')");
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesCalendar','noFinesWhenClosed','Specify whether to use the Calendar in calculating duedates and fines','ignoreCalendar|noFinesWhenClosed','Choice')");
-    $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'");
+    # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
     print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
     SetVersion ($DBversion);
 }
@@ -1379,12 +1378,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
        #);
        $dbh->do(q#
        INSERT INTO `systempreferences` VALUES
-               ('BakerTaylorBookstoreURL','','','URL template for \"My Libary Bookstore\" links, to which the \"key\" value is appended, and \"https://\" is prepended.  It should include your hostname and \"Parent Number\".  Make this variable empty to turn MLB links off.<br /> Example: ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=',''),
+               ('BakerTaylorBookstoreURL','','','URL template for \"My Libary Bookstore\" links, to which the \"key\" value is appended, and \"https://\" is prepended.  It should include your hostname and \"Parent Number\".  Make this variable empty to turn MLB links off.  Example: ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=',''),
                ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
                ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
                ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
                ('TagsEnabled','1','','Enables or disables all tagging features.  This is the main switch for tags.','YesNo'),
-               ('TagsExternalDictionary',NULL,'','Path on server to local ispell executable, used to set $Lingua::Ispell::path <br />This dictionary is used as a \"whitelist\" of pre-allowed tags.',''),
+               ('TagsExternalDictionary',NULL,'','Path on server to local ispell executable, used to set $Lingua::Ispell::path  This dictionary is used as a \"whitelist\" of pre-allowed tags.',''),
                ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.',         'YesNo'),
                ('TagsInputOnList',  '0','','Allow users to input tags from the search results list.', 'YesNo'),
                ('TagsModeration',  NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
@@ -1851,11 +1850,125 @@ $DBversion = '3.00.00.098';
 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
 
     $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
+    $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
 
     print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
     SetVersion($DBversion);
 }
 
+$DBversion = '3.00.00.099';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('OpacSuppression', '0', '', 'Turn ON the OPAC Suppression feature, requires further setup, ask your system administrator for details', 'YesNo')");
+    print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.100';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+       $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
+    print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.101';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+       $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
+       $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
+    print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.102';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+       $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
+       $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
+       $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
+       # before setting constraint, delete any unvalid data
+       $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
+       $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
+    print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.00.00.103";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
+    print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.104";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
+    print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.00.00.105';
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    # it is possible that this syspref is already defined since the feature was added some time ago.
+    unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
+        $dbh->do(<<'END_SQL');
+INSERT INTO `systempreferences`
+  (variable,value,explanation,options,type)
+VALUES
+('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
+END_SQL
+    }
+    print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.00.00.106";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
+
+# db revision 105 didn't apply correctly, so we're rolling this into 106
+       $dbh->do("INSERT INTO `systempreferences`
+   (variable,value,explanation,options,type)
+       VALUES
+       ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
+
+    print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
+    $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
+    $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.00.00.107';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do(<<'END_SQL');
+UPDATE systempreferences
+  SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
+  WHERE variable = 'OPACShelfBrowser'
+    AND explanation NOT LIKE '%WARNING%'
+END_SQL
+    $dbh->do(<<'END_SQL');
+UPDATE systempreferences
+  SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
+  WHERE variable = 'CataloguingLog'
+    AND explanation NOT LIKE '%WARNING%'
+END_SQL
+    $dbh->do(<<'END_SQL');
+UPDATE systempreferences
+  SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
+  WHERE variable = 'NoZebra'
+    AND explanation NOT LIKE '%WARNING%'
+END_SQL
+    print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
+    SetVersion ($DBversion);
+}
+if (C4::Context->preference("Version") =~/3\.00/) {
+        my $perllibdir=C4::Context->config('intranetdir');
+       my $return=do qq($perllibdir/installer/data/mysql/updatedatabase30.pl);
+       unless ($return){
+               print STDERR "cannot read file $perllibdir/installer/data/mysql/updatedatabase30.pl : $! \n" if ($!);
+               print STDERR "cannot read file $ENV{'PERL5LIB'}/installer/data/mysql/updatedatabase30.pl : $@ \n" if ($@);
+       }
+}
+
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table