$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;
}
if ( CheckVersion($DBversion) ) {
$dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('maxreserves',50,'System-wide maximum number of holds a patron can place','','Integer')");
print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n";
- SetVersion($DBversion);
+ SetVersion ($DBversion);
}
$DBversion = '3.17.00.014';
SetVersion ($DBversion);
}
+$DBversion = "3.17.00.018";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('HoldsInNoissuesCharge', '0', 'Hold charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
+ print "Upgrade to $DBversion done (Bug 12205: Add HoldsInNoissuesCharge systempreference)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.019";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHighlightedWords is enabled','free')"
+ );
+ print "Upgrade to $DBversion done (Bug 6149: Operator highlighted in search results)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.020";
+if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo')");
+ print "Upgrade to $DBversion done (Bug 8735 - Expire holds waiting only on days the library is open)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.021";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ my $pref = C4::Context->preference('HomeOrHoldingBranch');
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
+ VALUES ('StaffSearchResultsDisplayBranch', ?,'homebranch|holdingbranch','Controls the display of the home or holding branch for staff search results','choice')", undef, $pref);
+ print "Upgrade to $DBversion done (Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.17.00.022';
+if ( CheckVersion($DBversion) ) {
+ my @temp= $dbh->selectrow_array(qq|
+ SELECT count(*)
+ FROM marc_subfield_structure
+ WHERE kohafield='permanent_location' OR kohafield='items.permanent_location'
+ |);
+ print "Upgrade to $DBversion done (Bug 7817: Check for permanent_location)\n";
+ if( $temp[0] ) {
+ print "WARNING for Koha administrator: Your database contains one or more mappings for permanent_location to the MARC structure. This item field however is for internal use and should not be linked to a MARC (sub)field. Please correct it. See also Bugzilla reports 7817 and 12818.\n";
+ }
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.023";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('AcqItemSetSubfieldsWhenReceiptIsCancelled','', '','Upon cancelling a receipt, update the items subfields if they were created when placing an order (e.g. o=5|a="bar foo")', 'Free')
+ });
+ print "Upgrade to $DBversion done (Bug 11169 - Add AcqItemSetSubfieldsWhenReceiptIsCancelled syspref)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.024";
+if(CheckVersion($DBversion)) {
+ $dbh->do(q{
+ ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
+ });
+ $dbh->do(q{
+ ALTER TABLE old_issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
+ });
+ $dbh->do(q{
+ ALTER TABLE issuingrules ADD auto_renew BOOLEAN default FALSE AFTER norenewalbefore
+ });
+ print "Upgrade to $DBversion done (Bug 11577: [ENH] Automatic renewal feature)\n";
+ 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)