$dbh->do(q|
INSERT IGNORE INTO letter (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
- VALUES ('circulation', 'PATRON_NOTE', '', 'Patron note on item', '0', 'Patron issue note', '<<borrowers.firstname>> <<borrowers.surname>> has added a note to the item <<biblio.item>> - <<biblio.author>> (<<biblio.biblionumber>>).','email');
+ VALUES ('circulation', 'CHECKOUT_NOTE', '', 'Checkout note on item set by patron', '0', 'Checkout note', '<<borrowers.firstname>> <<borrowers.surname>> has added a note to the item <<biblio.title>> - <<biblio.author>> (<<biblio.biblionumber>>).','email');
|);
$dbh->do(q|
$requested_expiration = dt_from_string($hold->expirationdate);
}
- my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
- my $expirationdate = dt_from_string();
- $expirationdate->add(days => $max_pickup_delay);
-
+ my $expirationdate = dt_from_string($hold->waitingdate);
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
- $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
+ my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
+ $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
+ } else {
+ $expirationdate->add( days => $max_pickup_delay );
}
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
print "Upgrade to $DBversion done (Bug 8612 - Add new column export_format.used_for)\n";
}
+$DBversion = '17.06.00.002';
+if ( CheckVersion($DBversion) ) {
+
+ unless ( column_exists('virtualshelves', 'allow_change_from_owner' ) ) {
+ $dbh->do(q|
+ ALTER TABLE virtualshelves
+ ADD COLUMN allow_change_from_owner tinyint(1) default 1,
+ ADD COLUMN allow_change_from_others tinyint(1) default 0
+ |);
+
+ # Conversion:
+ # Since we had no readonly lists, change_from_owner is set to true.
+ # When adding or delete_other was granted, change_from_others is true.
+ # Note: In my opinion the best choice; there is no exact match.
+ $dbh->do(q|
+ UPDATE virtualshelves
+ SET allow_change_from_owner = 1,
+ allow_change_from_others = CASE WHEN allow_add=1 OR allow_delete_other=1 THEN 1 ELSE 0 END
+ |);
+
+ # Remove the old columns
+ $dbh->do(q|
+ ALTER TABLE virtualshelves
+ DROP COLUMN allow_add,
+ DROP COLUMN allow_delete_own,
+ DROP COLUMN allow_delete_other
+ |);
+ }
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 18228 - Alter table virtualshelves to simplify permissions)\n";
+}
+
+$DBversion = '17.06.00.003';
+if ( CheckVersion($DBversion) ) {
+
+ # Fetch all auth types
+ my $authtypes = $dbh->selectcol_arrayref(q|SELECT authtypecode FROM auth_types|);
+
+ if ( grep { $_ eq 'Default' } @$authtypes ) {
+
+ # If this exists as an authtypecode, we don't do anything
+ }
+ else {
+ # Replace the incorrect Default by empty string
+ $dbh->do(q|
+ UPDATE auth_header SET authtypecode='' WHERE authtypecode='Default'
+ |);
+ }
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 18801 - Update incorrect Default auth type codes)\n";
+}
+
+$DBversion = '17.06.00.004';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('GoogleOpenIDConnectAutoRegister', '0',NULL,' Google OpenID Connect logins to auto-register patrons.','YesNo'),
+ ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'),
+ ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 16892: Add automatic patron registration via OAuth2 login)\n";
+}
+
+$DBversion = '17.06.00.005';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff client','Choice')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18718 - Language selector in staff header menu similar to OPAC )\n";
+}
+
+$DBversion = '17.06.00.006';
+if( CheckVersion( $DBversion ) ) {
+ print q{WARNING: Bug 18811 fixed an inconsistency in the visibility settings for authority frameworks. It is recommended that you run script misc/maintenance/auth_show_hidden_data.pl to check if you have data in hidden fields and adjust your frameworks accordingly to prevent data loss when editing such records.};
+ print "\n";
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18811 - Visibility settings inconsistent between framework and authority editor)\n";
+}
+
+$DBversion = '17.06.00.007';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'branches', 'marcorgcode' ) ) {
+ $dbh->do( "ALTER TABLE branches ADD COLUMN marcorgcode VARCHAR(16) default NULL AFTER geolocation" );
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 10132 - MARCOrgCode on branch level (branches.marcorgcode))\n";
+}
+
+$DBversion = '17.06.00.008';
+if( CheckVersion( $DBversion ) ) {
+ unless ( column_exists( 'borrowers', 'date_renewed' ) ) {
+ $dbh->do(q{
+ ALTER TABLE borrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
+ });
+ }
+
+ unless ( column_exists( 'deletedborrowers', 'date_renewed' ) ) {
+ $dbh->do(q{
+ ALTER TABLE deletedborrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
+ });
+ }
+
+ unless ( column_exists( 'borrower_modifications', 'date_renewed' ) ) {
+ $dbh->do(q{
+ ALTER TABLE borrower_modifications ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 6758 - Capture membership renewal date for reporting purposes (borrowers.date_renewed))\n";
+}
+
+$DBversion = '17.06.00.009';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) AFTER lang;
+ });
+ $dbh->do(q{
+ ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) AFTER lang;
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19344 - Reorder lang and login_attempts in the [deleted]borrowers tables)\n";
+}
+
+$DBversion = '17.06.00.010';
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
+ VALUES (
+ 'DefaultCountryField008','','',
+ 'Fill in the default country code for field 008 Range 15-17 of MARC21 - Place of publication, production, or execution. See <a href=\"http://www.loc.gov/marc/countries/countries_code.html\">MARC Code List for Countries</a>','Free')
+ });
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 13912 - System preference for default place of publication (country code) for field 008, range 15-17)\n";
+}
+
+$DBversion = '17.06.00.011';
+if ( CheckVersion($DBversion) ) {
+ # Drop index that might exist because of bug 5337
+ if( index_exists('biblioitems', 'ean')) {
+ $dbh->do(q{ ALTER TABLE biblioitems DROP INDEX ean });
+ }
+ if( index_exists('deletedbiblioitems', 'ean')) {
+ $dbh->do(q{ ALTER TABLE deletedbiblioitems DROP INDEX ean });
+ }
+
+ # Change data type of column
+ $dbh->do(q{ ALTER TABLE biblioitems MODIFY COLUMN ean MEDIUMTEXT default NULL });
+ $dbh->do(q{ ALTER TABLE deletedbiblioitems MODIFY COLUMN ean MEDIUMTEXT default NULL });
+
+ # Add indexes
+ $dbh->do(q{ ALTER TABLE biblioitems ADD INDEX ean ( ean(255) )});
+ $dbh->do(q{ ALTER TABLE deletedbiblioitems ADD INDEX ean ( ean(255 ) )});
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 13766 - Make ean mediumtext and add ean indexes)\n";
+}
+
+$DBversion = '17.06.00.012';
+if( CheckVersion( $DBversion ) ) {
+ my $where = q|host='clio-db.cc.columbia.edu' AND port=7090|;
+ my $sql = "SELECT COUNT(*) FROM z3950servers WHERE $where";
+ my ( $cnt ) = $dbh->selectrow_array( $sql );
+ if( $cnt ) {
+ $dbh->do( "DELETE FROM z3950servers WHERE $where" );
+ print "Removed $cnt Z39.50 target(s) for Columbia University\n";
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19043 - Z39.50 target for Columbia University is no longer publicly available.)\n";
+}
+
+$DBversion = '17.06.00.013';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( "UPDATE systempreferences SET value = CONCAT('http://', value) WHERE variable = 'staffClientBaseURL' AND value <> '' AND value NOT LIKE 'http%'" );
+
+ my ( $staffClientBaseURL_used_in_notices ) = $dbh->selectrow_array(q|
+ SELECT COUNT(*) FROM letter where content like "%staffClientBaseURL%"
+ |);
+ if ( $staffClientBaseURL_used_in_notices ) {
+ warn "\tYou may need to update one or more notice templates if they contain 'staffClientBaseURL'\n";
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 16401 - fix potentialy bad set staffClientBaseURL preference)\n";
+}
+
+$DBversion = '17.06.00.014';
+if( CheckVersion( $DBversion ) ) {
+ unless( column_exists('aqbasket','create_items') ){
+ $dbh->do(q{
+ ALTER TABLE aqbasket
+ ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL AFTER is_standing
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15685 - Allow creation of items (AcqCreateItem) to be customizable per-basket)\n";
+}
+
+$DBversion = '17.06.00.015';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
+ ('SelfCheckoutByLogin','0',NULL,'Have patrons login into the web-based self checkout system with their username/password or their cardnumber','YesNo')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19186 - Insert system preference SelfCheckoutByLogin if missing)\n";
+}
+
+$DBversion = '17.06.00.016';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
+ VALUES ('RequireStrongPassword','0','','Require a strong login password for staff and patrons','YesNo');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18298 - Allow enforcing password complexity (system preference RequireStrongPassword))\n";
+}
+
+$DBversion = '17.06.00.017';
+if( CheckVersion( $DBversion ) ) {
+ unless (TableExists('account_offsets')) {
+ $dbh->do(q{
+ DROP TABLE IF EXISTS `accountoffsets`;
+ });
+
+ $dbh->do(q{
+ CREATE TABLE IF NOT EXISTS `account_offset_types` (
+ `type` varchar(16) NOT NULL, -- The type of offset this is
+ PRIMARY KEY (`type`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ });
+
+ $dbh->do(q{
+ CREATE TABLE IF NOT EXISTS `account_offsets` (
+ `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
+ `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
+ `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
+ `type` varchar(16) NOT NULL, -- The type of offset this is
+ `amount` decimal(26,6) NOT NULL, -- The amount of the change
+ `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES
+ ('Writeoff'),
+ ('Payment'),
+ ('Lost Item'),
+ ('Processing Fee'),
+ ('Manual Debit'),
+ ('Reverse Payment'),
+ ('Forgiven'),
+ ('Dropbox'),
+ ('Rental Fee'),
+ ('Fine Update'),
+ ('Fine');
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 14826 - Resurrect account offsets table (Add new tables account_offsets and account_offset_types))\n";
+}
+
+$DBversion = '17.06.00.018';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES ('useDefaultReplacementCost',0,'default replacement cost defined in item type','YesNo');
+ });
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES ('ProcessingFeeNote','','Set the text to be recorded in the column note, table accountlines when the processing fee (defined in item type) is applied','textarea');
+ });
+ $dbh->do(q{
+ ALTER TABLE `itemtypes` MODIFY COLUMN `rentalcharge` DECIMAL(28,6) NULL DEFAULT NULL;
+ });
+ unless ( column_exists( 'itemtypes', 'defaultreplacecost' ) ) {
+ $dbh->do(q{
+ ALTER TABLE `itemtypes` ADD `defaultreplacecost` DECIMAL(28,6) NULL DEFAULT NULL AFTER `rentalcharge`;
+ });
+ }
+ unless ( column_exists( 'itemtypes', 'processfee' ) ) {
+ $dbh->do(q{
+ ALTER TABLE `itemtypes` ADD `processfee` DECIMAL(28,6) NULL DEFAULT NULL AFTER `defaultreplacecost`;
+ });
+
+ }
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 12768 - Insert system preferences useDefaultReplacementCost and ProcessingFeeNote + Add new columns defaultreplacecost and processfee to the itemtypes table)\n";
+}
+
+$DBversion = '17.06.00.019';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Processing Fee' );
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 12768 - Add 'Processing Fee' to the account_offset_types table if missing)\n";
+}
+
+$DBversion = '17.06.00.020';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ UPDATE systempreferences
+ SET
+ variable='OpacLocationOnDetail',
+ options='holding|home|both|column',
+ explanation='In the OPAC detail, display the shelving location on its own column or under a library columns.'
+ WHERE
+ variable='OpacLocationBranchToDisplayShelving'
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19028: Add 'shelving location' to holdings table in detail page (Rename syspref OpacLocationBranchToDisplayShelving with OpacLocationOnDetail))\n";
+}
+
+$DBversion = '17.06.00.021';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type` ) VALUES ('SCOMainUserBlock','','70|10','Add a block of HTML that will display on the self checkout screen','Textarea')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17381 - Add system preference SCOMainUserBlock)\n";
+}
+
+$DBversion = '17.06.00.022';
+if( CheckVersion( $DBversion ) ) {
+ my $hide_barcode = C4::Context->preference('OPACShowBarcode') ? 0 : 1;
+ $dbh->do(q{
+ DELETE FROM systempreferences
+ WHERE
+ variable='OPACShowBarcode'
+ });
+
+ # Configure column visibility if it isn't
+ $dbh->do(q{
+ INSERT IGNORE INTO columns_settings
+ (module,page,tablename,columnname,cannot_be_toggled,is_hidden)
+ VALUES
+ ('opac','biblio-detail','holdingst','item_barcode',0,?)
+ }, undef, $hide_barcode);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19038: Remove OPACShowBarcode syspref)\n";
+}
+
+$DBversion = '17.06.00.023';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('MarkLostItemsAsReturned','1','','Mark items as returned when flagged as lost','YesNo');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 12363 - Add system preference MarkLostItemsAsReturned)\n";
+}
+
+$DBversion = '17.06.00.024';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES
+ ('OPACUserSummary', 1, NULL, "Show the summary of a logged in user's checkouts, overdues, holds and fines on the mainpage", 'YesNo');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 2093 - Add system preference OPACUserSummary)\n";
+}
+
+$DBversion = '17.06.00.025';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ ALTER TABLE borrowers MODIFY cardnumber varchar(32);
+ });
+ $dbh->do(q{
+ ALTER TABLE borrower_modifications MODIFY cardnumber varchar(32);
+ });
+ $dbh->do(q{
+ ALTER TABLE deletedborrowers MODIFY cardnumber varchar(32);
+ });
+ $dbh->do(q{
+ ALTER TABLE pending_offline_operations MODIFY cardnumber varchar(32);
+ });
+ $dbh->do(q{
+ ALTER TABLE tmp_holdsqueue MODIFY cardnumber varchar(32);
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 13178 - Increase cardnumber fields to VARCHAR(32))\n";
+}
+
+$DBversion = '17.06.00.026';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+ ('BlockReturnOfLostItems','0','0','If enabled, items that are marked as lost cannot be returned.','YesNo');
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 10748 - Add system preference BlockReturnOfLostItems)\n";
+}
+
+$DBversion = '17.06.00.027';
+if( CheckVersion( $DBversion ) ) {
+ if ( !column_exists( 'statistics', 'location' ) ) {
+ $dbh->do('ALTER TABLE statistics ADD COLUMN location VARCHAR(80) default NULL AFTER itemtype');
+ }
+
+ SetVersion($DBversion);
+ print "Upgrade to $DBversion done (Bug 18882 - Add location code to statistics table for checkouts and renewals)\n";
+}
+
+$DBversion = '17.06.00.028';
+if( CheckVersion( $DBversion ) ) {
+ if ( !TableExists( 'illrequests' ) ) {
+ $dbh->do(q{
+ CREATE TABLE illrequests (
+ illrequest_id serial PRIMARY KEY, -- ILL request number
+ borrowernumber integer DEFAULT NULL, -- Patron associated with request
+ biblio_id integer DEFAULT NULL, -- Potential bib linked to request
+ branchcode varchar(50) NOT NULL, -- The branch associated with the request
+ status varchar(50) DEFAULT NULL, -- Current Koha status of request
+ placed date DEFAULT NULL, -- Date the request was placed
+ replied date DEFAULT NULL, -- Last API response
+ updated timestamp DEFAULT CURRENT_TIMESTAMP -- Last modification to request
+ ON UPDATE CURRENT_TIMESTAMP,
+ completed date DEFAULT NULL, -- Date the request was completed
+ medium varchar(30) DEFAULT NULL, -- The Koha request type
+ accessurl varchar(500) DEFAULT NULL, -- Potential URL for accessing item
+ cost varchar(20) DEFAULT NULL, -- Cost of request
+ notesopac text DEFAULT NULL, -- Patron notes attached to request
+ notesstaff text DEFAULT NULL, -- Staff notes attached to request
+ orderid varchar(50) DEFAULT NULL, -- Backend id attached to request
+ backend varchar(20) DEFAULT NULL, -- The backend used to create request
+ CONSTRAINT `illrequests_bnfk`
+ FOREIGN KEY (`borrowernumber`)
+ REFERENCES `borrowers` (`borrowernumber`)
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT `illrequests_bcfk_2`
+ FOREIGN KEY (`branchcode`)
+ REFERENCES `branches` (`branchcode`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ });
+ }
+
+ if ( !TableExists( 'illrequestattributes' ) ) {
+ $dbh->do(q{
+ CREATE TABLE illrequestattributes (
+ illrequest_id bigint(20) unsigned NOT NULL, -- ILL request number
+ type varchar(200) NOT NULL, -- API ILL property name
+ value text NOT NULL, -- API ILL property value
+ PRIMARY KEY (`illrequest_id`,`type`),
+ CONSTRAINT `illrequestattributes_ifk`
+ FOREIGN KEY (illrequest_id)
+ REFERENCES `illrequests` (`illrequest_id`)
+ ON UPDATE CASCADE ON DELETE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ });
+ }
+
+ # System preferences
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
+ ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo');
+ });
+
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
+ ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea');
+ });
+ # userflags
+ $dbh->do(q{
+ INSERT IGNORE INTO userflags (bit,flag,flagdesc,defaulton) VALUES
+ (22,'ill','The Interlibrary Loans Module',0);
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 7317 - Add an Interlibrary Loan Module to Circulation and OPAC)\n";
+}
+
+$DBversion = '17.11.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Koha 17.11)\n";
+}
+
+$DBversion = '17.12.00.000';
+if( CheckVersion( $DBversion ) ) {
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Tē tōia, tē haumatia)\n";
+}
+
+$DBversion = '17.12.00.001';
+if( CheckVersion( $DBversion ) ) {
+ foreach my $table (qw(biblio_metadata deletedbiblio_metadata)) {
+ if (!column_exists($table, 'timestamp')) {
+ $dbh->do(qq{
+ ALTER TABLE `$table`
+ ADD COLUMN `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `metadata`,
+ ADD KEY `timestamp` (`timestamp`)
+ });
+ $dbh->do(qq{
+ UPDATE $table metadata
+ LEFT JOIN biblioitems ON (biblioitems.biblionumber = metadata.biblionumber)
+ LEFT JOIN biblio ON (biblio.biblionumber = metadata.biblionumber)
+ SET metadata.timestamp = GREATEST(biblioitems.timestamp, biblio.timestamp);
+ });
+ }
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19724 - Add [deleted]biblio_metadata.timestamp)\n";
+}
+
+$DBversion = '17.12.00.002';
+if( CheckVersion( $DBversion ) ) {
+
+ my $msss = $dbh->selectall_arrayref(q|
+ SELECT kohafield, tagfield, tagsubfield, frameworkcode
+ FROM marc_subfield_structure
+ WHERE frameworkcode != ''
+ |, { Slice => {} });
+
+
+ my $sth = $dbh->prepare(q|
+ SELECT kohafield
+ FROM marc_subfield_structure
+ WHERE frameworkcode = ''
+ AND tagfield = ?
+ AND tagsubfield = ?
+ |);
+
+ my @exceptions;
+ for my $mss ( @$msss ) {
+ $sth->execute($mss->{tagfield}, $mss->{tagsubfield} );
+ my ( $default_kohafield ) = $sth->fetchrow_array();
+ if( $mss->{kohafield} ) {
+ push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => $mss->{kohafield} } if not $default_kohafield or $default_kohafield ne $mss->{kohafield};
+ } else {
+ push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => q{} } if $default_kohafield;
+ }
+ }
+
+ if (@exceptions) {
+ print "WARNING: The Default framework is now considered as authoritative for Koha to MARC mappings. We have found that your additional frameworks contained "
+ . scalar(@exceptions)
+ . " mapping(s) that deviate from the standard mappings. Please look at the following list and consider if you need to add them again in Default (possibly as a second mapping).\n";
+ for my $exception (@exceptions) {
+ print "Field "
+ . $exception->{tagfield} . '$'
+ . $exception->{tagsubfield}
+ . " in framework "
+ . $exception->{frameworkcode} . ': ';
+ if ( $exception->{kohafield} ) {
+ print "Mapping to "
+ . $exception->{kohafield}
+ . " has been adjusted.\n";
+ }
+ else {
+ print "Mapping has been reset.\n";
+ }
+ }
+
+ # Sync kohafield
+
+ # Clear the destination frameworks first
+ $dbh->do(q|
+ UPDATE marc_subfield_structure
+ SET kohafield = NULL
+ WHERE frameworkcode > ''
+ AND Kohafield > ''
+ |);
+
+ # Now copy from Default
+ my $msss = $dbh->selectall_arrayref(q|
+ SELECT kohafield, tagfield, tagsubfield
+ FROM marc_subfield_structure
+ WHERE frameworkcode = ''
+ AND kohafield > ''
+ |, { Slice => {} });
+ my $sth = $dbh->prepare(q|
+ UPDATE marc_subfield_structure
+ SET kohafield = ?
+ WHERE frameworkcode > ''
+ AND tagfield = ?
+ AND tagsubfield = ?
+ |);
+ for my $mss (@$msss) {
+ $sth->execute( $mss->{kohafield}, $mss->{tagfield},
+ $mss->{tagsubfield} );
+ }
+
+ # Clear the cache
+ my @frameworkcodes = $dbh->selectall_arrayref(q|
+ SELECT frameworkcode FROM biblio_framework WHERE frameworkcode > ''
+ |);
+ for my $frameworkcode (@frameworkcodes) {
+ Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
+ }
+ Koha::Caches->get_instance->clear_from_cache("default_value_for_mod_marc-");
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19096 - Make Default authoritative for Koha to MARC mappings)\n";
+}
+
+$DBversion = '17.12.00.003';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q|DROP TABLE IF EXISTS notifys|);
+
+ if( column_exists( 'accountlines', 'notify_id' ) ) {
+ $dbh->do(q|ALTER TABLE accountlines DROP COLUMN notify_id|);
+ $dbh->do(q|ALTER TABLE accountlines DROP COLUMN notify_level|);
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 10021 - Drop notifys-related table and columns)\n";
+}
+
+$DBversion = '17.12.00.004';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
+ VALUES
+ ('RESTdefaultPageSize','20','','Set the default number of results returned by the REST API endpoints','Integer')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 19278 - Add a configurable default page size for REST endpoints)\n";
+}
+
+$DBversion = '17.12.00.005';
+if( CheckVersion( $DBversion ) ) {
+ # For installations having the note already
+ $dbh->do(q{
+ UPDATE letter
+ SET code = 'CHECKOUT_NOTE',
+ name = 'Checkout note on item set by patron',
+ title = 'Checkout note',
+ content = REPLACE(content, "<<biblio.item>>", "<<biblio.title>>")
+ WHERE code = 'PATRON_NOTE'
+ });
+ # For installations coming from 17.11
+ $dbh->do(q{
+ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
+ VALUES ('circulation', 'CHECKOUT_NOTE', '', 'Checkout note on item set by patron', '0', 'Checkout note', '<<borrowers.firstname>> <<borrowers.surname>> has added a note to the item <<biblio.title>> - <<biblio.author>> (<<biblio.biblionumber>>).','email')
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18915 - Correct CHECKOUT_NOTE notice template)\n";
+}
+
+$DBversion = '17.12.00.006';
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do(q{
+ UPDATE systempreferences SET value=replace(value, "http://www.scholar", "https://scholar") WHERE variable='OPACSearchForTitleIn';
+ });
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17682 - Update URL for Google Scholar in OPACSearchForTitleIn)\n";
+}
+
+$DBversion = '17.12.00.007';
+if( CheckVersion( $DBversion ) ) {
+
+ unless ( TableExists( 'library_groups' ) ) {
+ $dbh->do(q{
+ CREATE TABLE library_groups (
+ id INT(11) NOT NULL auto_increment, -- unique id for each group
+ parent_id INT(11) NULL DEFAULT NULL, -- if this is a child group, the id of the parent group
+ branchcode VARCHAR(10) NULL DEFAULT NULL, -- The branchcode of a branch belonging to the parent group
+ title VARCHAR(100) NULL DEFAULT NULL, -- Short description of the goup
+ description TEXT NULL DEFAULT NULL, -- Longer explanation of the group, if necessary
+ created_on TIMESTAMP NULL, -- Date and time of creation
+ updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Date and time of last
+ PRIMARY KEY id ( id ),
+ FOREIGN KEY (parent_id) REFERENCES library_groups(id) ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE,
+ UNIQUE KEY title ( title )
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ });
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15707 - Add new table library_groups)\n";
+}
+
+$DBversion = '17.12.00.008';
+if ( CheckVersion($DBversion) ) {
+
+ if ( TableExists( 'branchcategories' ) and TableExists('branchrelations' )) {
+ $dbh->do(q{
+ INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups', NOW() )
+ });
+ my $search_groups_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
+
+ my $sth = $dbh->prepare("SELECT * FROM branchcategories");
+
+ my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
+
+ my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
+
+ my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
+
+ $sth->execute();
+ while ( my $lc = $sth->fetchrow_hashref ) {
+ my $description = $lc->{categorycode};
+ $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
+
+ $sth2->execute($search_groups_root_id, $lc->{categoryname}, $description);
+
+ my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
+
+ $sth3->execute( $lc->{categorycode} );
+
+ while ( my $l = $sth3->fetchrow_hashref ) {
+ $sth4->execute( $subgroup_id, $l->{branchcode} );
+ }
+ }
+
+ $dbh->do("DROP TABLE branchrelations");
+ $dbh->do("DROP TABLE branchcategories");
+ }
+
+ print "Upgrade to $DBversion done (Bug 16735 - Migrate library search groups into the new hierarchical groups)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '17.12.00.009';
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q|
+ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
+ (4, 'edit_borrowers', 'Add, modify and view patron information'),
+ (4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries');
+ |);
+
+ # We are lucky here, there is nothing else to do: flags 4-borrowers did not contain sub permissions
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 18403 - Add the view_borrower_infos_from_any_libraries permission )\n";
+}
+
+$DBversion = '17.12.00.010';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'library_groups', 'ft_hide_patron_info' ) ) {
+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_hide_patron_info tinyint(1) NOT NULL DEFAULT 0 AFTER description" );
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20133 - Add library_groups.ft_hide_patron_info)\n";
+}
+
+$DBversion = '17.12.00.011';
+if( CheckVersion( $DBversion ) ) {
+
+ if( !column_exists( 'library_groups', 'ft_search_groups_opac' ) ) {
+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0 AFTER ft_hide_patron_info" );
+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_opac" );
+ $dbh->do( "UPDATE library_groups SET ft_search_groups_staff = 1 AND ft_search_groups_opac = 1 WHERE title = '__SEARCH_GROUPS__'" );
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality)\n";
+}
+
+$DBversion = '17.12.00.012';
+if( CheckVersion( $DBversion ) ) {
+
+ $dbh->do( q|
+ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+ VALUES ('AutoSwitchPatron', '0', '', 'Auto switch to patron', 'YesNo');
+ |);
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 15752 - Add system preference AutoSwitchPatron)\n";
+}
+
# 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.