@@ -, +, @@ --- installer/data/mysql/atomicupdate/bug_12933.sql | 5 + .../data/mysql/de-DE/mandatory/sample_notices.sql | 8 +- .../data/mysql/en/mandatory/sample_notices.sql | 8 +- .../mysql/fr-FR/1-Obligatoire/sample_notices.sql | 8 +- .../mysql/nb-NO/1-Obligatorisk/sample_notices.sql | 8 +- .../data/mysql/pl-PL/mandatory/sample_notices.sql | 8 +- .../data/mysql/ru-RU/mandatory/sample_notices.sql | 8 +- .../data/mysql/uk-UA/mandatory/sample_notices.sql | 8 +- installer/data/mysql/updatedatabase.pl | 1157 +------------------- 9 files changed, 78 insertions(+), 1140 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12933.sql --- a/installer/data/mysql/atomicupdate/bug_12933.sql +++ a/installer/data/mysql/atomicupdate/bug_12933.sql @@ -0,0 +1,5 @@ +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/de-DE/mandatory/sample_notices.sql +++ a/installer/data/mysql/de-DE/mandatory/sample_notices.sql @@ -135,4 +135,10 @@ Ihr Biblioheksteam' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Benachrichtigung bei Zugang', 'Bestelltes Medium ist eingetroffen', 'Liebe/r <> <>,\n\nDie Bestellung <> (<>) ist eingetroffen und wird bearbeitet.\n\nIhr Bibliotheksteam', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Benachrichtigung bei Zugang', 'Bestelltes Medium ist eingetroffen', 'Liebe/r <> <>,\n\nDie Bestellung <> (<>) ist eingetroffen und wird bearbeitet.\n\nIhr Bibliotheksteam', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ a/installer/data/mysql/en/mandatory/sample_notices.sql @@ -154,4 +154,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql +++ a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql @@ -150,4 +150,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql +++ a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql @@ -169,4 +169,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql +++ a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql @@ -147,4 +147,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql +++ a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql @@ -149,4 +149,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql +++ a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql @@ -148,4 +148,10 @@ Your library.' ); INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) -VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') +VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email'); + +INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type ) +VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue: + +"<>" by <>, <>, Barcode: <> Fine: <> +', 'print' ); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6,18 +6,18 @@ # Parts copyright Catalyst IT 2011 # Part of the Koha Library Software www.koha-community.org -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. # -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Bugs/ToDo: @@ -37,8 +37,6 @@ use Getopt::Long; use C4::Context; use C4::Installer; use C4::Dates; -use Koha::Database; -use Koha; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); @@ -59,8 +57,6 @@ my ( $prefitem, # preference item in systempreferences table ); -my $schema = Koha::Database->new()->schema(); - my $silent; GetOptions( 's' =>\$silent @@ -3813,8 +3809,8 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { print "Upgrade to $DBversion done (3.2.0 general release)\n"; SetVersion ($DBversion); } -# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't +# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't # apply updates that have already been done $DBversion = "3.03.00.001"; @@ -4945,52 +4941,10 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $DBversion = "3.07.00.029"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { - $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;}); - $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;}); - $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;}); - $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;}); - - $dbh->do(q{ - CREATE TABLE `oai_sets` ( - `id` int(11) NOT NULL auto_increment, - `spec` varchar(80) NOT NULL UNIQUE, - `name` varchar(80) NOT NULL, - PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - }); - - $dbh->do(q{ - CREATE TABLE `oai_sets_descriptions` ( - `set_id` int(11) NOT NULL, - `description` varchar(255) NOT NULL, - CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - }); - - $dbh->do(q{ - CREATE TABLE `oai_sets_mappings` ( - `set_id` int(11) NOT NULL, - `marcfield` char(3) NOT NULL, - `marcsubfield` char(1) NOT NULL, - `marcvalue` varchar(80) NOT NULL, - CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - }); - - $dbh->do(q{ - CREATE TABLE `oai_sets_biblios` ( - `biblionumber` int(11) NOT NULL, - `set_id` int(11) NOT NULL, - PRIMARY KEY (`biblionumber`, `set_id`), - CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - }); - - $dbh->do(q{ - INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo'); - }); - + my $installer = C4::Installer->new(); + my $full_path = C4::Context->config('intranetdir') . "/installer/data/$installer->{dbms}/atomicupdate/oai_sets.sql"; + my $error = $installer->load_sql($full_path); + warn $error if $error; print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n"; SetVersion($DBversion); } @@ -5006,7 +4960,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $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->preference('HomeOrHoldingBranchReturn') || 'homebranch'; + my $homeorholdingbranchreturn = C4::Context->prefernce('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); @@ -9668,7 +9622,7 @@ if ( CheckVersion($DBversion) ) { DROP INDEX userid , ADD UNIQUE userid (userid) }); - print "Upgrade to $DBversion done (Bug 1861: Unique patrons logins not (totally) enforced)\n"; + print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n"; } SetVersion($DBversion); @@ -9698,1086 +9652,23 @@ if(CheckVersion($DBversion)) { ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL }); - print "Upgrade to $DBversion done (Bug 13379: Modify authorised_values.category to varchar(32))\n"; + print "Upgrade to $DBversion done (Bug 13379 - Modify authorised_values.category to varchar(32))\n"; SetVersion($DBversion); } $DBversion = "3.19.00.006"; if ( CheckVersion($DBversion) ) { - $dbh->do(q|SET foreign_key_checks = 0|); - my $sth = $dbh->table_info( '','','','TABLE' ); - my ( $cat, $schema, $name, $type, $remarks ); - while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) { - my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|); - $table_sth->execute; - my @table = $table_sth->fetchrow_array; - unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables - if ( $name eq 'marc_subfield_structure' ) { - $dbh->do(q| - ALTER TABLE marc_subfield_structure - MODIFY COLUMN tagfield varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '', - MODIFY COLUMN liblibrarian varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - MODIFY COLUMN libopac varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - MODIFY COLUMN kohafield varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, - MODIFY COLUMN authorised_value varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - MODIFY COLUMN authtypecode varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - MODIFY COLUMN value_builder varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL, - MODIFY COLUMN frameworkcode varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - MODIFY COLUMN seealso varchar(1100) COLLATE utf8_unicode_ci DEFAULT NULL, - MODIFY COLUMN link varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL - |); - } - else { - $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|); - } - } + $dbh->do(q|SET foreign_key_checks = 0|);; + my @tables = $dbh->tables(); + for my $table ( @tables ) { + $dbh->do(qq|ALTER TABLE $table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|); } $dbh->do(q|SET foreign_key_checks = 1|);; - print "Upgrade to $DBversion done (Bug 11944: Convert DB tables to utf8_unicode_ci)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.007"; -if ( CheckVersion($DBversion) ) { - my $orphan_budgets = $dbh->selectall_arrayref(q| - SELECT budget_id, budget_name, budget_code - FROM aqbudgets - WHERE budget_parent_id IS NOT NULL - AND budget_parent_id NOT IN ( - SELECT DISTINCT budget_id FROM aqbudgets - ) - |, { Slice => {} } ); - - if ( @$orphan_budgets ) { - for my $b ( @$orphan_budgets ) { - print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n"; - } - print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n"; - } else { - print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n"; - } - SetVersion($DBversion); -} - -$DBversion = "3.19.00.008"; -if ( CheckVersion($DBversion) ) { - my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q| - SELECT COUNT(*) - FROM aqorders o - WHERE NOT EXISTS ( - SELECT NULL - FROM aqbudgets b - WHERE b.budget_id = o.budget_id - ); - |); - - if ( $number_of_orders_not_linked->[0] > 0 ) { - $dbh->do(q| - INSERT INTO aqbudgetperiods(budget_period_startdate, budget_period_enddate, budget_period_active, budget_period_description, budget_period_total) VALUES ( CAST(NOW() AS date), CAST(NOW() AS date), 0, "WARNING: This budget has been automatically created by the updatedatabase script, please see bug 12601 for more information", 0) - |); - my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef ); - $dbh->do(qq| - INSERT INTO aqbudgets(budget_code, budget_name, budget_amount, budget_period_id) VALUES ( "BACKUP_TMP", "WARNING: fund created by the updatedatabase script, please see bug 12601", 0, $budget_period_id ); - |); - my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef ); - $dbh->do(qq| - UPDATE aqorders o - SET budget_id = $budget_id - WHERE NOT EXISTS ( - SELECT NULL - FROM aqbudgets b - WHERE b.budget_id = o.budget_id - ) - |); - } - - $dbh->do(q| - ALTER TABLE aqorders - ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE - |); - - print "Upgrade to $DBversion done (Bug 12601: Add new foreign key aqorders.budget_id" . ( ( $number_of_orders_not_linked->[0] > 0 ) ? ' WARNING: temporary budget and fund have been created (search for "BACKUP_TMP"). At least one of your order was not linked to a budget' : '' ) . ")\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.009"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - UPDATE suggestions s SET s.budgetid = NULL - WHERE NOT EXISTS ( - SELECT NULL - FROM aqbudgets b - WHERE b.budget_id = s.budgetid - ); - |); - - $dbh->do(q| - ALTER TABLE suggestions - ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE - |); - - print "Upgrade to $DBversion done (Bug 13007: Add new foreign key suggestions.budgetid)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.010"; -if ( CheckVersion($DBversion) ) { - $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); -} - -$DBversion = "3.19.00.011"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES - (20, 'lists', 'Lists', 0) - |); - $dbh->do(q| - INSERT INTO permissions (module_bit, code, description) VALUES - (20, 'delete_public_lists', 'Delete public lists') - |); - print "Upgrade to $DBversion done (Bug 13417: Add permission to delete public lists)\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.012"; -if(CheckVersion($DBversion)) { - $dbh->do(q{ - ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext - }); - - $dbh->do(q{ - ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext - }); - - print "Upgrade to $DBversion done (Bug 13523 Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.013"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT INTO permissions (module_bit, code, description) VALUES - (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)') - |); - print "Upgrade to $DBversion done (Bug 11395: Add permission tools_records_batchmod)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.014"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - CREATE TABLE aqorder_users ( - ordernumber int(11) NOT NULL, - borrowernumber int(11) NOT NULL, - PRIMARY KEY (ordernumber, borrowernumber), - CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - |); - - $dbh->do(q| - INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) - VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <> <>,\n\n The order <> (<>) has been received.\n\nYour library.', 'email') - |); - print "Upgrade to $DBversion done (Bug 12648: Add letter ACQ_NOTIF_ON_RECEIV )\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.015"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id); - |); - print "Upgrade to $DBversion done (Bug 11430: Add primary key for search_history)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.016"; -if(CheckVersion($DBversion)) { - my @order_cancellation_reason = $dbh->selectrow_array("SELECT count(*) FROM authorised_values WHERE category='ORDER_CANCELLATION_REASON'"); - if ($order_cancellation_reason[0] == 0) { - $dbh->do(q{ - INSERT INTO authorised_values (category, authorised_value, lib) VALUES - ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'), - ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'), - ('ORDER_CANCELLATION_REASON', 2, 'Restocking') - }); - - my $already_existing_reasons = $dbh->selectcol_arrayref(q{ - SELECT DISTINCT( cancellationreason ) - FROM aqorders; - }, { Slice => {} }); - - my $update_orders_sth = $dbh->prepare(q{ - UPDATE aqorders - SET cancellationreason = ? - WHERE cancellationreason = ? - }); - - my $insert_av_sth = $dbh->prepare(q{ - INSERT INTO authorised_values (category, authorised_value, lib) VALUES - ('ORDER_CANCELLATION_REASON', ?, ?) - }); - my $i = 3; - for my $reason ( @$already_existing_reasons ) { - next unless $reason; - $insert_av_sth->execute( $i, $reason ); - $update_orders_sth->execute( $i, $reason ); - $i++; - } - print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n"; - } - else { - print "Upgrade to $DBversion done (Bug 13380: ORDER_CANCELLATION_REASON authorised value already existed from earlier update!)\n"; - } - - SetVersion($DBversion); -} - -$DBversion = '3.19.00.017'; -if ( CheckVersion($DBversion) ) { - # First create the column - $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL"); - # Now update the column - if (C4::Context->preference("AllowOnShelfHolds")){ - # Pref is on, set allow for all rules - $dbh->do("UPDATE issuingrules SET onshelfholds=1"); - } else { - # If the preference is not set, leave off - $dbh->do("UPDATE issuingrules SET onshelfholds=0"); - } - # Remove from the systempreferences table - $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'"); - - # First create the column - $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL"); - # Now update the column - my $opacitemholds = C4::Context->preference("OPACItemHolds") || ''; - if (lc ($opacitemholds) eq 'force') { - $opacitemholds = 'F'; - } - else { - $opacitemholds = $opacitemholds ? 'Y' : 'N'; - } - # Set allow for all rules - $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'"); - - # Remove from the systempreferences table - $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'"); - - print "Upgrade to $DBversion done (Bug 5786: Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n"; - SetVersion ($DBversion); -} - - -$DBversion = "3.19.00.018"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - UPDATE systempreferences set variable="OpacAdditionalStylesheet" WHERE variable="opaccolorstylesheet" - |); - print "Upgrade to $DBversion done (Bug 10328: Rename opaccolorstylesheet to OpacAdditionalStylesheet\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.019"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) - VALUES('Coce','0', 'If on, enables cover retrieval from the configured Coce server', NULL, 'YesNo') - }); - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) - VALUES('CoceHost', NULL, 'Coce server URL', NULL,'Free') - }); - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) - VALUES('CoceProviders', NULL, 'Coce providers', 'aws,gb,ol', 'multiple') - }); - print "Upgrade to $DBversion done (Bug 9580: Cover image from Coce, a remote image URL cache)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.020"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - ALTER TABLE aqorders DROP COLUMN supplierreference; - |); - - print "Upgrade to $DBversion done (Bug 11008: DROP column aqorders.supplierreference)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.021"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - ALTER TABLE issues DROP COLUMN issuingbranch - |); - $dbh->do(q| - ALTER TABLE old_issues DROP COLUMN issuingbranch - |); - print "Upgrade to $DBversion done (Bug 2806: Remove issuingbranch columns)\n"; - SetVersion ($DBversion); -} - -$DBversion = '3.19.00.022'; -if ( CheckVersion($DBversion) ) { - $dbh->do(q{ - ALTER TABLE suggestions DROP COLUMN mailoverseeing; - }); - print "Upgrade to $DBversion done (Bug 13006: Drop column suggestion.mailoverseeing)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.023"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - DELETE FROM systempreferences where variable = 'AddPatronLists' - |); - print "Upgrade to $DBversion done (Bug 13497: Remove the AddPatronLists system preferences)\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.024"; -if ( CheckVersion($DBversion) ) { - $dbh->do(qq|DROP table patroncards;|); - print "Upgrade to $DBversion done (Bug 13539: Remove table patroncards from database as it's no longer in use)\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.025"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES - ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo') - |); - print "Upgrade to $DBversion done (Bug 13528: Add the SearchWithISBNVariations syspref)\n"; + print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n"; SetVersion ($DBversion); } -$DBversion = "3.19.00.026"; -if( CheckVersion($DBversion) ) { - if ( C4::Context->preference('marcflavour') eq 'MARC21' ) { - $dbh->do(q{ - INSERT IGNORE INTO auth_tag_structure (authtypecode, tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value) VALUES - ('', '388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL); - }); - - $dbh->do(q{ - 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 - ('', '388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '388', '2', 'Source of term', 'Source of term', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '388', '3', 'Materials specified', 'Materials specified', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '388', '6', 'Linkage', 'Linkage', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''); - }); - - $dbh->do(q{ - UPDATE IGNORE auth_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND tagfield IN - ('100','110','111','130','400','410','411','430','500','510','511','530','700','710','730'); - }); - - $dbh->do(q{ - 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 - ('', '150', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '151', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '450', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '451', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '550', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '551', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '750', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '751', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '748', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '755', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '780', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '781', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '782', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '785', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '710', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '730', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '748', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '750', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '751', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '755', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '762', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '780', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '781', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '782', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '785', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''), - ('', '788', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''); - }); - - $dbh->do(q{ - UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship information', libopac = 'Relationship information' - WHERE tagsubfield = 'i' AND tagfield IN ('700','710','730','750','751','762'); - }); - - $dbh->do(q{ - UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship code', libopac = 'Relationship code' - WHERE tagsubfield = '4' AND tagfield IN ('700','710'); - }); - - $dbh->do(q{ - INSERT IGNORE INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) VALUES - ('370', 'ASSOCIATED PLACE', 'ASSOCIATED PLACE', 1, 0, NULL, ''), - ('388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL, ''); - }); - - $dbh->do(q{ - 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 - ('370', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', '6', 'Linkage', 'Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 'c', 'Associated country', 'Associated country', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 'f', 'Other associated place', 'Other associated place', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 'g', 'Place of origin of work', 'Place of origin of work', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 's', 'Start period', 'Start period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 't', 'End period', 'End period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('370', 'v', 'Source of information', 'Source of information', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('377', 'l', 'Language term', 'Language term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('382', 's', 'Total number of performers', 'Total number of performers', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', '3', ' Materials specified', ' Materials specified', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', '6', ' Linkage', ' Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL), - ('650', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL), - ('651', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL); - }); - - $dbh->do(q{ - UPDATE IGNORE marc_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND - tagfield IN ('100','110','111','130','240','243','246','247','600','610','611','630','700','710','711','730','800','810','811','830'); - }); - } - - print "Upgrade to $DBversion done (Bug 13322: Update MARC21 frameworks to Update No. 19 - October 2014)\n"; - SetVersion($DBversion); -} - -$DBversion = '3.19.00.027'; -if ( CheckVersion($DBversion) ) { - $dbh->do("ALTER TABLE items ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes"); - $dbh->do("ALTER TABLE deleteditems ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes"); - print "Upgrade to $DBversion done (Bug 4222: Nonpublic note not appearing in the staff client) Please check each of your frameworks to ensure your non-public item notes are mapped to items.itemnotes_nonpublic. After doing so please have your administrator run misc/batchRebuildItemsTables.pl )\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.028"; -if( CheckVersion($DBversion) ) { - eval { - local $dbh->{PrintError} = 0; - $dbh->do(q{ - ALTER TABLE issues DROP PRIMARY KEY - }); - }; - - $dbh->do(q{ - ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST - }); - - $dbh->do(q{ - ALTER TABLE old_issues CHANGE issue_id issue_id INT( 11 ) NOT NULL - }); - - $dbh->do(q{ - ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST - }); - - $dbh->do(q{ - UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC - }); - - my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max(); - if ($max_issue_id) { - $max_issue_id++; - $dbh->do(qq{ - ALTER TABLE issues AUTO_INCREMENT = $max_issue_id - }); - } - - print "Upgrade to $DBversion done (Bug 13790: Add unique id issue_id to issues and oldissues tables)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.029"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - ALTER TABLE sessions CHANGE COLUMN a_session a_session MEDIUMTEXT - |); - print "Upgrade to $DBversion done (Bug 13606: Upgrade sessions.a_session to MEDIUMTEXT)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.030"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| -UPDATE language_subtag_registry SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada'; - |); - $dbh->do(q| -UPDATE language_rfc4646_to_iso639 SET rfc4646_subtag = 'kn' WHERE rfc4646_subtag = 'ka' AND iso639_2_code = 'kan'; - |); - $dbh->do(q| -UPDATE language_descriptions SET subtag = 'kn', lang = 'kn' WHERE subtag = 'ka' AND lang = 'ka' AND description = 'ಕನ್ನಡ'; - |); - $dbh->do(q| -UPDATE language_descriptions SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada'; - |); - $dbh->do(q| -INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Georgian','2015-04-20'); - |); - $dbh->do(q| -DELETE FROM language_subtag_registry - WHERE NOT id IN - (SELECT id FROM - (SELECT MIN(id) as id,subtag,type,description,added - FROM language_subtag_registry - GROUP BY subtag,type,description,added) - AS subtable); - |); - $dbh->do(q| -INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka', 'geo'); - |); - $dbh->do(q| -DELETE FROM language_rfc4646_to_iso639 - WHERE NOT id IN - (SELECT id FROM - (SELECT MIN(id) as id,rfc4646_subtag,iso639_2_code - FROM language_rfc4646_to_iso639 - GROUP BY rfc4646_subtag,iso639_2_code) - AS subtable); - |); - $dbh->do(q| -INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ქართული'); - |); - $dbh->do(q| -INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Georgian'); - |); - $dbh->do(q| -INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'fr', 'Géorgien'); - |); - $dbh->do(q| -INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'de', 'Georgisch'); - |); - $dbh->do(q| -INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'es', 'Georgiano'); - |); - $dbh->do(q| -DELETE FROM language_descriptions - WHERE NOT id IN - (SELECT id FROM - (SELECT MIN(id) as id,subtag,type,lang,description - FROM language_descriptions GROUP BY subtag,type,lang,description) - AS subtable); - |); - print "Upgrade to $DBversion done (Bug 14030: Add Georgian language and fix Kannada language code)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.031"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) - VALUES('IdRef','0','Disable/enable the IdRef webservice from the OPAC detail page.',NULL,'YesNo') - }); - print "Upgrade to $DBversion done (Bug 8992: Add system preference IdRef))\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.032"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) - VALUES('AddressFormat','us','Choose format to display postal addresses','','Choice') - |); - print "Upgrade to $DBversion done (Bug 4041: Address Format as a I18N/L10N system preference\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.033"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - ALTER TABLE auth_header - CHANGE COLUMN datemodified modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP - |); - $dbh->do(q| - ALTER TABLE auth_header - CHANGE COLUMN modification_time modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP - |); - print "Upgrade to $DBversion done (Bug 11165: Update auth_header.datemodified when updated)\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.034"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) - VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free') - |); - print "Upgrade to $DBversion done (Bug 13984: CardnumberLength syspref missing on some setups\n"; - SetVersion ($DBversion); -} - -$DBversion = "3.19.00.035"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('useDischarge','','Allows librarians to discharge borrowers and borrowers to request a discharge','','YesNo') - |); - $dbh->do(q| - INSERT IGNORE INTO letter (module, code, name, title, content) VALUES('members', 'DISCHARGE', 'Discharge', 'Discharge for <> <>', '

Discharge

\r\n\r\nThe library <> certifies that the following borrower :\r\n\r\n <> <>\r\n Cardnumber : <>\r\n\r\nreturned all his documents.') - |); - - $dbh->do(q| - ALTER TABLE borrower_debarments CHANGE type type ENUM('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL' - |); - - $dbh->do(q| - CREATE TABLE discharges ( - borrower int(11) DEFAULT NULL, - needed timestamp NULL DEFAULT NULL, - validated timestamp NULL DEFAULT NULL, - KEY borrower_discharges_ibfk1 (borrower), - CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - |); - - print "Upgrade to $DBversion done (Bug 8007: Add System Preferences useDischarge, the discharge notice and the new table discharges)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.19.00.036"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q| - INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) - VALUES ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo') - |); - print "Upgrade to $DBversion done (Bug 13889: Add cron jobs information to system log)\n"; - 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://<>', - '<>') - WHERE content LIKE "%http://<>%"; } ); - } - - 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 <> <>,\n\nA new suggestion is ready to be processed: <> by <>.\n\nThank you,\n\n<>', '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 = "3.21.00.017"; -if ( CheckVersion($DBversion) ) { - $dbh->do(" - CREATE TABLE uploaded_files ( - id int(11) NOT NULL AUTO_INCREMENT, - hashvalue CHAR(40) NOT NULL, - filename TEXT NOT NULL, - dir TEXT NOT NULL, - filesize int(11), - dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - categorycode tinytext, - owner int(11), - PRIMARY KEY (id) - ) 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 config variable (upload_path) and a new table (uploaded_files)\n"; - print "To use it, set 'upload_path' config variable and 'OPACBaseURL' system preference and link this plugin to a subfield (856\$u for instance)\n"; - SetVersion($DBversion); -} - -$DBversion = "3.21.00.018"; -if ( CheckVersion($DBversion) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) - VALUES - ('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: \"127.0.0,127.0.2\")','Free'), - ('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'), - ('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free') - }); - print "Upgrade to $DBversion done (Bug 13485: Add a page to display links to restricted sites)\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. - -my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -opendir( my $dirh, $update_dir ); -foreach my $file ( sort readdir $dirh ) { - next if $file !~ /\.(sql|perl)$/; #skip other files - print "DEV atomic update: $file\n"; - if ( $file =~ /\.sql$/ ) { - my $installer = C4::Installer->new(); - my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1; - } elsif ( $file =~ /\.perl$/ ) { - do $update_dir . $file; - } -} - =head1 FUNCTIONS =head2 TableExists($table) @@ -10880,7 +9771,7 @@ sub CheckVersion { return 1 if ( $proposed_version =~ m/XXX/ ); if ( C4::Context->preference("Version") < $version_number - && $version_number <= TransformToNum( $Koha::VERSION ) ) + && $version_number <= TransformToNum( C4::Context->final_linear_version ) ) { return 1; } --