Bug 11611: DBRev 3.15.00.017
[koha_fer] / installer / data / mysql / updatedatabase.pl
index 0fb9af6..22bba73 100755 (executable)
@@ -7626,7 +7626,7 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
     SetVersion($DBversion);
 }
 
-$DBversion = "XXX";
+$DBversion = "3.13.00.036";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(qq{
         INSERT INTO systempreferences (variable, value, explanation, options, type)
@@ -7636,6 +7636,344 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.13.00.037";
+if ( CheckVersion($DBversion) ) {
+    #add phone if it is not there already (explains the ignore option)
+    $dbh->do("
+INSERT IGNORE INTO message_transport_types (message_transport_type) values ('phone');
+    ");
+    print "Upgrade to $DBversion done (Bug 10572: Add phone to message_transport_types table for new installs)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.038";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
+    print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.039";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("
+        ALTER TABLE aqbasket ADD branch varchar(10) default NULL
+    ");
+    $dbh->do("
+        ALTER TABLE aqbasket
+        ADD CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch)
+            REFERENCES branches (branchcode)
+            ON UPDATE CASCADE ON DELETE SET NULL
+    ");
+    $dbh->do("
+        DROP TABLE IF EXISTS aqbasketusers
+    ");
+    $dbh->do("
+        CREATE TABLE aqbasketusers (
+            basketno int(11) NOT NULL,
+            borrowernumber int(11) NOT NULL,
+            PRIMARY KEY (basketno,borrowernumber),
+            CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON DELETE CASCADE ON UPDATE CASCADE,
+            CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    ");
+    $dbh->do("
+        INSERT INTO permissions (module_bit, code, description)
+        VALUES (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them')
+    ");
+
+    print "Upgrade to $DBversion done (Add branch and users list to baskets. "
+        . "New permission order_manage_all)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.040";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("CREATE TABLE IF NOT EXISTS marc_modification_templates (
+              template_id int(11) NOT NULL auto_increment,
+              name text NOT NULL,
+              PRIMARY KEY  (template_id)
+              ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;"
+    );
+
+    $dbh->do("
+      CREATE TABLE IF NOT EXISTS marc_modification_template_actions (
+      mmta_id int(11) NOT NULL auto_increment,
+      template_id int(11) NOT NULL,
+      ordering int(3) NOT NULL,
+      action enum('delete_field','update_field','move_field','copy_field') NOT NULL,
+      field_number smallint(6) NOT NULL default '0',
+      from_field varchar(3) NOT NULL,
+      from_subfield varchar(1) NULL,
+      field_value varchar(100) default NULL,
+      to_field varchar(3) default NULL,
+      to_subfield varchar(1) default NULL,
+      to_regex_search text,
+      to_regex_replace text,
+      to_regex_modifiers varchar(8) default '',
+      conditional enum('if','unless') default NULL,
+      conditional_field varchar(3) default NULL,
+      conditional_subfield varchar(1) default NULL,
+      conditional_comparison enum('exists','not_exists','equals','not_equals') default NULL,
+      conditional_value text,
+      conditional_regex tinyint(1) NOT NULL default '0',
+      description text,
+      PRIMARY KEY  (mmta_id),
+      CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
+      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
+    ");
+
+    $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'marc_modification_templates', 'Manage marc modification templates')");
+
+    print "Upgrade to $DBversion done ( Bug 8015: Added tables for MARC Modification Framework )\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.041";
+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";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.042";
+if(CheckVersion($DBversion)) {
+    print "Upgrade to $DBversion done (Koha 3.14 beta)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.043";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
+    print "Upgrade to $DBversion done (Bug 11196: Add system preference SearchEngine if missing )\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.14.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (3.14.0 release)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.15.00.000';
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (the road goes ever on)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.001";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("UPDATE systempreferences SET value='clear' where variable = 'CircAutoPrintQuickSlip' and value = '0'");
+    $dbh->do("UPDATE systempreferences SET value='qslip' where variable = 'CircAutoPrintQuickSlip' and value = '1'");
+    $dbh->do("UPDATE systempreferences SET explanation = 'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.', type = 'Choice' where variable = 'CircAutoPrintQuickSlip'");
+    print "Upgrade to $DBversion done (Bug 11040: Add option to print full slip when checking out a null barcode)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.002";
+if(CheckVersion($DBversion)) {
+    $dbh->do("ALTER TABLE deleteditems MODIFY materials text;");
+    print "Upgrade to $DBversion done (Bug 11275: alter deleteditems.materials from varchar(10) to text)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.003";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE accountlines
+        SET description = ''
+        WHERE description IN (
+            ' New Card',
+            ' Fine',
+            ' Sundry',
+            'Writeoff',
+            ' Account Management fee',
+            'Payment,thanks', 'Payment,thanks - ',
+            ' Lost Item'
+        )
+    });
+    print "Upgrade to $DBversion done (Bug 2546: Update fine descriptions)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.004";
+if ( CheckVersion($DBversion) ) {
+    if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
+        $dbh->do(qq{
+            INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
+            kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link,
+            defaultvalue) VALUES
+            ('015', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
+            ('020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
+            ('024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
+            ('027', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
+            ('800', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
+            ('810', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
+            ('811', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
+            ('830', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL);
+        });
+        $dbh->do(qq{
+            INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
+            mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
+            ('', '020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', ''),
+            ('', '024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', '');
+        });
+    }
+    print "Upgrade to $DBversion done (Bug 10970 - Update MARC21 frameworks to Update Nr. 17 - DB update)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.005";
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo');");
+   print "Upgrade to $DBversion done (Bug 8230: Add AcquisitionDetails system preference)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.006";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        ALTER TABLE `borrowers`
+        ADD KEY `surname_idx` (`surname`(255)),
+        ADD KEY `firstname_idx` (`firstname`(255)),
+        ADD KEY `othernames_idx` (`othernames`(255))
+    });
+    print "Upgrade to $DBversion done (Bug 11249 - Add DB indexes on borrower names)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.15.00.007";
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
+   $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER withdrawn");
+   $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
+   $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER withdrawn");
+   print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.008";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        ALTER TABLE collections_tracking CHANGE ctId collections_tracking_id integer(11) NOT NULL auto_increment;
+    });
+    print "Upgrade to $DBversion done (Bug 11384) - change name of collections_tracker.ctId column)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.009";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        ALTER TABLE suggestions MODIFY suggesteddate DATE NOT NULL
+    });
+    print "Upgrade to $DBversion done (Bug 11391) - drop default value on suggestions.suggesteddate column)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.010";
+if(CheckVersion($DBversion)) {
+    $dbh->do("ALTER TABLE deleteditems DROP COLUMN marc");
+    print "Upgrade to $DBversion done (Bug 6331: remove obsolete column in deleteditems.marc)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.011";
+if(CheckVersion($DBversion)) {
+    $dbh->do("UPDATE marc_subfield_structure SET maxlength=9999 WHERE maxlength IS NULL OR maxlength=0;");
+    print "Upgrade to $DBversion done (Bug 8018: set 9999 as default max length for subfields)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.15.00.012";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'force_checkout', 'Force checkout if a limitation exists')
+    });
+    $dbh->do(q{
+        INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_restrictions', 'Manage restrictions for accounts')
+    });
+    $dbh->do(q{
+        INSERT INTO user_permissions (borrowernumber, module_bit, code)
+            SELECT user_permissions.borrowernumber, 1, 'force_checkout'
+            FROM user_permissions
+            LEFT JOIN borrowers USING(borrowernumber)
+            WHERE borrowers.flags & (1 << 1)
+    });
+    $dbh->do(q{
+        INSERT INTO user_permissions (borrowernumber, module_bit, code)
+            SELECT user_permissions.borrowernumber, 1, 'manage_restrictions'
+            FROM user_permissions
+            LEFT JOIN borrowers USING(borrowernumber)
+            WHERE borrowers.flags & (1 << 1)
+    });
+
+    print "Upgrade to $DBversion done (Bug 10863 - Add permissions force_checkout and manage_restrictions)\n";
+    SetVersion($DBversion);
+}
+
+$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"
+    });
+
+    $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 ( C4::Context->preference("Version") < TransformToNum($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);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)