use C4::Installer;
use C4::Dates;
use Koha::Database;
+use Koha;
use MARC::Record;
use MARC::File::XML ( BinaryEncoding => 'utf8' );
$dbh->do("ALTER TABLE default_branch_item_rules ADD
COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
# set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
- my $homeorholdingbranchreturn = C4::Context->prefernce('HomeOrHoldingBranchReturn') || 'homebranch';
+ my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') || 'homebranch';
$dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
SetVersion($DBversion);
$DBversion = "3.19.00.010";
if ( CheckVersion($DBversion) ) {
- $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SessionRestrictionByIP','1','Check for Change in Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')");
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES('SessionRestrictionByIP','1','Check for Change in Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')
+ |);
print "Upgrade to $DBversion done (Bug 5511: SessionRestrictionByIP)\n";
SetVersion ($DBversion);
}
SetVersion ($DBversion);
}
+
$DBversion = "3.19.00.018";
if ( CheckVersion($DBversion) ) {
$dbh->do(q|
SetVersion ($DBversion);
}
+$DBversion = "3.19.00.037";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER TABLE marc_subfield_structure
+ MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT ''
+ |);
+ print "Upgrade to $DBversion done (Bug 13810: Change collate for tagsubfield (utf8_bin))\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.038";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER TABLE virtualshelves
+ ADD COLUMN created_on TIMESTAMP NOT NULL AFTER lastmodified
+ |);
+ # Set created_on = lastmodified
+ # I would say it's better than 0000-00-00
+ # Set modified to the existing value (do not get the current ts!)
+ $dbh->do(q|
+ UPDATE virtualshelves
+ SET created_on = lastmodified, lastmodified = lastmodified
+ |);
+ print "Upgrade to $DBversion done (Bug 13421: Add DB field virtualshelves.created_on)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.039";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.040";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER TABLE aqorders DROP COLUMN totalamount
+ |);
+ print "Upgrade to $DBversion done (Bug 11006: Drop column aqorders.totalamount)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.041";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER IGNORE TABLE suggestions ADD KEY status (STATUS)
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE suggestions ADD KEY biblionumber (biblionumber)
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE suggestions ADD KEY branchcode (branchcode)
+ |);
+ print "Upgrade to $DBversion done (Bug 14132: suggestions table is missing indexes)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.042";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ DELETE ass.*
+ FROM auth_subfield_structure AS ass
+ LEFT JOIN auth_types USING(authtypecode)
+ WHERE auth_types.authtypecode IS NULL
+ });
+
+ $dbh->do(q{
+ ALTER IGNORE TABLE auth_subfield_structure
+ ADD CONSTRAINT auth_subfield_structure_ibfk_1
+ FOREIGN KEY (authtypecode) REFERENCES auth_types(authtypecode)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ });
+
+ print "Upgrade to $DBversion done (Bug 8480: Add foreign key on auth_subfield_structure.authtypecode)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.19.00.043";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
+ ('REPORT_GROUP', 'SER', 'Serials')
+ |);
+
+ print "Upgrade to $DBversion done (Bug 5338: Add Serial to the report groups if does not exist)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.20.00.000";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (Koha 3.20)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.000";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (El tiempo vuela, un nuevo ciclo comienza.)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.001";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ UPDATE systempreferences SET variable='IntranetUserJS' where variable='intranetuserjs'
+ |);
+ print "Upgrade to $DBversion done (Bug 12160: Rename intranetuserjs to IntranetUserJS)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.002";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ UPDATE systempreferences SET variable='OPACUserJS' where variable='opacuserjs'
+ |);
+ print "Upgrade to $DBversion done (Bug 12160: Rename opacuserjs to OPACUserJS)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.003";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added)
+ VALUES ( 'IN', 'region', 'India','2015-05-28');
+ |);
+ $dbh->do(q|
+ INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
+ VALUES ( 'IN', 'region', 'en', 'India');
+ |);
+ $dbh->do(q|
+ INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
+ VALUES ( 'IN', 'region', 'bn', 'ভারত');
+ |);
+ print "Upgrade to $DBversion done (Bug 14285: Add new region India)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.21.00.004';
+if ( CheckVersion($DBversion) ) {
+ my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
+ if (defined($OPACBaseURL) && substr($OPACBaseURL,0,4) ne "http") {
+ my $explanation = q{Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.};
+ $OPACBaseURL = 'http://' . $OPACBaseURL;
+ my $sth_OPACBaseURL = $dbh->prepare( q{
+ UPDATE systempreferences SET value=?,explanation=?
+ WHERE variable='OPACBaseURL'; } );
+ $sth_OPACBaseURL->execute($OPACBaseURL,$explanation);
+ }
+ if (defined($OPACBaseURL)) {
+ $dbh->do( q{ UPDATE letter
+ SET content=replace(content,
+ 'http://<<OPACBaseURL>>',
+ '<<OPACBaseURL>>')
+ WHERE content LIKE "%http://<<OPACBaseURL>>%"; } );
+ }
+
+ print "Upgrade to $DBversion done (Bug 5010: Fix OPACBaseURL to include protocol)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.005";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo')
+ |);
+ print "Upgrade to $DBversion done (Bug 14024: Add reports to action logs)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.006";
+if ( CheckVersion($DBversion) ) {
+ # Remove the borrow permission flag (bit 7)
+ $dbh->do(q|
+ UPDATE borrowers
+ SET flags = flags - ( flags & (1<<7) )
+ WHERE flags IS NOT NULL
+ AND flags > 0
+ |);
+ $dbh->do(q|
+ DELETE FROM userflags WHERE bit=7;
+ |);
+ print "Upgrade to $DBversion done (Bug 7976: Remove the 'borrow' permission)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.007";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER IGNORE TABLE aqbasket
+ ADD KEY authorisedby (authorisedby)
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE aqbooksellers
+ ADD KEY name (name(255))
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE aqbudgets
+ ADD KEY budget_parent_id (budget_parent_id),
+ ADD KEY budget_code (budget_code),
+ ADD KEY budget_branchcode (budget_branchcode),
+ ADD KEY budget_period_id (budget_period_id),
+ ADD KEY budget_owner_id (budget_owner_id)
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE aqbudgets_planning
+ ADD KEY budget_period_id (budget_period_id)
+ |);
+ $dbh->do(q|
+ ALTER IGNORE TABLE aqorders
+ ADD KEY parent_ordernumber (parent_ordernumber),
+ ADD KEY orderstatus (orderstatus)
+ |);
+ print "Upgrade to $DBversion done (Bug 14053: Acquisition db tables are missing indexes)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.008";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ DELETE IGNORE FROM systempreferences
+ WHERE variable = 'HomeOrHoldingBranchReturn';
+ });
+ print "Upgrade to $DBversion done (Bug 7981: Transfer message on return. HomeOrHoldingBranchReturn syspref removed in favour of circulation rules.)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.009";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ UPDATE aqorders SET orderstatus='cancelled'
+ WHERE (datecancellationprinted IS NOT NULL OR
+ datecancellationprinted<>'0000-00-00');
+ |);
+ print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.010";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ ALTER TABLE message_queue
+ DROP message_id
+ |);
+ $dbh->do(q|
+ ALTER TABLE message_queue
+ ADD message_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
+ |);
+ print "Upgrade to $DBversion done (Bug 7793: redefine the field message_id as PRIMARY KEY of message_queue)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.011";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('OpacLangSelectorMode','footer','top|both|footer','Select the location to display the language selector','Choice')
+ });
+ print "Upgrade to $DBversion done (Bug 14252: Make the OPAC language switcher available in the masthead navbar, footer, or both)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.012";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ INSERT INTO letter (module, code, name, title, content, message_transport_type)
+ VALUES
+ ('suggestions','TO_PROCESS','Notify budget owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.autho r>>.\n\nThank you,\n\n<<branches.branchname>>', 'email')
+ |);
+ print "Upgrade to $DBversion done (Bug 13014: Add the TO_PROCESS letter code)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.013";
+if ( CheckVersion($DBversion) ) {
+ my $msg;
+ if ( C4::Context->preference('OPACPrivacy') ) {
+ if ( my $anonymous_patron = C4::Context->preference('AnonymousPatron') ) {
+ my $anonymous_patron_exists = $dbh->selectcol_arrayref(q|
+ SELECT COUNT(*)
+ FROM borrowers
+ WHERE borrowernumber=?
+ |, {}, $anonymous_patron);
+ unless ( $anonymous_patron_exists->[0] ) {
+ $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not linked to an existing patron";
+ }
+ }
+ else {
+ $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not";
+ }
+ }
+ else {
+ my $patrons_have_required_anonymity = $dbh->selectcol_arrayref(q|
+ SELECT COUNT(*)
+ FROM borrowers
+ WHERE privacy = 2
+ |, {} );
+ if ( $patrons_have_required_anonymity->[0] ) {
+ $msg = "Configuration WARNING: OPACPrivacy is not set but $patrons_have_required_anonymity->[0] patrons have required anonymity (perhaps in a previous configuration). You should fix that asap.";
+ }
+ }
+
+ $msg //= "Privacy is correctly set";
+ print "Upgrade to $DBversion done (Bug 9942: $msg)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.014";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent) or might be deleted (transient)','transient|persistent','Choice')
+ });
+ $dbh->do(q|
+ ALTER TABLE oai_sets_biblios DROP FOREIGN KEY oai_sets_biblios_ibfk_1
+ |);
+ print "Upgrade to $DBversion done (Bug 3206: OAI repository deleted record support)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.015";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ UPDATE systempreferences SET value='0' WHERE variable='CalendarFirstDayOfWeek' AND value='Sunday';
+ });
+ $dbh->do(q{
+ UPDATE systempreferences SET value='1' WHERE variable='CalendarFirstDayOfWeek' AND value='Monday';
+ });
+ $dbh->do(q{
+ UPDATE systempreferences SET options='0|1|2|3|4|5|6' WHERE variable='CalendarFirstDayOfWeek';
+ });
+
+ print "Upgrade to $DBversion done (Bug 12137: Extend functionality of CalendarFirstDayOfWeek to be any day)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.016";
+if ( CheckVersion($DBversion) ) {
+ my $rs = $schema->resultset('Systempreference');
+ $rs->find_or_create(
+ {
+ variable => 'DumpTemplateVarsIntranet',
+ value => 0,
+ explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',
+ type => 'YesNo',
+ }
+ );
+ $rs->find_or_create(
+ {
+ variable => 'DumpTemplateVarsOpac',
+ value => 0,
+ explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',
+ type => 'YesNo',
+ }
+ );
+ print "Upgrade to $DBversion done (Bug 13948: Add ability to dump template toolkit variables to html comment)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "XXX";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+ VALUES('uploadPath','','Sets the upload path for the upload.pl plugin','','');
+ ");
+
+ $dbh->do("
+ CREATE TABLE uploaded_files (
+ id CHAR(40) NOT NULL PRIMARY KEY,
+ filename TEXT NOT NULL,
+ dir TEXT NOT NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ ");
+
+ print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
+ print "This plugin comes with a new syspref (uploadPath) and a new table (uploaded_files)\n";
+ print "To use it, set 'uploadPath' and 'OPACBaseURL' system preferences and link this plugin to a subfield (856\$u for instance)\n";
+ SetVersion($DBversion);
+}
+
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.
return 1 if ( $proposed_version =~ m/XXX/ );
if ( C4::Context->preference("Version") < $version_number
- && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
+ && $version_number <= TransformToNum( $Koha::VERSION ) )
{
return 1;
}