Bug 11334: add ability to control which library fields are used for facets
[koha_fer] / installer / data / mysql / updatedatabase.pl
index 7f706c1..8b68faf 100755 (executable)
@@ -7165,7 +7165,6 @@ $DBversion = "3.13.00.024";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;});
     print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n";
-    SetVersion ($DBversion);
 }
 
 $DBversion = "3.13.00.025";
@@ -7613,8 +7612,13 @@ CREATE TABLE borrower_debarments (
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
     });
 
+    # debarments with end date
+    $dbh->do(q{
+INSERT INTO borrower_debarments ( borrowernumber, expiration, comment ) SELECT borrowernumber, debarred, debarredcomment FROM borrowers WHERE debarred IS NOT NULL AND debarred <> '9999-12-31'
+    });
+    # debarments with no end date
     $dbh->do(q{
-INSERT INTO borrower_debarments ( borrowernumber, expiration, comment ) SELECT borrowernumber, debarred, debarredcomment FROM borrowers WHERE debarred IS NOT NULL
+INSERT INTO borrower_debarments ( borrowernumber, comment ) SELECT borrowernumber, debarredcomment FROM borrowers WHERE debarred = '9999-12-31'
     });
 
     $dbh->do(q{
@@ -7733,7 +7737,7 @@ if(CheckVersion($DBversion)) {
     $dbh->do(q{
         INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AcqItemSetSubfieldsWhenReceived','','Set subfields for item when items are created when receiving (e.g. o=5|a="foo bar")','','Free');
     });
-    print "Upgrade to $DBversion done (Added AcqItemSetSubfieldsWhenReceived syspref)\n";
+    print "Upgrade to $DBversion done (Bug 10986: Added AcqItemSetSubfieldsWhenReceived syspref)\n";
     SetVersion($DBversion);
 }
 
@@ -7912,17 +7916,332 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
-$DBversion = "3.15.00.XXX";
+$DBversion = "3.15.00.013";
 if(CheckVersion($DBversion)) {
     $dbh->do(q{
         UPDATE systempreferences
         SET explanation = 'Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")'
         WHERE variable = "AcqItemSetSubfieldsWhenReceived"
     });
-    print "Upgrade to $DBversion done (Bug 11237: Update explanation for AcqItemSetSubfieldsWhenReceived syspref)\n";
+
+    $dbh->do(q{
+        UPDATE systempreferences
+        SET value = ''
+        WHERE variable = "AcqItemSetSubfieldsWhenReceived"
+            AND value = "0"
+    });
+    print "Upgrade to $DBversion done (Bug 11237: Update explanation and default value for AcqItemSetSubfieldsWhenReceived syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.014";
+if (CheckVersion($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SelfCheckReceiptPrompt', '1', 'NULL', 'If ON, print receipt dialog pops up when self checkout is finished.', 'YesNo');");
+    print "Upgrade to $DBversion done (Bug 11415: add system preference for automatic self checkout receipt printing)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.015";
+if (CheckVersion($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
+        ('OpacSuggestionManagedBy',1,'','Show the name of the staff member who managed a suggestion in OPAC','YesNo');");
+    print "Upgrade to $DBversion done (Bug 10907: Add OpacSuggestionManagedBy system preference)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.016";
+if (CheckVersion($DBversion)) {
+    $dbh->do("ALTER TABLE biblioitems CHANGE url url TEXT NULL DEFAULT NULL");
+    $dbh->do("ALTER TABLE deletedbiblioitems CHANGE url url TEXT NULL DEFAULT NULL");
+    print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.017";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        UPDATE systempreferences
+        SET explanation = 'Define the contents of UNIMARC authority control field 100 position 08-35'
+        WHERE variable = "UNIMARCAuthorityField100"
+    });
+    $dbh->do(q{
+        UPDATE systempreferences
+        SET explanation = 'Define the contents of MARC21 authority control field 008 position 06-39'
+        WHERE variable = "MARCAuthorityControlField008"
+    });
+    $dbh->do(q{
+        UPDATE systempreferences
+        SET explanation = 'Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html'
+        WHERE variable = "MARCOrgCode"
+    });
+    print "Upgrade to $DBversion done (Bug 11611 - fix possible confusion between UNIMARC and MARC21 in some sysprefs)\n";
     SetVersion($DBversion);
 }
 
+$DBversion = "3.15.00.018";
+if ( CheckVersion($DBversion) ) {
+    $dbh->{AutoCommit} = 0;
+    $dbh->{RaiseError} = 1;
+
+    my $av_added = $dbh->do(q|
+        INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
+            SELECT 'ROADTYPE', roadtypeid, road_type, road_type
+            FROM roadtype;
+    |);
+
+    my $rt_deleted = $dbh->do(q|
+        DELETE FROM roadtype
+    |);
+
+    if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
+        $dbh->do(q|
+            DROP TABLE roadtype;
+        |);
+        $dbh->commit;
+        print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
+        SetVersion($DBversion);
+    } else {
+        print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
+        $dbh->rollback;
+    }
+
+    $dbh->{AutoCommit} = 1;
+    $dbh->{RaiseError} = 0;
+}
+
+$DBversion = "3.15.00.019";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer')");
+    print "Upgrade to $DBversion done (Bug 11256: Add system preference OpacMaxItemsToDisplay)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.020";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('MaxItemsForBatch','1000',NULL,'Max number of items record to process in a batch (modification or deletion)','Integer')
+    |);
+    print "Upgrade to $DBversion done (Bug 11343: Add system preference MaxItemsForBatch )\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.021";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE `action_logs`
+            DROP KEY timestamp,
+            ADD KEY `timestamp_idx` (`timestamp`),
+            ADD KEY `user_idx` (`user`),
+            ADD KEY `module_idx` (`module`(255)),
+            ADD KEY `action_idx` (`action`(255)),
+            ADD KEY `object_idx` (`object`),
+            ADD KEY `info_idx` (`info`(255))
+    });
+    print "Upgrade to $DBversion done (Bug 3445: Add indexes to action_logs table)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.022";
+if (CheckVersion($DBversion)) {
+    $dbh->do(q|
+        DELETE FROM systempreferences WHERE variable= "memberofinstitution"
+    |);
+    print "Upgrade to $DBversion done (Bug 11751: Remove memberofinstitytion system preference)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.023";
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("
+       INSERT INTO systempreferences (variable,value,options,explanation,type)
+       VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free');
+    ");
+   print "Upgrade to $DBversion done (Bug 10861: Add CardnumberLength syspref)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.024";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DELETE FROM systempreferences WHERE variable = 'NoZebraIndexes'
+    });
+    print "Upgrade to $DBversion done (Bug 10012 - remove last vestiges of NoZebra)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.025";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DROP TABLE aqorderdelivery;
+    });
+    print "Upgrade to $DBversion done (Bug 11928 - remove unused table)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.026";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE language_descriptions SET description = 'Հայերեն' WHERE subtag = 'hy' AND lang = 'hy';
+    });
+    print "Upgrade to $DBversion done (Bug 11973 - Fix Armenian language description)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.027";
+if (CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE opac_news ADD branchcode varchar(10) DEFAULT NULL
+                                  AFTER idnew,
+                              ADD CONSTRAINT opac_news_branchcode_ibfk
+                                  FOREIGN KEY (branchcode)
+                                  REFERENCES branches (branchcode)
+                                  ON DELETE CASCADE ON UPDATE CASCADE;
+    });
+    print "Upgrade to $DBversion done (Bug 7567: Add branchcode to opac_news)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.028";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE issuingrules ADD norenewalbefore int(4) default NULL AFTER renewalperiod
+    });
+    print "Upgrade to $DBversion done (Bug 7413: Allow OPAC renewal x days before due date)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.029";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE borrower_debarments SET expiration = NULL WHERE expiration = '9999-12-31'
+    });
+    print "Upgrade to $DBversion done (Bug 11846 - correct borrower_debarments with expiration 9999-12-31)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.030";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q|
+        INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACMySummaryNote','','','Note to display on the patron summary page. This note only appears if the patron is connected.','Free')
+    |);
+    print "Upgrade to $DBversion done (Bug 12052: Add OPACMySummaryNote syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.031";
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'writeoff', 'Write off fines and fees')");
+   $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'remaining_permissions', 'Remaining permissions for managing fines and fees')");
+   print "Upgrade to $DBversion done (Bug 9448 - Add separate permission for writing off fees)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.032";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("ALTER TABLE aqorders CHANGE notes order_internalnote MEDIUMTEXT;");
+    $dbh->do("ALTER TABLE aqorders ADD COLUMN order_vendornote MEDIUMTEXT AFTER order_internalnote;");
+    print "Upgrade to $DBversion done (Bug 9416 - In each order, add a new note made for the vendor)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.033";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea')");
+    print "Upgrade to $DBversion done (Bug 10951: Add NoLoginInstructions pref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.034";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an advanced search option.  Example: eng|fra|ita','Textarea')");
+    print "Upgrade to $DBversion done (Bug 10986: system preferences to limit languages in advanced search )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.035";
+if ( CheckVersion($DBversion) ) {
+    #insert a notice for sharing a list and accepting a share
+    $dbh->do("
+INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
+VALUES ( 'members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
+
+One of our patrons, <<borrowers.firstname>> <<borrowers.surname>>, invites you to share a list <<listname>> in our library catalog.
+
+To access this shared list, please click on the following URL or copy-and-paste it into your browser address bar.
+
+<<shareurl>>
+
+In case you are not a patron in our library or do not want to accept this invitation, please ignore this mail. Note also that this invitation expires within two weeks.
+
+Thank you.
+
+Your library.'
+    )");
+    $dbh->do("
+INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
+VALUES ( 'members', 'SHARE_ACCEPT', '', 'Notification about an accepted share', '0', 'Share on list <<listname>> accepted', 'Dear patron,
+
+We want to inform you that <<borrowers.firstname>> <<borrowers.surname>> accepted your invitation to share your list <<listname>> in our library catalog.
+
+Thank you.
+
+Your library.'
+    )");
+    print "Upgrade to $DBversion done (Bug 9032: Share a list)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.036";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+        VALUES('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo')
+    });
+
+    print "Upgrade to $DBversion done (Bug 10859 - Add system preference AllowMultipleIssuesOnABiblio)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.037";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) DEFAULT NULL AFTER checkinmsgtype
+    });
+    $dbh->do(q{
+        INSERT INTO authorised_values (category, authorised_value, lib) VALUES
+         ('SIP_MEDIA_TYPE', '000', 'Other'),
+         ('SIP_MEDIA_TYPE', '001', 'Book'),
+         ('SIP_MEDIA_TYPE', '002', 'Magazine'),
+         ('SIP_MEDIA_TYPE', '003', 'Bound journal'),
+         ('SIP_MEDIA_TYPE', '004', 'Audio tape'),
+         ('SIP_MEDIA_TYPE', '005', 'Video tape'),
+         ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'),
+         ('SIP_MEDIA_TYPE', '007', 'Diskette'),
+         ('SIP_MEDIA_TYPE', '008', 'Book with diskette'),
+         ('SIP_MEDIA_TYPE', '009', 'Book with CD'),
+         ('SIP_MEDIA_TYPE', '010', 'Book with audio tape')
+    });
+    print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = '3.15.00.XXX';
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT INTO  systempreferences (
+            variable,
+            value,
+            options,
+            explanation,
+            type
+            )
+        VALUES (
+            'DisplayLibraryFacets',  'holdingbranch',  'home|holding|both',  'Defines which library facets to display.',  'Choice'
+        );
+    });
+    print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n";
+    SetVersion ($DBversion);
+}
 
 =head1 FUNCTIONS