Bug 12539: PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm
[koha-ffzg.git] / installer / data / mysql / updatedatabase.pl
index edfcbe9..3739f38 100755 (executable)
@@ -7984,28 +7984,32 @@ 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
-    |);
+    eval {
+        $dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|);
+    };
+    unless ( $@ ) {
+        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;
+        |);
 
-    if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
-        $dbh->do(q|
-            DROP TABLE roadtype;
+        my $rt_deleted = $dbh->do(q|
+            DELETE FROM 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;
-    }
 
+        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;
 }
@@ -8751,7 +8755,7 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
-$DBversion = "3.17.00.XXX";
+$DBversion = "3.17.00.024";
 if(CheckVersion($DBversion)) {
     $dbh->do(q{
         ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
@@ -8766,6 +8770,155 @@ if(CheckVersion($DBversion)) {
     SetVersion($DBversion);
 }
 
+$DBversion = '3.17.00.025';
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(qq{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('StatisticsFields','location|itype|ccode','Define fields (from the items table) used for statistics members',NULL,'Free')
+    });
+    print "Upgrade to $DBversion done (Bug 12728: Checked syspref StatisticsFields)\n";
+}
+
+$DBversion = "3.17.00.026";
+if ( CheckVersion($DBversion) ) {
+    if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
+        $dbh->do("UPDATE marc_subfield_structure SET liblibrarian = 'Encoded bitrate', libopac = 'Encoded bitrate' WHERE tagfield = '347' AND tagsubfield = 'f'");
+        $dbh->do("UPDATE marc_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','610','611','710','711','810','811') AND tagsubfield = 'c'");
+        $dbh->do("UPDATE auth_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','410','411','510','511','710','711') AND tagsubfield = 'c'");
+        print "Upgrade to $DBversion done (Bug 12435 - Update MARC21 frameworks to Update No. 18 (April 2014))\n";
+    }
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.027";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DELETE FROM systempreferences WHERE variable = 'SearchEngine'
+    });
+    print "Upgrade to $DBversion done (Bug 12538 - Remove SearchEngine syspref)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.028";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT INTO systempreferences (variable,value) VALUES('OpacCustomSearch','');
+    });
+    print "Upgrade to $DBversion done (Bug 12296 - search box replaceable with a system preference)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.029";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("ALTER TABLE  `items` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
+    $dbh->do("ALTER TABLE  `deleteditems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
+    $dbh->do("ALTER TABLE  `biblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
+    $dbh->do("ALTER TABLE  `deletedbiblioitems` CHANGE  `cn_sort`  `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
+    print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.030";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(
+        q{
+       INSERT INTO systempreferences (variable, value, options, explanation, type )
+       VALUES
+        ('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'YesNo'),
+        ('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.',  'Free'),
+        ('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
+        ('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
+        ('UsageStatsLibraryType', 'public', 'public|university', 'The library type to be shown on the Hea Koha community website', 'Choice'),
+        ('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
+        ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo')
+    });
+    print "Upgrade to $DBversion done (Bug 11926: Add UsageStats systempreferences (HEA))\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.031";
+if ( CheckVersion($DBversion) ) {
+   $dbh->do("ALTER TABLE saved_sql CHANGE report_name report_name VARCHAR( 255 ) NOT NULL DEFAULT '' ");
+   print "Upgrade to $DBversion done (Bug 2969: Report Name should be mandatory for saved reports)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.032";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(
+"INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReplytoDefault',  '',  NULL,  'The default email address to be set as replyto.',  'Free')"
+    );
+    $dbh->do(
+"INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReturnpathDefault',  '',  NULL,  'The default email address to be set as return-path',  'Free')"
+    );
+    $dbh->do("ALTER TABLE branches ADD branchreplyto mediumtext AFTER branchemail");
+    $dbh->do("ALTER TABLE branches ADD branchreturnpath mediumtext AFTER branchreplyto");
+    print "Upgrade to $DBversion done (Bug 9530: Adding replyto and returnpath addresses.)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.033";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
+        VALUES('FacetMaxCount', '20','Specify the max facet count for each category',NULL,'Integer')
+    });
+    print "Upgrade to $DBversion done (Bug 13088 - Allow the user to specify a max amount of facets to show)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.034";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE aqorders DROP COLUMN cancelledby;
+    |);
+
+    print "Upgrade to $DBversion done (Bug 11007 - DROP column aqorders.cancelledby)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.035";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0 after claimdate
+    |);
+    $dbh->do(q|
+        UPDATE serial
+        SET claims_count = 1
+        WHERE claimdate IS NOT NULL
+    |);
+    print "Upgrade to $DBversion done (Bug 5342: Add claims_count field in serial table)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowLibrariesPulldownMobile'");
+    print "Upgrade to $DBversion done ( Bug 12513 - PROG/CCSR deprecation: Remove OpacShowLibrariesPulldownMobile system preference )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlockMobile'");
+    print "Upgrade to $DBversion done ( Bug 12246 - PROG/CCSR deprecation: Remove OpacMainUserBlockMobile system preference )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable='OPACMobileUserCSS'");
+    print "Upgrade to $DBversion done ( Bug 12245 - PROG/CCSR deprecation: Remove OPACMobileUserCSS system preference )\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
+    ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes')");
+    print "Upgrade to $DBversion done (Bug 12539 - PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)