4 # This script checks for required updates to the database.
6 # Parts copyright Catalyst IT 2011
8 # Part of the Koha Library Software www.koha-community.org
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 # - Would also be a good idea to offer to do a backup at this time...
26 # NOTE: If you do something more than once in here, make it table driven.
28 # NOTE: Please keep the version in kohaversion.pl up-to-date!
45 use MARC::File::XML ( BinaryEncoding => 'utf8' );
47 use File::Path qw[remove_tree]; # perl core module
50 # FIXME - The user might be installing a new database, so can't rely
51 # on /etc/koha.conf anyway.
62 my $schema = Koha::Database->new()->schema();
68 my $dbh = C4::Context->dbh;
69 $|=1; # flushes output
71 local $dbh->{RaiseError} = 0;
73 # Record the version we are coming from
75 my $original_version = C4::Context->preference("Version");
77 # Deal with virtualshelves
78 my $DBversion = "3.00.00.001";
79 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
80 # update virtualshelves table to
82 $dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
83 $dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
84 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
85 $dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
86 # drop all foreign keys : otherwise, we can't drop itemnumber field.
87 DropAllForeignKeys('virtualshelfcontents');
88 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
89 # create the new foreign keys (on biblionumber)
90 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
91 # re-create the foreign key on virtualshelf
92 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
93 $dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
94 print "Upgrade to $DBversion done (virtualshelves)\n";
95 SetVersion ($DBversion);
99 $DBversion = "3.00.00.002";
100 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
101 $dbh->do("DROP TABLE sessions");
102 $dbh->do("CREATE TABLE `sessions` (
103 `id` varchar(32) NOT NULL,
104 `a_session` text NOT NULL,
105 UNIQUE KEY `id` (`id`)
106 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
107 print "Upgrade to $DBversion done (sessions uses CGI::session, new table structure for sessions)\n";
108 SetVersion ($DBversion);
112 $DBversion = "3.00.00.003";
113 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
114 if (C4::Context->preference("opaclanguages") eq "fr") {
115 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ReservesNeedReturns','0','Si ce paramètre est mis à 1, une réservation posée sur un exemplaire présent sur le site devra être passée en retour pour être disponible. Sinon, elle sera automatiquement disponible, Koha considère que le bibliothécaire place la réservation en ayant le document en mains','','YesNo')");
117 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ReservesNeedReturns','0','If set, a reserve done on an item available in this branch need a check-in, otherwise, a reserve on a specific item, that is on the branch & available is considered as available','','YesNo')");
119 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
120 SetVersion ($DBversion);
124 $DBversion = "3.00.00.004";
125 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
126 $dbh->do("INSERT INTO `systempreferences` VALUES ('DebugLevel','2','set the level of error info sent to the browser. 0=none, 1=some, 2=most','0|1|2','Choice')");
127 print "Upgrade to $DBversion done (adding DebugLevel systempref, in 'Admin' tab)\n";
128 SetVersion ($DBversion);
131 $DBversion = "3.00.00.005";
132 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
133 $dbh->do("CREATE TABLE `tags` (
134 `entry` varchar(255) NOT NULL default '',
135 `weight` bigint(20) NOT NULL default 0,
136 PRIMARY KEY (`entry`)
137 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
139 $dbh->do("CREATE TABLE `nozebra` (
140 `server` varchar(20) NOT NULL,
141 `indexname` varchar(40) NOT NULL,
142 `value` varchar(250) NOT NULL,
143 `biblionumbers` longtext NOT NULL,
144 KEY `indexname` (`server`,`indexname`),
145 KEY `value` (`server`,`value`))
146 ENGINE=InnoDB DEFAULT CHARSET=utf8;
148 print "Upgrade to $DBversion done (adding tags and nozebra tables )\n";
149 SetVersion ($DBversion);
152 $DBversion = "3.00.00.006";
153 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
154 $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate='0000-00-00'");
155 print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n";
156 SetVersion ($DBversion);
159 $DBversion = "3.00.00.007";
160 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
161 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SessionStorage','mysql','Use mysql or a temporary file for storing session data','mysql|tmp','Choice')");
162 print "Upgrade to $DBversion done (set SessionStorage variable)\n";
163 SetVersion ($DBversion);
166 $DBversion = "3.00.00.008";
167 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
168 $dbh->do("ALTER TABLE `biblio` ADD `datecreated` DATE NOT NULL AFTER `timestamp` ;");
169 $dbh->do("UPDATE biblio SET datecreated=timestamp");
170 print "Upgrade to $DBversion done (biblio creation date)\n";
171 SetVersion ($DBversion);
174 $DBversion = "3.00.00.009";
175 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
177 # Create backups of call number columns
178 # in case default migration needs to be customized
180 # UPGRADE NOTE: temp_upg_biblioitems_call_num should be dropped
181 # after call numbers have been transformed to the new structure
183 # Not bothering to do the same with deletedbiblioitems -- assume
184 # default is good enough.
185 $dbh->do("CREATE TABLE `temp_upg_biblioitems_call_num` AS
186 SELECT `biblioitemnumber`, `biblionumber`,
187 `classification`, `dewey`, `subclass`,
189 FROM `biblioitems`");
191 # biblioitems changes
192 $dbh->do("ALTER TABLE `biblioitems` CHANGE COLUMN `volumeddesc` `volumedesc` TEXT,
193 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
194 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
195 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
196 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
197 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
198 ADD `totalissues` INT(10) AFTER `cn_sort`");
200 # default mapping of call number columns:
201 # cn_class = concatentation of classification + dewey,
202 # trimmed to fit -- assumes that most users do not
203 # populate both classification and dewey in a single record
205 # cn_source = left null
208 # After upgrade, cn_sort will have to be set based on whatever
209 # default call number scheme user sets as a preference. Misc
210 # script will be added at some point to do that.
212 $dbh->do("UPDATE `biblioitems`
213 SET cn_class = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
218 # Now drop the old call number columns
219 $dbh->do("ALTER TABLE `biblioitems` DROP COLUMN `classification`,
221 DROP COLUMN `subclass`,
222 DROP COLUMN `lcsort`,
223 DROP COLUMN `ccode`");
225 # deletedbiblio changes
226 $dbh->do("ALTER TABLE `deletedbiblio` ALTER COLUMN `frameworkcode` SET DEFAULT '',
228 ADD `datecreated` DATE NOT NULL AFTER `timestamp`");
229 $dbh->do("UPDATE deletedbiblio SET datecreated = timestamp");
231 # deletedbiblioitems changes
232 $dbh->do("ALTER TABLE `deletedbiblioitems`
233 MODIFY `publicationyear` TEXT,
234 CHANGE `volumeddesc` `volumedesc` TEXT,
235 MODIFY `collectiontitle` MEDIUMTEXT DEFAULT NULL AFTER `volumedesc`,
236 MODIFY `collectionissn` TEXT DEFAULT NULL AFTER `collectiontitle`,
237 MODIFY `collectionvolume` MEDIUMTEXT DEFAULT NULL AFTER `collectionissn`,
238 MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
239 MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
240 MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
241 MODIFY `marc` LONGBLOB,
242 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
243 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
244 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
245 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
246 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
247 ADD `totalissues` INT(10) AFTER `cn_sort`,
248 ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
249 ADD KEY `isbn` (`isbn`),
250 ADD KEY `publishercode` (`publishercode`)
253 $dbh->do("UPDATE `deletedbiblioitems`
254 SET `cn_class` = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
255 `cn_item` = `subclass`,
258 $dbh->do("ALTER TABLE `deletedbiblioitems`
259 DROP COLUMN `classification`,
261 DROP COLUMN `subclass`,
262 DROP COLUMN `lcsort`,
266 # deleteditems changes
267 $dbh->do("ALTER TABLE `deleteditems`
268 MODIFY `barcode` VARCHAR(20) DEFAULT NULL,
269 MODIFY `price` DECIMAL(8,2) DEFAULT NULL,
270 MODIFY `replacementprice` DECIMAL(8,2) DEFAULT NULL,
272 MODIFY `itemcallnumber` VARCHAR(30) DEFAULT NULL AFTER `wthdrawn`,
273 MODIFY `holdingbranch` VARCHAR(10) DEFAULT NULL,
275 MODIFY `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER `paidfor`,
277 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
278 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
279 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
280 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
281 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`,
282 MODIFY `marc` LONGBLOB AFTER `uri`,
284 DROP KEY `itembarcodeidx`,
285 DROP KEY `itembinoidx`,
286 DROP KEY `itembibnoidx`,
287 ADD UNIQUE KEY `delitembarcodeidx` (`barcode`),
288 ADD KEY `delitembinoidx` (`biblioitemnumber`),
289 ADD KEY `delitembibnoidx` (`biblionumber`),
290 ADD KEY `delhomebranch` (`homebranch`),
291 ADD KEY `delholdingbranch` (`holdingbranch`)");
292 $dbh->do("UPDATE deleteditems SET `ccode` = `itype`");
293 $dbh->do("ALTER TABLE deleteditems DROP `itype`");
294 $dbh->do("UPDATE `deleteditems` SET `cn_sort` = `itemcallnumber`");
297 $dbh->do("ALTER TABLE `items` ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
298 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
299 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
300 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
301 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`
303 $dbh->do("ALTER TABLE `items`
304 DROP KEY `itembarcodeidx`,
305 ADD UNIQUE KEY `itembarcodeidx` (`barcode`)");
307 # map items.itype to items.ccode and
308 # set cn_sort to itemcallnumber -- as with biblioitems.cn_sort,
309 # will have to be subsequently updated per user's default
310 # classification scheme
311 $dbh->do("UPDATE `items` SET `cn_sort` = `itemcallnumber`,
314 $dbh->do("ALTER TABLE `items` DROP `cutterextra`,
317 print "Upgrade to $DBversion done (major changes to biblio, biblioitems, items, and deleted* versions of same\n";
318 SetVersion ($DBversion);
321 $DBversion = "3.00.00.010";
322 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
323 $dbh->do("CREATE INDEX `userid` ON borrowers (`userid`) ");
324 print "Upgrade to $DBversion done (userid index added)\n";
325 SetVersion ($DBversion);
328 $DBversion = "3.00.00.011";
329 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
330 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
331 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
332 $dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
333 $dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
334 $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
335 print "Upgrade to $DBversion done (added branchcategory type)\n";
336 SetVersion ($DBversion);
339 $DBversion = "3.00.00.012";
340 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
341 $dbh->do("CREATE TABLE `class_sort_rules` (
342 `class_sort_rule` varchar(10) NOT NULL default '',
343 `description` mediumtext,
344 `sort_routine` varchar(30) NOT NULL default '',
345 PRIMARY KEY (`class_sort_rule`),
346 UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
347 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
348 $dbh->do("CREATE TABLE `class_sources` (
349 `cn_source` varchar(10) NOT NULL default '',
350 `description` mediumtext,
351 `used` tinyint(4) NOT NULL default 0,
352 `class_sort_rule` varchar(10) NOT NULL default '',
353 PRIMARY KEY (`cn_source`),
354 UNIQUE KEY `cn_source_idx` (`cn_source`),
355 KEY `used_idx` (`used`),
356 CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`)
357 REFERENCES `class_sort_rules` (`class_sort_rule`)
358 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
359 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type)
360 VALUES('DefaultClassificationSource','ddc',
361 'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'free')");
362 $dbh->do("INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
363 ('dewey', 'Default filing rules for DDC', 'Dewey'),
364 ('lcc', 'Default filing rules for LCC', 'LCC'),
365 ('generic', 'Generic call number filing rules', 'Generic')");
366 $dbh->do("INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
367 ('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
368 ('lcc', 'Library of Congress Classification', 1, 'lcc'),
369 ('udc', 'Universal Decimal Classification', 0, 'generic'),
370 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
371 ('z', 'Other/Generic Classification Scheme', 0, 'generic')");
372 print "Upgrade to $DBversion done (classification sources added)\n";
373 SetVersion ($DBversion);
376 $DBversion = "3.00.00.013";
377 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
378 $dbh->do("CREATE TABLE `import_batches` (
379 `import_batch_id` int(11) NOT NULL auto_increment,
380 `template_id` int(11) default NULL,
381 `branchcode` varchar(10) default NULL,
382 `num_biblios` int(11) NOT NULL default 0,
383 `num_items` int(11) NOT NULL default 0,
384 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
385 `overlay_action` enum('replace', 'create_new', 'use_template') NOT NULL default 'create_new',
386 `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
387 `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
388 `file_name` varchar(100),
389 `comments` mediumtext,
390 PRIMARY KEY (`import_batch_id`),
391 KEY `branchcode` (`branchcode`)
392 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
393 $dbh->do("CREATE TABLE `import_records` (
394 `import_record_id` int(11) NOT NULL auto_increment,
395 `import_batch_id` int(11) NOT NULL,
396 `branchcode` varchar(10) default NULL,
397 `record_sequence` int(11) NOT NULL default 0,
398 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
399 `import_date` DATE default NULL,
400 `marc` longblob NOT NULL,
401 `marcxml` longtext NOT NULL,
402 `marcxml_old` longtext NOT NULL,
403 `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
404 `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
405 `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted') NOT NULL default 'staged',
406 `import_error` mediumtext,
407 `encoding` varchar(40) NOT NULL default '',
408 `z3950random` varchar(40) default NULL,
409 PRIMARY KEY (`import_record_id`),
410 CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
411 REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
412 KEY `branchcode` (`branchcode`),
413 KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
414 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
415 $dbh->do("CREATE TABLE `import_record_matches` (
416 `import_record_id` int(11) NOT NULL,
417 `candidate_match_id` int(11) NOT NULL,
418 `score` int(11) NOT NULL default 0,
419 CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
420 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
421 KEY `record_score` (`import_record_id`, `score`)
422 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
423 $dbh->do("CREATE TABLE `import_biblios` (
424 `import_record_id` int(11) NOT NULL,
425 `matched_biblionumber` int(11) default NULL,
426 `control_number` varchar(25) default NULL,
427 `original_source` varchar(25) default NULL,
428 `title` varchar(128) default NULL,
429 `author` varchar(80) default NULL,
430 `isbn` varchar(14) default NULL,
431 `issn` varchar(9) default NULL,
432 `has_items` tinyint(1) NOT NULL default 0,
433 CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
434 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
435 KEY `matched_biblionumber` (`matched_biblionumber`),
436 KEY `title` (`title`),
438 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
439 $dbh->do("CREATE TABLE `import_items` (
440 `import_items_id` int(11) NOT NULL auto_increment,
441 `import_record_id` int(11) NOT NULL,
442 `itemnumber` int(11) default NULL,
443 `branchcode` varchar(10) default NULL,
444 `status` enum('error', 'staged', 'imported', 'reverted') NOT NULL default 'staged',
445 `marcxml` longtext NOT NULL,
446 `import_error` mediumtext,
447 PRIMARY KEY (`import_items_id`),
448 CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
449 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
450 KEY `itemnumber` (`itemnumber`),
451 KEY `branchcode` (`branchcode`)
452 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
454 $dbh->do("INSERT INTO `import_batches`
455 (`overlay_action`, `import_status`, `batch_type`, `file_name`)
456 SELECT distinct 'create_new', 'staged', 'z3950', `file`
457 FROM `marc_breeding`");
459 $dbh->do("INSERT INTO `import_records`
460 (`import_batch_id`, `import_record_id`, `record_sequence`, `marc`, `record_type`, `status`,
461 `encoding`, `z3950random`, `marcxml`, `marcxml_old`)
462 SELECT `import_batch_id`, `id`, 1, `marc`, 'biblio', 'staged', `encoding`, `z3950random`, '', ''
464 JOIN `import_batches` ON (`file_name` = `file`)");
466 $dbh->do("INSERT INTO `import_biblios`
467 (`import_record_id`, `title`, `author`, `isbn`)
468 SELECT `import_record_id`, `title`, `author`, `isbn`
470 JOIN `import_records` ON (`import_record_id` = `id`)");
472 $dbh->do("UPDATE `import_batches`
473 SET `num_biblios` = (
475 FROM `import_records`
476 WHERE `import_batch_id` = `import_batches`.`import_batch_id`
479 $dbh->do("DROP TABLE `marc_breeding`");
481 print "Upgrade to $DBversion done (import_batches et al. added)\n";
482 SetVersion ($DBversion);
485 $DBversion = "3.00.00.014";
486 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
487 $dbh->do("ALTER TABLE subscription ADD lastbranch VARCHAR(4)");
488 print "Upgrade to $DBversion done (userid index added)\n";
489 SetVersion ($DBversion);
492 $DBversion = "3.00.00.015";
493 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
494 $dbh->do("CREATE TABLE `saved_sql` (
495 `id` int(11) NOT NULL auto_increment,
496 `borrowernumber` int(11) default NULL,
497 `date_created` datetime default NULL,
498 `last_modified` datetime default NULL,
500 `last_run` datetime default NULL,
501 `report_name` varchar(255) default NULL,
502 `type` varchar(255) default NULL,
505 KEY boridx (`borrowernumber`)
506 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
507 $dbh->do("CREATE TABLE `saved_reports` (
508 `id` int(11) NOT NULL auto_increment,
509 `report_id` int(11) default NULL,
511 `date_run` datetime default NULL,
513 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
514 print "Upgrade to $DBversion done (saved_sql and saved_reports added)\n";
515 SetVersion ($DBversion);
518 $DBversion = "3.00.00.016";
519 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
520 $dbh->do(" CREATE TABLE reports_dictionary (
521 id int(11) NOT NULL auto_increment,
522 name varchar(255) default NULL,
524 date_created datetime default NULL,
525 date_modified datetime default NULL,
527 area int(11) default NULL,
529 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
530 print "Upgrade to $DBversion done (reports_dictionary) added)\n";
531 SetVersion ($DBversion);
534 $DBversion = "3.00.00.017";
535 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
536 $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
537 $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)");
538 $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
539 $dbh->do("UPDATE action_logs SET action_id = if (\@a, \@a:=\@a+1, \@a:=1)");
540 $dbh->do("ALTER TABLE action_logs MODIFY action_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY");
541 print "Upgrade to $DBversion done (added column to action_logs)\n";
542 SetVersion ($DBversion);
545 $DBversion = "3.00.00.018";
546 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
547 $dbh->do("ALTER TABLE `zebraqueue`
548 ADD `done` INT NOT NULL DEFAULT '0',
549 ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
551 print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
552 SetVersion ($DBversion);
555 $DBversion = "3.00.00.019";
556 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
557 $dbh->do("ALTER TABLE biblio MODIFY biblionumber INT(11) NOT NULL AUTO_INCREMENT");
558 $dbh->do("ALTER TABLE biblioitems MODIFY biblioitemnumber INT(11) NOT NULL AUTO_INCREMENT");
559 $dbh->do("ALTER TABLE items MODIFY itemnumber INT(11) NOT NULL AUTO_INCREMENT");
560 print "Upgrade to $DBversion done (made bib/item PKs auto_increment)\n";
561 SetVersion ($DBversion);
564 $DBversion = "3.00.00.020";
565 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
566 $dbh->do("ALTER TABLE deleteditems
567 DROP KEY `delitembarcodeidx`,
568 ADD KEY `delitembarcodeidx` (`barcode`)");
569 print "Upgrade to $DBversion done (dropped uniqueness of key on deleteditems.barcode)\n";
570 SetVersion ($DBversion);
573 $DBversion = "3.00.00.021";
574 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
575 $dbh->do("ALTER TABLE items CHANGE homebranch homebranch VARCHAR(10)");
576 $dbh->do("ALTER TABLE deleteditems CHANGE homebranch homebranch VARCHAR(10)");
577 $dbh->do("ALTER TABLE statistics CHANGE branch branch VARCHAR(10)");
578 $dbh->do("ALTER TABLE subscription CHANGE lastbranch lastbranch VARCHAR(10)");
579 print "Upgrade to $DBversion done (extended missed branchcode columns to 10 chars)\n";
580 SetVersion ($DBversion);
583 $DBversion = "3.00.00.022";
584 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
585 $dbh->do("ALTER TABLE items
586 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
587 $dbh->do("ALTER TABLE deleteditems
588 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
589 print "Upgrade to $DBversion done (adding damaged column to items table)\n";
590 SetVersion ($DBversion);
593 $DBversion = "3.00.00.023";
594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
595 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
596 VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
597 print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
598 SetVersion ($DBversion);
600 $DBversion = "3.00.00.024";
601 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
602 $dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
603 print "Upgrade to $DBversion done (changing itemtype to (10))\n";
604 SetVersion ($DBversion);
607 $DBversion = "3.00.00.025";
608 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
609 $dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
610 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
611 if(C4::Context->preference('item-level_itypes')){
612 $dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
614 print "Upgrade to $DBversion done (reintroduce items.itype - fill from itemtype)\n ";
615 SetVersion ($DBversion);
618 $DBversion = "3.00.00.026";
619 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
620 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
621 VALUES ('HomeOrHoldingBranch','homebranch','homebranch|holdingbranch','With independent branches turned on this decides whether to check the items holdingbranch or homebranch at circulatilon','choice')");
622 print "Upgrade to $DBversion done (adding new system preference for choosing whether homebranch or holdingbranch is checked in circulation)\n";
623 SetVersion ($DBversion);
626 $DBversion = "3.00.00.027";
627 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
628 $dbh->do("CREATE TABLE `marc_matchers` (
629 `matcher_id` int(11) NOT NULL auto_increment,
630 `code` varchar(10) NOT NULL default '',
631 `description` varchar(255) NOT NULL default '',
632 `record_type` varchar(10) NOT NULL default 'biblio',
633 `threshold` int(11) NOT NULL default 0,
634 PRIMARY KEY (`matcher_id`),
636 KEY `record_type` (`record_type`)
637 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
638 $dbh->do("CREATE TABLE `matchpoints` (
639 `matcher_id` int(11) NOT NULL,
640 `matchpoint_id` int(11) NOT NULL auto_increment,
641 `search_index` varchar(30) NOT NULL default '',
642 `score` int(11) NOT NULL default 0,
643 PRIMARY KEY (`matchpoint_id`),
644 CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
645 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
646 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
647 $dbh->do("CREATE TABLE `matchpoint_components` (
648 `matchpoint_id` int(11) NOT NULL,
649 `matchpoint_component_id` int(11) NOT NULL auto_increment,
650 sequence int(11) NOT NULL default 0,
651 tag varchar(3) NOT NULL default '',
652 subfields varchar(40) NOT NULL default '',
653 offset int(4) NOT NULL default 0,
654 length int(4) NOT NULL default 0,
655 PRIMARY KEY (`matchpoint_component_id`),
656 KEY `by_sequence` (`matchpoint_id`, `sequence`),
657 CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
658 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
659 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
660 $dbh->do("CREATE TABLE `matchpoint_component_norms` (
661 `matchpoint_component_id` int(11) NOT NULL,
662 `sequence` int(11) NOT NULL default 0,
663 `norm_routine` varchar(50) NOT NULL default '',
664 KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
665 CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
666 REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
667 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
668 $dbh->do("CREATE TABLE `matcher_matchpoints` (
669 `matcher_id` int(11) NOT NULL,
670 `matchpoint_id` int(11) NOT NULL,
671 CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
672 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
673 CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
674 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
675 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
676 $dbh->do("CREATE TABLE `matchchecks` (
677 `matcher_id` int(11) NOT NULL,
678 `matchcheck_id` int(11) NOT NULL auto_increment,
679 `source_matchpoint_id` int(11) NOT NULL,
680 `target_matchpoint_id` int(11) NOT NULL,
681 PRIMARY KEY (`matchcheck_id`),
682 CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
683 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
684 CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
685 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
686 CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
687 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
688 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
689 print "Upgrade to $DBversion done (added C4::Matcher serialization tables)\n ";
690 SetVersion ($DBversion);
693 $DBversion = "3.00.00.028";
694 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
695 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
696 VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
697 print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
698 SetVersion ($DBversion);
702 $DBversion = "3.00.00.029";
703 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
704 $dbh->do("ALTER TABLE `import_batches` ADD `matcher_id` int(11) NULL AFTER `import_batch_id`");
705 print "Upgrade to $DBversion done (adding matcher_id to import_batches)\n";
706 SetVersion ($DBversion);
709 $DBversion = "3.00.00.030";
710 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
712 CREATE TABLE services_throttle (
713 service_type varchar(10) NOT NULL default '',
714 service_count varchar(45) default NULL,
715 PRIMARY KEY (service_type)
716 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
718 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
719 VALUES ('FRBRizeEditions',0,'','If ON, Koha will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo')");
720 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
721 VALUES ('XISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the OCLC xISBN web service in the Editions tab on the detail pages. See: http://www.worldcat.org/affiliate/webservices/xisbn/app.jsp','YesNo')");
722 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
723 VALUES ('OCLCAffiliateID','','','Use with FRBRizeEditions and XISBN. You can sign up for an AffiliateID here: http://www.worldcat.org/wcpa/do/AffiliateUserServices?method=initSelfRegister','free')");
724 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
725 VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free')");
726 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
727 VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo')");
728 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
729 VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo')");
730 print "Upgrade to $DBversion done (adding services throttle table and sysprefs for xISBN)\n";
731 SetVersion ($DBversion);
734 $DBversion = "3.00.00.031";
735 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
737 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryStemming',1,'If ON, enables query stemming',NULL,'YesNo')");
738 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryFuzzy',1,'If ON, enables fuzzy option for searches',NULL,'YesNo')");
739 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryWeightFields',1,'If ON, enables field weighting',NULL,'YesNo')");
740 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo')");
741 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'free')");
742 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to display on a page of results',NULL,'free')");
743 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to display for each result on a page of results',NULL,'free')");
744 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice')");
745 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice')");
746 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortField',NULL,'Specify the default field used for sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice')");
747 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortOrder',NULL,'Specify the default sort order','asc|dsc|za|az','Choice')");
748 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
749 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
750 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
751 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('emailLibrarianWhenHoldIsPlaced',0,'If ON, emails the librarian whenever a hold is placed',NULL,'YesNo')");
752 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
753 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('libraryAddress','','The address to use for printing receipts, overdues, etc. if different than physical address',NULL,'free')");
754 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice')");
755 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('globalDueDate','','If set, allows a global static due date for all checkouts',NULL,'free')");
756 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
757 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo')");
758 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
759 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACSubscriptionDisplay','economical','Specify how to display subscription information in the OPAC','economical|off|full','Choice')");
760 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACDisplayExtendedSubInfo',1,'If ON, extended subscription information is displayed in the OPAC',NULL,'YesNo')");
761 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACViewOthersSuggestions',0,'If ON, allows all suggestions to be displayed in the OPAC',NULL,'YesNo')");
762 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACURLOpenInNewWindow',0,'If ON, URLs in the OPAC open in a new window',NULL,'YesNo')");
763 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
765 print "Upgrade to $DBversion done (adding additional system preference)\n";
766 SetVersion ($DBversion);
769 $DBversion = "3.00.00.032";
770 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
771 $dbh->do("UPDATE `marc_subfield_structure` SET `kohafield` = 'items.wthdrawn' WHERE `kohafield` = 'items.withdrawn'");
772 print "Upgrade to $DBversion done (fixed MARC framework references to items.withdrawn)\n";
773 SetVersion ($DBversion);
776 $DBversion = "3.00.00.033";
777 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
778 $dbh->do("INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0)");
779 print "Upgrade to $DBversion done (Adding permissions flag for staff member access modification. )\n";
780 SetVersion ($DBversion);
783 $DBversion = "3.00.00.034";
784 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
785 $dbh->do("ALTER TABLE `virtualshelves` ADD COLUMN `sortfield` VARCHAR(16) ");
786 print "Upgrade to $DBversion done (Adding sortfield for Virtual Shelves. )\n";
787 SetVersion ($DBversion);
790 $DBversion = "3.00.00.035";
791 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
792 $dbh->do("UPDATE marc_subfield_structure
793 SET authorised_value = 'cn_source'
794 WHERE kohafield IN ('items.cn_source', 'biblioitems.cn_source')
795 AND (authorised_value is NULL OR authorised_value = '')");
796 print "Upgrade to $DBversion done (MARC frameworks: make classification source a drop-down)\n";
797 SetVersion ($DBversion);
800 $DBversion = "3.00.00.036";
801 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
802 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACItemsResultsDisplay','statuses','statuses : show only the status of items in result list. itemdisplay : show full location of items (branch+location+callnumber) as in staff interface','statuses|itemdetails','Choice');");
803 print "Upgrade to $DBversion done (OPACItemsResultsDisplay systempreference added)\n";
804 SetVersion ($DBversion);
807 $DBversion = "3.00.00.037";
808 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
809 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactfirstname` varchar(255)");
810 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactsurname` varchar(255)");
811 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress1` varchar(255)");
812 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress2` varchar(255)");
813 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress3` varchar(255)");
814 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactzipcode` varchar(50)");
815 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactphone` varchar(50)");
816 print "Upgrade to $DBversion done (Adding Alternative Contact Person information to borrowers table)\n";
817 SetVersion ($DBversion);
820 $DBversion = "3.00.00.038";
821 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
822 $dbh->do("UPDATE `systempreferences` set explanation='Choose the fines mode, off, test (emails admin report) or production (accrue overdue fines). Requires fines cron script' , options='off|test|production' where variable='finesMode'");
823 $dbh->do("DELETE FROM `systempreferences` WHERE variable='hideBiblioNumber'");
824 print "Upgrade to $DBversion done ('alter finesMode systempreference, remove superfluous syspref.')\n";
825 SetVersion ($DBversion);
828 $DBversion = "3.00.00.039";
829 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
830 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('uppercasesurnames',0,'If ON, surnames are converted to upper case in patron entry form',NULL,'YesNo')");
831 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('CircControl','ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','PickupLibrary|PatronLibrary|ItemHomeLibrary','Choice')");
832 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesCalendar','noFinesWhenClosed','Specify whether to use the Calendar in calculating duedates and fines','ignoreCalendar|noFinesWhenClosed','Choice')");
833 # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
834 print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
835 SetVersion ($DBversion);
838 $DBversion = "3.00.00.040";
839 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
840 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('previousIssuesDefaultSortOrder','asc','Specify the sort order of Previous Issues on the circulation page','asc|desc','Choice')");
841 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('todaysIssuesDefaultSortOrder','desc','Specify the sort order of Todays Issues on the circulation page','asc|desc','Choice')");
842 print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
843 SetVersion ($DBversion);
847 $DBversion = "3.00.00.041";
848 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
849 # Strictly speaking it is not necessary to explicitly change
850 # NULL values to 0, because the ALTER TABLE statement will do that.
851 # However, setting them first avoids a warning.
852 $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL");
853 $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL");
854 $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL");
855 $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL");
856 $dbh->do("ALTER TABLE items
857 MODIFY notforloan tinyint(1) NOT NULL default 0,
858 MODIFY damaged tinyint(1) NOT NULL default 0,
859 MODIFY itemlost tinyint(1) NOT NULL default 0,
860 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
861 $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
862 $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
863 $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
864 $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
865 $dbh->do("ALTER TABLE deleteditems
866 MODIFY notforloan tinyint(1) NOT NULL default 0,
867 MODIFY damaged tinyint(1) NOT NULL default 0,
868 MODIFY itemlost tinyint(1) NOT NULL default 0,
869 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
870 print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
871 SetVersion ($DBversion);
874 $DBversion = "3.00.00.04";
875 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
876 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
877 print "Upgrade to $DBversion done (disallow NULL in aqbooksellers.name; part of fix for bug 1251)\n";
878 SetVersion ($DBversion);
881 $DBversion = "3.00.00.043";
882 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
883 $dbh->do("ALTER TABLE `currency` ADD `symbol` varchar(5) default NULL AFTER currency, ADD `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER symbol");
884 print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
885 SetVersion ($DBversion);
888 $DBversion = "3.00.00.044";
889 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
890 $dbh->do("ALTER TABLE deletedborrowers
891 ADD `altcontactfirstname` varchar(255) default NULL,
892 ADD `altcontactsurname` varchar(255) default NULL,
893 ADD `altcontactaddress1` varchar(255) default NULL,
894 ADD `altcontactaddress2` varchar(255) default NULL,
895 ADD `altcontactaddress3` varchar(255) default NULL,
896 ADD `altcontactzipcode` varchar(50) default NULL,
897 ADD `altcontactphone` varchar(50) default NULL
899 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
900 ('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
901 ('language','en','Set the default language in the staff client.',NULL,'Languages'),
902 ('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
903 ('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
905 print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
906 SetVersion ($DBversion);
909 #-- http://www.w3.org/International/articles/language-tags/
912 $DBversion = "3.00.00.045";
913 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
915 CREATE TABLE language_subtag_registry (
917 type varchar(25), -- language-script-region-variant-extension-privateuse
918 description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
920 KEY `subtag` (`subtag`)
921 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
923 #-- TODO: add suppress_scripts
924 #-- this maps three letter codes defined in iso639.2 back to their
925 #-- two letter equivilents in rfc4646 (LOC maintains iso639+)
926 $dbh->do("CREATE TABLE language_rfc4646_to_iso639 (
927 rfc4646_subtag varchar(25),
928 iso639_2_code varchar(25),
929 KEY `rfc4646_subtag` (`rfc4646_subtag`)
930 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
932 $dbh->do("CREATE TABLE language_descriptions (
936 description varchar(255),
938 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
940 #-- bi-directional support, keyed by script subcode
941 $dbh->do("CREATE TABLE language_script_bidi (
942 rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
943 bidi varchar(3), -- rtl ltr
944 KEY `rfc4646_subtag` (`rfc4646_subtag`)
945 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
947 #-- BIDI Stuff, Arabic and Hebrew
948 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
949 VALUES( 'Arab', 'rtl')");
950 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
951 VALUES( 'Hebr', 'rtl')");
953 #-- TODO: need to map language subtags to script subtags for detection
954 #-- of bidi when script is not specified (like ar, he)
955 $dbh->do("CREATE TABLE language_script_mapping (
956 language_subtag varchar(25),
957 script_subtag varchar(25),
958 KEY `language_subtag` (`language_subtag`)
959 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
961 #-- Default mappings between script and language subcodes
962 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
963 VALUES( 'ar', 'Arab')");
964 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
965 VALUES( 'he', 'Hebr')");
967 print "Upgrade to $DBversion done (adding language subtag registry and basic BiDi support NOTE: You should import the subtag registry SQL)\n";
968 SetVersion ($DBversion);
971 $DBversion = "3.00.00.046";
972 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
973 $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
974 CHANGE `weeklength` `weeklength` int(11) default '0'");
975 $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
976 $dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
977 print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
978 SetVersion ($DBversion);
981 $DBversion = "3.00.00.047";
982 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
983 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'If ON, users can renew their issues directly from their OPAC account',NULL,'YesNo');");
984 print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
985 SetVersion ($DBversion);
988 $DBversion = "3.00.00.048";
989 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
990 $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
991 print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
992 SetVersion ($DBversion);
995 $DBversion = "3.00.00.049";
996 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
997 $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
998 print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
999 SetVersion ($DBversion);
1002 $DBversion = "3.00.00.050";
1003 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1004 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
1005 print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
1006 SetVersion ($DBversion);
1009 $DBversion = "3.00.00.051";
1010 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1011 $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
1012 print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
1013 SetVersion ($DBversion);
1016 $DBversion = "3.00.00.052";
1017 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1018 $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
1019 print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
1020 SetVersion ($DBversion);
1023 $DBversion = "3.00.00.053";
1024 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1025 $dbh->do("CREATE TABLE `printers_profile` (
1026 `prof_id` int(4) NOT NULL auto_increment,
1027 `printername` varchar(40) NOT NULL,
1028 `tmpl_id` int(4) NOT NULL,
1029 `paper_bin` varchar(20) NOT NULL,
1030 `offset_horz` float default NULL,
1031 `offset_vert` float default NULL,
1032 `creep_horz` float default NULL,
1033 `creep_vert` float default NULL,
1034 `unit` char(20) NOT NULL default 'POINT',
1035 PRIMARY KEY (`prof_id`),
1036 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1037 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1038 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1039 $dbh->do("CREATE TABLE `labels_profile` (
1040 `tmpl_id` int(4) NOT NULL,
1041 `prof_id` int(4) NOT NULL,
1042 UNIQUE KEY `tmpl_id` (`tmpl_id`),
1043 UNIQUE KEY `prof_id` (`prof_id`)
1044 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1045 print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
1046 SetVersion ($DBversion);
1049 $DBversion = "3.00.00.054";
1050 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1051 $dbh->do("UPDATE systempreferences SET options = 'incremental|annual|hbyymmincr|OFF', explanation = 'Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB = Home Branch' WHERE variable = 'autoBarcode';");
1052 print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
1053 SetVersion ($DBversion);
1056 $DBversion = "3.00.00.055";
1057 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1058 $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
1059 print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
1060 SetVersion ($DBversion);
1062 $DBversion = "3.00.00.056";
1063 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1064 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
1065 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('995', 'v', 'Note sur le N° de périodique','Note sur le N° de périodique', 0, 0, 'items.enumchron', 10, '', '', '', 0, 0, '', '', '', NULL) ");
1067 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('952', 'h', 'Serial Enumeration / chronology','Serial Enumeration / chronology', 0, 0, 'items.enumchron', 10, '', '', '', 0, 0, '', '', '', NULL) ");
1069 $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
1070 print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
1071 SetVersion ($DBversion);
1074 $DBversion = "3.00.00.057";
1075 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1076 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
1077 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
1078 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:MaxCount','50','OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries',NULL,'Integer');");
1079 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:Set','SET,Experimental set\r\nSET:SUBSET,Experimental subset','OAI-PMH exported set, the set name is followed by a comma and a short description, one set by line',NULL,'Free');");
1080 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:Subset',\"itemtype='BOOK'\",'Restrict answer to matching raws of the biblioitems table (experimental)',NULL,'Free');");
1081 SetVersion ($DBversion);
1084 $DBversion = "3.00.00.058";
1085 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1086 $dbh->do("ALTER TABLE `opac_news`
1087 CHANGE `lang` `lang` VARCHAR( 25 )
1089 COLLATE utf8_general_ci
1090 NOT NULL default ''");
1091 print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
1092 SetVersion ($DBversion);
1095 $DBversion = "3.00.00.059";
1096 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1098 $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
1099 `tmpl_id` int(4) NOT NULL auto_increment,
1100 `tmpl_code` char(100) default '',
1101 `tmpl_desc` char(100) default '',
1102 `page_width` float default '0',
1103 `page_height` float default '0',
1104 `label_width` float default '0',
1105 `label_height` float default '0',
1106 `topmargin` float default '0',
1107 `leftmargin` float default '0',
1108 `cols` int(2) default '0',
1109 `rows` int(2) default '0',
1110 `colgap` float default '0',
1111 `rowgap` float default '0',
1112 `active` int(1) default NULL,
1113 `units` char(20) default 'PX',
1114 `fontsize` int(4) NOT NULL default '3',
1115 PRIMARY KEY (`tmpl_id`)
1116 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1117 $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
1118 `prof_id` int(4) NOT NULL auto_increment,
1119 `printername` varchar(40) NOT NULL,
1120 `tmpl_id` int(4) NOT NULL,
1121 `paper_bin` varchar(20) NOT NULL,
1122 `offset_horz` float default NULL,
1123 `offset_vert` float default NULL,
1124 `creep_horz` float default NULL,
1125 `creep_vert` float default NULL,
1126 `unit` char(20) NOT NULL default 'POINT',
1127 PRIMARY KEY (`prof_id`),
1128 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1129 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1130 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1131 print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
1132 SetVersion ($DBversion);
1135 $DBversion = "3.00.00.060";
1136 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1137 $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
1138 `cardnumber` varchar(16) NOT NULL,
1139 `mimetype` varchar(15) NOT NULL,
1140 `imagefile` mediumblob NOT NULL,
1141 PRIMARY KEY (`cardnumber`),
1142 CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1143 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1144 print "Upgrade to $DBversion done ( Added patronimage table. )\n";
1145 SetVersion ($DBversion);
1148 $DBversion = "3.00.00.061";
1149 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1150 $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
1151 print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
1152 SetVersion ($DBversion);
1155 $DBversion = "3.00.00.062";
1156 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1157 $dbh->do("CREATE TABLE `old_issues` (
1158 `borrowernumber` int(11) default NULL,
1159 `itemnumber` int(11) default NULL,
1160 `date_due` date default NULL,
1161 `branchcode` varchar(10) default NULL,
1162 `issuingbranch` varchar(18) default NULL,
1163 `returndate` date default NULL,
1164 `lastreneweddate` date default NULL,
1165 `return` varchar(4) default NULL,
1166 `renewals` tinyint(4) default NULL,
1167 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1168 `issuedate` date default NULL,
1169 KEY `old_issuesborridx` (`borrowernumber`),
1170 KEY `old_issuesitemidx` (`itemnumber`),
1171 KEY `old_bordate` (`borrowernumber`,`timestamp`),
1172 CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1173 ON DELETE SET NULL ON UPDATE SET NULL,
1174 CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1175 ON DELETE SET NULL ON UPDATE SET NULL
1176 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1177 $dbh->do("CREATE TABLE `old_reserves` (
1178 `borrowernumber` int(11) default NULL,
1179 `reservedate` date default NULL,
1180 `biblionumber` int(11) default NULL,
1181 `constrainttype` varchar(1) default NULL,
1182 `branchcode` varchar(10) default NULL,
1183 `notificationdate` date default NULL,
1184 `reminderdate` date default NULL,
1185 `cancellationdate` date default NULL,
1186 `reservenotes` mediumtext,
1187 `priority` smallint(6) default NULL,
1188 `found` varchar(1) default NULL,
1189 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1190 `itemnumber` int(11) default NULL,
1191 `waitingdate` date default NULL,
1192 KEY `old_reserves_borrowernumber` (`borrowernumber`),
1193 KEY `old_reserves_biblionumber` (`biblionumber`),
1194 KEY `old_reserves_itemnumber` (`itemnumber`),
1195 KEY `old_reserves_branchcode` (`branchcode`),
1196 CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1197 ON DELETE SET NULL ON UPDATE SET NULL,
1198 CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1199 ON DELETE SET NULL ON UPDATE SET NULL,
1200 CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1201 ON DELETE SET NULL ON UPDATE SET NULL
1202 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1204 # move closed transactions to old_* tables
1205 $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
1206 $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
1207 $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1208 $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1210 print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
1211 SetVersion ($DBversion);
1214 $DBversion = "3.00.00.063";
1215 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1216 $dbh->do("ALTER TABLE deleteditems
1217 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
1218 ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
1219 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1220 $dbh->do("ALTER TABLE items
1221 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
1222 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1223 print "Upgrade to $DBversion done ( Changed items.booksellerid and deleteditems.booksellerid to MEDIUMTEXT and added missing items.copynumber and deleteditems.copynumber to fix Bug 1927)\n";
1224 SetVersion ($DBversion);
1227 $DBversion = "3.00.00.064";
1228 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1229 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonLocale','US','Use to set the Locale of your Amazon.com Web Services','US|CA|DE|FR|JP|UK','Choice');");
1230 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
1231 $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
1232 $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
1233 $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
1234 print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
1235 SetVersion ($DBversion);
1238 $DBversion = "3.00.00.065";
1239 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1240 $dbh->do("CREATE TABLE `patroncards` (
1241 `cardid` int(11) NOT NULL auto_increment,
1242 `batch_id` varchar(10) NOT NULL default '1',
1243 `borrowernumber` int(11) NOT NULL,
1244 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1245 PRIMARY KEY (`cardid`),
1246 KEY `patroncards_ibfk_1` (`borrowernumber`),
1247 CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1248 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1249 print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
1250 SetVersion ($DBversion);
1253 $DBversion = "3.00.00.066";
1254 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1255 $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
1256 DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
1258 print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
1259 SetVersion ($DBversion);
1262 $DBversion = "3.00.00.067";
1263 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1264 $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
1265 print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
1266 SetVersion ($DBversion);
1269 $DBversion = "3.00.00.068";
1270 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1271 $dbh->do("CREATE TABLE `permissions` (
1272 `module_bit` int(11) NOT NULL DEFAULT 0,
1273 `code` varchar(30) DEFAULT NULL,
1274 `description` varchar(255) DEFAULT NULL,
1275 PRIMARY KEY (`module_bit`, `code`),
1276 CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
1277 ON DELETE CASCADE ON UPDATE CASCADE
1278 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1279 $dbh->do("CREATE TABLE `user_permissions` (
1280 `borrowernumber` int(11) NOT NULL DEFAULT 0,
1281 `module_bit` int(11) NOT NULL DEFAULT 0,
1282 `code` varchar(30) DEFAULT NULL,
1283 CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1284 ON DELETE CASCADE ON UPDATE CASCADE,
1285 CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
1286 REFERENCES `permissions` (`module_bit`, `code`)
1287 ON DELETE CASCADE ON UPDATE CASCADE
1288 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1290 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
1291 (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
1292 (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
1293 (13, 'edit_calendar', 'Define days when the library is closed'),
1294 (13, 'moderate_comments', 'Moderate patron comments'),
1295 (13, 'edit_notices', 'Define notices'),
1296 (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
1297 (13, 'view_system_logs', 'Browse the system logs'),
1298 (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
1299 (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
1300 (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
1301 (13, 'export_catalog', 'Export bibliographic and holdings data'),
1302 (13, 'import_patrons', 'Import patron data'),
1303 (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
1304 (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
1305 (13, 'schedule_tasks', 'Schedule tasks to run')");
1307 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
1309 print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
1310 SetVersion ($DBversion);
1312 $DBversion = "3.00.00.069";
1313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1314 $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
1315 print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
1316 SetVersion ($DBversion);
1319 $DBversion = "3.00.00.070";
1320 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1321 $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
1323 my ($value) = $sth->fetchrow;
1324 $value =~ s/2.3.1/2.5.1/;
1325 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
1326 print "Update yuipath syspref to 2.5.1 if necessary\n";
1327 SetVersion ($DBversion);
1330 $DBversion = "3.00.00.071";
1331 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1332 $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
1333 # fill the new field with the previous systempreference value, then drop the syspref
1334 my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
1336 my ($serialsadditems) = $sth->fetchrow();
1337 $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
1338 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1339 print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
1340 SetVersion ($DBversion);
1343 $DBversion = "3.00.00.072";
1344 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1345 $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring mediumtext DEFAULT NULL AFTER printingtype");
1346 print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
1347 SetVersion ($DBversion);
1350 $DBversion = "3.00.00.073";
1351 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1352 $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
1354 CREATE TABLE `tags_all` (
1355 `tag_id` int(11) NOT NULL auto_increment,
1356 `borrowernumber` int(11) NOT NULL,
1357 `biblionumber` int(11) NOT NULL,
1358 `term` varchar(255) NOT NULL,
1359 `language` int(4) default NULL,
1360 `date_created` datetime NOT NULL,
1361 PRIMARY KEY (`tag_id`),
1362 KEY `tags_borrowers_fk_1` (`borrowernumber`),
1363 KEY `tags_biblionumber_fk_1` (`biblionumber`),
1364 CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
1365 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1366 CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1367 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1368 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1370 $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
1372 CREATE TABLE `tags_approval` (
1373 `term` varchar(255) NOT NULL,
1374 `approved` int(1) NOT NULL default '0',
1375 `date_approved` datetime default NULL,
1376 `approved_by` int(11) default NULL,
1377 `weight_total` int(9) NOT NULL default '1',
1378 PRIMARY KEY (`term`),
1379 KEY `tags_approval_borrowers_fk_1` (`approved_by`),
1380 CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
1381 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1382 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1384 $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
1386 CREATE TABLE `tags_index` (
1387 `term` varchar(255) NOT NULL,
1388 `biblionumber` int(11) NOT NULL,
1389 `weight` int(9) NOT NULL default '1',
1390 PRIMARY KEY (`term`,`biblionumber`),
1391 KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
1392 CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
1393 REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
1394 CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1395 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1396 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1399 INSERT INTO `systempreferences` VALUES
1400 ('BakerTaylorBookstoreURL','','','URL template for \"My Libary Bookstore\" links, to which the \"key\" value is appended, and \"https://\" is prepended. It should include your hostname and \"Parent Number\". Make this variable empty to turn MLB links off. Example: ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=',''),
1401 ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
1402 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
1403 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
1404 ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
1405 ('TagsExternalDictionary',NULL,'','Path on server to local ispell executable, used to set $Lingua::Ispell::path This dictionary is used as a \"whitelist\" of pre-allowed tags.',''),
1406 ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
1407 ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
1408 ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
1409 ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
1410 ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
1412 print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
1413 SetVersion ($DBversion);
1416 $DBversion = "3.00.00.074";
1417 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1418 $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
1419 where imageurl not like 'http%'
1420 and imageurl is not NULL
1421 and imageurl != '') );
1422 print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
1423 SetVersion ($DBversion);
1426 $DBversion = "3.00.00.075";
1427 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1428 $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
1429 print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
1430 SetVersion ($DBversion);
1433 $DBversion = "3.00.00.076";
1434 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1435 $dbh->do("ALTER TABLE import_batches
1436 ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
1437 $dbh->do("ALTER TABLE import_batches
1438 ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
1439 NOT NULL default 'always_add' AFTER nomatch_action");
1440 $dbh->do("ALTER TABLE import_batches
1441 MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
1442 NOT NULL default 'create_new'");
1443 $dbh->do("ALTER TABLE import_records
1444 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
1445 'ignored') NOT NULL default 'staged'");
1446 $dbh->do("ALTER TABLE import_items
1447 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
1449 print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
1450 SetVersion ($DBversion);
1453 $DBversion = "3.00.00.077";
1454 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1455 # drop these tables only if they exist and none of them are empty
1456 # these tables are not defined in the packaged 2.2.9, but since it is believed
1457 # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
1458 # some care is taken.
1459 my ($print_error) = $dbh->{PrintError};
1460 $dbh->{PrintError} = 0;
1461 my ($raise_error) = $dbh->{RaiseError};
1462 $dbh->{RaiseError} = 1;
1466 eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
1470 eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
1474 eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
1480 $dbh->do("DROP TABLE IF EXISTS `categorytable`");
1481 $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
1482 $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
1485 $dbh->{PrintError} = $print_error;
1486 $dbh->{RaiseError} = $raise_error;
1487 print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
1488 SetVersion ($DBversion);
1491 $DBversion = "3.00.00.078";
1492 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1493 my ($print_error) = $dbh->{PrintError};
1494 $dbh->{PrintError} = 0;
1496 unless ($dbh->do("SELECT 1 FROM browser")) {
1497 $dbh->{PrintError} = $print_error;
1498 $dbh->do("CREATE TABLE `browser` (
1499 `level` int(11) NOT NULL,
1500 `classification` varchar(20) NOT NULL,
1501 `description` varchar(255) NOT NULL,
1502 `number` bigint(20) NOT NULL,
1503 `endnode` tinyint(4) NOT NULL
1504 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1506 $dbh->{PrintError} = $print_error;
1507 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1508 SetVersion ($DBversion);
1511 $DBversion = "3.00.00.079";
1512 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1513 my ($print_error) = $dbh->{PrintError};
1514 $dbh->{PrintError} = 0;
1516 $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
1517 ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
1518 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1519 SetVersion ($DBversion);
1522 $DBversion = "3.00.00.080";
1523 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1524 $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
1525 $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
1526 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
1527 print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
1528 SetVersion ($DBversion);
1531 $DBversion = "3.00.00.081";
1532 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1533 $dbh->do("CREATE TABLE `borrower_attribute_types` (
1534 `code` varchar(10) NOT NULL,
1535 `description` varchar(255) NOT NULL,
1536 `repeatable` tinyint(1) NOT NULL default 0,
1537 `unique_id` tinyint(1) NOT NULL default 0,
1538 `opac_display` tinyint(1) NOT NULL default 0,
1539 `password_allowed` tinyint(1) NOT NULL default 0,
1540 `staff_searchable` tinyint(1) NOT NULL default 0,
1541 `authorised_value_category` varchar(10) default NULL,
1542 PRIMARY KEY (`code`)
1543 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1544 $dbh->do("CREATE TABLE `borrower_attributes` (
1545 `borrowernumber` int(11) NOT NULL,
1546 `code` varchar(10) NOT NULL,
1547 `attribute` varchar(30) default NULL,
1548 `password` varchar(30) default NULL,
1549 KEY `borrowernumber` (`borrowernumber`),
1550 KEY `code_attribute` (`code`, `attribute`),
1551 CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1552 ON DELETE CASCADE ON UPDATE CASCADE,
1553 CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1554 ON DELETE CASCADE ON UPDATE CASCADE
1555 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1556 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
1557 print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
1558 SetVersion ($DBversion);
1561 $DBversion = "3.00.00.082";
1562 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1563 $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
1564 print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
1565 SetVersion ($DBversion);
1568 $DBversion = "3.00.00.083";
1569 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1570 $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
1571 print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
1572 SetVersion ($DBversion);
1574 $DBversion = "3.00.00.084";
1575 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1576 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RenewSerialAddsSuggestion','0','if ON, adds a new suggestion at serial subscription renewal',NULL,'YesNo')");
1577 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
1578 print "Upgrade to $DBversion done (add new sysprefs)\n";
1579 SetVersion ($DBversion);
1582 $DBversion = "3.00.00.085";
1583 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1584 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1585 $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
1586 $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
1587 $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
1588 $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
1589 $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
1590 $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
1592 print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
1593 SetVersion ($DBversion);
1596 $DBversion = "3.00.00.086";
1597 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1599 "CREATE TABLE `tmp_holdsqueue` (
1600 `biblionumber` int(11) default NULL,
1601 `itemnumber` int(11) default NULL,
1602 `barcode` varchar(20) default NULL,
1603 `surname` mediumtext NOT NULL,
1606 `borrowernumber` int(11) NOT NULL,
1607 `cardnumber` varchar(16) default NULL,
1608 `reservedate` date default NULL,
1610 `itemcallnumber` varchar(30) default NULL,
1611 `holdingbranch` varchar(10) default NULL,
1612 `pickbranch` varchar(10) default NULL,
1614 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1616 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RandomizeHoldsQueueWeight','0','if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight',NULL,'YesNo')");
1617 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaticHoldsQueueWeight','0','Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective',NULL,'TextArea')");
1619 print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
1620 SetVersion ($DBversion);
1623 $DBversion = "3.00.00.087";
1624 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1625 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
1626 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailPrimaryAddress','OFF','email|emailpro|B_email|cardnumber|OFF','Defines the default email address where Account Details emails are sent.','Choice')");
1627 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1628 SetVersion ($DBversion);
1631 $DBversion = "3.00.00.088";
1632 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1633 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
1634 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACItemHolds','1','Allow OPAC users to place hold on specific items. If OFF, users can only request next available copy.','','YesNo')");
1635 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo')");
1636 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC WARNING: MARC21 Only','YesNo')");
1637 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1638 SetVersion ($DBversion);
1641 $DBversion = "3.00.00.089";
1642 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1643 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice')");
1644 print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
1645 SetVersion ($DBversion);
1648 $DBversion = "3.00.00.090";
1649 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1651 CREATE TABLE `branch_borrower_circ_rules` (
1652 `branchcode` VARCHAR(10) NOT NULL,
1653 `categorycode` VARCHAR(10) NOT NULL,
1654 `maxissueqty` int(4) default NULL,
1655 PRIMARY KEY (`categorycode`, `branchcode`),
1656 CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1657 ON DELETE CASCADE ON UPDATE CASCADE,
1658 CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1659 ON DELETE CASCADE ON UPDATE CASCADE
1660 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1663 CREATE TABLE `default_borrower_circ_rules` (
1664 `categorycode` VARCHAR(10) NOT NULL,
1665 `maxissueqty` int(4) default NULL,
1666 PRIMARY KEY (`categorycode`),
1667 CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1668 ON DELETE CASCADE ON UPDATE CASCADE
1669 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1672 CREATE TABLE `default_branch_circ_rules` (
1673 `branchcode` VARCHAR(10) NOT NULL,
1674 `maxissueqty` int(4) default NULL,
1675 PRIMARY KEY (`branchcode`),
1676 CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1677 ON DELETE CASCADE ON UPDATE CASCADE
1678 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1681 CREATE TABLE `default_circ_rules` (
1682 `singleton` enum('singleton') NOT NULL default 'singleton',
1683 `maxissueqty` int(4) default NULL,
1684 PRIMARY KEY (`singleton`)
1685 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1687 print "Upgrade to $DBversion done (added several circ rules tables)\n";
1688 SetVersion ($DBversion);
1692 $DBversion = "3.00.00.091";
1693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1694 $dbh->do(<<'END_SQL');
1695 ALTER TABLE borrowers
1696 ADD `smsalertnumber` varchar(50) default NULL
1699 $dbh->do(<<'END_SQL');
1700 CREATE TABLE `message_attributes` (
1701 `message_attribute_id` int(11) NOT NULL auto_increment,
1702 `message_name` varchar(20) NOT NULL default '',
1703 `takes_days` tinyint(1) NOT NULL default '0',
1704 PRIMARY KEY (`message_attribute_id`),
1705 UNIQUE KEY `message_name` (`message_name`)
1706 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1709 $dbh->do(<<'END_SQL');
1710 CREATE TABLE `message_transport_types` (
1711 `message_transport_type` varchar(20) NOT NULL,
1712 PRIMARY KEY (`message_transport_type`)
1713 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1716 $dbh->do(<<'END_SQL');
1717 CREATE TABLE `message_transports` (
1718 `message_attribute_id` int(11) NOT NULL,
1719 `message_transport_type` varchar(20) NOT NULL,
1720 `is_digest` tinyint(1) NOT NULL default '0',
1721 `letter_module` varchar(20) NOT NULL default '',
1722 `letter_code` varchar(20) NOT NULL default '',
1723 PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
1724 KEY `message_transport_type` (`message_transport_type`),
1725 KEY `letter_module` (`letter_module`,`letter_code`),
1726 CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1727 CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
1728 CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
1729 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1732 $dbh->do(<<'END_SQL');
1733 CREATE TABLE `borrower_message_preferences` (
1734 `borrower_message_preference_id` int(11) NOT NULL auto_increment,
1735 `borrowernumber` int(11) NOT NULL default '0',
1736 `message_attribute_id` int(11) default '0',
1737 `days_in_advance` int(11) default '0',
1738 `wants_digets` tinyint(1) NOT NULL default '0',
1739 PRIMARY KEY (`borrower_message_preference_id`),
1740 KEY `borrowernumber` (`borrowernumber`),
1741 KEY `message_attribute_id` (`message_attribute_id`),
1742 CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1743 CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
1744 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1747 $dbh->do(<<'END_SQL');
1748 CREATE TABLE `borrower_message_transport_preferences` (
1749 `borrower_message_preference_id` int(11) NOT NULL default '0',
1750 `message_transport_type` varchar(20) NOT NULL default '0',
1751 PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1752 KEY `message_transport_type` (`message_transport_type`),
1753 CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY (`borrower_message_preference_id`) REFERENCES `borrower_message_preferences` (`borrower_message_preference_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1754 CONSTRAINT `borrower_message_transport_preferences_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE
1755 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1758 $dbh->do(<<'END_SQL');
1759 CREATE TABLE `message_queue` (
1760 `message_id` int(11) NOT NULL auto_increment,
1761 `borrowernumber` int(11) NOT NULL,
1764 `message_transport_type` varchar(20) NOT NULL,
1765 `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
1766 `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1767 KEY `message_id` (`message_id`),
1768 KEY `borrowernumber` (`borrowernumber`),
1769 KEY `message_transport_type` (`message_transport_type`),
1770 CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1771 CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
1772 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1775 $dbh->do(<<'END_SQL');
1776 INSERT INTO `systempreferences`
1777 (variable,value,explanation,options,type)
1779 ('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
1782 $dbh->do( <<'END_SQL');
1783 INSERT INTO `letter`
1784 (module, code, name, title, content)
1786 ('circulation','DUE','Item Due Reminder','Item Due Reminder','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item is now due:\r\n\r\n<<biblio.title>> by <<biblio.author>>'),
1787 ('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
1788 ('circulation','PREDUE','Advance Notice of Item Due','Advance Notice of Item Due','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThe following item will be due soon:\r\n\r\n<<biblio.title>> by <<biblio.author>>'),
1789 ('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
1790 ('circulation','EVENT','Upcoming Library Event','Upcoming Library Event','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThis is a reminder of an upcoming library event in which you have expressed interest.');
1794 'installer/data/mysql/en/mandatory/message_transport_types.sql',
1795 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
1796 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
1799 my $installer = C4::Installer->new();
1800 foreach my $script ( @sql_scripts ) {
1801 my $full_path = $installer->get_file_path_from_name($script);
1802 my $error = $installer->load_sql($full_path);
1803 warn $error if $error;
1806 print "Upgrade to $DBversion done (Table structure for table `message_queue`, `message_transport_types`, `message_attributes`, `message_transports`, `borrower_message_preferences`, and `borrower_message_transport_preferences`. Alter `borrowers` table,\n";
1807 SetVersion ($DBversion);
1810 $DBversion = "3.00.00.092";
1811 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1812 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowOnShelfHolds', '0', '', 'Allow hold requests to be placed on items that are not on loan', 'YesNo')");
1813 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
1814 print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
1815 SetVersion ($DBversion);
1818 $DBversion = "3.00.00.093";
1819 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1820 $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1821 $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1822 print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
1823 SetVersion ($DBversion);
1826 $DBversion = "3.00.00.094";
1827 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1828 $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
1829 print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
1830 SetVersion ($DBversion);
1833 $DBversion = "3.00.00.095";
1834 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1835 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1836 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
1837 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
1839 print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
1840 SetVersion ($DBversion);
1843 $DBversion = "3.00.00.096";
1844 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1845 $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
1847 if (my $row = $sth->fetchrow_hashref) {
1848 $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
1850 print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
1851 SetVersion ($DBversion);
1854 $DBversion = '3.00.00.097';
1855 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1857 $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
1858 $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
1859 $dbh->do('ALTER TABLE message_queue ADD content_type text');
1860 $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
1862 print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
1863 SetVersion($DBversion);
1866 $DBversion = '3.00.00.098';
1867 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1869 $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
1870 $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
1872 print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
1873 SetVersion($DBversion);
1876 $DBversion = '3.00.00.099';
1877 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1878 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('OpacSuppression', '0', '', 'Turn ON the OPAC Suppression feature, requires further setup, ask your system administrator for details', 'YesNo')");
1879 print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
1880 SetVersion($DBversion);
1883 $DBversion = '3.00.00.100';
1884 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1885 $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
1886 print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
1887 SetVersion($DBversion);
1890 $DBversion = '3.00.00.101';
1891 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1892 $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1893 $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1894 print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
1895 SetVersion($DBversion);
1898 $DBversion = '3.00.00.102';
1899 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1900 $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
1901 $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
1902 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
1903 # before setting constraint, delete any unvalid data
1904 $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
1905 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
1906 print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
1907 SetVersion($DBversion);
1910 $DBversion = "3.00.00.103";
1911 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1912 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1913 print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
1914 SetVersion ($DBversion);
1917 $DBversion = "3.00.00.104";
1918 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1919 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1920 print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
1921 SetVersion ($DBversion);
1924 $DBversion = '3.00.00.105';
1925 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
1927 # it is possible that this syspref is already defined since the feature was added some time ago.
1928 unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
1929 $dbh->do(<<'END_SQL');
1930 INSERT INTO `systempreferences`
1931 (variable,value,explanation,options,type)
1933 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
1936 print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
1937 SetVersion($DBversion);
1940 $DBversion = "3.00.00.106";
1941 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1942 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1944 # db revision 105 didn't apply correctly, so we're rolling this into 106
1945 $dbh->do("INSERT INTO `systempreferences`
1946 (variable,value,explanation,options,type)
1948 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
1950 print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
1951 $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
1952 $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
1953 SetVersion ($DBversion);
1956 $DBversion = '3.00.00.107';
1957 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1958 $dbh->do(<<'END_SQL');
1959 UPDATE systempreferences
1960 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
1961 WHERE variable = 'OPACShelfBrowser'
1962 AND explanation NOT LIKE '%WARNING%'
1964 $dbh->do(<<'END_SQL');
1965 UPDATE systempreferences
1966 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
1967 WHERE variable = 'CataloguingLog'
1968 AND explanation NOT LIKE '%WARNING%'
1970 $dbh->do(<<'END_SQL');
1971 UPDATE systempreferences
1972 SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
1973 WHERE variable = 'NoZebra'
1974 AND explanation NOT LIKE '%WARNING%'
1976 print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
1977 SetVersion ($DBversion);
1980 $DBversion = '3.01.00.000';
1981 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1982 print "Upgrade to $DBversion done (start of 3.1)\n";
1983 SetVersion ($DBversion);
1986 $DBversion = '3.01.00.001';
1987 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1989 CREATE TABLE hold_fill_targets (
1990 `borrowernumber` int(11) NOT NULL,
1991 `biblionumber` int(11) NOT NULL,
1992 `itemnumber` int(11) NOT NULL,
1993 `source_branchcode` varchar(10) default NULL,
1994 `item_level_request` tinyint(4) NOT NULL default 0,
1995 PRIMARY KEY `itemnumber` (`itemnumber`),
1996 KEY `bib_branch` (`biblionumber`, `source_branchcode`),
1997 CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
1998 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1999 CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
2000 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2001 CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
2002 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2003 CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
2004 REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2005 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2008 ALTER TABLE tmp_holdsqueue
2009 ADD item_level_request tinyint(4) NOT NULL default 0
2012 print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
2013 SetVersion($DBversion);
2016 $DBversion = '3.01.00.002';
2017 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2018 # use statistics where available
2020 ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
2025 SELECT max(datetime)
2027 WHERE type = 'issue'
2028 AND itemnumber = iss.itemnumber
2029 AND borrowernumber = iss.borrowernumber
2031 WHERE issuedate IS NULL;
2033 $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
2035 # default to last renewal date
2038 SET issuedate = lastreneweddate
2039 WHERE issuedate IS NULL
2040 and lastreneweddate IS NOT NULL
2043 my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
2044 if ($num_bad_issuedates > 0) {
2045 print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
2046 "Please check the issues table in your database.";
2048 print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
2049 SetVersion($DBversion);
2052 $DBversion = "3.01.00.003";
2053 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2054 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowRenewalLimitOverride', '0', 'if ON, allows renewal limits to be overridden on the circulation screen',NULL,'YesNo')");
2055 print "Upgrade to $DBversion done (add new syspref)\n";
2056 SetVersion ($DBversion);
2059 $DBversion = '3.01.00.004';
2060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2061 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACDisplayRequestPriority','0','Show patrons the priority level on holds in the OPAC','','YesNo')");
2062 print "Upgrade to $DBversion done (added OPACDisplayRequestPriority system preference)\n";
2063 SetVersion ($DBversion);
2066 $DBversion = '3.01.00.005';
2067 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2069 INSERT INTO `letter` (module, code, name, title, content)
2070 VALUES('reserves', 'HOLD', 'Hold Available for Pickup', 'Hold Available for Pickup at <<branches.branchname>>', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\nLocation: <<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n<<branches.branchaddress3>>')
2072 $dbh->do("INSERT INTO `message_attributes` (message_attribute_id, message_name, takes_days) values(4, 'Hold Filled', 0)");
2073 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'sms', 0, 'reserves', 'HOLD')");
2074 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'email', 0, 'reserves', 'HOLD')");
2075 print "Upgrade to $DBversion done (Add letter for holds notifications)\n";
2076 SetVersion ($DBversion);
2079 $DBversion = '3.01.00.006';
2080 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2081 $dbh->do("ALTER TABLE `biblioitems` ADD KEY issn (issn)");
2082 print "Upgrade to $DBversion done (add index on biblioitems.issn)\n";
2083 SetVersion ($DBversion);
2086 $DBversion = "3.01.00.007";
2087 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2088 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetmainUserblock'");
2089 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetuserjs'");
2090 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacheader'");
2091 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacMainUserBlock'");
2092 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacNav'");
2093 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacuserjs'");
2094 $dbh->do("UPDATE `systempreferences` SET options='30|10', type='Textarea' WHERE variable='OAI-PMH:Set'");
2095 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetstylesheet'");
2096 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetcolorstylesheet'");
2097 $dbh->do("UPDATE `systempreferences` SET options='10' WHERE variable='globalDueDate'");
2098 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='numSearchResults'");
2099 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='OPACnumSearchResults'");
2100 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='ReservesMaxPickupDelay'");
2101 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='TransfersMaxDaysWarning'");
2102 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='StaticHoldsQueueWeight'");
2103 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='holdCancelLength'");
2104 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='XISBNDailyLimit'");
2105 $dbh->do("UPDATE `systempreferences` SET type='Float' WHERE variable='gist'");
2106 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorUsername'");
2107 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorPassword'");
2108 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10' WHERE variable='ISBD'");
2109 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10', explanation='Enter a specific hash for NoZebra indexes. Enter : \\\'indexname\\\' => \\\'100a,245a,500*\\\',\\\'index2\\\' => \\\'...\\\'' WHERE variable='NoZebraIndexes'");
2110 print "Upgrade to $DBversion done (fix display of many sysprefs)\n";
2111 SetVersion ($DBversion);
2114 $DBversion = '3.01.00.008';
2115 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2117 $dbh->do("CREATE TABLE branch_transfer_limits (
2118 limitId int(8) NOT NULL auto_increment,
2119 toBranch varchar(4) NOT NULL,
2120 fromBranch varchar(4) NOT NULL,
2121 itemtype varchar(4) NOT NULL,
2122 PRIMARY KEY (limitId)
2123 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
2126 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'UseBranchTransferLimits', '0', '', 'If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.', 'YesNo')");
2128 print "Upgrade to $DBversion done (added branch_transfer_limits table and UseBranchTransferLimits system preference)\n";
2129 SetVersion ($DBversion);
2132 $DBversion = "3.01.00.009";
2133 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2134 $dbh->do("ALTER TABLE permissions MODIFY `code` varchar(64) DEFAULT NULL");
2135 $dbh->do("ALTER TABLE user_permissions MODIFY `code` varchar(64) DEFAULT NULL");
2136 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'circulate_remaining_permissions', 'Remaining circulation permissions')");
2137 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'override_renewals', 'Override blocked renewals')");
2138 print "Upgrade to $DBversion done (added subpermissions for circulate permission)\n";
2141 $DBversion = '3.01.00.010';
2142 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2143 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `attribute` VARCHAR(64) DEFAULT NULL");
2144 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `password` VARCHAR(64) DEFAULT NULL");
2145 print "Upgrade to $DBversion done (bug 2687: increase length of borrower attribute fields)\n";
2146 SetVersion ($DBversion);
2149 $DBversion = '3.01.00.011';
2150 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2152 # Yes, the old value was ^M terminated.
2153 my $bad_value = "function prepareEmailPopup(){\r\n if (!document.getElementById) return false;\r\n if (!document.getElementById('reserveemail')) return false;\r\n rsvlink = document.getElementById('reserveemail');\r\n rsvlink.onclick = function() {\r\n doReservePopup();\r\n return false;\r\n }\r\n}\r\n\r\nfunction doReservePopup(){\r\n}\r\n\r\nfunction prepareReserveList(){\r\n}\r\n\r\naddLoadEvent(prepareEmailPopup);\r\naddLoadEvent(prepareReserveList);";
2155 my $intranetuserjs = C4::Context->preference('intranetuserjs');
2156 if ($intranetuserjs and $intranetuserjs eq $bad_value) {
2157 my $sql = <<'END_SQL';
2158 UPDATE systempreferences
2160 WHERE variable = 'intranetuserjs'
2164 print "Upgrade to $DBversion done (removed bogus intranetuserjs syspref)\n";
2165 SetVersion($DBversion);
2168 $DBversion = "3.01.00.012";
2169 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2170 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo')");
2172 CREATE TABLE `branch_item_rules` (
2173 `branchcode` varchar(10) NOT NULL,
2174 `itemtype` varchar(10) NOT NULL,
2175 `holdallowed` tinyint(1) default NULL,
2176 PRIMARY KEY (`itemtype`,`branchcode`),
2177 KEY `branch_item_rules_ibfk_2` (`branchcode`),
2178 CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
2179 CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2180 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2183 CREATE TABLE `default_branch_item_rules` (
2184 `itemtype` varchar(10) NOT NULL,
2185 `holdallowed` tinyint(1) default NULL,
2186 PRIMARY KEY (`itemtype`),
2187 CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
2188 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2191 ALTER TABLE default_branch_circ_rules
2192 ADD COLUMN holdallowed tinyint(1) NULL
2195 ALTER TABLE default_circ_rules
2196 ADD COLUMN holdallowed tinyint(1) NULL
2198 print "Upgrade to $DBversion done (Add tables and system preferences for holds policies)\n";
2199 SetVersion ($DBversion);
2202 $DBversion = '3.01.00.013';
2203 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2205 CREATE TABLE item_circulation_alert_preferences (
2206 id int(11) AUTO_INCREMENT,
2207 branchcode varchar(10) NOT NULL,
2208 categorycode varchar(10) NOT NULL,
2209 item_type varchar(10) NOT NULL,
2210 notification varchar(16) NOT NULL,
2212 KEY (branchcode, categorycode, item_type, notification)
2213 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2216 $dbh->do(q{ ALTER TABLE `message_queue` ADD metadata text DEFAULT NULL AFTER content; });
2217 $dbh->do(q{ ALTER TABLE `message_queue` ADD letter_code varchar(64) DEFAULT NULL AFTER metadata; });
2220 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2221 ('circulation','CHECKIN','Item Check-in','Check-ins','The following items have been checked in:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you.');
2224 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2225 ('circulation','CHECKOUT','Item Checkout','Checkouts','The following items have been checked out:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you for visiting <<branches.branchname>>.');
2228 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (5, 'Item Check-in', 0);});
2229 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (6, 'Item Checkout', 0);});
2231 $dbh->do(q{INSERT INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES (5, 'email', 0, 'circulation', 'CHECKIN');});
2232 $dbh->do(q{INSERT INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES (5, 'sms', 0, 'circulation', 'CHECKIN');});
2233 $dbh->do(q{INSERT INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES (6, 'email', 0, 'circulation', 'CHECKOUT');});
2234 $dbh->do(q{INSERT INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES (6, 'sms', 0, 'circulation', 'CHECKOUT');});
2236 print "Upgrade to $DBversion done (data for Email Checkout Slips project)\n";
2237 SetVersion ($DBversion);
2240 $DBversion = "3.01.00.014";
2241 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2242 $dbh->do("ALTER TABLE `branch_transfer_limits` CHANGE `itemtype` `itemtype` VARCHAR( 4 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL");
2243 $dbh->do("ALTER TABLE `branch_transfer_limits` ADD `ccode` VARCHAR( 10 ) NULL ;");
2244 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2246 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice'
2249 print "Upgrade to $DBversion done ( Updated table for Branch Transfer Limits)\n";
2250 SetVersion ($DBversion);
2253 $DBversion = '3.01.00.015';
2254 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2255 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsClientCode', '0', 'Client Code for using Syndetics Solutions content','','free')");
2257 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEnabled', '0', 'Turn on Syndetics Enhanced Content','','YesNo')");
2259 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImages', '0', 'Display Cover Images from Syndetics','','YesNo')");
2261 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsTOC', '0', 'Display Table of Content information from Syndetics','','YesNo')");
2263 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSummary', '0', 'Display Summary Information from Syndetics','','YesNo')");
2265 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEditions', '0', 'Display Editions from Syndetics','','YesNo')");
2267 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsExcerpt', '0', 'Display Excerpts and first chapters on OPAC from Syndetics','','YesNo')");
2269 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsReviews', '0', 'Display Reviews on OPAC from Syndetics','','YesNo')");
2271 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAuthorNotes', '0', 'Display Notes about the Author on OPAC from Syndetics','','YesNo')");
2273 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAwards', '0', 'Display Awards on OPAC from Syndetics','','YesNo')");
2275 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSeries', '0', 'Display Series information on OPAC from Syndetics','','YesNo')");
2277 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImageSize', 'MC', 'Choose the size of the Syndetics Cover Image to display on the OPAC detail page, MC is Medium, LC is Large','MC|LC','Choice')");
2279 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from Amazon Web Services','','YesNo')");
2281 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from Amazon Web Services','','YesNo')");
2283 $dbh->do("UPDATE systempreferences SET variable='AmazonEnabled' WHERE variable = 'AmazonContent'");
2285 $dbh->do("UPDATE systempreferences SET variable='OPACAmazonEnabled' WHERE variable = 'OPACAmazonContent'");
2287 print "Upgrade to $DBversion done (added Syndetics Enhanced Content system preferences)\n";
2288 SetVersion ($DBversion);
2291 $DBversion = "3.01.00.016";
2292 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2293 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Babeltheque',0,'Turn ON Babeltheque content - See babeltheque.com to subscribe to this service','','YesNo')");
2294 print "Upgrade to $DBversion done (Added Babeltheque syspref)\n";
2295 SetVersion ($DBversion);
2298 $DBversion = "3.01.00.017";
2299 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2300 $dbh->do("ALTER TABLE `subscription` ADD `staffdisplaycount` VARCHAR(10) NULL;");
2301 $dbh->do("ALTER TABLE `subscription` ADD `opacdisplaycount` VARCHAR(10) NULL;");
2302 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2304 'StaffSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the Staff client', 'Integer'
2306 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2308 'OPACSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the OPAC', 'Integer'
2311 print "Upgrade to $DBversion done ( Updated table for Serials Display)\n";
2312 SetVersion ($DBversion);
2315 $DBversion = "3.01.00.018";
2316 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2317 $dbh->do("ALTER TABLE deletedborrowers ADD `smsalertnumber` varchar(50) default NULL");
2318 print "Upgrade to $DBversion done (added deletedborrowers.smsalertnumber, missed in 3.00.00.091)\n";
2319 SetVersion ($DBversion);
2322 $DBversion = "3.01.00.019";
2323 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2324 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACShowCheckoutName','0','Displays in the OPAC the name of patron who has checked out the material. WARNING: Most sites should leave this off. It is intended for corporate or special sites which need to track who has the item.','','YesNo')");
2325 print "Upgrade to $DBversion done (adding OPACShowCheckoutName systempref)\n";
2326 SetVersion ($DBversion);
2329 $DBversion = "3.01.00.020";
2330 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2331 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesID','','See:http://librarything.com/forlibraries/','','free')");
2332 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesEnabled','0','Enable or Disable Library Thing for Libraries Features','','YesNo')");
2333 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesTabbedView','0','Put LibraryThingForLibraries Content in Tabs.','','YesNo')");
2334 print "Upgrade to $DBversion done (adding LibraryThing for Libraries sysprefs)\n";
2335 SetVersion ($DBversion);
2338 $DBversion = "3.01.00.021";
2339 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2340 my $enable_reviews = C4::Context->preference('OPACAmazonEnabled') ? '1' : '0';
2341 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonReviews', '$enable_reviews', 'Display Amazon readers reviews on OPAC','','YesNo')");
2342 print "Upgrade to $DBversion done (adding OPACAmazonReviews syspref)\n";
2343 SetVersion ($DBversion);
2346 $DBversion = '3.01.00.022';
2347 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2348 $dbh->do("ALTER TABLE `labels_conf` MODIFY COLUMN `formatstring` mediumtext DEFAULT NULL");
2349 print "Upgrade to $DBversion done (bug 2945: increase size of labels_conf.formatstring)\n";
2350 SetVersion ($DBversion);
2353 $DBversion = '3.01.00.023';
2354 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2355 $dbh->do("ALTER TABLE biblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2356 $dbh->do("ALTER TABLE deletedbiblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2357 $dbh->do("ALTER TABLE import_biblios MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2358 $dbh->do("ALTER TABLE suggestions MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2359 print "Upgrade to $DBversion done (bug 2765: increase width of isbn column in several tables)\n";
2360 SetVersion ($DBversion);
2363 $DBversion = "3.01.00.024";
2364 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2365 $dbh->do("ALTER TABLE labels MODIFY COLUMN batch_id int(10) NOT NULL default 1;");
2366 print "Upgrade to $DBversion done (change labels.batch_id from varchar to int)\n";
2367 SetVersion ($DBversion);
2370 $DBversion = '3.01.00.025';
2371 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2372 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'ceilingDueDate', '', '', 'If set, date due will not be past this date. Enter date according to the dateformat System Preference', 'free')");
2374 print "Upgrade to $DBversion done (added ceilingDueDate system preference)\n";
2375 SetVersion ($DBversion);
2378 $DBversion = '3.01.00.026';
2379 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2380 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'numReturnedItemsToShow', '20', '', 'Number of returned items to show on the check-in page', 'Integer')");
2382 print "Upgrade to $DBversion done (added numReturnedItemsToShow system preference)\n";
2383 SetVersion ($DBversion);
2386 $DBversion = '3.01.00.027';
2387 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2388 $dbh->do("ALTER TABLE zebraqueue CHANGE `biblio_auth_number` `biblio_auth_number` bigint(20) unsigned NOT NULL default 0");
2389 print "Upgrade to $DBversion done (Increased size of zebraqueue biblio_auth_number to address bug 3148.)\n";
2390 SetVersion ($DBversion);
2393 $DBversion = '3.01.00.028';
2394 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2395 my $enable_reviews = C4::Context->preference('AmazonEnabled') ? '1' : '0';
2396 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonReviews', '$enable_reviews', 'Display Amazon reviews on staff interface','','YesNo')");
2397 print "Upgrade to $DBversion done (added AmazonReviews)\n";
2398 SetVersion ($DBversion);
2401 $DBversion = '3.01.00.029';
2402 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2403 $dbh->do(q( UPDATE language_rfc4646_to_iso639
2404 SET iso639_2_code = 'spa'
2405 WHERE rfc4646_subtag = 'es'
2406 AND iso639_2_code = 'rus' )
2408 print "Upgrade to $DBversion done (fixed bug 2599: using Spanish search limit retrieves Russian results)\n";
2409 SetVersion ($DBversion);
2412 $DBversion = "3.01.00.030";
2413 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2414 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'AllowNotForLoanOverride', '0', '', 'If ON, Koha will allow the librarian to loan a not for loan item.', 'YesNo')");
2415 print "Upgrade to $DBversion done (added AllowNotForLoanOverride system preference)\n";
2416 SetVersion ($DBversion);
2419 $DBversion = "3.01.00.031";
2420 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2421 $dbh->do("ALTER TABLE branch_transfer_limits
2422 MODIFY toBranch varchar(10) NOT NULL,
2423 MODIFY fromBranch varchar(10) NOT NULL,
2424 MODIFY itemtype varchar(10) NULL");
2425 print "Upgrade to $DBversion done (fix column widths in branch_transfer_limits)\n";
2426 SetVersion ($DBversion);
2429 $DBversion = "3.01.00.032";
2430 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2431 $dbh->do(<<ENDOFRENEWAL);
2432 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RenewalPeriodBase', 'now', 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','date_due|now','Choice');
2434 print "Upgrade to $DBversion done (Change the field)\n";
2435 SetVersion ($DBversion);
2438 $DBversion = "3.01.00.033";
2439 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2441 ALTER TABLE borrower_message_preferences
2442 MODIFY borrowernumber int(11) default NULL,
2443 ADD categorycode varchar(10) default NULL AFTER borrowernumber,
2444 ADD KEY `categorycode` (`categorycode`),
2445 ADD CONSTRAINT `borrower_message_preferences_ibfk_3`
2446 FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
2447 ON DELETE CASCADE ON UPDATE CASCADE
2449 print "Upgrade to $DBversion done (DB changes to allow patron category defaults for messaging preferences)\n";
2450 SetVersion ($DBversion);
2453 $DBversion = "3.01.00.034";
2454 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2455 $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
2456 print "Upgrade to $DBversion done (Adding graceperiod column to subscription table)\n";
2457 SetVersion ($DBversion);
2460 $DBversion = '3.01.00.035';
2461 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2462 $dbh->do(q{ ALTER TABLE `subscription` ADD location varchar(80) NULL DEFAULT '' AFTER callnumber; });
2463 print "Upgrade to $DBversion done (Adding location to subscription table)\n";
2464 SetVersion ($DBversion);
2467 $DBversion = '3.01.00.036';
2468 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2469 $dbh->do("UPDATE systempreferences SET explanation = 'Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd'
2470 WHERE variable = 'IntranetBiblioDefaultView'
2471 AND explanation = 'IntranetBiblioDefaultView'");
2472 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = 'normal|marc|isbd|labeled_marc'
2473 WHERE variable = 'IntranetBiblioDefaultView'");
2474 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewISBD','1','Allow display of ISBD view of bibiographic records','','YesNo')");
2475 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo')");
2476 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo')");
2477 print "Upgrade to $DBversion done (new viewISBD, viewLabeledMARC, viewMARC sysprefs and tweak IntranetBiblioDefaultView)\n";
2478 SetVersion ($DBversion);
2481 $DBversion = '3.01.00.037';
2482 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2483 $dbh->do('ALTER TABLE authorised_values ADD KEY `lib` (`lib`)');
2484 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo')");
2485 SetVersion ($DBversion);
2486 print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
2489 $DBversion = "3.01.00.038";
2490 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2491 # update branches table
2493 $dbh->do("ALTER TABLE branches ADD `branchzip` varchar(25) default NULL AFTER `branchaddress3`");
2494 $dbh->do("ALTER TABLE branches ADD `branchcity` mediumtext AFTER `branchzip`");
2495 $dbh->do("ALTER TABLE branches ADD `branchcountry` text AFTER `branchcity`");
2496 $dbh->do("ALTER TABLE branches ADD `branchurl` mediumtext AFTER `branchemail`");
2497 $dbh->do("ALTER TABLE branches ADD `branchnotes` mediumtext AFTER `branchprinter`");
2498 print "Upgrade to $DBversion done (add ZIP, city, country, URL, and notes column to branches)\n";
2499 SetVersion ($DBversion);
2502 $DBversion = '3.01.00.039';
2503 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2504 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelFormat', '<itemcallnumber><copynumber>', '30|10', 'This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.', 'Textarea')");
2505 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('SpineLabelAutoPrint', '0', '', 'If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.', 'YesNo')");
2506 SetVersion ($DBversion);
2507 print "Upgrade to $DBversion done (added SpineLabelFormat and SpineLabelAutoPrint sysprefs)\n";
2510 $DBversion = '3.01.00.040';
2511 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2512 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('AllowHoldDateInFuture','0','If set a date field is displayed on the Hold screen of the Staff Interface, allowing the hold date to be set in the future.','','YesNo')");
2513 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('OPACAllowHoldDateInFuture','0','If set, along with the AllowHoldDateInFuture system preference, OPAC users can set the date of a hold to be in the future.','','YesNo')");
2514 SetVersion ($DBversion);
2515 print "Upgrade to $DBversion done (AllowHoldDateInFuture and OPACAllowHoldDateInFuture sysprefs)\n";
2518 $DBversion = '3.01.00.041';
2519 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2520 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSPrivateKey','','See: http://aws.amazon.com. Note that this is required after 2009/08/15 in order to retrieve any enhanced content other than book covers from Amazon.','','free')");
2521 SetVersion ($DBversion);
2522 print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that if you use enhanced content from Amazon, this should be set right away.)\n";
2525 $DBversion = '3.01.00.042';
2526 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2527 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACFineNoRenewals','99999','Fine Limit above which user canmot renew books via OPAC','','Integer')");
2528 SetVersion ($DBversion);
2529 print "Upgrade to $DBversion done (added OPACFineNoRenewals syspref)\n";
2532 $DBversion = '3.01.00.043';
2533 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2534 $dbh->do('ALTER TABLE items ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2535 $dbh->do('UPDATE items SET permanent_location = location');
2536 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'NewItemsDefaultLocation', '', '', 'If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )', '')");
2537 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'InProcessingToShelvingCart', '0', '', 'If set, when any item with a location code of PROC is ''checked in'', it''s location code will be changed to CART.', 'YesNo')");
2538 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'ReturnToShelvingCart', '0', '', 'If set, when any item is ''checked in'', it''s location code will be changed to CART.', 'YesNo')");
2539 SetVersion ($DBversion);
2540 print "Upgrade to $DBversion done (amended Item added NewItemsDefaultLocation, InProcessingToShelvingCart, ReturnToShelvingCart sysprefs)\n";
2543 $DBversion = '3.01.00.044';
2544 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2545 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES( 'DisplayClearScreenButton', '0', 'If set to yes, a clear screen button will appear on the circulation page.', 'If set to yes, a clear screen button will appear on the circulation page.', 'YesNo')");
2546 SetVersion ($DBversion);
2547 print "Upgrade to $DBversion done (added DisplayClearScreenButton system preference)\n";
2550 $DBversion = '3.01.00.045';
2551 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2552 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('HidePatronName', '0', '', 'If this is switched on, patron''s cardnumber will be shown instead of their name on the holds and catalog screens', 'YesNo')");
2553 SetVersion ($DBversion);
2554 print "Upgrade to $DBversion done (added a preference to hide the patrons name in the staff catalog)\n";
2557 $DBversion = "3.01.00.046";
2558 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2559 # update borrowers table
2561 $dbh->do("ALTER TABLE borrowers ADD `country` text AFTER zipcode");
2562 $dbh->do("ALTER TABLE borrowers ADD `B_country` text AFTER B_zipcode");
2563 $dbh->do("ALTER TABLE deletedborrowers ADD `country` text AFTER zipcode");
2564 $dbh->do("ALTER TABLE deletedborrowers ADD `B_country` text AFTER B_zipcode");
2565 print "Upgrade to $DBversion done (add country and B_country to borrowers)\n";
2566 SetVersion ($DBversion);
2569 $DBversion = '3.01.00.047';
2570 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2571 $dbh->do("ALTER TABLE items MODIFY itemcallnumber varchar(255);");
2572 $dbh->do("ALTER TABLE deleteditems MODIFY itemcallnumber varchar(255);");
2573 $dbh->do("ALTER TABLE tmp_holdsqueue MODIFY itemcallnumber varchar(255);");
2574 SetVersion ($DBversion);
2575 print " Upgrade to $DBversion done (bug 2761: change max length of itemcallnumber to 255 from 30)\n";
2578 $DBversion = '3.01.00.048';
2579 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2580 $dbh->do("UPDATE userflags SET flagdesc='View Catalog (Librarian Interface)' WHERE bit=2;");
2581 $dbh->do("UPDATE userflags SET flagdesc='Edit Catalog (Modify bibliographic/holdings data)' WHERE bit=9;");
2582 $dbh->do("UPDATE userflags SET flagdesc='Allow to edit authorities' WHERE bit=14;");
2583 $dbh->do("UPDATE userflags SET flagdesc='Allow to access to the reports module' WHERE bit=16;");
2584 $dbh->do("UPDATE userflags SET flagdesc='Allow to manage serials subscriptions' WHERE bit=15;");
2585 SetVersion ($DBversion);
2586 print " Upgrade to $DBversion done (bug 2611: fix spelling/capitalization in permission flag descriptions)\n";
2589 $DBversion = '3.01.00.049';
2590 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2591 $dbh->do("UPDATE permissions SET description = 'Perform inventory (stocktaking) of your catalog' WHERE code = 'inventory';");
2592 SetVersion ($DBversion);
2593 print "Upgrade to $DBversion done (bug 2611: changed catalogue to catalog per the standard)\n";
2596 $DBversion = '3.01.00.050';
2597 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2598 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACSearchForTitleIn','<li class=\"yuimenuitem\">\n<a target=\"_blank\" class=\"yuimenuitemlabel\" href=\"http://worldcat.org/search?q=TITLE\">Other Libraries (WorldCat)</a></li>\n<li class=\"yuimenuitem\">\n<a class=\"yuimenuitemlabel\" href=\"http://www.scholar.google.com/scholar?q=TITLE\" target=\"_blank\">Other Databases (Google Scholar)</a></li>\n<li class=\"yuimenuitem\">\n<a class=\"yuimenuitemlabel\" href=\"http://www.bookfinder.com/search/?author=AUTHOR&title=TITLE&st=xl&ac=qr\" target=\"_blank\">Online Stores (Bookfinder.com)</a></li>','Enter the HTML that will appear in the ''Search for this title in'' box on the detail page in the OPAC. Enter TITLE, AUTHOR, or ISBN in place of their respective variables in the URL. Leave blank to disable ''More Searches'' menu.','70|10','Textarea');");
2599 SetVersion ($DBversion);
2600 print "Upgrade to $DBversion done (bug 1934: Add OPACSearchForTitleIn syspref)\n";
2603 $DBversion = '3.01.00.051';
2604 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2605 $dbh->do("UPDATE systempreferences SET explanation='Fine limit above which user cannot renew books via OPAC' WHERE variable='OPACFineNoRenewals';");
2606 $dbh->do("UPDATE systempreferences SET explanation='If set to ON, a clear screen button will appear on the circulation page.' WHERE variable='DisplayClearScreenButton';");
2607 SetVersion ($DBversion);
2608 print "Upgrade to $DBversion done (fixed typos in new sysprefs)\n";
2611 $DBversion = '3.01.00.052';
2612 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2613 $dbh->do('ALTER TABLE deleteditems ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2614 SetVersion ($DBversion);
2615 print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
2618 $DBversion = '3.01.00.053';
2619 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2620 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
2621 system("perl $upgrade_script");
2622 print "Upgrade to $DBversion done (Migrated labels tables and data to new schema.) NOTE: All existing label batches have been assigned to the first branch in the list of branches. This is ONLY true of migrated label batches.\n";
2623 SetVersion ($DBversion);
2626 $DBversion = '3.01.00.054';
2627 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2628 $dbh->do("ALTER TABLE borrowers ADD `B_address2` text AFTER B_address");
2629 $dbh->do("ALTER TABLE borrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2630 $dbh->do("ALTER TABLE deletedborrowers ADD `B_address2` text AFTER B_address");
2631 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2632 SetVersion ($DBversion);
2633 print "Upgrade to $DBversion done (bug 1600, bug 3454: add altcontactcountry and B_address2 to borrowers and deletedborrowers)\n";
2636 $DBversion = '3.01.00.055';
2637 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2638 $dbh->do(qq|UPDATE systempreferences set explanation='Enter the HTML that will appear in the ''Search for this title in'' box on the detail page in the OPAC. Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable ''More Searches'' menu.', value='<li><a href="http://worldcat.org/search?q={TITLE}" target="_blank">Other Libraries (WorldCat)</a></li>\n<li><a href="http://www.scholar.google.com/scholar?q={TITLE}" target="_blank">Other Databases (Google Scholar)</a></li>\n<li><a href="http://www.bookfinder.com/search/?author={AUTHOR}&title={TITLE}&st=xl&ac=qr" target="_blank">Online Stores (Bookfinder.com)</a></li>' WHERE variable='OPACSearchForTitleIn'|);
2639 SetVersion ($DBversion);
2640 print "Upgrade to $DBversion done (changed OPACSearchForTitleIn per requests in bug 1934)\n";
2643 $DBversion = '3.01.00.056';
2644 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2645 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACPatronDetails','1','If OFF the patron details tab in the OPAC is disabled.','','YesNo');");
2646 SetVersion ($DBversion);
2647 print "Upgrade to $DBversion done (Bug 1172 : Add OPACPatronDetails syspref)\n";
2650 $DBversion = '3.01.00.057';
2651 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2652 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACFinesTab','1','If OFF the patron fines tab in the OPAC is disabled.','','YesNo');");
2653 SetVersion ($DBversion);
2654 print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
2657 $DBversion = '3.01.00.058';
2658 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2659 $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2660 $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2661 $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2662 SetVersion ($DBversion);
2663 print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
2666 $DBversion = '3.01.00.059';
2667 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2668 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo')");
2669 SetVersion ($DBversion);
2670 print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
2673 $DBversion = '3.01.00.060';
2674 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2675 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
2676 $dbh->do('DROP TABLE IF EXISTS messages');
2677 $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
2678 `borrowernumber` int(11) NOT NULL,
2679 `branchcode` varchar(4) default NULL,
2680 `message_type` varchar(1) NOT NULL,
2681 `message` text NOT NULL,
2682 `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2683 PRIMARY KEY (`message_id`)
2684 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
2686 print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
2687 SetVersion ($DBversion);
2690 $DBversion = '3.01.00.061';
2691 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2692 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'If ON, displays patron image when a patron uses web-based self-checkout', '', 'YesNo')");
2693 print "Upgrade to $DBversion done ( Added ShowPatronImageInWebBasedSelfCheck system preference )\n";
2694 SetVersion ($DBversion);
2697 $DBversion = "3.01.00.062";
2698 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2699 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'manage_csv_profiles', 'Manage CSV export profiles')");
2701 CREATE TABLE `export_format` (
2702 `export_format_id` int(11) NOT NULL auto_increment,
2703 `profile` varchar(255) NOT NULL,
2704 `description` mediumtext NOT NULL,
2705 `marcfields` mediumtext NOT NULL,
2706 PRIMARY KEY (`export_format_id`)
2707 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
2709 print "Upgrade to $DBversion done (added csv export profiles)\n";
2712 $DBversion = "3.01.00.063";
2713 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2715 CREATE TABLE `fieldmapping` (
2716 `id` int(11) NOT NULL auto_increment,
2717 `field` varchar(255) NOT NULL,
2718 `frameworkcode` char(4) NOT NULL default '',
2719 `fieldcode` char(3) NOT NULL,
2720 `subfieldcode` char(1) NOT NULL,
2722 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2724 SetVersion ($DBversion);print "Upgrade to $DBversion done (Created table fieldmapping)\n";print "Upgrade to 3.01.00.064 done (Version number skipped: nothing done)\n";
2727 $DBversion = '3.01.00.065';
2728 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2729 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
2730 $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
2733 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
2735 while(my $row = $sth->fetchrow_hashref){
2736 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
2739 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
2741 SetVersion ($DBversion);
2742 print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2745 $DBversion = '3.01.00.066';
2746 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2747 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2749 my $maxreserves = C4::Context->preference('maxreserves');
2750 $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2751 $sth->execute($maxreserves);
2753 $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2755 $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2757 SetVersion ($DBversion);
2758 print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2761 $DBversion = "3.01.00.067";
2762 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2763 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
2764 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
2765 print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
2766 SetVersion ($DBversion);
2769 $DBversion = "3.01.00.068";
2770 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2771 $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
2772 print "Upgrade to $DBversion done (Adding finedays in issuingrules table)\n";
2773 SetVersion ($DBversion);
2777 $DBversion = "3.01.00.069";
2778 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2779 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableOpacSearchHistory', '1', '', 'Enable or disable opac search history', 'YesNo')");
2781 my $create = <<SEARCHHIST;
2782 CREATE TABLE IF NOT EXISTS `search_history` (
2783 `userid` int(11) NOT NULL,
2784 `sessionid` varchar(32) NOT NULL,
2785 `query_desc` varchar(255) NOT NULL,
2786 `query_cgi` varchar(255) NOT NULL,
2787 `total` int(11) NOT NULL,
2788 `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2789 KEY `userid` (`userid`),
2790 KEY `sessionid` (`sessionid`)
2791 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
2795 print "Upgrade to $DBversion done (added OPAC search history preference and table)\n";
2798 $DBversion = "3.01.00.070";
2799 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2800 $dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
2801 print "Upgrade to $DBversion done (Added a lib_opac field in authorised_values table)\n";
2804 $DBversion = "3.01.00.071";
2805 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2806 $dbh->do("ALTER TABLE `subscription` ADD `enddate` date default NULL");
2807 $dbh->do("ALTER TABLE subscriptionhistory CHANGE enddate histenddate DATE default NULL");
2808 print "Upgrade to $DBversion done ( Adding enddate to subscription)\n";
2811 # Acquisitions update
2813 $DBversion = "3.01.00.072";
2814 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2815 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacPrivacy', '0', 'if ON, allows patrons to define their privacy rules (reading history)',NULL,'YesNo')");
2816 # create a new syspref for the 'Mr anonymous' patron
2817 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AnonymousPatron', '0', \"Set the identifier (borrowernumber) of the 'Mister anonymous' patron. Used for Suggestion and reading history privacy\",NULL,'')");
2818 # fill AnonymousPatron with AnonymousSuggestion value (copy)
2819 my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='AnonSuggestions'");
2821 my ($value) = $sth->fetchrow() || 0;
2822 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='AnonymousPatron'");
2823 # set AnonymousSuggestion do YesNo
2824 # 1st, set the value (1/True if it had a borrowernumber)
2825 $dbh->do("UPDATE systempreferences SET value=1 WHERE variable='AnonSuggestions' AND value>0");
2826 # 2nd, change the type to Choice
2827 $dbh->do("UPDATE systempreferences SET type='YesNo' WHERE variable='AnonSuggestions'");
2828 # borrower reading record privacy : 0 : forever, 1 : laws, 2 : don't keep at all
2829 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
2830 print "Upgrade to $DBversion done (add new syspref and column in borrowers)\n";
2831 SetVersion ($DBversion);
2834 $DBversion = '3.01.00.073';
2835 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2836 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2837 $dbh->do(<<'END_SQL');
2838 CREATE TABLE IF NOT EXISTS `aqcontract` (
2839 `contractnumber` int(11) NOT NULL auto_increment,
2840 `contractstartdate` date default NULL,
2841 `contractenddate` date default NULL,
2842 `contractname` varchar(50) default NULL,
2843 `contractdescription` mediumtext,
2844 `booksellerid` int(11) not NULL,
2845 PRIMARY KEY (`contractnumber`),
2846 CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2847 REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2848 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2850 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2851 print "Upgrade to $DBversion done (adding aqcontract table)\n";
2852 SetVersion ($DBversion);
2855 $DBversion = '3.01.00.074';
2856 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2857 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `basketname` varchar(50) default NULL AFTER `basketno`");
2858 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `note` mediumtext AFTER `basketname`");
2859 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `booksellernote` mediumtext AFTER `note`");
2860 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `contractnumber` int(11) AFTER `booksellernote`");
2861 $dbh->do("ALTER TABLE `aqbasket` ADD FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`)");
2862 print "Upgrade to $DBversion done (edit aqbasket table done)\n";
2863 SetVersion ($DBversion);
2866 $DBversion = '3.01.00.075';
2867 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2868 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `uncertainprice` tinyint(1)");
2870 print "Upgrade to $DBversion done (adding uncertainprices)\n";
2871 SetVersion ($DBversion);
2874 $DBversion = '3.01.00.076';
2875 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2876 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2877 $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` (
2878 `id` int(11) NOT NULL auto_increment,
2879 `name` varchar(50) default NULL,
2880 `closed` tinyint(1) default NULL,
2881 `booksellerid` int(11) NOT NULL,
2883 KEY `booksellerid` (`booksellerid`),
2884 CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2885 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
2886 $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
2887 $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
2888 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
2889 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2890 print "Upgrade to $DBversion done (adding basketgroups)\n";
2891 SetVersion ($DBversion);
2893 $DBversion = '3.01.00.077';
2894 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2896 $dbh->do("SET FOREIGN_KEY_CHECKS=0 ");
2897 # create a mapping table holding the info we need to match orders to budgets
2898 $dbh->do('DROP TABLE IF EXISTS fundmapping');
2900 q|CREATE TABLE fundmapping AS
2901 SELECT aqorderbreakdown.ordernumber, branchcode, bookfundid, budgetdate, entrydate
2902 FROM aqorderbreakdown JOIN aqorders ON aqorderbreakdown.ordernumber = aqorders.ordernumber|);
2903 # match the new type of the corresponding field
2904 $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)');
2905 # System did not ensure budgetdate was valid historically
2906 $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = '0000-00-00' OR budgetdate IS NULL|);
2907 # We save the map in fundmapping in case you need later processing
2908 $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|);
2909 # these can speed processing up
2910 $dbh->do(q|CREATE INDEX fundmaporder ON fundmapping (ordernumber)|);
2911 $dbh->do(q|CREATE INDEX fundmapid ON fundmapping (bookfundid)|);
2913 $dbh->do("DROP TABLE IF EXISTS `aqbudgetperiods` ");
2916 CREATE TABLE `aqbudgetperiods` (
2917 `budget_period_id` int(11) NOT NULL auto_increment,
2918 `budget_period_startdate` date NOT NULL,
2919 `budget_period_enddate` date NOT NULL,
2920 `budget_period_active` tinyint(1) default '0',
2921 `budget_period_description` mediumtext,
2922 `budget_period_locked` tinyint(1) default NULL,
2923 `sort1_authcat` varchar(10) default NULL,
2924 `sort2_authcat` varchar(10) default NULL,
2925 PRIMARY KEY (`budget_period_id`)
2926 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |);
2928 $dbh->do(<<ADDPERIODS);
2929 INSERT INTO aqbudgetperiods (budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_locked)
2930 SELECT DISTINCT startdate, enddate, NOW() BETWEEN startdate and enddate, concat(startdate," ",enddate),NOT NOW() BETWEEN startdate AND enddate from aqbudget
2932 # SORRY , NO AQBUDGET/AQBOOKFUND -> AQBUDGETS IMPORT JUST YET,
2933 # BUT A NEW CLEAN AQBUDGETS TABLE CREATE FOR NOW..
2934 # DROP TABLE IF EXISTS `aqbudget`;
2935 #CREATE TABLE `aqbudget` (
2936 # `bookfundid` varchar(10) NOT NULL default ',
2937 # `startdate` date NOT NULL default 0,
2938 # `enddate` date default NULL,
2939 # `budgetamount` decimal(13,2) default NULL,
2940 # `aqbudgetid` tinyint(4) NOT NULL auto_increment,
2941 # `branchcode` varchar(10) default NULL,
2942 DropAllForeignKeys('aqbudget');
2943 #$dbh->do("drop table aqbudget;");
2946 my $maxbudgetid = $dbh->selectcol_arrayref(<<IDsBUDGET);
2947 SELECT MAX(aqbudgetid) from aqbudget
2950 $$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
2952 $dbh->do(<<BUDGETAUTOINCREMENT);
2953 ALTER TABLE aqbudget AUTO_INCREMENT=$$maxbudgetid[0]
2956 $dbh->do(<<BUDGETNAME);
2957 ALTER TABLE aqbudget RENAME `aqbudgets`
2960 $dbh->do(<<BUDGETS);
2961 ALTER TABLE `aqbudgets`
2962 CHANGE COLUMN aqbudgetid `budget_id` int(11) NOT NULL AUTO_INCREMENT,
2963 CHANGE COLUMN branchcode `budget_branchcode` varchar(10) default NULL,
2964 CHANGE COLUMN budgetamount `budget_amount` decimal(28,6) NOT NULL default '0.00',
2965 CHANGE COLUMN bookfundid `budget_code` varchar(30) default NULL,
2966 ADD COLUMN `budget_parent_id` int(11) default NULL,
2967 ADD COLUMN `budget_name` varchar(80) default NULL,
2968 ADD COLUMN `budget_encumb` decimal(28,6) default '0.00',
2969 ADD COLUMN `budget_expend` decimal(28,6) default '0.00',
2970 ADD COLUMN `budget_notes` mediumtext,
2971 ADD COLUMN `budget_description` mediumtext,
2972 ADD COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2973 ADD COLUMN `budget_amount_sublevel` decimal(28,6) AFTER `budget_amount`,
2974 ADD COLUMN `budget_period_id` int(11) default NULL,
2975 ADD COLUMN `sort1_authcat` varchar(80) default NULL,
2976 ADD COLUMN `sort2_authcat` varchar(80) default NULL,
2977 ADD COLUMN `budget_owner_id` int(11) default NULL,
2978 ADD COLUMN `budget_permission` int(1) default '0';
2981 $dbh->do(<<BUDGETCONSTRAINTS);
2982 ALTER TABLE `aqbudgets`
2983 ADD CONSTRAINT `aqbudgets_ifbk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
2985 # $dbh->do(<<BUDGETPKDROP);
2986 #ALTER TABLE `aqbudgets`
2989 # $dbh->do(<<BUDGETPKADD);
2990 #ALTER TABLE `aqbudgets`
2991 # ADD PRIMARY KEY budget_id
2995 my $query_period= $dbh->prepare(qq|SELECT budget_period_id from aqbudgetperiods where budget_period_startdate=? and budget_period_enddate=?|);
2996 my $query_bookfund= $dbh->prepare(qq|SELECT * from aqbookfund where bookfundid=?|);
2997 my $selectbudgets=$dbh->prepare(qq|SELECT * from aqbudgets|);
2998 my $updatebudgets=$dbh->prepare(qq|UPDATE aqbudgets SET budget_period_id= ? , budget_name=?, budget_branchcode=? where budget_id=?|);
2999 $selectbudgets->execute;
3000 while (my $databudget=$selectbudgets->fetchrow_hashref){
3001 $query_period->execute ($$databudget{startdate},$$databudget{enddate});
3002 my ($budgetperiodid)=$query_period->fetchrow;
3003 $query_bookfund->execute ($$databudget{budget_code});
3004 my $databf=$query_bookfund->fetchrow_hashref;
3005 my $branchcode=$$databudget{budget_branchcode}||$$databf{branchcode};
3006 $updatebudgets->execute($budgetperiodid,$$databf{bookfundname},$branchcode,$$databudget{budget_id});
3008 $dbh->do(<<BUDGETDROPDATES);
3009 ALTER TABLE `aqbudgets`
3015 $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
3016 $dbh->do("CREATE TABLE `aqbudgets_planning` (
3017 `plan_id` int(11) NOT NULL auto_increment,
3018 `budget_id` int(11) NOT NULL,
3019 `budget_period_id` int(11) NOT NULL,
3020 `estimated_amount` decimal(28,6) default NULL,
3021 `authcat` varchar(30) NOT NULL,
3022 `authvalue` varchar(30) NOT NULL,
3023 `display` tinyint(1) DEFAULT 1,
3024 PRIMARY KEY (`plan_id`),
3025 CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
3026 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
3028 $dbh->do("ALTER TABLE `aqorders`
3029 ADD COLUMN `budget_id` tinyint(4) NOT NULL,
3030 ADD COLUMN `budgetgroup_id` int(11) NOT NULL,
3031 ADD COLUMN `sort1_authcat` varchar(10) default NULL,
3032 ADD COLUMN `sort2_authcat` varchar(10) default NULL" );
3033 # We need to map the orders to the budgets
3034 # For Historic reasons this is more complex than it should be on occasions
3035 my $budg_arr = $dbh->selectall_arrayref(
3036 q|SELECT aqbudgets.budget_id, aqbudgets.budget_code, aqbudgetperiods.budget_period_startdate,
3037 aqbudgetperiods.budget_period_enddate
3038 FROM aqbudgets JOIN aqbudgetperiods ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id
3039 ORDER BY budget_code, budget_period_startdate|, { Slice => {} });
3040 # We arbitarily order on start date, this means if you have overlapping periods the order will be
3041 # linked to the latest matching budget YMMV
3042 my $b_sth = $dbh->prepare(
3043 'UPDATE fundmapping set aqbudgetid = ? where bookfundid =? AND budgetdate >= ? AND budgetdate <= ?');
3044 for my $b ( @{$budg_arr}) {
3045 $b_sth->execute($b->{budget_id}, $b->{budget_code}, $b->{budget_period_startdate}, $b->{budget_period_enddate});
3047 # move the budgetids to aqorders
3048 $dbh->do(q|UPDATE aqorders, fundmapping SET aqorders.budget_id = fundmapping.aqbudgetid
3049 WHERE aqorders.ordernumber = fundmapping.ordernumber AND fundmapping.aqbudgetid IS NOT NULL|);
3050 # NB fundmapping is left as an accontants trail also if you have budgetids that werent set
3051 # you can decide what to do with them
3054 q|UPDATE aqorders, aqbudgets SET aqorders.budgetgroup_id = aqbudgets.budget_period_id
3055 WHERE aqorders.budget_id = aqbudgets.budget_id|);
3056 # cannot do until aqorderbreakdown removed
3057 # $dbh->do("DROP TABLE aqbookfund ");
3058 # $dbh->do("ALTER TABLE aqorders ADD FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON UPDATE CASCADE " ); ????
3059 $dbh->do("SET FOREIGN_KEY_CHECKS=1 ");
3061 print "Upgrade to $DBversion done (Adding new aqbudgetperiods, aqbudgets and aqbudget_planning tables )\n";
3062 SetVersion ($DBversion);
3067 $DBversion = '3.01.00.078';
3068 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3069 $dbh->do("ALTER TABLE aqbudgetperiods ADD COLUMN budget_period_total decimal(28,6)");
3070 print "Upgrade to $DBversion done (adds 'budget_period_total' column to aqbudgetperiods table)\n";
3071 SetVersion($DBversion);
3075 $DBversion = '3.01.00.079';
3076 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3077 $dbh->do("ALTER TABLE currency ADD COLUMN active tinyint(1)");
3079 print "Upgrade to $DBversion done (adds 'active' column to currencies table)\n";
3080 SetVersion($DBversion);
3083 $DBversion = '3.01.00.080';
3084 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3085 $dbh->do(<<BUDG_PERM );
3086 INSERT INTO permissions (module_bit, code, description) VALUES
3087 (11, 'vendors_manage', 'Manage vendors'),
3088 (11, 'contracts_manage', 'Manage contracts'),
3089 (11, 'period_manage', 'Manage periods'),
3090 (11, 'budget_manage', 'Manage budgets'),
3091 (11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
3092 (11, 'planning_manage', 'Manage budget plannings'),
3093 (11, 'order_manage', 'Manage orders & basket'),
3094 (11, 'group_manage', 'Manage orders & basketgroups'),
3095 (11, 'order_receive', 'Manage orders & basket'),
3096 (11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
3099 print "Upgrade to $DBversion done (adds permissions for the acquisitions module)\n";
3100 SetVersion($DBversion);
3104 $DBversion = '3.01.00.081';
3105 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3106 $dbh->do("ALTER TABLE aqbooksellers ADD COLUMN `gstrate` decimal(6,4) default NULL");
3107 if (my $gist=C4::Context->preference("gist")){
3108 my $sql=$dbh->prepare("UPDATE aqbooksellers set `gstrate`=? ");
3109 $sql->execute($gist) ;
3111 print "Upgrade to $DBversion done (added per-supplier gstrate setting)\n";
3112 SetVersion($DBversion);
3115 $DBversion = "3.01.00.082";
3116 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3117 if (C4::Context->preference("opaclanguages") eq "fr") {
3118 $dbh->do(qq#INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AcqCreateItem','ordering',"Définit quand l'exemplaire est créé : à la commande, à la livraison, au catalogage",'ordering|receiving|cataloguing','Choice')#);
3120 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AcqCreateItem','ordering','Define when the item is created : when ordering, when receiving, or in cataloguing module','ordering|receiving|cataloguing','Choice')");
3122 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
3123 SetVersion ($DBversion);
3126 $DBversion = "3.01.00.083";
3127 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3129 CREATE TABLE `aqorders_items` (
3130 `ordernumber` int(11) NOT NULL,
3131 `itemnumber` int(11) NOT NULL,
3132 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
3133 PRIMARY KEY (`itemnumber`),
3134 KEY `ordernumber` (`ordernumber`)
3135 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
3138 $dbh->do(qq| DROP TABLE aqorderbreakdown |);
3139 $dbh->do('DROP TABLE aqbookfund');
3140 print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
3141 SetVersion ($DBversion);
3144 $DBversion = "3.01.00.084";
3145 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3146 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('CurrencyFormat','US','US|FR','Determines the display format of currencies. eg: ''36000'' is displayed as ''360 000,00'' in ''FR'' or 360,000.00'' in ''US''.','Choice') #);
3148 print "Upgrade to $DBversion done (CurrencyFormat syspref added)\n";
3149 SetVersion ($DBversion);
3152 $DBversion = "3.01.00.085";
3153 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3154 $dbh->do("ALTER table aqorders drop column title");
3155 $dbh->do("ALTER TABLE `aqorders` CHANGE `budget_id` `budget_id` INT( 11 ) NOT NULL");
3156 print "Upgrade to $DBversion done update budget_id size that should not be a tinyint\n";
3157 SetVersion ($DBversion);
3160 $DBversion = "3.01.00.086";
3161 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3162 $dbh->do(<<SUGGESTIONS);
3163 ALTER table suggestions
3164 ADD budgetid INT(11),
3165 ADD branchcode VARCHAR(10) default NULL,
3166 ADD acceptedby INT(11) default NULL,
3167 ADD accepteddate date default NULL,
3168 ADD suggesteddate date default NULL,
3169 ADD manageddate date default NULL,
3170 ADD rejectedby INT(11) default NULL,
3171 ADD rejecteddate date default NULL,
3172 ADD collectiontitle text default NULL,
3173 ADD itemtype VARCHAR(30) default NULL
3176 print "Upgrade to $DBversion done (Suggestions)\n";
3177 SetVersion ($DBversion);
3180 $DBversion = "3.01.00.087";
3181 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3182 $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;");
3183 print "Upgrade to $DBversion done (Drop column budget_amount_sublevel from aqbudgets)\n";
3184 SetVersion ($DBversion);
3187 $DBversion = "3.01.00.088";
3188 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3189 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo') #);
3191 print "Upgrade to $DBversion done (intranetbookbag syspref added)\n";
3192 SetVersion ($DBversion);
3195 $DBversion = "3.01.00.090";
3196 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3198 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3199 (16, 'execute_reports', 'Execute SQL reports'),
3200 (16, 'create_reports', 'Create SQL Reports')
3203 print "Upgrade to $DBversion done (granular permissions for guided reports added)\n";
3204 SetVersion ($DBversion);
3207 $DBversion = "3.01.00.091";
3208 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3210 UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions'
3211 WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1
3214 print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
3215 SetVersion ($DBversion);
3218 $DBversion = "3.01.00.092";
3219 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3220 if (C4::Context->preference("opaclanguages") =~ /fr/) {
3222 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RoutingListAddReserves','1','Si activé, des reservations sont automatiquement créées pour chaque lecteur de la liste de circulation d''un numéro de périodique','','YesNo');
3226 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RoutingListAddReserves','1','If ON the patrons on routing lists are automatically added to holds on the issue.','','YesNo');
3229 print "Upgrade to $DBversion done (Added RoutingListAddReserves syspref)\n";
3230 SetVersion ($DBversion);
3233 $DBversion = "3.01.00.093";
3234 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3236 ALTER TABLE biblioitems ADD INDEX issn_idx (issn);
3238 print "Upgrade to $DBversion done (added index to ISSN)\n";
3239 SetVersion ($DBversion);
3242 $DBversion = "3.01.00.094";
3243 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3245 ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10) default NULL, ADD deliverycomment VARCHAR(255) default NULL;
3248 print "Upgrade to $DBversion done (adding deliveryplace deliverycomment to basketgroups)\n";
3249 SetVersion ($DBversion);
3252 $DBversion = "3.01.00.095";
3253 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3255 ALTER TABLE items ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number";
3258 ALTER TABLE items ADD UNIQUE INDEX itemsstocknumberidx (stocknumber);
3261 ALTER TABLE deleteditems ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number of deleted items";
3264 ALTER TABLE deleteditems ADD UNIQUE INDEX deleteditemsstocknumberidx (stocknumber);
3266 if (C4::Context->preference('marcflavour') eq 'UNIMARC'){
3268 INSERT IGNORE INTO marc_subfield_structure (frameworkcode,tagfield, tagsubfield, tab, repeatable, mandatory,kohafield)
3269 SELECT DISTINCT (frameworkcode),995,"j",10,0,0,"items.stocknumber" from biblio_framework ;
3271 #Previously, copynumber was used as stocknumber
3273 UPDATE items set stocknumber=copynumber;
3276 UPDATE items set copynumber=NULL;
3279 print "Upgrade to $DBversion done (stocknumber field added)\n";
3280 SetVersion ($DBversion);
3283 $DBversion = "3.01.00.096";
3284 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3285 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPdfTemplate','','Uploads a PDF template to use for printing baskets','NULL','Upload')");
3286 $dbh->do("UPDATE systempreferences SET variable='OrderPdfFormat' WHERE variable='pdfformat'");
3287 print "Upgrade to $DBversion done (PDF orders system preferences added and updated)\n";
3288 SetVersion ($DBversion);
3291 $DBversion = "3.01.00.097";
3292 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3294 ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10) NOT NULL AFTER deliverycomment;
3297 print "Upgrade to $DBversion done (Adding billingplace to aqbasketgroups)\n";
3298 SetVersion ($DBversion);
3301 $DBversion = "3.01.00.098";
3302 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3304 ALTER TABLE auth_subfield_structure MODIFY frameworkcode VARCHAR(10) NULL;
3307 print "Upgrade to $DBversion done (changing frameworkcode length in auth_subfield_structure)\n";
3308 SetVersion ($DBversion);
3311 $DBversion = "3.01.00.099";
3312 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3314 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3315 (9, 'edit_catalogue', 'Edit catalogue'),
3316 (9, 'fast_cataloging', 'Fast cataloging')
3319 print "Upgrade to $DBversion done (granular permissions for cataloging added)\n";
3320 SetVersion ($DBversion);
3323 $DBversion = "3.01.00.100";
3324 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3325 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('casAuthentication', '0', '', 'Enable or disable CAS authentication', 'YesNo'), ('casLogout', '1', '', 'Does a logout from Koha should also log out of CAS ?', 'YesNo'), ('casServerUrl', 'https://localhost:8443/cas', '', 'URL of the cas server', 'Free')");
3326 print "Upgrade to $DBversion done (added CAS authentication system preferences)\n";
3327 SetVersion ($DBversion);
3330 $DBversion = "3.01.00.101";
3331 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3333 "INSERT INTO systempreferences
3334 (variable, value, options, explanation, type)
3336 'OverdueNoticeBcc', '', '',
3337 'Email address to Bcc outgoing notices sent by email',
3340 print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
3341 SetVersion ($DBversion);
3343 $DBversion = "3.01.00.102";
3344 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3346 "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
3348 print "Upgrade to $DBversion done (fixed spelling error in edit_catalogue permission)\n";
3349 SetVersion ($DBversion);
3352 $DBversion = "3.01.00.103";
3353 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3354 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
3355 print "Upgrade to $DBversion done (adding patron permissions for tags tool)\n";
3356 SetVersion ($DBversion);
3359 $DBversion = "3.01.00.104";
3360 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3362 my ($maninv_count, $borrnotes_count);
3363 eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
3364 if ($maninv_count == 0) {
3365 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
3367 eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
3368 if ($borrnotes_count == 0) {
3369 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
3372 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
3373 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
3375 print "Upgrade to $DBversion done ( add defaults to authorized values for MANUAL_INV and BOR_NOTES and add new default LOC authorized values for shelf to cart processing )\n";
3376 SetVersion ($DBversion);
3380 $DBversion = "3.01.00.105";
3381 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3383 CREATE TABLE `collections` (
3384 `colId` int(11) NOT NULL auto_increment,
3385 `colTitle` varchar(100) NOT NULL default '',
3386 `colDesc` text NOT NULL,
3387 `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
3388 PRIMARY KEY (`colId`)
3389 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3393 CREATE TABLE `collections_tracking` (
3394 `ctId` int(11) NOT NULL auto_increment,
3395 `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
3396 `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
3397 PRIMARY KEY (`ctId`)
3398 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3401 INSERT INTO permissions (module_bit, code, description)
3402 VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
3403 print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
3404 SetVersion ($DBversion);
3406 $DBversion = "3.01.00.106";
3407 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3408 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ( 'OpacAddMastheadLibraryPulldown', '0', '', 'Adds a pulldown menu to select the library to search on the opac masthead.', 'YesNo' )");
3409 print "Upgrade to $DBversion done (added OpacAddMastheadLibraryPulldown system preferences)\n";
3410 SetVersion ($DBversion);
3413 $DBversion = '3.01.00.107';
3414 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3415 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
3416 system("perl $upgrade_script");
3417 print "Upgrade to $DBversion done (Migrated labels and patroncards tables and data to new schema.)\n";
3418 SetVersion ($DBversion);
3421 $DBversion = '3.01.00.108';
3422 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3424 ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
3425 ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
3426 ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator`
3428 print "Upgrade to $DBversion done (added separators for csv export)\n";
3429 SetVersion ($DBversion);
3432 $DBversion = "3.01.00.109";
3433 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3435 ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
3437 print "Upgrade to $DBversion done (added encoding for csv export)\n";
3438 SetVersion ($DBversion);
3441 $DBversion = '3.01.00.110';
3442 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3443 $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
3444 print "Upgrade to $DBversion done (Add enrolment period date support)\n";
3445 SetVersion ($DBversion);
3448 $DBversion = '3.01.00.111';
3449 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3450 print "Upgrade to $DBversion done (mark DBrev for 3.2-alpha release)\n";
3451 SetVersion ($DBversion);
3454 $DBversion = '3.01.00.112';
3455 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3456 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('SpineLabelShowPrintOnBibDetails', '0', '', 'If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.', 'YesNo');");
3457 print "Upgrade to $DBversion done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
3458 SetVersion ($DBversion);
3461 $DBversion = '3.01.00.113';
3462 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3463 my $value = C4::Context->preference("XSLTResultsDisplay");
3465 "INSERT INTO systempreferences (variable,value,type)
3466 VALUES('OPACXSLTResultsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3467 $value = C4::Context->preference("XSLTDetailsDisplay");
3469 "INSERT INTO systempreferences (variable,value,type)
3470 VALUES('OPACXSLTDetailsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3471 print "Upgrade to $DBversion done (added two new syspref: OPACXSLTResultsDisplay and OPACXSLTDetailDisplay). You may have to go in Admin > System preference to tweak XSLT related syspref both in OPAC and Search tabs.\n";
3472 SetVersion ($DBversion);
3475 $DBversion = '3.01.00.114';
3476 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3477 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('AutoSelfCheckAllowed', '0', 'For corporate and special libraries which want web-based self-check available from any PC without the need for a manual staff login. Most libraries will want to leave this turned off. If on, requires self-check ID and password to be entered in AutoSelfCheckID and AutoSelfCheckPass sysprefs.', '', 'YesNo')");
3478 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoSelfCheckID','','Staff ID with circulation rights to be used for automatic web-based self-check. Only applies if AutoSelfCheckAllowed syspref is turned on.','','free')");
3479 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoSelfCheckPass','','Password to be used for automatic web-based self-check. Only applies if AutoSelfCheckAllowed syspref is turned on.','','free')");
3480 print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
3481 SetVersion ($DBversion);
3484 $DBversion = '3.01.00.115';
3485 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3486 $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
3487 $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
3488 print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
3489 SetVersion ($DBversion);
3492 $DBversion = '3.01.00.116';
3493 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3494 if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
3495 $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
3497 print "Upgrade to $DBversion done (corrected default OrderPdfFormat value if still set wrong )\n";
3498 SetVersion ($DBversion);
3501 $DBversion = '3.01.00.117';
3502 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3503 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'por' WHERE rfc4646_subtag='pt' ");
3504 print "Upgrade to $DBversion done (corrected ISO 639-2 language code for Portuguese)\n";
3505 SetVersion ($DBversion);
3508 $DBversion = '3.01.00.118';
3509 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3510 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns
3511 WHERE table_name = 'aqbudgets_planning'
3512 AND column_name = 'display'");
3514 $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1");
3516 print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n";
3517 SetVersion ($DBversion);
3520 $DBversion = '3.01.00.119';
3521 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3522 eval{require Locale::Currency::Format};
3524 print "Upgrade to $DBversion done (Locale::Currency::Format installed.)\n";
3525 SetVersion ($DBversion);
3528 print "Upgrade to $DBversion done.\n";
3529 print "NOTICE: The Locale::Currency::Format package is not installed on your system or not found in \@INC.\nThis dependency is required in order to include fine information in overdue notices.\nPlease ask your system administrator to install this package.\n";
3530 SetVersion ($DBversion);
3534 $DBversion = '3.01.00.120';
3535 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3537 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('soundon','0','Enable circulation sounds during checkin and checkout in the staff interface. Not supported by all web browsers yet.','','YesNo');
3539 print "Upgrade to $DBversion done (bug 1080: add soundon system preference for circulation sounds)\n";
3540 SetVersion ($DBversion);
3543 $DBversion = '3.01.00.121';
3544 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3545 $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE DEFAULT NULL");
3546 $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3547 $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE DEFAULT NULL");
3548 $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3549 print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
3550 SetVersion ($DBversion);
3553 $DBversion = '3.01.00.122';
3554 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3556 INSERT INTO systempreferences (variable,value,explanation,options,type)
3557 VALUES ('OAI-PMH:ConfFile', '', 'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','','File');
3559 print "Upgrade to $DBversion done. — Add a new system preference OAI-PMF:ConfFile\n";
3560 SetVersion ($DBversion);
3563 $DBversion = "3.01.00.123";
3564 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3565 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3566 (6, 'place_holds', 'Place holds for patrons')");
3567 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3568 (6, 'modify_holds_priority', 'Modify holds priority')");
3569 $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
3570 print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
3571 SetVersion ($DBversion);
3574 $DBversion = '3.01.00.124';
3575 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3577 INSERT INTO `letter` (module, code, name, title, content) VALUES('reserves', 'HOLDPLACED', 'Hold Placed on Item', 'Hold Placed on Item','A hold has been placed on the following item : <<title>> (<<biblionumber>>) by the user <<firstname>> <<surname>> (<<cardnumber>>).');
3579 print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
3580 SetVersion ($DBversion);
3583 $DBversion = '3.01.00.125';
3584 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3586 INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'PrintNoticesMaxLines', '0', '', 'If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.', 'Integer' );
3589 INSERT INTO message_transport_types (message_transport_type) values ('print');
3591 print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
3592 SetVersion ($DBversion);
3595 $DBversion = "3.01.00.126";
3596 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3597 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ILS-DI','0','Enable ILS-DI services. See http://your.opac.name/cgi-bin/koha/ilsdi.pl for online documentation.','','YesNo')");
3598 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ILS-DI:AuthorizedIPs','127.0.0.1','A comma separated list of IP addresses authorized to access the web services.','','free')");
3600 print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:AuthorizedIPs)\n";
3601 SetVersion ($DBversion);
3604 $DBversion = '3.01.00.127';
3605 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3606 $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
3607 print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
3608 SetVersion ($DBversion);
3611 $DBversion = '3.01.00.128';
3612 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3613 $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
3614 print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
3615 SetVersion ($DBversion);
3618 $DBversion = "3.01.00.129";
3619 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3620 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
3621 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
3622 print "Upgrade to $DBversion done (Change permissions names for item batch modification / deletion)\n";
3624 SetVersion ($DBversion);
3627 $DBversion = "3.01.00.130";
3628 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3629 $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'");
3630 print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n";
3631 SetVersion ($DBversion);
3634 $DBversion = "3.01.00.131";
3635 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3637 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
3639 print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
3640 SetVersion ($DBversion);
3643 $DBversion = "3.01.00.132";
3644 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3646 ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
3648 print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
3649 SetVersion ($DBversion);
3652 $DBversion = '3.01.00.133';
3653 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3654 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OverduesBlockCirc','noblock','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','noblock|confirmation|block','Choice')");
3655 print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
3656 SetVersion ($DBversion);
3659 $DBversion = '3.01.00.134';
3660 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3661 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
3662 print "Upgrade to $DBversion done (adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page)\n";
3663 SetVersion ($DBversion);
3666 $DBversion = '3.01.00.135';
3667 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3669 INSERT INTO `letter` (module, code, name, title, content) VALUES
3670 ('reserves', 'HOLD_PRINT', 'Hold Available for Pickup (print notice)', 'Hold Available for Pickup (print notice)', '<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n\r\n\r\nChange Service Requested\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>>\r\n<<borrowers.address>>\r\n<<borrowers.city>> <<borrowers.zipcode>>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>> <<borrowers.cardnumber>>\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\n')
3672 print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)\n";
3673 SetVersion ($DBversion);
3676 $DBversion = '3.01.00.136';
3677 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3679 INSERT INTO permissions (module_bit, code, description) VALUES
3680 ( 9, 'edit_items', 'Edit Items');});
3681 print "Upgrade to $DBversion done (Adding a new permission to edit items)\n";
3682 SetVersion ($DBversion);
3685 $DBversion = "3.01.00.137";
3686 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3688 INSERT INTO permissions (module_bit, code, description) VALUES
3689 (15, 'check_expiration', 'Check the expiration of a serial'),
3690 (15, 'claim_serials', 'Claim missing serials'),
3691 (15, 'create_subscription', 'Create a new subscription'),
3692 (15, 'delete_subscription', 'Delete an existing subscription'),
3693 (15, 'edit_subscription', 'Edit an existing subscription'),
3694 (15, 'receive_serials', 'Serials receiving'),
3695 (15, 'renew_subscription', 'Renew a subscription'),
3696 (15, 'routing', 'Routing');
3698 print "Upgrade to $DBversion done (adding granular permissions for serials)\n";
3699 SetVersion ($DBversion);
3702 $DBversion = "3.01.00.138";
3703 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3704 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
3705 print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)\n";
3706 SetVersion ($DBversion);
3709 $DBversion = '3.01.00.139';
3710 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3711 $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
3712 print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
3713 SetVersion ($DBversion);
3716 $DBversion = '3.01.00.140';
3717 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3718 $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'TagsModeration' AND value is NULL");
3719 print "Upgrade to $DBversion done (bug 4312 TagsModeration changed from NULL to 0)\n";
3720 SetVersion ($DBversion);
3723 $DBversion = '3.01.00.141';
3724 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3725 $dbh->do(qq{DELETE FROM message_attributes WHERE message_attribute_id=3;});
3726 $dbh->do(qq{DELETE FROM letter WHERE code='EVENT' AND title='Upcoming Library Event';});
3727 print "Upgrade to $DBversion done Remove upcoming events messaging option (bug 2434)\n";
3728 SetVersion ($DBversion);
3731 $DBversion = '3.01.00.142';
3732 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3733 $dbh->do(qq{DELETE FROM message_transports WHERE message_attribute_id=3;});
3734 print "Upgrade to $DBversion done (Remove upcoming events messaging option part 2 (bug 2434))\n";
3735 SetVersion ($DBversion);
3738 $DBversion = '3.01.00.143';
3739 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3740 $dbh->do(qq{CREATE INDEX auth_value_idx ON authorised_values (authorised_value)});
3741 $dbh->do(qq{CREATE INDEX auth_val_cat_idx ON borrower_attribute_types (authorised_value_category)});
3742 print "Upgrade to $DBversion done (Create index on authorised_values and borrower_attribute_types (bug 4139))\n";
3743 SetVersion ($DBversion);
3746 $DBversion = '3.01.00.144';
3747 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3748 $dbh->do(qq{UPDATE systempreferences SET value='normal' where value='default' and variable='IntranetBiblioDefaultView'});
3749 print "Upgrade to $DBversion done (Update the 'default' to 'normal' for the IntranetBiblioDefaultView syspref (bug 5007))\n";
3750 SetVersion ($DBversion);
3753 $DBversion = "3.01.00.145";
3754 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3755 $dbh->do("ALTER TABLE borrowers ADD KEY `guarantorid` (guarantorid);");
3756 print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3757 SetVersion ($DBversion);
3760 $DBversion = '3.01.00.999';
3761 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3762 print "Upgrade to $DBversion done (3.2.0 release candidate)\n";
3763 SetVersion ($DBversion);
3766 $DBversion = "3.02.00.000";
3767 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3768 my $value = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'HomeOrHoldingBranch'");
3769 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranchReturn','$value','Used by Circulation to determine which branch of an item to check checking-in items','holdingbranch|homebranch','Choice');");
3770 print "Upgrade to $DBversion done (Add HomeOrHoldingBranchReturn system preference)\n";
3771 SetVersion ($DBversion);
3774 $DBversion = "3.02.00.001";
3775 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3776 $dbh->do(q{DELETE FROM systempreferences WHERE variable IN (
3781 'OPACSubscriptionDisplay',
3782 'OPACDisplayExtendedSubInfo',
3793 print "Upgrade to $DBversion done (bug 3756: remove disused system preferences)\n";
3794 SetVersion ($DBversion);
3797 $DBversion = "3.02.00.002";
3798 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3799 $dbh->do(q{DELETE FROM systempreferences WHERE variable = 'OpacPrivacy'});
3800 print "Upgrade to $DBversion done (bug 3881: remove unused OpacPrivacy system preference)\n";
3801 SetVersion ($DBversion);
3804 $DBversion = "3.02.00.003";
3805 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3806 $dbh->do(q{UPDATE systempreferences SET variable = 'ILS-DI:AuthorizedIPs' WHERE variable = 'ILS-DI:Authorized_IPs'});
3807 print "Upgrade to $DBversion done (correct ILS-DI:AuthorizedIPs)\n";
3808 SetVersion ($DBversion);
3811 $DBversion = "3.02.00.004";
3812 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3813 print "Upgrade to $DBversion done (3.2.0 general release)\n";
3814 SetVersion ($DBversion);
3816 # This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3818 # apply updates that have already been done
3820 $DBversion = "3.03.00.001";
3821 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.005")) {
3822 $dbh->do("DELETE FROM subscriptionroutinglist WHERE borrowernumber IS NULL;");
3823 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `borrowernumber` int(11) NOT NULL;");
3824 $dbh->do("DELETE FROM subscriptionroutinglist WHERE subscriptionid IS NULL;");
3825 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `subscriptionid` int(11) NOT NULL;");
3826 $dbh->do("CREATE TEMPORARY TABLE del_subscriptionroutinglist
3827 SELECT s1.routingid FROM subscriptionroutinglist s1
3828 WHERE EXISTS (SELECT * FROM subscriptionroutinglist s2
3829 WHERE s2.borrowernumber = s1.borrowernumber
3830 AND s2.subscriptionid = s1.subscriptionid
3831 AND s2.routingid < s1.routingid);");
3832 $dbh->do("DELETE FROM subscriptionroutinglist
3833 WHERE routingid IN (SELECT routingid FROM del_subscriptionroutinglist);");
3834 $dbh->do("ALTER TABLE subscriptionroutinglist ADD UNIQUE (subscriptionid, borrowernumber);");
3835 $dbh->do("ALTER TABLE subscriptionroutinglist
3836 ADD CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`)
3837 REFERENCES `borrowers` (`borrowernumber`)
3838 ON DELETE CASCADE ON UPDATE CASCADE");
3839 $dbh->do("ALTER TABLE subscriptionroutinglist
3840 ADD CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`)
3841 REFERENCES `subscription` (`subscriptionid`)
3842 ON DELETE CASCADE ON UPDATE CASCADE");
3843 print "Upgrade to $DBversion done (Make subscriptionroutinglist more strict)\n";
3844 SetVersion ($DBversion);
3847 $DBversion = '3.03.00.002';
3848 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.006")) {
3849 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='arm' WHERE rfc4646_subtag='hy';");
3850 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='eng' WHERE rfc4646_subtag='en';");
3851 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'fi','fin');");
3852 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='fre' WHERE rfc4646_subtag='fr';");
3853 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'lo','lao');");
3854 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it';");
3855 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'sr','srp');");
3856 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'tet','tet');");
3857 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ur','urd');");
3859 print "Upgrade to $DBversion done (Correct language mappings)\n";
3860 SetVersion ($DBversion);
3863 $DBversion = '3.03.00.003';
3864 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.007")) {
3865 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('UseTablesortForCirc','0','If on, use the JQuery tablesort function on the list of current borrower checkouts on the circulation page. Note that the use of this function may slow down circ for patrons with may checkouts.','','YesNo');");
3866 print "Upgrade to $DBversion done (Add UseTablesortForCirc syspref)\n";
3867 SetVersion ($DBversion);
3870 $DBversion = '3.03.00.004';
3871 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.001")) {
3872 my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ACCEPTED');
3874 INSERT INTO `letter`
3875 (module, code, name, title, content)
3877 ('suggestions','ACCEPTED','Suggestion accepted', 'Purchase suggestion accepted','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nYou have suggested that the library acquire <<suggestions.title>> by <<suggestions.author>>.\n\nThe library has reviewed your suggestion today. The item will be ordered as soon as possible. You will be notified by mail when the order is completed, and again when the item arrives at the library.\n\nIf you have any questions, please email us at <<branches.branchemail>>.\n\nThank you,\n\n<<branches.branchname>>')
3878 /) unless $count > 0;
3879 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'AVAILABLE');
3881 INSERT INTO `letter`
3882 (module, code, name, title, content)
3884 ('suggestions','AVAILABLE','Suggestion available', 'Suggested purchase available','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nYou have suggested that the library acquire <<suggestions.title>> by <<suggestions.author>>.\n\nWe are pleased to inform you that the item you requested is now part of the collection.\n\nIf you have any questions, please email us at <<branches.branchemail>>.\n\nThank you,\n\n<<branches.branchname>>')
3885 /) unless $count > 0;
3886 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ORDERED');
3888 INSERT INTO `letter`
3889 (module, code, name, title, content)
3891 ('suggestions','ORDERED','Suggestion ordered', 'Suggested item ordered','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nYou have suggested that the library acquire <<suggestions.title>> by <<suggestions.author>>.\n\nWe are pleased to inform you that the item you requested has now been ordered. It should arrive soon, at which time it will be processed for addition into the collection.\n\nYou will be notified again when the book is available.\n\nIf you have any questions, please email us at <<branches.branchemail>>\n\nThank you,\n\n<<branches.branchname>>')
3892 /) unless $count > 0;
3893 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'REJECTED');
3895 INSERT INTO `letter`
3896 (module, code, name, title, content)
3898 ('suggestions','REJECTED','Suggestion rejected', 'Purchase suggestion declined','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nYou have suggested that the library acquire <<suggestions.title>> by <<suggestions.author>>.\n\nThe library has reviewed your request today, and has decided not to accept the suggestion at this time.\n\nThe reason given is: <<suggestions.reason>>\n\nIf you have any questions, please email us at <<branches.branchemail>>.\n\nThank you,\n\n<<branches.branchname>>')
3899 /) unless $count > 0;
3900 print "Upgrade to $DBversion done (bug 5127: add default templates for suggestion status change notifications)\n";
3901 SetVersion ($DBversion);
3904 $DBversion = '3.03.00.005';
3905 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3906 $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
3907 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
3910 $DBversion = '3.03.00.006';
3911 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.002")) {
3912 $dbh->do("ALTER TABLE deletedborrowers ADD `privacy` int(11) AFTER smsalertnumber;");
3913 $dbh->do("ALTER TABLE deletedborrowers CHANGE `cardnumber` `cardnumber` varchar(16);");
3914 print "Upgrade to $DBversion done (Fix differences between borrowers and deletedborrowers)\n";
3915 SetVersion ($DBversion);
3918 $DBversion = '3.03.00.007';
3919 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3920 $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL,
3921 ADD currency VARCHAR(3) default NULL,
3922 ADD price DECIMAL(28,6) default NULL,
3923 ADD total DECIMAL(28,6) default NULL;
3925 print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n";
3926 SetVersion ($DBversion);
3929 $DBversion = '3.03.00.008';
3930 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3931 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACNoResultsFound','','Display this HTML when no results are found for a search in the OPAC','70|10','Textarea')");
3932 print "Upgrade to $DBversion done (adding syspref OPACNoResultsFound to control what displays when no results are found for a search in the OPAC.)\n";
3933 SetVersion ($DBversion);
3936 $DBversion = '3.03.00.009';
3937 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.003")) {
3938 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetUserCSS','','Add CSS to be included in the Intranet',NULL,'free')");
3939 print "Upgrade to $DBversion done (Add IntranetUserCSS syspref)\n";
3940 SetVersion ($DBversion);
3943 $DBversion = "3.03.00.010";
3944 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.02.001")) {
3945 $dbh->do("UPDATE `marc_subfield_structure` SET liblibrarian = 'Distance from earth' WHERE liblibrarian = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3946 $dbh->do("UPDATE `marc_subfield_structure` SET libopac = 'Distance from earth' WHERE libopac = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3947 print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
3948 SetVersion ($DBversion);
3951 $DBversion = "3.03.00.011";
3952 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3953 $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3954 print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
3955 SetVersion ($DBversion);
3958 $DBversion = "3.03.00.012";
3959 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3960 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to display for each result on a page of results',NULL,'free')");
3961 print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
3962 SetVersion ($DBversion);
3965 $DBversion = "3.03.00.013";
3966 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3967 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacPublic','1','If set to OFF and user is not logged in, all OPAC pages require authentication, and OPAC searchbar is removed)','','YesNo')");
3968 print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n";
3969 SetVersion ($DBversion);
3972 $DBversion = "3.03.00.014";
3973 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3974 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesLocation','1','Use the item location when finding items for the shelf browser.','1','YesNo')");
3975 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesHomeBranch','1','Use the item home branch when finding items for the shelf browser.','1','YesNo')");
3976 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','0','Use the item collection code when finding items for the shelf browser.','1','YesNo')");
3977 print "Upgrade to $DBversion done (Add flexible shelf browser constraints)\n";
3978 SetVersion ($DBversion);
3981 $DBversion = "3.03.00.015";
3982 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3983 if ( C4::Context->preference("marcflavour") eq "MARC21" ) {
3984 my $sth = $dbh->prepare(
3985 "INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`,
3986 `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`)
3987 VALUES ( ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, '', 6, '', '', '', 0, -5, '', '', '', NULL)"
3989 $sth->execute('648');
3990 $sth->execute('654');
3991 $sth->execute('655');
3992 $sth->execute('656');
3993 $sth->execute('657');
3994 $sth->execute('658');
3995 $sth->execute('662');
3998 "Upgrade to $DBversion done (Bug 5619: Add subfield 9 to marc21 648,654,655,656,657,658,662)\n";
4000 SetVersion($DBversion);
4003 $DBversion = '3.03.00.016';
4004 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4005 # reimplement OpacPrivacy system preference
4006 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacPrivacy', '0', 'if ON, allows patrons to define their privacy rules (reading history)',NULL,'YesNo')");
4007 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4008 $dbh->do("ALTER TABLE `deletedborrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4009 print "Upgrade to $DBversion done (OpacPrivacy reimplementation)\n";
4010 SetVersion($DBversion);
4013 $DBversion = '3.03.00.017';
4014 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.001")) {
4015 $dbh->do("ALTER TABLE `currency` CHANGE `rate` `rate` FLOAT( 15, 5 ) NULL DEFAULT NULL;");
4016 print "Upgrade to $DBversion done (Enable currency rates >= 100)\n";
4017 SetVersion ($DBversion);
4020 $DBversion = '3.03.00.018';
4021 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.002")) {
4022 $dbh->do( q|update language_descriptions set description = 'Nederlands' where lang = 'nl' and subtag = 'nl'|);
4023 $dbh->do( q|update language_descriptions set description = 'Dansk' where lang = 'da' and subtag = 'da'|);
4024 print "Upgrade to $DBversion done (Correct language descriptions)\n";
4025 SetVersion ($DBversion);
4028 $DBversion = '3.03.00.019';
4029 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.003")) {
4031 $dbh->do("UPDATE language_subtag_registry SET description = 'Norwegian bokmål' WHERE subtag = 'nb';");
4032 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nb','nob');");
4033 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokmål' WHERE subtag = 'nb' AND lang = 'nb';");
4034 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokmål' WHERE subtag = 'nb' AND lang = 'en';");
4035 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokmål' WHERE subtag = 'nb' AND lang = 'fr';");
4037 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'nn', 'language', 'Norwegian nynorsk','2011-02-14' )");
4038 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nn','nno')");
4039 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nb', 'Norsk nynorsk')");
4040 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nn', 'Norsk nynorsk')");
4041 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'en', 'Norwegian nynorsk')");
4042 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'fr', 'Norvégien nynorsk')");
4043 print "Upgrade to $DBversion done (Correct language descriptions for Norwegian)\n";
4044 SetVersion ($DBversion);
4047 $DBversion = '3.03.00.020';
4048 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4049 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo')");
4050 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo')");
4051 print "Upgrade to $DBversion done (Bug 5811: Add sysprefs controlling overriding fines)\n";
4052 SetVersion($DBversion);
4055 $DBversion = '3.03.00.021';
4056 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.001")) {
4057 $dbh->do("ALTER TABLE items MODIFY enumchron TEXT");
4058 $dbh->do("ALTER TABLE deleteditems MODIFY enumchron TEXT");
4059 print "Upgrade to $DBversion done (bug 5642: longer serial enumeration)\n";
4060 SetVersion ($DBversion);
4063 $DBversion = '3.03.00.022';
4064 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4065 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo');");
4066 print "Upgrade to $DBversion done (Add AuthoritiesLog syspref)\n";
4067 SetVersion ($DBversion);
4070 # due to a mismatch in kohastructure.sql some koha will have missing columns in aqbasketgroup
4071 # this attempts to fix that
4072 $DBversion = '3.03.00.023';
4073 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.002")) {
4074 my $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'billingplace'");
4076 $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4077 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliveryplace'");
4079 $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4080 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliverycomment'");
4082 $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") if ! $sth->fetchrow_hashref;
4083 print "Upgrade to $DBversion done (Reconcile aqbasketgroups)\n";
4084 SetVersion ($DBversion);
4087 $DBversion = '3.03.00.024';
4088 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4089 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo')");
4090 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo')");
4091 print "Upgrade to $DBversion done (Add syspref to force whole-subfield matching on subject tracings)\n";
4092 SetVersion($DBversion);
4095 $DBversion = "3.03.00.025";
4096 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4097 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAllowUserToChooseBranch', 1, 'Allow the user to choose the branch they want to pickup their hold from','1','YesNo')");
4098 print "Upgrade to $DBversion done (Add syspref to control if user can choose pickup branch for holds)\n";
4099 SetVersion ($DBversion);
4102 $DBversion = '3.03.00.026';
4103 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.003")) {
4104 $dbh->do("UPDATE `message_attributes` SET message_name='Item Due' WHERE message_attribute_id=1 AND message_name LIKE 'Item DUE'");
4105 print "Upgrade to $DBversion done ( fix capitalization in message type )\n";
4106 SetVersion ($DBversion);
4109 $DBversion = '3.03.00.027';
4110 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4111 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('displayFacetCount', '0', NULL, NULL, 'YesNo')");
4112 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('maxRecordsForFacets', '20', NULL, NULL, 'Integer')");
4113 print "Upgrade to $DBversion done (Preferences for facet count)\n";
4114 SetVersion ($DBversion);
4117 $DBversion = "3.03.00.028";
4118 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4119 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('FacetLabelTruncationLength', 20, 'Truncate facets length to','','free')");
4120 print "Upgrade to $DBversion done (Add FacetLabelTruncationLength syspref to control facets displayed length)\n";
4121 SetVersion ($DBversion);
4124 $DBversion = "3.03.00.029";
4125 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4126 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowPurchaseSuggestionBranchChoice', 0, 'Allow user to choose branch when making a purchase suggestion','1','YesNo')");
4127 print "Upgrade to $DBversion done (Add syspref to control if user can choose branch when making purchase suggestion)\n";
4128 SetVersion ($DBversion);
4131 $DBversion = "3.03.00.030";
4132 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4133 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','','free')");
4134 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free')");
4135 print "Upgrade to $DBversion done (Add sysprefs to control custom favicons)\n";
4136 SetVersion ($DBversion);
4139 $DBversion = "3.03.00.031";
4140 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4141 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('FineNotifyAtCheckin',0,'If ON notify librarians of overdue fines on the items they are checking in.',NULL,'YesNo');");
4142 print "Upgrade to $DBversion done (Add syspref FineNotifyAtCheckin)\n";
4143 SetVersion ($DBversion);
4146 $DBversion = '3.03.00.032';
4147 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4148 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', 1, 'Create searches on all subdivisions for subject tracings.','1','YesNo')");
4149 print "Upgrade to $DBversion done ( include subdivisions when generating subject tracing searches )\n";
4153 $DBversion = '3.03.00.033';
4154 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4155 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages', '1', '', NULL, 'YesNo')");
4156 print "Upgrade to $DBversion done (System pref StaffAuthorisedValueImages)\n";
4157 SetVersion ($DBversion);
4160 $DBversion = '3.03.00.034';
4161 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4162 $dbh->do("ALTER TABLE `categories` ADD `hidelostitems` tinyint(1) NOT NULL default '0' AFTER `reservefee`");
4163 print "Upgrade to $DBversion done (Add hidelostitems preference to borrower categories)\n";
4164 SetVersion ($DBversion);
4167 $DBversion = '3.03.00.035';
4168 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4169 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedate date default NULL AFTER issuelength");
4170 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedatecompare tinyint NOT NULL default 0 AFTER hardduedate");
4172 if (C4::Context->preference("globalDueDate")) {
4173 $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("globalDueDate") ), dateonly => 1, dateformat => 'iso' } ); };
4174 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = 0");
4175 } elsif (C4::Context->preference("ceilingDueDate")) {
4176 $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("ceilingDueDate") ), dateonly => 1, dateformat => 'iso' } ); };
4177 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = -1");
4179 $dbh->do("DELETE FROM `systempreferences` WHERE variable = 'globalDueDate' OR variable = 'ceilingDueDate'");
4180 print "Upgrade to $DBversion done (Move global and ceiling due dates to Circ Rules level)\n";
4181 SetVersion ($DBversion);
4184 $DBversion = '3.03.00.036';
4185 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4186 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('COinSinOPACResults', 1, 'If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','','YesNo')");
4187 print "Upgrade to $DBversion done ( Make COinS optional in OPAC search results )\n";
4188 SetVersion ($DBversion);
4191 $DBversion = '3.03.00.037';
4192 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4193 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACDisplay856uAsImage','OFF','Display the URI in the 856u field as an image, the corresponding OPACXSLT option must be on','OFF|Details|Results|Both','Choice')");
4194 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Display856uAsImage','OFF','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','OFF|Details|Results|Both','Choice')");
4195 print "Upgrade to $DBversion done (Add 'Display856uAsImage' and 'OPACDisplay856uAsImage' syspref)\n";
4196 SetVersion ($DBversion);
4199 $DBversion = '3.03.00.038';
4200 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4201 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SelfCheckTimeout',120,'Define the number of seconds before the Web-based Self Checkout times out a patron','','Integer')");
4202 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowSelfCheckReturns',0,'If enabled, patrons may return items through the Web-based Self Checkout','','YesNo')");
4203 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SelfCheckHelpMessage','','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','70|10','Textarea')");
4204 print "Upgrade to $DBversion done ( Add Self-checkout by Login system preferences )\n";
4207 $DBversion = "3.03.00.039";
4208 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4209 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ShowReviewer',1,'If ON, name of reviewer will be shown above comments in OPAC',NULL,'YesNo');");
4210 print "Upgrade to $DBversion done (Add syspref ShowReviewer)\n";
4213 $DBversion = "3.03.00.040";
4214 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4215 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('UseControlNumber',0,'If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','','YesNo');");
4216 print "Upgrade to $DBversion done (Add syspref UseControlNumber)\n";
4219 $DBversion = "3.03.00.041";
4220 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4221 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AlternateHoldingsField','','The MARC field/subfield that contains alternate holdings information for bibs taht do not have items attached (e.g. 852abchi for libraries converting from MARC Magician).',NULL,'free')");
4222 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AlternateHoldingsSeparator','','The string to use to separate subfields in alternate holdings displays.',NULL,'free')");
4223 print "Upgrade to $DBversion done (Add sysprefs to control alternate holdings information display)\n";
4224 SetVersion ($DBversion);
4227 $DBversion = '3.03.00.042';
4228 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4229 stocknumber_checker();
4230 print "Upgrade to $DBversion done (5860 Index itemstocknumber)\n";
4231 SetVersion ($DBversion);
4234 sub stocknumber_checker { #code reused later on
4236 #drop the obsolete itemSStocknumber idx if it exists
4237 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemsstocknumberidx'");
4238 $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;") if @row;
4240 #check itemstocknumber idx; remove it if it is unique
4241 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx' AND non_unique=0");
4242 $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;") if @row;
4244 #add itemstocknumber index non-unique IF it still not exists
4245 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx'");
4246 $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);") unless @row;
4249 $DBversion = "3.03.00.043";
4250 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4252 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No')");
4253 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes')");
4255 print "Upgrade to $DBversion done ( add generic boolean YES_NO authorised_values pair )\n";
4256 SetVersion ($DBversion);
4259 $DBversion = '3.03.00.044';
4260 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4261 $dbh->do("ALTER TABLE `aqbasketgroups` ADD `freedeliveryplace` TEXT NULL AFTER `deliveryplace`;");
4262 print "Upgrade to $DBversion done (adding freedeliveryplace to basketgroups)\n";
4265 $DBversion = '3.03.00.045';
4266 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4267 #Remove obsolete columns from aqbooksellers if needed
4268 my $a = $dbh->selectall_hashref('SHOW columns from aqbooksellers','Field');
4269 my $sqldrop="ALTER TABLE aqbooksellers DROP COLUMN ";
4270 foreach(qw/deliverydays followupdays followupscancel invoicedisc nocalc specialty/) {
4271 $dbh->do($sqldrop.$_) if exists $a->{$_};
4273 #Remove obsolete column from aqbudgets if needed
4274 #The correct column is budget_notes
4275 $a = $dbh->selectall_hashref('SHOW columns from aqbudgets','Field');
4276 if(exists $a->{budget_description}) {
4277 $dbh->do("ALTER TABLE aqbudgets DROP COLUMN budget_description");
4279 print "Upgrade to $DBversion done (Remove obsolete columns from aqbooksellers and aqbudgets if needed)\n";
4280 SetVersion ($DBversion);
4283 $DBversion = "3.03.00.046";
4284 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4285 $dbh->do("ALTER TABLE overduerules ALTER delay1 SET DEFAULT NULL, ALTER delay2 SET DEFAULT NULL, ALTER delay3 SET DEFAULT NULL");
4286 print "Upgrade to $DBversion done (Setting NULL default value for delayn columns in table overduerules)\n";
4287 SetVersion($DBversion);
4290 $DBversion = '3.03.00.047';
4291 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4292 $dbh->do("ALTER TABLE borrowers ADD `state` mediumtext AFTER city;");
4293 $dbh->do("ALTER TABLE borrowers ADD `B_state` mediumtext AFTER B_city;");
4294 $dbh->do("ALTER TABLE borrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4295 $dbh->do("ALTER TABLE deletedborrowers ADD `state` mediumtext AFTER city;");
4296 $dbh->do("ALTER TABLE deletedborrowers ADD `B_state` mediumtext AFTER B_city;");
4297 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4298 print "Upgrade to $DBversion done (Add state field to patron's addresses)\n";
4301 $DBversion = '3.03.00.048';
4302 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4303 $dbh->do("ALTER TABLE branches ADD `branchstate` mediumtext AFTER `branchcity`;");
4304 print "Upgrade to $DBversion done (Add state to branch address)\n";
4305 SetVersion ($DBversion);
4308 $DBversion = '3.03.00.049';
4309 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4310 $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4311 $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4312 print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n";
4313 SetVersion($DBversion);
4316 $DBversion = "3.03.00.050";
4317 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4319 INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','','Textarea');
4321 print "Upgrade to $DBversion done (Adding OpacHiddenItems syspref)\n";
4322 SetVersion($DBversion);
4325 $DBversion = "3.03.00.051";
4326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4327 print "Upgrade to $DBversion done (Remove spaces and dashes from message_attribute names)\n";
4328 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Due' WHERE message_name='Item Due'");
4329 $dbh->do("UPDATE message_attributes SET message_name = 'Advance_Notice' WHERE message_name='Advance Notice'");
4330 $dbh->do("UPDATE message_attributes SET message_name = 'Hold_Filled' WHERE message_name='Hold Filled'");
4331 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Check_in' WHERE message_name='Item Check-in'");
4332 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Checkout' WHERE message_name='Item Checkout'");
4333 SetVersion ($DBversion);
4336 $DBversion = "3.03.00.052";
4337 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4338 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WaitingNotifyAtCheckin',0,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.',NULL,'YesNo');");
4339 print "Upgrade to $DBversion done (Add syspref WaitingNotifyAtCheckin)\n";
4340 SetVersion ($DBversion);
4343 $DBversion = "3.04.00.000";
4344 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4345 print "Upgrade to $DBversion done Koha 3.4.0 release \n";
4346 SetVersion ($DBversion);
4349 $DBversion = "3.05.00.001";
4350 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4352 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer');
4354 print "Upgrade to $DBversion done (Adds New System preference numSearchRSSResults)\n";
4355 SetVersion($DBversion);
4358 $DBversion = '3.05.00.002';
4359 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4360 #follow up fix 5860: some installs already past 3.3.0.42
4361 stocknumber_checker();
4362 print "Upgrade to $DBversion done (Fix for stocknumber index)\n";
4363 SetVersion ($DBversion);
4366 $DBversion = "3.05.00.003";
4367 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4369 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
4371 print "Upgrade to $DBversion done (Adds New System preference OpacRenewalBranch)\n";
4372 SetVersion($DBversion);
4375 $DBversion = "3.05.00.004";
4376 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4377 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ShowReviewerPhoto',1,'If ON, photo of reviewer will be shown beside comments in OPAC',NULL,'YesNo');");
4378 print "Upgrade to $DBversion done (Add syspref ShowReviewerPhoto)\n";
4379 SetVersion($DBversion);
4382 $DBversion = "3.05.00.005";
4383 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4384 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice');");
4385 print "Upgrade to $DBversion done (Adds pref BasketConfirmations)\n";
4386 SetVersion($DBversion);
4389 $DBversion = "3.05.00.006";
4390 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4391 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea')");
4392 print "Upgrade to $DBversion done (Add syspref MARCAuthorityControlField008)\n";
4393 SetVersion ($DBversion);
4396 $DBversion = "3.05.00.007";
4397 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4398 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');");
4399 print "Upgrade to $DBversion done (Add syspref OpenLibraryCovers)\n";
4400 SetVersion($DBversion);
4403 $DBversion = "3.05.00.008";
4404 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4405 $dbh->do("ALTER TABLE `cities` ADD `city_state` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_name`;");
4406 $dbh->do("ALTER TABLE `cities` ADD `city_country` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_zipcode`;");
4407 print "Add state and country to cities table corresponding to new columns in borrowers\n";
4408 SetVersion($DBversion);
4411 $DBversion = "3.05.00.009";
4412 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4413 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4414 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE borrowernumber IS NULL");
4415 $dbh->do("DELETE FROM issues WHERE borrowernumber IS NULL");
4417 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4418 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE itemnumber IS NULL");
4419 $dbh->do("DELETE FROM issues WHERE itemnumber IS NULL");
4421 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4422 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowernumber = issues.borrowernumber)");
4423 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowernumber = issues.borrowernumber)");
4425 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4426 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE NOT EXISTS (SELECT * FROM items WHERE itemnumber = issues.itemnumber)");
4427 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM items WHERE itemnumber = issues.itemnumber)");
4429 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_1`");
4430 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_2`");
4431 $dbh->do("ALTER TABLE issues ALTER COLUMN borrowernumber DROP DEFAULT");
4432 $dbh->do("ALTER TABLE issues ALTER COLUMN itemnumber DROP DEFAULT");
4433 $dbh->do("ALTER TABLE issues MODIFY COLUMN borrowernumber int(11) NOT NULL");
4434 $dbh->do("ALTER TABLE issues MODIFY COLUMN itemnumber int(11) NOT NULL");
4435 $dbh->do("ALTER TABLE issues DROP KEY `issuesitemidx`");
4436 $dbh->do("ALTER TABLE issues ADD PRIMARY KEY (`itemnumber`)");
4437 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4438 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4440 print "Upgrade to $DBversion done (issues referential integrity)\n";
4441 SetVersion ($DBversion);
4444 $DBversion = "3.05.00.010";
4445 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4446 $dbh->do("CREATE INDEX priorityfoundidx ON reserves (priority,found)");
4447 print "Create an index on reserves to speed up holds awaiting pickup report bug 5866\n";
4448 SetVersion($DBversion);
4452 $DBversion = "3.05.00.011";
4453 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4454 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACResultsSidebar','','Define HTML to be included on the search results page, underneath the facets sidebar','70|10','Textarea')");
4455 print "Upgrade to $DBversion done (add OPACResultsSidebar syspref (enh 6165))\n";
4456 SetVersion($DBversion);
4459 $DBversion = "3.05.00.012";
4460 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4461 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RecordLocalUseOnReturn',0,'If ON, statistically record returns of unissued items as local use, instead of return',NULL,'YesNo')");
4462 print "Upgrade to $DBversion done (add RecordLocalUseOnReturn syspref (enh 6403))\n";
4463 SetVersion($DBversion);
4466 $DBversion = "3.05.00.013";
4467 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4468 $dbh->do(qq|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','0',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL)|);
4469 print "Upgrade to $DBversion done (Add syspref 'OpacKohaUrl')\n";
4470 SetVersion($DBversion);
4473 $DBversion = "3.05.00.014";
4474 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4475 $dbh->do("ALTER TABLE `borrowers` MODIFY `userid` VARCHAR(75)");
4476 print "Modified userid column length into 75 in borrowers\n";
4477 SetVersion($DBversion);
4480 $DBversion = "3.05.00.015";
4481 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4482 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectEnabled',0,'Enable Novelist Select content. Requires Novelist Profile and Password',NULL,'YesNo')");
4483 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectProfile',NULL,'Novelist Select user Password',NULL,'free')");
4484 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectPassword',NULL,'Enable Novelist user Profile',NULL,'free')");
4485 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectView','tab','Where to display Novelist Select content','tab|above|below|right','Choice')");
4486 print "Upgrade to $DBversion done (Add support for EBSCO's NoveList Select (enh 6902))\n";
4487 SetVersion($DBversion);
4490 $DBversion = '3.05.00.016';
4491 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4492 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');");
4493 print "Upgrade to $DBversion done (Add EasyAnalyticalRecords syspref)\n";
4494 SetVersion ($DBversion);
4497 $DBversion = '3.05.00.017';
4498 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4499 if (C4::Context->preference("marcflavour") eq 'MARC21' ||
4500 C4::Context->preference("marcflavour") eq 'NORMARC'){
4501 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('773', '0', 'Host Biblionumber', 'Host Biblionumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)");
4502 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('773', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)");
4503 print "Upgrade to $DBversion done (Add 773 subfield 9 and 0 to default framework)\n";
4504 SetVersion ($DBversion);
4505 } elsif (C4::Context->preference("marcflavour") eq 'UNIMARC'){
4506 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('461', '9', 'Host Itemnumber', 'Host Itemnumber', 0, 0, NULL, 7, NULL, NULL, '', NULL, -6, '', '', '', NULL)");
4507 print "Upgrade to $DBversion done (Add 461 subfield 9 to default framework)\n";
4508 SetVersion ($DBversion);
4512 $DBversion = "3.05.00.018";
4513 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4514 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacNavBottom','','Links after OpacNav links','70|10','Textarea')");
4515 print "Upgrade to $DBversion done (add OpacNavBottom syspref (enh 6825): if appropriate, you can split OpacNav into OpacNav and OpacNavBottom)\n";
4516 SetVersion($DBversion);
4519 $DBversion = "3.05.00.019";
4520 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4521 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4522 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4523 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4524 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4525 print "Upgrade to $DBversion done (remove duplicate VOKAL Book icons, bug 6862)\n";
4526 SetVersion($DBversion);
4529 $DBversion = "3.05.00.020";
4530 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4531 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice')");
4532 print "Upgrade to $DBversion done (Add syspref AcqViewBaskets)\n";
4533 SetVersion($DBversion);
4536 $DBversion = "3.05.00.021";
4537 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4538 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN display_checkout TINYINT(1) NOT NULL DEFAULT '0';");
4539 print "Upgrade to $DBversion done (Added a display_checkout field in borrower_attribute_types table)\n";
4540 SetVersion($DBversion);
4543 $DBversion = "3.05.00.022";
4544 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4545 $dbh->do("CREATE TABLE need_merge_authorities (id int NOT NULL auto_increment PRIMARY KEY, authid bigint NOT NULL, done tinyint DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8");
4546 print "Upgrade to $DBversion done (6094: Fixing ModAuthority problems, add a need_merge_authorities table)\n";
4547 SetVersion($DBversion);
4550 $DBversion = "3.05.00.023";
4551 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4552 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowRecentComments',0,'If ON a link to recent comments will appear in the OPAC masthead',NULL,'YesNo');");
4553 print "Upgrade to $DBversion done (Add syspref OpacShowRecentComments. When the preference is turned on a link to recent comments will appear in the OPAC masthead. )\n";
4554 SetVersion($DBversion);
4557 $DBversion = "3.06.00.000";
4558 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4559 print "Upgrade to $DBversion done Koha 3.6.0 release \n";
4560 SetVersion ($DBversion);
4563 $DBversion = "3.07.00.001";
4564 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4565 my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred =1;", { Columns => [1] } );
4566 $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
4567 $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
4568 $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4569 $dbh->do("ALTER TABLE deletedborrowers MODIFY debarred DATE DEFAULT NULL;");
4570 $dbh->do("ALTER TABLE deletedborrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4571 print "Upgrade done (Change borrowers.debarred into Date )\n";
4572 SetVersion($DBversion);
4575 $DBversion = "3.07.00.002";
4576 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4577 $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';");
4578 print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n";
4579 SetVersion($DBversion);
4582 $DBversion = "3.07.00.003";
4583 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4584 $dbh->do(" UPDATE `message_attributes` SET message_name='Item_Due' WHERE message_name='Item_DUE'");
4585 print "Updating message_name in message_attributes\n";
4586 SetVersion($DBversion);
4589 $DBversion = "3.07.00.004";
4590 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4591 $dbh->do("ALTER TABLE `suggestions` ADD `patronreason` TEXT NULL AFTER `reason`");
4592 print "Upgrade to $DBversion done (Add column to suggestions table to store patrons' reasons for submitting a suggestion. )\n";
4593 SetVersion($DBversion);
4596 $DBversion = "3.07.00.005";
4597 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4598 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BorrowerUnwantedField','','Name the fields you don''t need to store for a patron''s account',NULL,'free')");
4599 print "Upgrade to $DBversion done (BorrowerUnwantedField syspref)\n";
4600 SetVersion ($DBversion);
4603 $DBversion = "3.07.00.006";
4604 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4605 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CircAutoPrintQuickSlip', '1', 'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window or Clear the screen.',NULL,'YesNo');");
4606 print "Upgrade to $DBversion done (Add syspref CircAutoPrintQuickSlip to control what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window (default value, 3.6 behaviour) or clear the screen (previous 3.6 behaviour). )\n";
4607 SetVersion($DBversion);
4610 $DBversion = "3.07.00.007";
4611 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4612 $dbh->do("ALTER TABLE items MODIFY materials text;");
4613 print "Upgrade to $DBversion done alter items.material from varchar(10) to text \n";
4614 SetVersion($DBversion);
4617 $DBversion = '3.07.00.008';
4618 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4619 if (C4::Context->preference("marcflavour") eq 'MARC21') {
4620 if (C4::Context->preference("opaclanguages") eq "de") {
4621 $dbh->do("INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `authorised_value`, `frameworkcode`) VALUES ('545', 'Fußnote zu biografischen oder historischen Daten', 'Fußnote zu biografischen oder historischen Daten', 1, 0, NULL, '');");
4623 $dbh->do("INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `authorised_value`, `frameworkcode`) VALUES ('545', 'BIOGRAPHICAL OR HISTORICAL DATA', 'BIOGRAPHICAL OR HISTORICAL DATA', 1, 0, NULL, '');");
4626 print "Upgrade to $DBversion done (add MARC21 field 545 to framework)\n";
4627 SetVersion ($DBversion);
4630 $DBversion = "3.07.00.009";
4631 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4632 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `claims_count` INT(11) DEFAULT 0, ADD COLUMN `claimed_date` DATE DEFAULT NULL AFTER `claims_count`");
4633 print "Upgrade to $DBversion done (Add claims_count and claimed_date fields in aqorders table)\n";
4634 SetVersion($DBversion);
4637 $DBversion = "3.07.00.010";
4638 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4640 q|CREATE TABLE `biblioimages` (
4641 `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
4642 `biblionumber` int(11) NOT NULL,
4643 `mimetype` varchar(15) NOT NULL,
4644 `imagefile` mediumblob NOT NULL,
4645 `thumbnail` mediumblob NOT NULL,
4646 PRIMARY KEY (`imagenumber`),
4647 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4648 ) ENGINE=InnoDB DEFAULT CHARSET=utf8|
4651 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|
4654 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|
4657 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowMultipleCovers','0','Allow multiple cover images to be attached to each bibliographic record.','1','YesNo')|
4660 q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|
4662 print "Upgrade to $DBversion done (Added support for local cover images)\n";
4663 SetVersion($DBversion);
4666 $DBversion = "3.07.00.011";
4667 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4668 $dbh->do(<<ENDOFRENEWAL);
4669 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BorrowerRenewalPeriodBase', 'now', 'Set whether the borrower renewal date should be counted from the dateexpiry or from the current date ','dateexpiry|now','Choice');
4671 print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
4672 SetVersion($DBversion);
4675 $DBversion = "3.07.00.012";
4676 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4677 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowItemsOnHoldCheckout',0,'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','','YesNo')");
4678 print "Upgrade to $DBversion add 'AllowItemsOnHoldCheckout' syspref \n";
4679 SetVersion ($DBversion);
4682 $DBversion = "3.07.00.013";
4683 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4684 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define available export options on OPAC detail page.','','free');");
4685 print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n";
4686 SetVersion ($DBversion);
4689 $DBversion = "3.07.00.014";
4690 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4691 print "RELTERMS category available for English-, French-, and Spanish-language relator terms. They are not loaded during upgrade but can be easily inserted using the provided marc21_relatorterms.sql SQL script (MARC21 only, and currently available for en, es, and fr only).\n";
4692 SetVersion($DBversion);
4695 $DBversion = "3.07.00.015";
4696 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4697 my $sth = $dbh->prepare(q|
4698 SELECT COUNT(*) FROM marc_subfield_structure where kohafield="biblioitems.editionstatement"
4701 my $already_exists = $sth->fetchrow;
4702 if ( not $already_exists ) {
4703 my $field = C4::Context->preference("marcflavour") eq "UNIMARC" ? "205" : "250";
4705 my $sth = $dbh->prepare( q|
4706 UPDATE marc_subfield_structure SET kohafield = "biblioitems.editionstatement"
4707 WHERE tagfield = ? AND tagsubfield = ?
4709 $sth->execute( $field, $subfield );
4710 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement.)\n";
4712 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement (already exists, nothing to do).)\n";
4714 SetVersion($DBversion);
4717 $DBversion = "3.07.00.016";
4718 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4719 $dbh->do("ALTER TABLE items ADD KEY `itemcallnumber` (itemcallnumber)");
4720 print "Upgrade to $DBversion done (Added index on items.itemcallnumber)\n";
4721 SetVersion($DBversion);
4724 $DBversion = "3.07.00.017";
4725 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4726 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo')");
4727 print "Upgrade to $DBversion done (Add sysprefs to control transfer when cancel all waiting holds)\n";
4728 SetVersion ($DBversion);
4731 $DBversion = "3.07.00.018";
4732 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4733 $dbh->do("CREATE TABLE pending_offline_operations ( operationid int(11) NOT NULL AUTO_INCREMENT, userid varchar(30) NOT NULL, branchcode varchar(10) NOT NULL, timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, action varchar(10) NOT NULL, barcode varchar(20) NOT NULL, cardnumber varchar(16) DEFAULT NULL, PRIMARY KEY (operationid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
4734 print "Upgrade to $DBversion done ( adding offline operations table )\n";
4735 SetVersion($DBversion);
4738 $DBversion = "3.07.00.019";
4739 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4740 $dbh->do(" UPDATE `systempreferences` SET `value` = 'none', `options` = 'none|full|first|surname|firstandinitial|username', `explanation` = 'Choose how a commenter''s identity is presented alongside comments in the OPAC', `type` = 'Choice' WHERE `systempreferences`.`variable` = 'ShowReviewer' AND `systempreferences`.`variable` = 0");
4741 $dbh->do(" UPDATE `systempreferences` SET `value` = 'full', `options` = 'none|full|first|surname|firstandinitial|username', `explanation` = 'Choose how a commenter''s identity is presented alongside comments in the OPAC', `type` = 'Choice' WHERE `systempreferences`.`variable` = 'ShowReviewer' AND `systempreferences`.`variable` = 1");
4742 print "Upgrade to $DBversion done ( Adding additional options for the display of commenter's identity in the OPAC: Full name, first name, last name, first name and last name first initial, username, or no information)\n";
4743 SetVersion($DBversion);
4746 $DBversion = "3.07.00.020";
4747 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4748 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo');");
4749 print "Upgrade to $DBversion done (Bug 3516: Add the option to show patron images in the OPAC.)\n";
4750 SetVersion($DBversion);
4753 $DBversion = "3.07.00.021";
4754 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4756 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerModule','Default','Chooses which linker module to use (see documentation).','Default|FirstMatchLastMatch','Choice');"
4759 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free');"
4762 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo');"
4765 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo');"
4768 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AutoCreateAuthorities',0,'Automatically create authorities that do not exist when cataloging records.',NULL,'YesNo');"
4771 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo');"
4773 print "Upgrade to $DBversion done (Enhancement 7284, improved authority matching, see http://wiki.koha-community.org/wiki/Bug7284_authority_matching_improvement wiki page for configuration update needed)\n";
4774 SetVersion($DBversion);
4777 $DBversion = "3.07.00.022";
4778 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4779 $dbh->do("DELETE FROM reviews WHERE biblionumber NOT IN (SELECT biblionumber from biblio)");
4780 $dbh->do("UPDATE reviews SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers)");
4781 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_2 FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
4782 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber ) ON UPDATE CASCADE ON DELETE SET NULL");
4783 print "Upgrade to $DBversion done (Bug 7493 - Add constraint linking OPAC comment biblionumber to biblio, OPAC comment borrowernumber to borrowers.)\n";
4784 SetVersion($DBversion);
4787 $DBversion = "3.07.00.023";
4788 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4789 $dbh->do("ALTER TABLE `message_transports` DROP FOREIGN KEY `message_transports_ibfk_3`");
4790 $dbh->do("ALTER TABLE `letter` DROP PRIMARY KEY");
4791 $dbh->do("ALTER TABLE `letter` ADD `branchcode` varchar(10) default NULL AFTER `code`");
4792 $dbh->do("ALTER TABLE `letter` ADD PRIMARY KEY (`module`,`code`, `branchcode`)");
4793 $dbh->do("ALTER TABLE `message_transports` ADD `branchcode` varchar(10) NOT NULL default ''");
4794 $dbh->do("ALTER TABLE `message_transports` ADD CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`, `branchcode`) REFERENCES `letter` (`module`, `code`, `branchcode`) ON DELETE CASCADE ON UPDATE CASCADE");
4795 $dbh->do("ALTER TABLE `letter` ADD `is_html` tinyint(1) default 0 AFTER `name`");
4797 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4798 VALUES ('circulation','ISSUESLIP','Issue Slip','Issue Slip', '<h3><<branches.branchname>></h3>
4799 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4800 (<<borrowers.cardnumber>>) <br />
4804 <h4>Checked Out</h4>
4807 <<biblio.title>> <br />
4808 Barcode: <<items.barcode>><br />
4809 Date due: <<issues.date_due>><br />
4816 <<biblio.title>> <br />
4817 Barcode: <<items.barcode>><br />
4818 Date due: <<issues.date_due>><br />
4824 <h4 style=\"text-align: center; font-style:italic;\">News</h4>
4826 <div class=\"newsitem\">
4827 <h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>
4828 <p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.new>></p>
4829 <p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<opac_news.timestamp>></p>
4833 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4834 VALUES ('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '<h3><<branches.branchname>></h3>
4835 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4836 (<<borrowers.cardnumber>>) <br />
4840 <h4>Checked Out Today</h4>
4843 <<biblio.title>> <br />
4844 Barcode: <<items.barcode>><br />
4845 Date due: <<issues.date_due>><br />
4847 </checkedout>', 1)");
4848 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4849 VALUES ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '<h5>Date: <<today>></h5>
4851 <h3> Transfer to/Hold in <<branches.branchname>></h3>
4853 <h3><<borrowers.surname>>, <<borrowers.firstname>></h3>
4856 <li><<borrowers.cardnumber>></li>
4857 <li><<borrowers.phone>></li>
4858 <li> <<borrowers.address>><br />
4859 <<borrowers.address2>><br />
4860 <<borrowers.city >> <<borrowers.zipcode>>
4862 <li><<borrowers.email>></li>
4865 <h3>ITEM ON HOLD</h3>
4866 <h4><<biblio.title>></h4>
4867 <h5><<biblio.author>></h5>
4869 <li><<items.barcode>></li>
4870 <li><<items.itemcallnumber>></li>
4871 <li><<reserves.waitingdate>></li>
4874 <pre><<reserves.reservenotes>></pre>
4876 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4877 VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
4878 <h3>Transfer to <<branches.branchname>></h3>
4881 <h4><<biblio.title>></h4>
4882 <h5><<biblio.author>></h5>
4884 <li><<items.barcode>></li>
4885 <li><<items.itemcallnumber>></li>
4888 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free')");
4889 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free')");
4891 $dbh->do("UPDATE `letter` SET content = replace(content, '<<title>>', '<<biblio.title>>') WHERE code = 'HOLDPLACED'");
4893 print "Upgrade to $DBversion done (Add branchcode and is_html to letter table; Default ISSUESLIP, RESERVESLIP and TRANSFERSLIP letters; Add NoticeCSS and SlipCSS sysprefs)\n";
4894 SetVersion($DBversion);
4897 $DBversion = "3.07.00.024";
4898 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4899 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelayCharge', '0', NULL , 'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.', 'free')");
4900 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo')");
4901 print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
4904 $DBversion = "3.07.00.025";
4905 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4906 if (TableExists('bibliocoverimage')) {
4907 $dbh->do( q|DROP TABLE bibliocoverimage;| );
4909 q|CREATE TABLE biblioimages (
4910 imagenumber int(11) NOT NULL AUTO_INCREMENT,
4911 biblionumber int(11) NOT NULL,
4912 mimetype varchar(15) NOT NULL,
4913 imagefile mediumblob NOT NULL,
4914 thumbnail mediumblob NOT NULL,
4915 PRIMARY KEY (imagenumber),
4916 CONSTRAINT bibliocoverimage_fk1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
4917 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
4920 print "Upgrade to $DBversion done (Correct table name for local cover images if needed. )\n";
4921 SetVersion($DBversion);
4924 $DBversion = "3.07.00.026";
4925 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4926 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CalendarFirstDayOfWeek','Sunday','Select the first day of week to use in the calendar.','Sunday|Monday','Choice');");
4927 print "Upgrade to $DBversion done (Add syspref CalendarFirstDayOfWeek used to select the first day of week to use in the calendar. )\n";
4928 SetVersion($DBversion);
4931 $DBversion = "3.07.00.027";
4932 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4933 $dbh->do(q{INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RoutingListNote','','Define a note to be shown on all routing lists','70|10','Textarea');});
4934 print "Upgrade to $DBversion done (Added system preference RoutingListNote for adding a general note to all routing lists.)\n";
4935 SetVersion($DBversion);
4938 $DBversion = "3.07.00.028";
4939 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4941 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowPKIAuth','None','Use the field from a client-side SSL certificate to look a user in the Koha database','None|Common Name|emailAddress','Choice');
4943 print "Upgrade to $DBversion done (Bug 6296 New System preference AllowPKIAuth)\n";
4946 $DBversion = "3.07.00.029";
4947 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4948 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;});
4949 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;});
4950 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;});
4951 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;});
4954 CREATE TABLE `oai_sets` (
4955 `id` int(11) NOT NULL auto_increment,
4956 `spec` varchar(80) NOT NULL UNIQUE,
4957 `name` varchar(80) NOT NULL,
4959 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4963 CREATE TABLE `oai_sets_descriptions` (
4964 `set_id` int(11) NOT NULL,
4965 `description` varchar(255) NOT NULL,
4966 CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4967 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4971 CREATE TABLE `oai_sets_mappings` (
4972 `set_id` int(11) NOT NULL,
4973 `marcfield` char(3) NOT NULL,
4974 `marcsubfield` char(1) NOT NULL,
4975 `marcvalue` varchar(80) NOT NULL,
4976 CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4977 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4981 CREATE TABLE `oai_sets_biblios` (
4982 `biblionumber` int(11) NOT NULL,
4983 `set_id` int(11) NOT NULL,
4984 PRIMARY KEY (`biblionumber`, `set_id`),
4985 CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4986 CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4987 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4991 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');
4994 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4995 SetVersion($DBversion);
4998 $DBversion = "3.07.00.030";
4999 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5000 $dbh->do("ALTER TABLE default_circ_rules ADD
5001 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5002 $dbh->do("ALTER TABLE branch_item_rules ADD
5003 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5004 $dbh->do("ALTER TABLE default_branch_circ_rules ADD
5005 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5006 $dbh->do("ALTER TABLE default_branch_item_rules ADD
5007 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5008 # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
5009 my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') || 'homebranch';
5010 $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
5011 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
5012 SetVersion($DBversion);
5015 $DBversion = "3.07.00.031";
5016 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5017 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UseICU', '1', 'Tell Koha if ICU indexing is in use for Zebra or not.','1','YesNo')");
5018 print "Upgrade to $DBversion done (Add syspref to tell Koha if ICU indexing is in use for Zebra or not.)\n";
5019 SetVersion ($DBversion);
5022 $DBversion = "3.07.00.032";
5023 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5024 $dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers)
5025 $dbh->do("UPDATE virtualshelves vi LEFT JOIN borrowers bo ON bo.borrowernumber=vi.owner SET vi.owner=NULL where bo.borrowernumber IS NULL"); #before adding the constraint on borrowernumber, we need to get rid of deleted owners
5026 $dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents)
5027 $dbh->do("ALTER TABLE virtualshelves ADD COLUMN allow_add tinyint(1) DEFAULT 0, ADD COLUMN allow_delete_own tinyint(1) DEFAULT 1, ADD COLUMN allow_delete_other tinyint(1) DEFAULT 0, ADD CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL");
5028 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1");
5029 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2");
5030 $dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3");
5031 $dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3");
5033 $dbh->do("ALTER TABLE virtualshelfcontents ADD COLUMN borrowernumber int, ADD CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL");
5034 $dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner");
5036 $dbh->do("CREATE TABLE virtualshelfshares
5037 (id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL,
5038 borrowernumber int, invitekey varchar(10), sharedate datetime,
5039 CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5040 CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5042 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');");
5043 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowSharingPrivateLists',0,'If set, allows opac users to share private lists with other patrons',NULL,'YesNo');");
5045 print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n";
5046 SetVersion($DBversion);
5049 $DBversion = "3.07.00.033";
5050 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5051 $dbh->do("ALTER TABLE branches ADD opac_info text;");
5052 print "Upgrade to $DBversion done add opac_info to branches \n";
5053 SetVersion($DBversion);
5056 $DBversion = "3.07.00.034";
5057 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5058 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
5059 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255) NOT NULL DEFAULT '' AFTER `category_code`");
5060 $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
5061 print "Upgrade to $DBversion done (New fields category_code and class in borrower_attribute_types table)\n";
5062 SetVersion($DBversion);
5065 $DBversion = "3.07.00.035";
5066 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5067 $dbh->do("ALTER TABLE issues CHANGE date_due date_due datetime");
5068 $dbh->do("UPDATE issues SET date_due = CONCAT(SUBSTR(date_due,1,11),'23:59:00')");
5069 $dbh->do("ALTER TABLE issues CHANGE returndate returndate datetime");
5070 $dbh->do("ALTER TABLE issues CHANGE lastreneweddate lastreneweddate datetime");
5071 $dbh->do("ALTER TABLE issues CHANGE issuedate issuedate datetime");
5072 $dbh->do("ALTER TABLE old_issues CHANGE date_due date_due datetime");
5073 $dbh->do("ALTER TABLE old_issues CHANGE returndate returndate datetime");
5074 $dbh->do("ALTER TABLE old_issues CHANGE lastreneweddate lastreneweddate datetime");
5075 $dbh->do("ALTER TABLE old_issues CHANGE issuedate issuedate datetime");
5076 $dbh->do("UPDATE accountlines SET description = CONCAT(description,' 23:59') WHERE accounttype='F' OR accounttype='FU'"); #BUG-8253
5077 print "Upgrade to $DBversion done (Setting up issues and accountlines tables for hourly loans)\n";
5078 SetVersion($DBversion);
5081 $DBversion = "3.07.00.036";
5082 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5084 ALTER TABLE z3950servers ADD timeout INT( 11 ) NOT NULL DEFAULT '0' AFTER syntax;
5086 print "Upgrade to $DBversion done (New timeout field in z3950servers)\n";
5089 $DBversion = "3.07.00.037";
5090 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5092 ALTER TABLE `marc_subfield_structure` ADD `maxlength` INT( 4 ) NOT NULL DEFAULT '9999';
5095 UPDATE `marc_subfield_structure` SET maxlength=24 WHERE tagfield='000';
5098 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='MARC21','40','9999') WHERE tagfield='008';
5101 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='NORMARC','40','9999') WHERE tagfield='008';
5104 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='UNIMARC','36','9999') WHERE tagfield='100';
5106 print "Upgrade to $DBversion done (Add new field maxlength to marc_subfield_structure)\n";
5107 SetVersion($DBversion);
5110 $DBversion = "3.07.00.038";
5111 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5113 INSERT INTO systempreferences(variable,value,explanation,options,type)
5114 VALUES('UniqueItemFields', 'barcode', 'Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table', '', 'Free')
5116 print "Upgrade to $DBversion done (Added system preference 'UniqueItemFields')\n";
5117 SetVersion($DBversion);
5120 $DBversion = "3.07.00.039";
5121 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5122 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('Babeltheque_url_js','','Url for Babeltheque javascript (e.g. http://www.babeltheque.com/bw_XX.js','','Free')} );
5123 $dbh->do( qq{CREATE TABLE IF NOT EXISTS social_data
5126 num_critics_pro INT,
5129 score_avg DECIMAL(5,2),
5132 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5134 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('Babeltheque_url_update', '', 'Url for Babeltheque update (E.G. http://www.babeltheque.com/.../file.csv.bz2)', '', 'Free')} );
5135 print "Upgrade to $DBversion done (added syspref and table for babeltheque (Babeltheque_url_js, babeltheque))\n";
5136 SetVersion($DBversion);
5139 $DBversion = "3.07.00.040";
5140 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5141 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('SocialNetworks','0','Enable/Disable social networks links in opac detail','','YesNo')} );
5142 print "Upgrade to $DBversion done (added syspref SocialNetworks, to display facebook/ggl+ and other buttons)\n";
5143 SetVersion($DBversion);
5148 $DBversion = "3.07.00.041";
5149 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5150 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free')");
5151 print "Upgrade to $DBversion done (Add system preference SubscriptionDuplicateDroppedInput)\n";
5152 SetVersion($DBversion);
5155 $DBversion = "3.07.00.042";
5156 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5157 $dbh->do("ALTER TABLE reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5158 $dbh->do("ALTER TABLE old_reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5160 $dbh->do("ALTER TABLE reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5161 $dbh->do("ALTER TABLE old_reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5163 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo')");
5165 print "Upgrade to $DBversion done (Add suspend fields to reserves table, add syspref AutoResumeSuspendedHolds)\n";
5166 SetVersion ($DBversion);
5169 $DBversion = "3.07.00.043";
5170 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5171 my $countXSLTDetailsDisplay = 0;
5172 my $valueXSLTDetailsDisplay = "";
5173 my $valueXSLTResultsDisplay = "";
5174 my $valueOPACXSLTDetailsDisplay = "";
5175 my $valueOPACXSLTResultsDisplay = "";
5176 #the line below test if database comes from a BibLibre's branch
5177 $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
5178 if ($countXSLTDetailsDisplay > 0)
5180 #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
5181 $dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
5182 $dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
5186 $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
5187 $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
5188 $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
5189 $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
5190 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
5191 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
5192 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
5193 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
5195 print "Upgrade to $DBversion done (XSLT systempreference takes a path to file rather than YesNo)\n";
5196 SetVersion($DBversion);
5199 $DBversion = "3.07.00.044";
5200 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5201 $dbh->do("ALTER TABLE aqbooksellers ADD deliverytime INT DEFAULT NULL");
5202 print "Upgrade to $DBversion done (Add deliverytime field in aqbooksellers table)";
5203 SetVersion($DBversion);
5206 $DBversion = "3.07.00.045";
5207 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5208 $dbh->do("ALTER TABLE import_batches MODIFY COLUMN batch_type ENUM('batch','z3950','webservice') NOT NULL default 'batch'");
5209 print "Upgrade to $DBversion done (Add 'webservice' to batch_type enum)\n";
5210 SetVersion ($DBversion);
5213 $DBversion = "3.07.00.046";
5214 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5215 $dbh->do("ALTER TABLE issuingrules ADD COLUMN lengthunit varchar(10) DEFAULT 'days' AFTER issuelength");
5216 print "Upgrade to $DBversion done (Setting up issues tables for hourly loans (lengthunit fix))\n";
5217 SetVersion($DBversion);
5220 $DBversion = "3.07.00.047";
5221 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5222 $dbh->do("CREATE INDEX items_location ON items(location)");
5223 $dbh->do("CREATE INDEX items_ccode ON items(ccode)");
5224 print "Upgrade to $DBversion done (items_location and items_ccode indexes added for ShelfBrowser)\n";
5225 SetVersion($DBversion);
5228 $DBversion = "3.07.00.048";
5229 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5231 q | CREATE TABLE ratings (
5232 borrowernumber int(11) NOT NULL,
5233 biblionumber int(11) NOT NULL,
5234 rating_value tinyint(1) NOT NULL,
5235 timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
5236 PRIMARY KEY (borrowernumber,biblionumber),
5237 CONSTRAINT ratings_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
5238 CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
5239 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
5243 q /INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','disable',NULL,'disable|all|details','Choice') /
5247 "Upgrade to $DBversion done (Add 'ratings' table and 'OpacStarRatings' syspref)\n";
5248 SetVersion($DBversion);
5251 $DBversion = "3.07.00.049";
5252 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5253 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo')");
5254 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5255 SetVersion($DBversion);
5258 $DBversion = "3.08.00.000";
5259 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5260 print "Upgrade to $DBversion done\n";
5261 SetVersion($DBversion);
5264 $DBversion = "3.09.00.001";
5265 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5266 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 1 ) NULL DEFAULT NULL");
5267 print "Upgrade to $DBversion done. (Bug 8002: Update patron attribute types table to allow NULL category_code)\n";
5268 SetVersion($DBversion);
5271 $DBversion = "3.09.00.002";
5272 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5273 $dbh->do("ALTER TABLE saved_sql
5275 cache_expiry INT NOT NULL DEFAULT 300,
5276 public BOOLEAN NOT NULL DEFAULT FALSE
5279 print "Upgrade to $DBversion done (Added cache_expiry and public fields in
5280 saved_reports table.)\n";
5281 SetVersion($DBversion);
5284 $DBversion = "3.09.00.003";
5285 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5286 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');");
5287 print "Upgrade to $DBversion done (Added SvcMaxReportRows syspref)\n";
5288 SetVersion($DBversion);
5291 $DBversion = "3.09.00.004";
5292 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5293 $dbh->do("INSERT IGNORE INTO permissions (module_bit, code, description) VALUES('13', 'edit_patrons', 'Perform batch modifivation of patrons')");
5294 print "Upgrade to $DBversion done (Adds permissions flag for access to the patron modifications tool)\n";
5295 SetVersion($DBversion);
5298 $DBversion = "3.09.00.005";
5299 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5300 unless (TableExists('quotes')) {
5302 CREATE TABLE `quotes` (
5303 `id` int(11) NOT NULL AUTO_INCREMENT,
5304 `source` text DEFAULT NULL,
5305 `text` mediumtext NOT NULL,
5306 `timestamp` datetime NOT NULL,
5308 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5312 INSERT IGNORE INTO permissions VALUES (13, "edit_quotes","Edit quotes for quote-of-the-day feature");
5315 INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QuoteOfTheDay',0,'Enable or disable display of Quote of the Day on the OPAC home page',NULL,'YesNo');
5317 print "Upgrade to $DBversion done (Adding Quote of the Day Option.)\n";
5318 SetVersion($DBversion);
5321 $DBversion = "3.09.00.006";
5322 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5323 $dbh->do("UPDATE systempreferences SET
5324 variable = 'OPACShowHoldQueueDetails',
5325 value = CASE value WHEN '1' THEN 'priority' ELSE 'none' END,
5326 options = 'none|priority|holds|holds_priority',
5327 explanation = 'Show holds details in OPAC',
5329 WHERE variable = 'OPACDisplayRequestPriority'");
5330 print "Upgrade to $DBversion done (Changed system preference OPACDisplayRequestPriority -> OPACShowHoldQueueDetails)\n";
5331 SetVersion($DBversion);
5334 $DBversion = "3.09.00.007";
5335 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5336 unless(C4::Context->preference('ReservesControlBranch')){
5337 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights.','Choice')");
5339 print "Upgrade to $DBversion done (Insert ReservesControlBranch systempreference into systempreferences table )\n";
5340 SetVersion($DBversion);
5343 $DBversion = "3.09.00.008";
5344 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5345 $dbh->do("ALTER TABLE sessions ADD PRIMARY KEY (id);");
5346 $dbh->do("ALTER TABLE sessions DROP INDEX `id`;");
5347 print "Upgrade to $DBversion done (redefine the field id as PRIMARY KEY of sessions)\n";
5348 SetVersion($DBversion);
5351 $DBversion = "3.09.00.009";
5352 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5353 $dbh->do("ALTER TABLE branches ADD PRIMARY KEY (branchcode);");
5354 $dbh->do("ALTER TABLE branches DROP INDEX branchcode;");
5355 print "Upgrade to $DBversion done (redefine the field branchcode as PRIMARY KEY of branches)\n";
5356 SetVersion ($DBversion);
5359 $DBversion = "3.09.00.010";
5360 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5361 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IssueLostItem', 'alert', 'alert|confirm|nothing', 'Defines what should be done when an attempt is made to issue an item that has been marked as lost.', 'Choice')");
5362 print "Upgrade to $DBversion done (Add system preference issuelostitem ))\n";
5363 SetVersion($DBversion);
5366 $DBversion = "3.09.00.011";
5367 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5368 $dbh->do("ALTER TABLE `biblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5369 $dbh->do("CREATE INDEX `ean` ON biblioitems (`ean`) ");
5370 $dbh->do("ALTER TABLE `deletedbiblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5371 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
5372 $dbh->do("UPDATE marc_subfield_structure SET kohafield='biblioitems.ean' WHERE tagfield='073' and tagsubfield='a'");
5374 print "Upgrade to $DBversion done (Adding ean in biblioitems and deletedbiblioitems)\n";
5375 print "If you have records with ean, please run misc/batchRebuildBiblioTables.pl to populate bibliotems.ean\n" if (C4::Context->preference("marcflavour") eq 'UNIMARC');
5376 SetVersion($DBversion);
5379 $DBversion = "3.09.00.012";
5380 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5381 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo')");
5382 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo')");
5383 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5384 SetVersion($DBversion);
5387 $DBversion ="3.09.00.013";
5388 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5389 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('DefaultLanguageField008','','Fill in the default language for field 008 Range 35-37 (e.g. eng, nor, ger, see www.loc.gov/marc/languages/language_code.html)','','Free');");
5390 print "Upgrade to $DBversion done (Add system preference DefaultLanguageField008))\n";
5391 SetVersion($DBversion);
5394 $DBversion ="3.09.00.014";
5395 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5396 # add phone message transport type
5397 $dbh->do("INSERT INTO message_transport_types (message_transport_type) VALUES ('phone')");
5399 # adds HOLD_PHONE and PREDUE_PHONE letters (as placeholders)
5400 $dbh->do("INSERT INTO letter (module, code, name, title, content) VALUES
5401 ('reserves', 'HOLD_PHONE', 'Item Available for Pick-up (phone notice)', 'Item Available for Pick-up (phone notice)', 'Your item is available for pickup'),
5402 ('circulation', 'PREDUE_PHONE', 'Advance Notice of Item Due (phone notice)', 'Advance Notice of Item Due (phone notice)', 'Your item is due soon'),
5403 ('circulation', 'OVERDUE_PHONE', 'Overdue Notice (phone notice)', 'Overdue Notice (phone notice)', 'Your item is overdue')
5406 # add phone notifications to patron message preferences options
5407 $dbh->do("INSERT INTO message_transports
5408 (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES
5409 (4, 'phone', 0, 'reserves', 'HOLD_PHONE'),
5410 (2, 'phone', 0, 'circulation', 'PREDUE_PHONE')
5413 # add TalkingTechItivaPhoneNotification syspref
5414 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('TalkingTechItivaPhoneNotification',0,'If ON, enables Talking Tech I-tiva phone notifications',NULL,'YesNo');");
5416 print "Upgrade done (Support for Talking Tech i-tiva phone notification system)\n";
5417 SetVersion($DBversion);
5420 $DBversion = "3.09.00.015";
5421 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5423 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('StatisticsFields','location|itype|ccode','Define Fields (from the items table) used for statistics members','location|itype|ccode','free')
5425 print "Upgrade to $DBversion done (Add System preference StatisticsFields)\n";
5426 SetVersion($DBversion);
5429 $DBversion = "3.09.00.016";
5430 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5431 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo')");
5432 print "Upgrade to $DBversion done (Add syspref OPACShowBarcode)\n";
5433 SetVersion ($DBversion);
5436 $DBversion = "3.09.00.017";
5437 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5438 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacNavRight', '', '70|10', 'Show the following HTML in the right hand column of the main page under the main login form', 'Textarea');");
5439 print "Upgrade to $DBversion done (Add customizable OpacNavRight region to the OPAC main page)\n";
5440 SetVersion ($DBversion);
5443 $DBversion = "3.09.00.018";
5444 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5445 $dbh->do("DROP TABLE IF EXISTS aqbudgetborrowers");
5447 CREATE TABLE aqbudgetborrowers (
5448 budget_id int(11) NOT NULL,
5449 borrowernumber int(11) NOT NULL,
5450 PRIMARY KEY (budget_id, borrowernumber),
5451 CONSTRAINT aqbudgetborrowers_ibfk_1 FOREIGN KEY (budget_id)
5452 REFERENCES aqbudgets (budget_id)
5453 ON DELETE CASCADE ON UPDATE CASCADE,
5454 CONSTRAINT aqbudgetborrowers_ibfk_2 FOREIGN KEY (borrowernumber)
5455 REFERENCES borrowers (borrowernumber)
5456 ON DELETE CASCADE ON UPDATE CASCADE
5457 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5460 INSERT INTO permissions (module_bit, code, description)
5461 VALUES (11, 'budget_manage_all', 'Manage all budgets')
5463 print "Upgrade to $DBversion done (Add aqbudgetborrowers table)\n";
5464 SetVersion($DBversion);
5467 $DBversion = "3.09.00.019";
5468 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5469 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo')");
5470 print "Upgrade to $DBversion done (Add OPACShowUnusedAuthorities system preference)\n";
5471 SetVersion ($DBversion);
5474 $DBversion = "3.09.00.020";
5475 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5476 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo')");
5478 CREATE TABLE IF NOT EXISTS borrower_files (
5479 file_id int(11) NOT NULL AUTO_INCREMENT,
5480 borrowernumber int(11) NOT NULL,
5481 file_name varchar(255) NOT NULL,
5482 file_type varchar(255) NOT NULL,
5483 file_description varchar(255) DEFAULT NULL,
5484 file_content longblob NOT NULL,
5485 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5486 PRIMARY KEY (file_id),
5487 KEY borrowernumber (borrowernumber)
5488 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5490 $dbh->do("ALTER TABLE borrower_files ADD CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE");
5492 print "Upgrade to $DBversion done (Added borrow_files table, EnableBorrowerFiles syspref)\n";
5493 SetVersion($DBversion);
5496 $DBversion = "3.09.00.021";
5497 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5498 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');");
5499 print "Upgrade to $DBversion done (Add syspref UpdateTotalIssuesOnCirc)\n";
5500 SetVersion($DBversion);
5503 $DBversion = "3.09.00.022";
5504 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5505 $dbh->do("ALTER TABLE search_history MODIFY COLUMN query_cgi text NOT NULL");
5506 print "Upgrade to $DBversion done (Change search_history.query_cgi type to text. bug 5981)\n";
5507 SetVersion($DBversion);
5510 $DBversion = "3.09.00.023";
5511 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5512 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
5513 print "Upgrade to $DBversion done (Add system preference SearchEngine )\n";
5514 SetVersion($DBversion);
5517 $DBversion ="3.09.00.024";
5518 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5519 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free')");
5520 print "Upgrade to $DBversion done (Add system preference IntranetSlipPrinterJS))\n";
5521 SetVersion($DBversion);
5524 $DBversion = "3.09.00.025";
5525 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5526 $dbh->do('START TRANSACTION');
5527 $dbh->do('CREATE TABLE tmp_reserves AS SELECT * FROM old_reserves LIMIT 0');
5528 $dbh->do('ALTER TABLE tmp_reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5530 INSERT INTO tmp_reserves (
5531 borrowernumber, reservedate, biblionumber,
5532 constrainttype, branchcode, notificationdate,
5533 reminderdate, cancellationdate, reservenotes,
5534 priority, found, timestamp, itemnumber,
5535 waitingdate, expirationdate, lowestPriority,
5536 suspend, suspend_until
5538 borrowernumber, reservedate, biblionumber,
5539 constrainttype, branchcode, notificationdate,
5540 reminderdate, cancellationdate, reservenotes,
5541 priority, found, timestamp, itemnumber,
5542 waitingdate, expirationdate, lowestPriority,
5543 suspend, suspend_until
5544 FROM old_reserves ORDER BY reservedate
5546 $dbh->do('SET @ai = ( SELECT MAX( reserve_id ) FROM tmp_reserves )');
5547 $dbh->do('TRUNCATE old_reserves');
5548 $dbh->do('ALTER TABLE old_reserves ADD reserve_id INT( 11 ) NOT NULL PRIMARY KEY FIRST');
5549 $dbh->do('INSERT INTO old_reserves SELECT * FROM tmp_reserves WHERE reserve_id <= @ai');
5551 INSERT INTO tmp_reserves (
5552 borrowernumber, reservedate, biblionumber,
5553 constrainttype, branchcode, notificationdate,
5554 reminderdate, cancellationdate, reservenotes,
5555 priority, found, timestamp, itemnumber,
5556 waitingdate, expirationdate, lowestPriority,
5557 suspend, suspend_until
5559 borrowernumber, reservedate, biblionumber,
5560 constrainttype, branchcode, notificationdate,
5561 reminderdate, cancellationdate, reservenotes,
5562 priority, found, timestamp, itemnumber,
5563 waitingdate, expirationdate, lowestPriority,
5564 suspend, suspend_until
5565 FROM reserves ORDER BY reservedate
5567 $dbh->do('TRUNCATE reserves');
5568 $dbh->do('ALTER TABLE reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5569 $dbh->do('INSERT INTO reserves SELECT * FROM tmp_reserves WHERE reserve_id > COALESCE(@ai, 0)');
5570 $dbh->do('DROP TABLE tmp_reserves');
5573 my $sth = $dbh->prepare("
5574 SELECT COUNT( * ) AS count
5575 FROM information_schema.COLUMNS
5576 WHERE COLUMN_NAME = 'reserve_id'
5578 TABLE_NAME LIKE 'reserves'
5580 TABLE_NAME LIKE 'old_reserves'
5584 my $row = $sth->fetchrow_hashref();
5585 die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} );
5587 print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n";
5588 SetVersion($DBversion);
5591 $DBversion = "3.09.00.026";
5592 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5593 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
5594 ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'),
5595 ( 3, 'manage_circ_rules', 'manage circulation rules')");
5596 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5597 SELECT borrowernumber, 3, 'parameters_remaining_permissions'
5598 FROM borrowers WHERE flags & (1 << 3)");
5599 # Give new subpermissions to all users that have 'parameters' permission flag (bit 3) set
5600 # see userflags table
5601 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5602 SELECT borrowernumber, 3, 'manage_circ_rules'
5603 FROM borrowers WHERE flags & (1 << 3)");
5604 print "Upgrade to $DBversion done (Added parameters subpermissions)\n";
5605 SetVersion($DBversion);
5608 $DBversion = '3.09.00.027';
5609 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5610 $dbh->do("ALTER TABLE issuingrules ADD overduefinescap decimal(28,6) DEFAULT NULL");
5611 my $maxfine = C4::Context->preference('MaxFine');
5612 if ($maxfine && $maxfine < 900) { # an arbitrary value that tells us it's not "some huge value"
5613 $dbh->do("UPDATE issuingrules SET overduefinescap=?",undef,$maxfine);
5614 $dbh->do("UPDATE systempreferences SET value = NULL WHERE variable = 'MaxFine'");
5616 $dbh->do("UPDATE systempreferences SET explanation = 'Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.' WHERE variable = 'MaxFine'");
5617 print "Upgrade to $DBversion done (Bug 7420 add overduefinescap to circulation matrix)\n";
5618 SetVersion ($DBversion);
5621 $DBversion = "3.09.00.028";
5622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5623 unless ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
5624 my %referencetypes = ( '00' => 'PERSO_NAME',
5625 '10' => 'CORPO_NAME',
5626 '11' => 'MEETI_NAME',
5627 '30' => 'UNIF_TITLE',
5628 '48' => 'CHRON_TERM',
5629 '50' => 'TOPIC_TERM',
5630 '51' => 'GEOGR_NAME',
5631 '55' => 'GENRE/FORM'
5633 my $query = q{SELECT DISTINCT authtypecode, tagfield
5634 FROM auth_subfield_structure
5635 WHERE (tagfield BETWEEN '400' AND '455' OR
5636 tagfield BETWEEN '500' and '555') AND tagsubfield='a' AND
5637 frameworkcode = '' AND ROW(authtypecode, tagfield) NOT IN
5638 (SELECT authtypecode, tagfield FROM auth_subfield_structure
5639 WHERE tagsubfield ='9' )};
5640 $sth = $dbh->prepare($query);
5642 my $sth2 = $dbh->prepare(q{INSERT INTO auth_subfield_structure
5643 (authtypecode, tagfield, tagsubfield, liblibrarian, libopac,
5644 repeatable, mandatory, tab, authorised_value, value_builder,
5645 seealso, isurl, hidden, linkid, kohafield, frameworkcode)
5646 VALUES (?, ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, ?, NULL, NULL,
5647 NULL, 0, 1, '', '', '')});
5648 my $sth3 = $dbh->prepare(q{UPDATE auth_subfield_structure SET
5649 frameworkcode = ? WHERE authtypecode = ? AND
5650 tagfield = ? AND tagsubfield = 'a'});
5651 while (my $row = $sth->fetchrow_arrayref()) {
5652 my ($authtypecode, $field) = @$row;
5653 $sth2->execute($authtypecode, $field, substr($field, 0, 1));
5654 my $authtypemarker = substr $field, 1, 2;
5655 if ($authtypemarker && $referencetypes{$authtypemarker}) {
5656 $sth3->execute($referencetypes{$authtypemarker}, $authtypecode, $field);
5661 print "Upgrade to $DBversion done (Add thesaurus links for MARC21/NORMARC)\n";
5662 SetVersion($DBversion);
5665 $DBversion = "3.09.00.029"; # FIXME
5666 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5667 $dbh->do("UPDATE systempreferences SET options=concat(options,'|EAN13') WHERE variable='itemBarcodeInputFilter' AND options NOT LIKE '%EAN13%'");
5668 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice EAN13)\n";
5670 $dbh->do("UPDATE systempreferences SET options = concat(options,'|EAN13'), explanation = concat(explanation,'; EAN13 - incremental') WHERE variable = 'autoBarcode' AND options NOT LIKE '%EAN13%'");
5671 print "Upgrade to $DBversion done ( Added EAN13 barcode autogeneration sequence )\n";
5672 SetVersion($DBversion);
5675 $DBversion ="3.09.00.030";
5676 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5677 my $query = "SELECT value FROM systempreferences WHERE variable='opacstylesheet'";
5678 my $remote= $dbh->selectrow_arrayref($query);
5679 $dbh->do("DELETE from systempreferences WHERE variable='opacstylesheet'");
5680 if($remote && $remote->[0]) {
5681 $query="UPDATE systempreferences SET value=? WHERE variable='opaclayoutstylesheet'";
5682 $dbh->do($query,undef,$remote->[0]);
5683 print "NOTE: The URL of your remote opac css file has been moved to preference opaclayoutstylesheet.\n";
5685 print "Upgrade to $DBversion done (BZ 8263: Make OPAC stylesheet preferences more consistent)\n";
5686 SetVersion($DBversion);
5689 $DBversion = "3.09.00.031";
5690 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5691 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonReviews'");
5692 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonSimilarItems'");
5693 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSAccessKeyID'");
5694 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSPrivateKey'");
5695 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonReviews'");
5696 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonSimilarItems'");
5697 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonEnabled'");
5698 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonEnabled'");
5699 print "Upgrade to $DBversion done ('Remove preferences controlling broken Amazon features (Bug 8679')\n";
5700 SetVersion ($DBversion);
5703 $DBversion = "3.09.00.032";
5704 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5705 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'defaultSortField' AND value = 'callnumber'");
5706 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'OPACdefaultSortField' AND value = 'callnumber'");
5707 print "Upgrade to $DBversion done (Bug 8657 - Default sort by call number does not work. Correcting system preference value.)\n";
5708 SetVersion ($DBversion);
5712 $DBversion = '3.09.00.033';
5713 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5714 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
5715 print "Upgrade to $DBversion done (Add OpacSuppressionByIPRange syspref)\n";
5716 SetVersion ($DBversion);
5719 $DBversion ="3.09.00.034";
5720 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5721 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'PERSO_NAME' WHERE frameworkcode = 'PERSO_CODE'");
5722 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'CORPO_NAME' WHERE frameworkcode = 'ORGO_CODE'");
5723 print "Upgrade to $DBversion done (Bug 8207: correct typo in authority types)\n";
5724 SetVersion ($DBversion);
5727 $DBversion = "3.09.00.035";
5728 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5730 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PrefillItem','0','When a new item is added, should it be prefilled with last created item values?','','YesNo');
5733 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
5735 print "Upgrade to $DBversion done (Adding PrefillItem and SubfieldsToUseWhenPrefill sysprefs)\n";
5736 SetVersion ($DBversion);
5739 $DBversion = "3.09.00.036";
5740 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5741 # biblioitems changes
5742 $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5743 $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5744 # preferences changes
5745 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|. See: http://wiki.koha-community.org/wiki/Age_restriction',NULL,'free')");
5746 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo')");
5748 print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5749 SetVersion ($DBversion);
5752 $DBversion = "3.09.00.037";
5753 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5754 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('UseTransportCostMatrix',0,'Use Transport Cost Matrix when filling holds','','YesNo')");
5756 $dbh->do("CREATE TABLE `transport_cost` (
5757 `frombranch` varchar(10) NOT NULL,
5758 `tobranch` varchar(10) NOT NULL,
5759 `cost` decimal(6,2) NOT NULL,
5760 `disable_transfer` tinyint(1) NOT NULL DEFAULT 0,
5761 CHECK ( `frombranch` <> `tobranch` ), -- a dud check, mysql does not support that
5762 PRIMARY KEY (`frombranch`, `tobranch`),
5763 CONSTRAINT `transport_cost_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5764 CONSTRAINT `transport_cost_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5765 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5767 print "Upgrade to $DBversion done (creating `transport_cost` table; adding UseTransportCostMatrix systempref, in circulation)\n";
5768 SetVersion($DBversion);
5771 $DBversion ="3.09.00.038";
5772 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5773 $dbh->do("ALTER TABLE borrower_attributes CHANGE attribute attribute VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
5774 print "Upgrade to $DBversion done (Increase the maximum size of a borrower attribute value)\n";
5775 SetVersion($DBversion);
5778 $DBversion ="3.09.00.039";
5779 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5780 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('DidYouMeanFromAuthorities','0','Suggest searches based on authority file.','YesNo');");
5781 print "Upgrade to $DBversion done (Add system preference DidYouMeanFromAuthorities)\n";
5782 SetVersion($DBversion);
5785 $DBversion = "3.09.00.040";
5786 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5787 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');");
5788 print "Upgrade to $DBversion done (Add IncludeSeeFromInSearches system preference)\n";
5789 SetVersion ($DBversion);
5792 $DBversion = "3.09.00.041";
5793 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5795 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportRemoveFields','','List of fields for non export in circulation.pl (separated by a space)','','');
5797 print "Upgrade to $DBversion done (Add system preference ExportRemoveFields)\n";
5798 SetVersion($DBversion);
5801 $DBversion = "3.09.00.042";
5802 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5804 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportWithCsvProfile','','Set a profile name for CSV export','','');
5806 print "Upgrade to $DBversion done (Adds New System preference ExportWithCsvProfile)\n";
5807 SetVersion($DBversion)
5810 $DBversion = "3.09.00.043";
5811 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5813 ALTER TABLE aqorders
5814 ADD parent_ordernumber int(11) DEFAULT NULL
5818 SET parent_ordernumber = ordernumber;
5820 print "Upgrade to $DBversion done (Adding parent_ordernumber in aqorders)\n";
5821 SetVersion($DBversion);
5824 $DBversion = '3.09.00.044';
5825 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5826 $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
5827 $dbh->do("UPDATE statistics SET statistics.ccode = ( SELECT items.ccode FROM items WHERE statistics.itemnumber = items.itemnumber )");
5828 $dbh->do("UPDATE statistics SET statistics.ccode = (
5829 SELECT deleteditems.ccode FROM deleteditems
5830 WHERE statistics.itemnumber = deleteditems.itemnumber
5831 ) WHERE statistics.ccode IS NULL");
5832 print "Upgrade done ( Added Collection Code to Statistics table. )\n";
5833 SetVersion ($DBversion);
5836 $DBversion = "3.09.00.045";
5837 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5838 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 10 ) NULL DEFAULT NULL");
5839 print "Upgrade to $DBversion done. (Bug 8002: Update patron attribute types table from varchar(1) to varchar(10) category_code)\nWarning to Koha System Administrators: If you use borrower attributes defined by borrower categories, you have to check your configuration. A bug may have removed your attribute links to borrower categories.\nPlease check, and fix it if necessary.";
5840 SetVersion($DBversion);
5843 $DBversion = "3.09.00.046";
5844 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5845 $dbh->do("ALTER TABLE `accountlines` ADD `accountlines_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
5846 print "Upgrade to $DBversion done (adding accountlines_id field in accountlines table)\n";
5847 SetVersion($DBversion);
5850 $DBversion = "3.09.00.047";
5851 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5852 # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5853 my $prefvalue = 'anywhere';
5854 if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
5855 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
5857 print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
5858 SetVersion($DBversion);
5861 $DBversion = "3.09.00.048";
5862 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5863 $dbh->do("ALTER TABLE authorised_values MODIFY lib varchar(200)");
5864 $dbh->do("ALTER TABLE authorised_values MODIFY lib_opac varchar(200)");
5866 print "Upgrade to $DBversion done (Raise the length of Authorised Values descriptions)\n";
5867 SetVersion($DBversion);
5870 $DBversion ="3.09.00.049";
5871 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5872 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACMobileUserCSS','','Include the following CSS for the mobile view on all pages in the OPAC:',NULL,'free');");
5873 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacMainUserBlockMobile','','Show the following HTML in its own column on the main page of the OPAC (mobile version):',NULL,'free');");
5874 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowLibrariesPulldownMobile','1','Show the libraries pulldown on the mobile version of the OPAC.',NULL,'YesNo');");
5875 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowFiltersPulldownMobile','1','Show the search filters pulldown on the mobile version of the OPAC.',NULL,'YesNo');");
5876 print "Upgrade to $DBversion done (Add OPACMobileUserCSS, OpacMainUserBlockMobile, OpacShowLibrariesPulldownMobile and OpacShowFiltersPulldownMobile sysprefs)\n";
5877 SetVersion($DBversion);
5880 $DBversion = "3.09.00.050";
5881 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5882 $dbh->do("ALTER TABLE authorised_values MODIFY category varchar(16) NOT NULL DEFAULT '';");
5883 $dbh->do("INSERT INTO authorised_values (category, authorised_value, lib) VALUES
5884 ('REPORT_GROUP', 'CIRC', 'Circulation'),
5885 ('REPORT_GROUP', 'CAT', 'Catalog'),
5886 ('REPORT_GROUP', 'PAT', 'Patrons'),
5887 ('REPORT_GROUP', 'ACQ', 'Acquisitions'),
5888 ('REPORT_GROUP', 'ACC', 'Accounts');");
5890 $dbh->do("ALTER TABLE reports_dictionary ADD report_area varchar(6) DEFAULT NULL;");
5891 $dbh->do("UPDATE reports_dictionary SET report_area = CASE area
5898 $dbh->do("ALTER TABLE reports_dictionary DROP area;");
5899 $dbh->do("ALTER TABLE reports_dictionary ADD KEY dictionary_area_idx (report_area);");
5901 $dbh->do("ALTER TABLE saved_sql ADD report_area varchar(6) DEFAULT NULL;");
5902 $dbh->do("ALTER TABLE saved_sql ADD report_group varchar(80) DEFAULT NULL;");
5903 $dbh->do("ALTER TABLE saved_sql ADD report_subgroup varchar(80) DEFAULT NULL;");
5904 $dbh->do("ALTER TABLE saved_sql ADD KEY sql_area_group_idx (report_group, report_subgroup);");
5906 print "Upgrade to $DBversion done saved_sql new fields report_group and report_area; authorised_values.category 16 char \n";
5907 SetVersion($DBversion);
5910 $DBversion = "3.09.00.051";
5911 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5913 CREATE TABLE aqinvoices (
5914 invoiceid int(11) NOT NULL AUTO_INCREMENT,
5915 invoicenumber mediumtext NOT NULL,
5916 booksellerid int(11) NOT NULL,
5917 shipmentdate date default NULL,
5918 billingdate date default NULL,
5919 closedate date default NULL,
5920 shipmentcost decimal(28,6) default NULL,
5921 shipmentcost_budgetid int(11) default NULL,
5922 PRIMARY KEY (invoiceid),
5923 CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5924 CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5925 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5928 # Fill this new table with existing invoices
5929 my $sth = $dbh->prepare("
5930 SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid, aqorders.datereceived
5932 LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5933 WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5934 AND aqorders.booksellerinvoicenumber != ''
5935 GROUP BY aqorders.booksellerinvoicenumber
5938 my $results = $sth->fetchall_arrayref({});
5939 $sth = $dbh->prepare("
5940 INSERT INTO aqinvoices (invoicenumber, booksellerid, shipmentdate) VALUES (?,?,?)
5942 foreach(@$results) {
5943 $sth->execute($_->{invoicenumber}, $_->{booksellerid}, $_->{datereceived});
5946 # Add the column in aqorders, fill it with correct value
5947 # and then drop booksellerinvoicenumber column
5949 ALTER TABLE aqorders
5950 ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5951 ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5955 UPDATE aqorders, aqinvoices
5956 SET aqorders.invoiceid = aqinvoices.invoiceid
5957 WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5961 ALTER TABLE aqorders
5962 DROP COLUMN booksellerinvoicenumber
5965 print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5966 SetVersion ($DBversion);
5969 $DBversion = "3.09.00.052";
5970 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5971 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHolds', NULL, '', 'Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue', 'YesNo');");
5972 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHoldsValue', NULL, '', 'Specifies a threshold for the minimum number of holds needed to trigger a reduction in loan duration (used with decreaseLoanHighHolds)', 'Integer');");
5973 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('decreaseLoanHighHoldsDuration', NULL, '', 'Specifies a number of days that a loan is reduced to when used in conjunction with decreaseLoanHighHolds', 'Integer');");
5974 print "Upgrade to $DBversion done (Add systempreferences to decrease loan length on high demand items decreaseLoanHighHolds, decreaseLoanHighHoldsValue and decreaseLoanHighHoldsDuration) \n";
5975 SetVersion ($DBversion);
5978 $DBversion = "3.09.00.053";
5979 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5981 q|CREATE TABLE `import_auths` (
5982 import_record_id int(11) NOT NULL,
5983 matched_authid int(11) default NULL,
5984 control_number varchar(25) default NULL,
5985 authorized_heading varchar(128) default NULL,
5986 original_source varchar(25) default NULL,
5987 CONSTRAINT import_auths_ibfk_1 FOREIGN KEY (import_record_id)
5988 REFERENCES import_records (import_record_id) ON DELETE CASCADE ON UPDATE CASCADE,
5989 KEY matched_authid (matched_authid)
5990 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
5992 $dbh->do("ALTER TABLE import_batches
5993 CHANGE COLUMN num_biblios num_records int(11) NOT NULL default 0,
5994 ADD COLUMN record_type enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio'");
5995 $dbh->do("UPDATE import_batches SET record_type='auth' WHERE import_batch_id IN
5996 (SELECT import_batch_id FROM import_records WHERE record_type='auth')");
5998 print "Upgrade to $DBversion done (Added support for staging authorities)\n";
5999 SetVersion ($DBversion);
6002 $DBversion = "3.09.00.054";
6003 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6004 $dbh->do("ALTER TABLE aqorders CHANGE COLUMN gst gstrate DECIMAL(6,4) DEFAULT NULL");
6005 print "Upgrade to $DBversion done (Change column name in aqorders gst --> gstrate)\n";
6006 SetVersion($DBversion);
6009 $DBversion = "3.09.00.055";
6010 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6011 $dbh->do("ALTER TABLE aqorders ADD discount float(6,4) DEFAULT NULL AFTER gstrate");
6012 print "Upgrade to $DBversion done (Add discount field in aqorders table)\n";
6013 SetVersion($DBversion);
6016 $DBversion ="3.09.00.056";
6017 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6018 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('AuthDisplayHierarchy','0','Display authority hierarchies','','YesNo')");
6019 print "Upgrade to $DBversion done (Add system preference AuthDisplayHierarchy)\n";
6020 SetVersion($DBversion);
6023 $DBversion = "3.09.00.057";
6024 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6025 $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL AFTER basketgroupid;");
6026 $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL AFTER deliveryplace;");
6027 print "Upgrade to $DBversion done (Bug 5356: Added billingplace, deliveryplace to the aqbasket table)\n";
6028 SetVersion($DBversion);
6031 $DBversion ="3.09.00.058";
6032 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6033 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidyoumean',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');");
6034 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');");
6035 print "Upgrade to $DBversion done (Add Did You Mean? configuration)\n";
6036 SetVersion($DBversion);
6039 $DBversion ="3.09.00.059";
6040 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6041 $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo');");
6042 print "Upgrade to $DBversion done (Add system preference BlockReturnOfWithdrawnItems)\n";
6043 SetVersion($DBversion);
6046 $DBversion = "3.09.00.060";
6047 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6048 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer')");
6049 print "Upgrade to $DBversion done (Added HoldsToPullStartDate syspref)\n";
6050 SetVersion($DBversion);
6053 $DBversion = "3.09.00.061";
6054 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6055 $dbh->do("UPDATE systempreferences set value=0 WHERE variable='OPACItemsResultsDisplay' AND value='statuses'");
6056 $dbh->do("UPDATE systempreferences set value=1 WHERE variable='OPACItemsResultsDisplay' AND value='itemdetails'");
6057 $dbh->do("UPDATE systempreferences SET explanation='If No, show only the status of items in result list. If Yes, show full location of items (branchlocation+callnumber) as in staff interface',options=NULL,type='YesNo' WHERE variable='OPACItemsResultsDisplay'");
6058 print "Upgrade to $DBversion done (Fixes Bug 5409, Set the syspref value to 1 if it is itemdetails and 0 if it is statuses, leaving it alone if it is already 1 or 0 and change the type of the syspref to YesNo.)\n";
6059 SetVersion ($DBversion);
6062 $DBversion = "3.09.00.062";
6063 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6064 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='NoZebra'");
6065 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='QueryRemoveStopwords'");
6066 print "Upgrade to $DBversion done (Disable obsolete NoZebra and QueryRemoveStopwords sysprefs)\n";
6067 SetVersion ($DBversion);
6070 $DBversion = "3.09.00.063";
6071 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6072 my $gst_booksellers = $dbh->selectcol_arrayref("SELECT DISTINCT(gstrate) FROM aqbooksellers");
6073 my $gist_syspref = C4::Context->preference("gist");
6074 # remove the undef values and construct and array with the syspref and the supplier values
6075 my @gstrates = map { defined $_ ? $_ : () } @$gst_booksellers;
6076 push @gstrates, split ('\|', $gist_syspref);
6077 # we want to compare integer (or float)
6078 $_ = $_ + 0 for @gstrates;
6079 use List::MoreUtils qw/uniq/;
6080 # remove duplicate values
6081 @gstrates = uniq sort @gstrates;
6082 my $new_syspref_value = join '|', @gstrates;
6083 # update the syspref with the new values
6084 my $sth = $dbh->prepare("UPDATE systempreferences set value=? WHERE variable='gist'");
6085 $sth->execute( $new_syspref_value );
6087 print "Upgrade to $DBversion done (Bug 8832, Set the syspref gist with the existing values)\n";
6088 SetVersion ($DBversion);
6091 $DBversion = "3.09.00.064";
6092 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6093 $dbh->do('ALTER TABLE items ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6094 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the items table)\n";
6095 SetVersion ($DBversion);
6098 $DBversion = "3.09.00.065";
6099 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6100 $dbh->do('ALTER TABLE deleteditems ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6101 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the deleteditems table)\n";
6102 SetVersion ($DBversion);
6105 $DBversion = "3.09.00.066";
6106 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6107 $dbh->do("DELETE FROM systempreferences WHERE variable='DidYouMeanFromAuthorities'");
6108 print "Upgrade to $DBversion done (Bug 9107: remove DidYouMeanFromAuthorities syspref)\n";
6109 SetVersion ($DBversion);
6112 $DBversion = "3.09.00.067";
6113 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6114 $dbh->do("ALTER TABLE statistics CHANGE COLUMN ccode ccode varchar(10) NULL");
6115 print "Upgrade to $DBversion done (Bug 9064: statistics.ccode potentially wrongly defined)\n";
6116 SetVersion ($DBversion);
6119 $DBversion = "3.10.00.00";
6120 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6121 print "Upgrade to $DBversion done (release tag)\n";
6122 SetVersion ($DBversion);
6125 $DBversion = "3.11.00.001";
6126 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6127 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet that can be expanded into browse links, e.g. on Home > Patrons',NULL,'free')");
6128 print "Upgrade to $DBversion done (Bug 2832 - Add alphabet syspref)\n";
6131 $DBversion = "3.11.00.002";
6132 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6134 DELETE from aqorders_items where ordernumber NOT IN (SELECT ordernumber FROM aqorders);
6137 ALTER TABLE aqorders_items
6138 ADD CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber)
6139 ON DELETE CASCADE ON UPDATE CASCADE;
6141 print "Upgrade to $DBversion done (Bug 9030: Add constraint on aqorders_items.ordernumber)\n";
6142 SetVersion ($DBversion);
6145 $DBversion = "3.11.00.003";
6146 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6147 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RefundLostItemFeeOnReturn', '1', 'If enabled, the lost item fee charged to a borrower will be refunded when the lost item is returned.', NULL, 'YesNo')");
6148 print "Upgrade to $DBversion done (Bug 7189: Add system preference RefundLostItemFeeOnReturn)\n";
6149 SetVersion($DBversion);
6152 $DBversion = "3.11.00.004";
6153 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6155 ALTER TABLE subscription ADD COLUMN closed INT(1) NOT NULL DEFAULT 0 AFTER enddate;
6158 print "Upgrade to $DBversion done (Bug 8782: Add field subscription.closed)\n";
6159 SetVersion($DBversion);
6162 $DBversion = "3.11.00.005";
6163 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6164 $dbh->do(qq{CREATE TABLE borrower_attribute_types_branches(bat_code VARCHAR(10), b_branchcode VARCHAR(10),FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
6166 $dbh->do(qq{CREATE TABLE categories_branches(categorycode VARCHAR(10), branchcode VARCHAR(10), FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE, FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
6168 $dbh->do(qq{CREATE TABLE authorised_values_branches(av_id INTEGER, branchcode VARCHAR(10), FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE, FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
6170 print "Upgrade to $DBversion done (Bug 7919: Display of values depending on the connexion library)\n";
6171 SetVersion($DBversion);
6174 $DBversion = "3.11.00.006";
6175 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6177 UPDATE virtualshelves SET sortfield="copyrightdate" where sortfield="year";
6179 print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
6180 SetVersion($DBversion);
6183 $DBversion = "3.11.00.007";
6184 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6185 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ar', 'language', 'de', 'Arabisch')");
6186 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hy', 'language', 'de', 'Armenisch')");
6187 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'bg', 'language', 'de', 'Bulgarisch')");
6188 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'zh', 'language', 'de', 'Chinesisch')");
6189 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'cs', 'language', 'de', 'Tschechisch')");
6190 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'da', 'language', 'de', 'Dänisch')");
6191 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nl', 'language', 'de', 'Niederländisch')");
6192 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'en', 'language', 'de', 'Englisch')");
6193 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fi', 'language', 'de', 'Finnisch')");
6194 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fr', 'language', 'de', 'Französisch')");
6195 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'fr', 'Laotien')");
6196 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'de', 'Laotisch')");
6197 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'el', 'language', 'de', 'Griechisch (Nach 1453)')");
6198 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'he', 'language', 'de', 'Hebräisch')");
6199 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hi', 'language', 'de', 'Hindi')");
6200 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hu', 'language', 'de', 'Ungarisch')");
6201 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'id', 'language', 'de', 'Indonesisch')");
6202 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'it', 'language', 'de', 'Italienisch')");
6203 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ja', 'language', 'de', 'Japanisch')");
6204 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ko', 'language', 'de', 'Koreanisch')");
6205 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'la', 'language', 'de', 'Latein')");
6206 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'fr', 'Galicien')");
6207 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'de', 'Galizisch')");
6208 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nb', 'language', 'de', 'Norwegisch bokmål')");
6209 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nn', 'language', 'de', 'Norwegisch nynorsk')");
6210 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fa', 'language', 'de', 'Persisch')");
6211 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pl', 'language', 'de', 'Polnisch')");
6212 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pt', 'language', 'de', 'Portugiesisch')");
6213 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ro', 'language', 'de', 'Rumänisch')");
6214 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ru', 'language', 'de', 'Russisch')");
6215 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'fr', 'Serbe')");
6216 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'de', 'Serbisch')");
6217 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'es', 'language', 'de', 'Spanisch')");
6218 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sv', 'language', 'de', 'Schwedisch')");
6219 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'fr', 'Tétoum')");
6220 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'de', 'Tetum')");
6221 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'th', 'language', 'de', 'Thailändisch')");
6222 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tr', 'language', 'de', 'Türkisch')");
6223 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'uk', 'language', 'de', 'Ukrainisch')");
6224 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'fr', 'Ourdou')");
6225 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'de', 'Urdu')");
6226 print "Upgrade to $DBversion done (Bug 9056: add German and a couple of French translations to language_descriptions)\n";
6227 SetVersion ($DBversion);
6230 $DBversion = "3.11.00.008";
6231 if (CheckVersion($DBversion)) {
6233 CREATE TABLE IF NOT EXISTS `borrower_modifications` (
6234 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6235 `verification_token` varchar(255) NOT NULL DEFAULT '',
6236 `borrowernumber` int(11) NOT NULL DEFAULT '0',
6237 `cardnumber` varchar(16) DEFAULT NULL,
6238 `surname` mediumtext,
6241 `othernames` mediumtext,
6243 `streetnumber` varchar(10) DEFAULT NULL,
6244 `streettype` varchar(50) DEFAULT NULL,
6245 `address` mediumtext,
6249 `zipcode` varchar(25) DEFAULT NULL,
6253 `mobile` varchar(50) DEFAULT NULL,
6257 `B_streetnumber` varchar(10) DEFAULT NULL,
6258 `B_streettype` varchar(50) DEFAULT NULL,
6259 `B_address` varchar(100) DEFAULT NULL,
6261 `B_city` mediumtext,
6263 `B_zipcode` varchar(25) DEFAULT NULL,
6266 `B_phone` mediumtext,
6267 `dateofbirth` date DEFAULT NULL,
6268 `branchcode` varchar(10) DEFAULT NULL,
6269 `categorycode` varchar(10) DEFAULT NULL,
6270 `dateenrolled` date DEFAULT NULL,
6271 `dateexpiry` date DEFAULT NULL,
6272 `gonenoaddress` tinyint(1) DEFAULT NULL,
6273 `lost` tinyint(1) DEFAULT NULL,
6274 `debarred` date DEFAULT NULL,
6275 `debarredcomment` varchar(255) DEFAULT NULL,
6276 `contactname` mediumtext,
6277 `contactfirstname` text,
6278 `contacttitle` text,
6279 `guarantorid` int(11) DEFAULT NULL,
6280 `borrowernotes` mediumtext,
6281 `relationship` varchar(100) DEFAULT NULL,
6282 `ethnicity` varchar(50) DEFAULT NULL,
6283 `ethnotes` varchar(255) DEFAULT NULL,
6284 `sex` varchar(1) DEFAULT NULL,
6285 `password` varchar(30) DEFAULT NULL,
6286 `flags` int(11) DEFAULT NULL,
6287 `userid` varchar(75) DEFAULT NULL,
6288 `opacnote` mediumtext,
6289 `contactnote` varchar(255) DEFAULT NULL,
6290 `sort1` varchar(80) DEFAULT NULL,
6291 `sort2` varchar(80) DEFAULT NULL,
6292 `altcontactfirstname` varchar(255) DEFAULT NULL,
6293 `altcontactsurname` varchar(255) DEFAULT NULL,
6294 `altcontactaddress1` varchar(255) DEFAULT NULL,
6295 `altcontactaddress2` varchar(255) DEFAULT NULL,
6296 `altcontactaddress3` varchar(255) DEFAULT NULL,
6297 `altcontactstate` text,
6298 `altcontactzipcode` varchar(50) DEFAULT NULL,
6299 `altcontactcountry` text,
6300 `altcontactphone` varchar(50) DEFAULT NULL,
6301 `smsalertnumber` varchar(50) DEFAULT NULL,
6302 `privacy` int(11) DEFAULT NULL,
6303 PRIMARY KEY (`verification_token`,`borrowernumber`),
6304 KEY `verification_token` (`verification_token`),
6305 KEY `borrowernumber` (`borrowernumber`)
6306 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6310 INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
6311 ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'),
6312 ('PatronSelfRegistrationVerifyByEmail', '0', NULL, 'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.', 'YesNo'),
6313 ('PatronSelfRegistrationDefaultCategory', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'),
6314 ('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'),
6315 ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'),
6316 ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free');
6320 INSERT INTO letter ( `module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content` )
6321 VALUES ( 'members', 'OPAC_REG_VERIFY', '', 'Opac Self-Registration Verification Email', '1', 'Verify Your Account', 'Hello!
6323 Your library account has been created. Please verify your email address by clicking this link to complete the signup process:
6325 http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>>
6327 If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
6330 print "Upgrade to $DBversion done (Bug 7067: Add Patron Self Registration)\n";
6331 SetVersion ($DBversion);
6334 $DBversion = "3.11.00.009";
6335 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6337 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
6338 ('SeparateHoldings', '0', 'Separate current branch holdings from other holdings', NULL, 'YesNo'),
6339 ('SeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings', 'homebranch|holdingbranch', 'Choice'),
6340 ('OpacSeparateHoldings', '0', 'Separate current branch holdings from other holdings (OPAC)', NULL, 'YesNo'),
6341 ('OpacSeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings (OPAC)', 'homebranch|holdingbranch', 'Choice')
6344 print "Upgrade to $DBversion done (Bug 7674: Add systempreferences SeparateHoldings, SeparateHoldingsBranch, OpacSeparateHoldings and OpacSeparateHoldingsBranch) \n";
6345 SetVersion ($DBversion);
6348 $DBversion = "3.11.00.010";
6349 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6350 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('RenewalSendNotice', '0', '', NULL, 'YesNo')");
6352 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
6353 ('circulation','RENEWAL','Item Renewals','Item Renewals','The following items have been renewed:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you for visiting <<branches.branchname>>.');
6355 print "Upgrade to $DBversion done (Bug 9151 - Renewal notice according to patron alert preferences)\n";
6356 SetVersion($DBversion);
6359 $DBversion = "3.11.00.011";
6360 if ( CheckVersion($DBversion) ) {
6361 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaEnabled','not','Show a HTML5 media player in a tab on opac-detail.pl for media files catalogued in field 856.','not|opac|staff|both','Choice');");
6362 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','Media file extensions','','free');");
6363 print "Upgrade to $DBversion done (Bug 8377: Add HTML5MediaEnabled and HTML5MediaExtensions sysprefs)\n";
6364 SetVersion ($DBversion);
6367 $DBversion = "3.11.00.012";
6368 if ( CheckVersion($DBversion) ) {
6369 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldsOnPatronsPossessions', '1', 'Allow holds on records that patron have items of it',NULL,'YesNo')");
6370 print "Upgrade to $DBversion done (Bug 9206: Only allow place holds in records that the patron don't have in his possession)\n";
6371 SetVersion($DBversion);
6374 $DBversion = "3.11.00.013";
6375 if ( CheckVersion($DBversion) ) {
6376 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free')");
6377 print "Upgrade to $DBversion done (Bug 9162 - Add a system preference to set which notes fields appears on title notes/description separator)\n";
6378 SetVersion($DBversion);
6381 $DBversion = "3.11.00.014";
6382 if ( CheckVersion($DBversion) ) {
6383 $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserCSS', '', 'Add CSS to be included in the SCO module in an embedded <style> tag.', 'free' )");
6384 $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserJS', '', 'Define custom javascript for inclusion in the SCO module', 'free' )");
6385 print "Upgrade to $DBversion done (Bug 9009: Add SCOUserCSS and SCOUserJS sysprefs)\n";
6388 $DBversion = "3.11.00.015";
6389 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6390 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissuesCharge', '1', 'Rental charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6391 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissuesCharge', '1', 'MANUAL_INV charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6392 print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissuesCharge and ManInvInNoissuesCharge.)\n";
6393 SetVersion($DBversion);
6396 $DBversion = "3.11.00.016";
6397 if ( CheckVersion($DBversion) ) {
6399 UPDATE userflags SET flagdesc="<b>Required for staff login.</b> Staff access, allows viewing of catalogue in staff client." where flagdesc="Modify login / permissions for staff users";
6402 UPDATE userflags SET flagdesc="Edit Authorities" where flagdesc="Allow to edit authorities";
6405 UPDATE userflags SET flagdesc="Allow access to the reports module" where flagdesc="Allow to access to the reports module";
6408 UPDATE userflags SET flagdesc="Set library management parameters (deprecated)" where flagdesc="Set library management parameters";
6411 UPDATE userflags SET flagdesc="Manage serial subscriptions" where flagdesc="Allow to manage serials subscriptions";
6414 UPDATE userflags SET flagdesc="Manage patrons fines and fees" where flagdesc="Update borrower charges";
6417 UPDATE userflags SET flagdesc="Check out and check in items" where flagdesc="Circulate books";
6420 UPDATE userflags SET flagdesc="Manage Koha system settings (Administration panel)" where flagdesc="Set Koha system parameters";
6423 UPDATE userflags SET flagdesc="Add or modify patrons" where flagdesc="Add or modify borrowers";
6426 UPDATE userflags SET flagdesc="Use all tools (expand for granular tools permissions)" where flagdesc="Use tools (export, import, barcodes)";
6429 UPDATE userflags SET flagdesc="Allow staff members to modify permissions for other staff members" where flagdesc="Set user permissions";
6432 UPDATE permissions SET description="Perform batch modification of patrons" where description="Perform batch modifivation of patrons";
6435 print "Upgrade to $DBversion done (Bug 9382 (updated with bug 9745) - refresh permission descriptions to make more sense)\n";
6436 SetVersion ($DBversion);
6439 $DBversion ="3.11.00.017";
6440 if ( CheckVersion($DBversion) ) {
6441 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');");
6442 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');");
6443 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');");
6444 print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n";
6445 SetVersion($DBversion);
6448 $DBversion = "3.11.00.018";
6449 if ( CheckVersion($DBversion) ) {
6450 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number OPAC searches', 'YesNo')");
6451 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo')");
6452 print "Upgrade to $DBversion done (Bug 9395: Problem with callnumber and standard number search in OPAC and Staff Client)\n";
6453 SetVersion ($DBversion);
6456 $DBversion = "3.11.00.019";
6457 if ( CheckVersion($DBversion) ) {
6458 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorityField100', 'afrey50 ba0', NULL, NULL, 'Textarea')");
6459 print "Upgrade to $DBversion done (Bug 9145 - Add syspref UNIMARCAuthorityField100)\n";
6460 SetVersion ($DBversion);
6463 $DBversion = "3.11.00.020";
6464 if ( CheckVersion($DBversion) ) {
6465 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')");
6466 print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n";
6467 SetVersion($DBversion);
6470 $DBversion ="3.11.00.021";
6471 if ( CheckVersion($DBversion) ) {
6472 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACPopupAuthorsSearch','0','Display the list of authors when clicking on one author.','','YesNo');");
6473 print "Upgrade to $DBversion done (Bug 5888 - Subject search pop-up for the OPAC)\n";
6474 SetVersion($DBversion);
6477 $DBversion = "3.11.00.022";
6478 if ( CheckVersion($DBversion) ) {
6480 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('Persona',0,'Use Mozilla Persona for login','','YesNo')"
6482 print "Upgrade to $DBversion done (Bug 9587 - Allow login via Persona)\n";
6483 SetVersion($DBversion);
6486 $DBversion = "3.11.00.023";
6487 if ( CheckVersion($DBversion) ) {
6488 $dbh->do("UPDATE z3950servers SET host = 'lx2.loc.gov', port = 210, db = 'LCDB', syntax = 'USMARC', encoding = 'utf8' WHERE name = 'LIBRARY OF CONGRESS'");
6489 print "Upgrade to $DBversion done (Bug 9520 - Update default LOC Z39.50 target)\n";
6490 SetVersion($DBversion);
6493 $DBversion = "3.11.00.024";
6494 if ( CheckVersion($DBversion) ) {
6495 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacItemLocation','callnum','Show the shelving location of items in the opac','callnum|ccode|location','Choice');");
6496 print "Upgrade to $DBversion done (Bug 5079: Add OpacItemLocation syspref)\n";
6497 SetVersion ($DBversion);
6500 $DBversion = "3.11.00.025";
6501 if ( CheckVersion($DBversion) ) {
6503 "CREATE TABLE linktracker (
6504 id int(11) NOT NULL AUTO_INCREMENT,
6505 biblionumber int(11) DEFAULT NULL,
6506 itemnumber int(11) DEFAULT NULL,
6507 borrowernumber int(11) DEFAULT NULL,
6509 timeclicked datetime DEFAULT NULL,
6511 KEY bibidx (biblionumber),
6512 KEY itemidx (itemnumber),
6513 KEY borridx (borrowernumber),
6514 KEY dateidx (timeclicked)
6515 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
6518 INSERT INTO systempreferences (variable,value,explanation,options,type)
6519 VALUES('TrackClicks','0','Track links clicked',NULL,'Integer')" );
6521 "Upgrade to $DBversion done (Adds feature Bug 8917, the ability to track links clicked)\n";
6522 SetVersion($DBversion);
6525 $DBversion = "3.11.00.026";
6526 if ( CheckVersion($DBversion) ) {
6528 ALTER TABLE import_records ADD INDEX batch_id_record_type ( import_batch_id, record_type );
6530 print "Upgrade to $DBversion done (Bug 9207: Add new index batch_id_record_type to import_records)\n";
6531 SetVersion($DBversion);
6534 $DBversion = "3.11.00.027";
6535 if ( CheckVersion($DBversion) ) {
6537 INSERT INTO permissions ( module_bit, code, description )
6538 VALUES ( '1', 'overdues_report', 'Execute overdue items report' )
6540 # add new permission for users with all report permissions and circulation remaining permission
6542 INSERT INTO user_permissions (borrowernumber, module_bit, code)
6543 SELECT user_permissions.borrowernumber, 1, 'overdues_report'
6544 FROM user_permissions
6545 LEFT JOIN borrowers USING(borrowernumber)
6546 WHERE borrowers.flags & (1 << 16)
6547 AND user_permissions.code = 'circulate_remaining_permissions'
6549 print "Upgrade to $DBversion done ( Add circ permission overdues_report )\n";
6550 SetVersion($DBversion);
6553 $DBversion = "3.11.00.028";
6554 if ( CheckVersion($DBversion) ) {
6555 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('PatronSelfRegistrationAdditionalInstructions', '', NULL , 'A free text field to display additional instructions to newly self registered patrons.', 'free' );");
6556 print "Upgrade to $DBversion done (Bug 9756 - Patron self registration missing the system preference PatronSelfRegistrationAdditionalInstructions)\n";
6557 SetVersion($DBversion);
6560 $DBversion = "3.11.00.029";
6561 if (CheckVersion($DBversion)) {
6562 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo')");
6563 print "Upgrade to $DBversion done (Bug 9239: Make it possible for Koha to use QueryParser)\n";
6564 SetVersion ($DBversion);
6567 $DBversion = "3.11.00.030";
6568 if ( CheckVersion($DBversion) ) {
6569 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');");
6570 print "Upgrade to $DBversion done (Add system preference FinesIncludeGracePeriod)\n";
6571 SetVersion($DBversion);
6574 $DBversion = "3.11.00.100";
6575 if ( CheckVersion($DBversion) ) {
6576 print "Upgrade to $DBversion done (3.12-alpha release)\n";
6577 SetVersion ($DBversion);
6580 $DBversion = "3.11.00.101";
6581 if ( CheckVersion($DBversion) ) {
6582 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short')");
6583 print "Upgrade to $DBversion done (Bug 9341: Problem with UNIMARC authors facets)\n";
6584 SetVersion ($DBversion);
6587 $DBversion = "3.11.00.102";
6588 if ( CheckVersion($DBversion) ) {
6590 DELETE FROM systempreferences WHERE variable='NoZebra'
6593 DELETE FROM systempreferences WHERE variable='QueryRemoveStopwords'
6595 print "Upgrade to $DBversion done (Remove deprecated NoZebra and QueryRemoveStopwords sysprefs)\n";
6596 SetVersion($DBversion);
6599 $DBversion = "3.11.00.103";
6600 if ( CheckVersion($DBversion) ) {
6601 $dbh->do("DELETE FROM systempreferences WHERE variable = 'insecure';");
6602 print "Upgrade to $DBversion done (Bug 9827 - Remove 'insecure' system preference)\n";
6603 SetVersion($DBversion);
6606 $DBversion = "3.11.00.104";
6607 if ( CheckVersion($DBversion) ) {
6608 print "Upgrade to $DBversion done (3.12-alpha2 release)\n";
6609 SetVersion ($DBversion);
6612 $DBversion = "3.11.00.105";
6613 if ( CheckVersion($DBversion) ) {
6614 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
6615 $sth = $dbh->prepare(
6616 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '029'"
6619 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6621 for my $frameworkcode ( keys %$frameworkcodes ) {
6623 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6624 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6625 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6626 ('029', 'a', 'OCLC library identifier', 'OCLC library identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6627 ('029', 'b', 'System control number', 'System control number', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6628 ('029', 'c', 'OAI set name', 'OAI set name', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6629 ('029', 't', 'Content type identifier', 'Content type identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL)
6633 for my $tag ( '863', '864', '865' ) {
6634 $sth = $dbh->prepare(
6635 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '$tag'"
6638 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6640 for my $frameworkcode ( keys %$frameworkcodes ) {
6642 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6643 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6644 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6645 ('$tag', '6', 'Linkage', 'Linkage', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6646 ('$tag', '8', 'Field link and sequence number', 'Field link and sequence number', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6647 ('$tag', 'a', 'First level of enumeration', 'First level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6648 ('$tag', 'b', 'Second level of enumeration', 'Second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6649 ('$tag', 'c', 'Third level of enumeration', 'Third level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6650 ('$tag', 'd', 'Fourth level of enumeration', 'Fourth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6651 ('$tag', 'e', 'Fifth level of enumeration', 'Fifth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6652 ('$tag', 'f', 'Sixth level of enumeration', 'Sixth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6653 ('$tag', 'g', 'Alternative numbering scheme, first level of enumeration', 'Alternative numbering scheme, first level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6654 ('$tag', 'h', 'Alternative numbering scheme, second level of enumeration', 'Alternative numbering scheme, second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6655 ('$tag', 'i', 'First level of chronology', 'First level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6656 ('$tag', 'j', 'Second level of chronology', 'Second level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6657 ('$tag', 'k', 'Third level of chronology', 'Third level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6658 ('$tag', 'l', 'Fourth level of chronology', 'Fourth level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6659 ('$tag', 'm', 'Alternative numbering scheme, chronology', 'Alternative numbering scheme, chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6660 ('$tag', 'n', 'Converted Gregorian year', 'Converted Gregorian year', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6661 ('$tag', 'o', 'Type of unit', 'Type of unit', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6662 ('$tag', 'p', 'Piece designation', 'Piece designation', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6663 ('$tag', 'q', 'Piece physical condition', 'Piece physical condition', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6664 ('$tag', 's', 'Copyright article-fee code', 'Copyright article-fee code', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6665 ('$tag', 't', 'Copy number', 'Copy number', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6666 ('$tag', 'v', 'Issuing date', 'Issuing date', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6667 ('$tag', 'w', 'Break indicator', 'Break indicator', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6668 ('$tag', 'x', 'Nonpublic note', 'Nonpublic note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6669 ('$tag', 'z', 'Public note', 'Public note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL)
6674 print "Upgrade to $DBversion done (Bug 9353: Missing subfields on MARC21 frameworks)\n";
6675 SetVersion($DBversion);
6679 $DBversion = "3.11.00.106";
6680 if ( CheckVersion($DBversion) ) {
6681 $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('19', 'plugins', 'Koha plugins', '0')");
6682 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
6683 ('19', 'manage', 'Manage plugins ( install / uninstall )'),
6684 ('19', 'tool', 'Use tool plugins'),
6685 ('19', 'report', 'Use report plugins'),
6686 ('19', 'configure', 'Configure plugins')
6688 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','0','Enable or disable the ability to use Koha Plugins.','','YesNo')");
6691 CREATE TABLE IF NOT EXISTS plugin_data (
6692 plugin_class varchar(255) NOT NULL,
6693 plugin_key varchar(255) NOT NULL,
6695 PRIMARY KEY (plugin_class,plugin_key)
6696 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6699 print "Upgrade to $DBversion done (Bug 7804: Added plugin system.)\n";
6700 SetVersion($DBversion);
6703 $DBversion = "3.11.00.107";
6704 if ( CheckVersion($DBversion) ) {
6705 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice')");
6706 print "Upgrade to $DBversion done (Bug 9014: Add syspref TimeFormat)\n";
6707 SetVersion ($DBversion);
6710 $DBversion = "3.11.00.108";
6711 if ( CheckVersion($DBversion) ) {
6712 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
6713 $dbh->do("UPDATE action_logs SET info=(SELECT itemnumber FROM items WHERE biblionumber= action_logs.info LIMIT 1) WHERE module='CIRCULATION' AND action in ('ISSUE','RETURN');");
6714 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;");
6715 print "Upgrade to $DBversion done (Bug 7241: Fix on circulation logs)\n";
6716 print "WARNING about bug 7241: to partially correct the broken logs, the log history is filled with the first found item for each biblio.\n";
6717 SetVersion($DBversion);
6720 $DBversion = "3.11.00.109";
6721 if ( CheckVersion($DBversion) ) {
6722 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('DisplayIconsXSLT', '1', '', 'If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.', 'YesNo');");
6723 print "Upgrade to $DBversion done (Bug 9403: Add DisplayIconsXSLT)\n";
6724 SetVersion ($DBversion);
6727 $DBversion = "3.11.00.110";
6728 if ( CheckVersion($DBversion) ) {
6729 $dbh->do("ALTER TABLE pending_offline_operations CHANGE barcode barcode VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
6730 $dbh->do("ALTER TABLE pending_offline_operations ADD amount DECIMAL( 28, 6 ) NULL DEFAULT NULL");
6731 print "Upgrade to $DBversion done (Bug 8220 - Allow koc uploads to go to process queue)\n";
6732 SetVersion ($DBversion);
6735 $DBversion = "3.11.00.111";
6736 if ( CheckVersion($DBversion) ) {
6737 my $sth = $dbh->prepare("
6738 SELECT module, code, branchcode, content
6740 WHERE content LIKE '%<fine>%'
6743 my $sth_update = $dbh->prepare("UPDATE letter SET content = ? WHERE module = ? AND code = ? AND branchcode = ?");
6744 while(my $row = $sth->fetchrow_hashref){
6745 $row->{content} =~ s/<fine>\w+<\/fine>/<<items.fine>>/;
6746 $sth_update->execute($row->{content}, $row->{module}, $row->{code}, $row->{branchcode});
6748 print "Upgrade to $DBversion done (use new <<items.fine>> syntax in notices)\n";
6749 SetVersion($DBversion);
6752 $DBversion = "3.11.00.112";
6753 if ( CheckVersion($DBversion) ) {
6755 ALTER TABLE issuingrules ADD COLUMN renewalperiod int(4) DEFAULT NULL AFTER renewalsallowed
6758 UPDATE issuingrules SET renewalperiod = issuelength
6760 print "Upgrade to $DBversion done (Bug 8365: Add colum issuingrules.renewalperiod)\n";
6761 SetVersion ($DBversion);
6764 $DBversion = "3.11.00.113";
6765 if ( CheckVersion($DBversion) ) {
6767 ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6768 ADD INDEX ( show_in_pulldown )
6770 print "Upgrade to $DBversion done (Bug 9257 - Add groups to normal search pulldown)\n";
6771 SetVersion ($DBversion);
6774 $DBversion = "3.11.00.115";
6775 if ( CheckVersion($DBversion) ) {
6776 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo')");
6777 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice')");
6778 print "Upgrade to $DBversion done (Bug 7740: Add syspref HighlightOwnItemsOnOPAC)\n";
6779 SetVersion ($DBversion);
6782 $DBversion = "3.11.00.116";
6783 if ( CheckVersion($DBversion) ) {
6784 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN serialid;});
6785 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN subscription;});
6786 $dbh->do(q{ALTER TABLE aqorders ADD COLUMN subscriptionid INT(11) DEFAULT NULL;});
6787 $dbh->do(q{ALTER TABLE aqorders ADD CONSTRAINT aqorders_subscriptionid FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE;});
6788 $dbh->do(q{ALTER TABLE subscription ADD COLUMN reneweddate DATE DEFAULT NULL;});
6789 print "Upgrade to $DBversion done (Bug 5343: table aqorders: DROP serialid and subscription fields and ADD subscriptionid, table subscription: ADD reneweddate)\n";
6790 SetVersion ($DBversion);
6793 $DBversion = "3.11.00.200";
6794 if ( CheckVersion($DBversion) ) {
6795 print "Upgrade to $DBversion done (3.12-beta1 release)\n";
6796 SetVersion ($DBversion);
6799 $DBversion = "3.11.00.201";
6800 if ( CheckVersion($DBversion) ) {
6801 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'BIBSYS' AND host LIKE 'z3950.bibsys.no'");
6802 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'NORBOK' AND host LIKE 'z3950.nb.no'");
6803 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'SAMBOK' AND host LIKE 'z3950.nb.no'");
6804 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'DEICHMAN' AND host like 'z3950.deich.folkebibl.no'");
6805 print "Upgrade to $DBversion done (Bug 9498 - Update encoding for Norwegian sample Z39.50 servers)\n";
6806 SetVersion($DBversion);
6809 $DBversion = "3.11.00.202";
6810 if ( CheckVersion($DBversion) ) {
6811 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ca', 'language', 'Catalan','2013-01-12' )");
6812 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ca','cat')");
6813 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'es', 'Catalán')");
6814 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'en', 'Catalan')");
6815 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'fr', 'Catalan')");
6816 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'ca', 'Català')");
6817 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'de', 'Katalanisch')");
6818 print "Upgrade to $DBversion done (Bug 9381: Add Catalan laguage)\n";
6819 SetVersion ($DBversion);
6822 $DBversion = "3.11.00.203";
6823 if ( CheckVersion($DBversion) ) {
6824 $dbh->do(q{ALTER TABLE suggestions CHANGE COLUMN title title VARCHAR(255) DEFAULT NULL;});
6825 print "Upgrade to $DBversion done (Bug 2046 - increasing title column length for suggestions)\n";
6826 SetVersion ($DBversion);
6829 $DBversion = "3.11.00.300";
6830 if ( CheckVersion($DBversion) ) {
6831 print "Upgrade to $DBversion done (3.12-beta3 release)\n";
6832 SetVersion ($DBversion);
6835 $DBversion = "3.11.00.301";
6836 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6839 ALTER TABLE `issues`
6840 ADD KEY `itemnumber_idx` (`itemnumber`),
6841 ADD KEY `branchcode_idx` (`branchcode`),
6842 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6845 ALTER TABLE `old_issues`
6846 ADD KEY `branchcode_idx` (`branchcode`),
6847 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6851 ALTER TABLE `items` ADD KEY `itype_idx` (`itype`)
6854 ALTER TABLE `deleteditems` ADD KEY `itype_idx` (`itype`)
6858 ALTER TABLE `biblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6861 ALTER TABLE `deletedbiblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6865 ALTER TABLE `statistics`
6866 ADD KEY `branch_idx` (`branch`),
6867 ADD KEY `proccode_idx` (`proccode`),
6868 ADD KEY `type_idx` (`type`),
6869 ADD KEY `usercode_idx` (`usercode`),
6870 ADD KEY `itemnumber_idx` (`itemnumber`),
6871 ADD KEY `itemtype_idx` (`itemtype`),
6872 ADD KEY `borrowernumber_idx` (`borrowernumber`),
6873 ADD KEY `associatedborrower_idx` (`associatedborrower`),
6874 ADD KEY `ccode_idx` (`ccode`)
6877 print "Upgrade to $DBversion done (Bug 9681: Add some database indexes)\n";
6878 SetVersion($DBversion);
6881 $DBversion = "3.12.00.000";
6882 if ( CheckVersion($DBversion) ) {
6883 print "Upgrade to $DBversion done (3.12.0 release)\n";
6884 SetVersion ($DBversion);
6887 $DBversion = '3.13.00.000';
6888 if ( CheckVersion($DBversion) ) {
6889 print "Upgrade to $DBversion done (start the journey to Koha Pi)\n";
6890 SetVersion ($DBversion);
6893 $DBversion = "3.13.00.001";
6894 if ( CheckVersion($DBversion) ) {
6895 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
6896 $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
6898 CREATE TABLE `courses` (
6899 `course_id` int(11) NOT NULL AUTO_INCREMENT,
6900 `department` varchar(20) DEFAULT NULL,
6901 `course_number` varchar(255) DEFAULT NULL,
6902 `section` varchar(255) DEFAULT NULL,
6903 `course_name` varchar(255) DEFAULT NULL,
6904 `term` varchar(20) DEFAULT NULL,
6905 `staff_note` mediumtext,
6906 `public_note` mediumtext,
6907 `students_count` varchar(20) DEFAULT NULL,
6908 `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
6909 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6910 PRIMARY KEY (`course_id`)
6911 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6915 CREATE TABLE `course_instructors` (
6916 `course_id` int(11) NOT NULL,
6917 `borrowernumber` int(11) NOT NULL,
6918 PRIMARY KEY (`course_id`,`borrowernumber`),
6919 KEY `borrowernumber` (`borrowernumber`)
6920 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6924 ALTER TABLE `course_instructors`
6925 ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
6926 ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6930 CREATE TABLE `course_items` (
6931 `ci_id` int(11) NOT NULL AUTO_INCREMENT,
6932 `itemnumber` int(11) NOT NULL,
6933 `itype` varchar(10) DEFAULT NULL,
6934 `ccode` varchar(10) DEFAULT NULL,
6935 `holdingbranch` varchar(10) DEFAULT NULL,
6936 `location` varchar(80) DEFAULT NULL,
6937 `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
6938 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6939 PRIMARY KEY (`ci_id`),
6940 UNIQUE KEY `itemnumber` (`itemnumber`),
6941 KEY `holdingbranch` (`holdingbranch`)
6942 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6946 ALTER TABLE `course_items`
6947 ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6948 ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6952 CREATE TABLE `course_reserves` (
6953 `cr_id` int(11) NOT NULL AUTO_INCREMENT,
6954 `course_id` int(11) NOT NULL,
6955 `ci_id` int(11) NOT NULL,
6956 `staff_note` mediumtext,
6957 `public_note` mediumtext,
6958 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6959 PRIMARY KEY (`cr_id`),
6960 UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
6961 KEY `course_id` (`course_id`)
6962 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6966 ALTER TABLE `course_reserves`
6967 ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
6971 INSERT INTO permissions (module_bit, code, description) VALUES
6972 (18, 'manage_courses', 'Add, edit and delete courses'),
6973 (18, 'add_reserves', 'Add course reserves'),
6974 (18, 'delete_reserves', 'Remove course reserves')
6979 print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
6980 SetVersion($DBversion);
6983 $DBversion = "3.13.00.002";
6984 if ( CheckVersion($DBversion) ) {
6985 $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6986 print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6987 SetVersion ($DBversion);
6990 $DBversion = '3.13.00.003';
6991 if ( CheckVersion($DBversion) ) {
6992 $dbh->do("ALTER TABLE serial DROP itemnumber");
6993 print "Upgrade to $DBversion done (Bug 7718 - Remove itemnumber column from serials table)\n";
6994 SetVersion($DBversion);
6997 $DBversion = "3.13.00.004";
6998 if(CheckVersion($DBversion)) {
7000 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo')"
7002 print "Upgrade to $DBversion done (Bug 9722: Allow users to add notes when placing a hold in OPAC)\n";
7003 SetVersion($DBversion);
7006 $DBversion = "3.13.00.005";
7007 if(CheckVersion($DBversion)) {
7008 my $intra= C4::Context->preference("intranetstylesheet");
7009 #if this pref is not blank or starting with http, https or / [root], then
7010 #add an additional / to the front
7011 if($intra && $intra !~ /^(\/|https?)/) {
7012 $dbh->do("UPDATE systempreferences SET value=? WHERE variable=?",
7013 undef,('/'.$intra,"intranetstylesheet"));
7014 print "WARNING: Your system preference intranetstylesheet has been prefixed with a slash to make it an absolute path.\n";
7016 print "Upgrade to $DBversion done (Bug 10052: Make intranetstylesheet and intranetcolorstylesheet behave exactly like their opac counterparts)\n";
7017 SetVersion ($DBversion);
7020 $DBversion = "3.13.00.006";
7021 if ( CheckVersion($DBversion) ) {
7023 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
7024 VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo')
7026 print "Upgrade to $DBversion done (Bug 10120: Fines on item return controlled by a systempreference)\n";
7027 SetVersion($DBversion);
7030 $DBversion = "3.13.00.007";
7031 if ( CheckVersion($DBversion) ) {
7032 $dbh->do("UPDATE systempreferences SET variable='OpacHoldNotes' WHERE variable='OpacShowHoldNotes'");
7033 print "Upgrade to $DBversion done (Bug 10343: Rename OpacShowHoldNotes to OpacHoldNotes)\n";
7034 SetVersion($DBversion);
7037 $DBversion = "3.13.00.008";
7038 if ( CheckVersion($DBversion) ) {
7040 CREATE TABLE IF NOT EXISTS borrower_files (
7041 file_id int(11) NOT NULL AUTO_INCREMENT,
7042 borrowernumber int(11) NOT NULL,
7043 file_name varchar(255) NOT NULL,
7044 file_type varchar(255) NOT NULL,
7045 file_description varchar(255) DEFAULT NULL,
7046 file_content longblob NOT NULL,
7047 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7048 PRIMARY KEY (file_id),
7049 KEY borrowernumber (borrowernumber),
7050 CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7051 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7053 print "Upgrade to $DBversion done (Bug 10443: make sure borrower_files table exists)\n";
7054 SetVersion($DBversion);
7057 $DBversion = "3.13.00.009";
7058 if ( CheckVersion($DBversion) ) {
7059 $dbh->do("ALTER TABLE aqorders DROP COLUMN biblioitemnumber");
7060 print "Upgrade to $DBversion done (Bug 9987 - Drop column aqorders.biblioitemnumber)\n";
7061 SetVersion($DBversion);
7064 $DBversion = "3.13.00.010";
7065 if ( CheckVersion($DBversion) ) {
7068 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
7072 "Upgrade to $DBversion done (Bug 10366 - Add system preference to enabling warning librarian when invoice is duplicated)\n";
7073 SetVersion($DBversion);
7076 $DBversion = "3.13.00.011";
7077 if ( CheckVersion($DBversion) ) {
7078 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it'");
7079 print "Upgrade to $DBversion done (Bug 9519: Wrong language code for Italian in the advanced search language limitations)\n";
7080 SetVersion($DBversion);
7083 $DBversion = "3.13.00.012";
7084 if ( CheckVersion($DBversion) ) {
7085 $dbh->do("ALTER TABLE issuingrules MODIFY COLUMN overduefinescap decimal(28,6) DEFAULT NULL;");
7086 print "Upgrade to $DBversion done (Bug 10490: Correct datatype for overduefinescap in issuingrules)\n";
7087 SetVersion($DBversion);
7090 $DBversion ="3.13.00.013";
7091 if ( CheckVersion($DBversion) ) {
7092 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');");
7093 print "Upgrade to $DBversion done (Bug 9576: add AllowTooManyOverride syspref to enable or disable issue limit confirmation)\n";
7094 SetVersion($DBversion);
7097 $DBversion = "3.13.00.014";
7098 if ( CheckVersion($DBversion) ) {
7099 $dbh->do("ALTER TABLE courses MODIFY COLUMN department varchar(80) DEFAULT NULL;");
7100 $dbh->do("ALTER TABLE courses MODIFY COLUMN term varchar(80) DEFAULT NULL;");
7101 print "Upgrade to $DBversion done (Bug 10604: correct width of courses.department and courses.term)\n";
7102 SetVersion($DBversion);
7105 $DBversion = "3.13.00.015";
7106 if ( CheckVersion($DBversion) ) {
7108 "INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeFallbackSearch','','If set, enables the automatic use of a keyword catalog search if the phrase entered as a barcode on the checkout page does not turn up any results during an item barcode search',NULL,'YesNo')"
7110 print "Upgrade to $DBversion done (Bug 7494: Add itemBarcodeFallbackSearch syspref)\n";
7111 SetVersion($DBversion);
7114 $DBversion = "3.13.00.016";
7115 if ( CheckVersion($DBversion) ) {
7117 ALTER TABLE items CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7121 ALTER TABLE deleteditems CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7125 UPDATE saved_sql SET savedsql = REPLACE(savedsql, 'wthdrawn', 'withdrawn')
7129 UPDATE marc_subfield_structure SET kohafield = 'items.withdrawn' WHERE kohafield = 'items.wthdrawn'
7132 print "Upgrade to $DBversion done (Bug 10550 - Fix database typo wthdrawn)\n";
7133 SetVersion($DBversion);
7136 $DBversion = "3.13.00.017";
7137 if ( CheckVersion($DBversion) ) {
7139 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientKey','','Client key for OverDrive integration','30','Free')"
7142 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientSecret','','Client key for OverDrive integration','30','YesNo')"
7145 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer')"
7147 print "Upgrade to $DBversion done (Bug 10320 - Show results from library's OverDrive collection in OPAC search)\n";
7148 SetVersion($DBversion);
7151 $DBversion = "3.13.00.018";
7152 if ( CheckVersion($DBversion) ) {
7153 $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7155 CREATE TABLE aqorders_transfers (
7156 ordernumber_from int(11) NULL,
7157 ordernumber_to int(11) NULL,
7158 timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7159 UNIQUE KEY ordernumber_from (ordernumber_from),
7160 UNIQUE KEY ordernumber_to (ordernumber_to),
7161 CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7162 CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7163 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7165 print "Upgrade to $DBversion done (Bug 5349: Add aqorders_transfers table)\n";
7166 SetVersion($DBversion);
7169 $DBversion = "3.13.00.019";
7170 if ( CheckVersion($DBversion) ) {
7171 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255) AFTER summary;");
7172 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL AFTER checkinmsg;");
7173 print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
7174 SetVersion($DBversion);
7177 $DBversion = "3.13.00.020";
7178 if ( CheckVersion($DBversion) ) {
7179 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
7180 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
7181 print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7182 SetVersion($DBversion);
7185 $DBversion ="3.13.00.021";
7186 if ( CheckVersion($DBversion) ) {
7187 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ConfirmFutureHolds','0','Number of days for confirming future holds','','Integer');");
7188 print "Upgrade to $DBversion done (Bug 9761: Add ConfirmFutureHolds pref)\n";
7189 SetVersion($DBversion);
7192 $DBversion = "3.13.00.022";
7193 if ( CheckVersion($DBversion) ) {
7194 $dbh->do("DELETE from auth_tag_structure WHERE tagfield IN ('68a','68b')");
7195 $dbh->do("DELETE from auth_subfield_structure WHERE tagfield IN ('68a','68b')");
7196 print "Upgrade to $DBversion done (Bug 10687 - Delete erroneous tags 68a and 68b on default MARC21 auth framework)\n";
7197 SetVersion($DBversion);
7200 $DBversion = "3.13.00.023";
7201 if ( CheckVersion($DBversion) ) {
7202 $dbh->do("ALTER TABLE borrowers CHANGE password password VARCHAR(60);");
7203 print "Upgrade to $DBversion done (Bug 9611 upgrading password storage system)\n";
7204 SetVersion($DBversion);
7207 $DBversion = "3.13.00.024";
7208 if ( CheckVersion($DBversion) ) {
7209 $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;});
7210 print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n";
7213 $DBversion = "3.13.00.025";
7214 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7215 $dbh->do("ALTER TABLE oai_sets_mappings ADD COLUMN operator varchar(8) NOT NULL default 'equal' AFTER marcsubfield;");
7216 print "Upgrade to $DBversion done (Bug 9295: OAI notequal: add operator column to OAI mappings table)\n";
7217 SetVersion ($DBversion);
7220 $DBversion = "3.13.00.026";
7221 if ( CheckVersion($DBversion) ) {
7223 ALTER TABLE auth_subfield_structure ADD COLUMN defaultvalue TEXT DEFAULT NULL AFTER frameworkcode
7225 print "Upgrade to $DBversion done (Bug 10602: Add the column auth_subfield_structure.defaultvalue)\n";
7226 SetVersion($DBversion);
7229 $DBversion = "3.13.00.027";
7230 if ( CheckVersion($DBversion) ) {
7231 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo')");
7232 print "Upgrade to $DBversion done (Bug 10240: Add syspref AllowOfflineCirculation)\n";
7233 SetVersion ($DBversion);
7236 $DBversion = "3.13.00.028";
7237 if ( CheckVersion($DBversion) ) {
7239 ALTER TABLE export_format ADD type VARCHAR(255) DEFAULT 'marc' AFTER encoding
7242 ALTER TABLE export_format CHANGE marcfields content mediumtext NOT NULL
7244 print "Upgrade to $DBversion done (Bug 10853: Add new field export_format.type and rename export_format.marcfields with export_format.content)\n";
7245 SetVersion($DBversion);
7248 $DBversion = "3.13.00.029";
7249 if ( CheckVersion($DBversion) ) {
7251 INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type )
7252 VALUES ( "issues to claim", "Default CSV export for serial issue claims",
7253 "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate",
7256 print "Upgrade to $DBversion done (Bug 10854: Add the default CSV profile for claiming issues)\n";
7257 SetVersion($DBversion);
7260 $DBversion = "3.13.00.030";
7261 if ( CheckVersion($DBversion) ) {
7263 DELETE FROM patronimage WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowers.cardnumber = patronimage.cardnumber)
7267 ALTER TABLE patronimage ADD borrowernumber INT( 11 ) NULL FIRST
7270 $dbh->{AutoCommit} = 0;
7271 $dbh->{RaiseError} = 1;
7275 UPDATE patronimage LEFT JOIN borrowers USING ( cardnumber ) SET patronimage.borrowernumber = borrowers.borrowernumber
7281 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber) failed! Transaction aborted because $@\n";
7282 eval { $dbh->rollback };
7286 ALTER TABLE patronimage DROP FOREIGN KEY patronimage_fk1
7289 ALTER TABLE patronimage DROP PRIMARY KEY, ADD PRIMARY KEY( borrowernumber )
7292 ALTER TABLE patronimage DROP cardnumber
7295 ALTER TABLE patronimage ADD FOREIGN KEY ( borrowernumber ) REFERENCES borrowers ( borrowernumber ) ON DELETE CASCADE ON UPDATE CASCADE
7298 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber)\n";
7299 SetVersion($DBversion);
7302 $dbh->{AutoCommit} = 1;
7303 $dbh->{RaiseError} = 0;
7306 $DBversion = "3.13.00.031";
7307 if ( CheckVersion($DBversion) ) {
7310 CREATE TABLE IF NOT EXISTS `patron_lists` (
7311 patron_list_id int(11) NOT NULL AUTO_INCREMENT,
7312 name varchar(255) CHARACTER SET utf8 NOT NULL,
7313 owner int(11) NOT NULL,
7314 PRIMARY KEY (patron_list_id),
7316 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7320 ALTER TABLE `patron_lists`
7321 ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7325 CREATE TABLE patron_list_patrons (
7326 patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT,
7327 patron_list_id int(11) NOT NULL,
7328 borrowernumber int(11) NOT NULL,
7329 PRIMARY KEY (patron_list_patron_id),
7330 KEY patron_list_id (patron_list_id),
7331 KEY borrowernumber (borrowernumber)
7332 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7336 ALTER TABLE `patron_list_patrons`
7337 ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
7338 ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7342 INSERT INTO permissions (module_bit, code, description) VALUES
7343 (13, 'manage_patron_lists', 'Add, edit and delete patron lists and their contents')
7346 print "Upgrade to $DBversion done (Bug 10565 - Add a 'Patron List' feature for storing and manipulating collections of patrons)\n";
7347 SetVersion($DBversion);
7350 $DBversion = "3.13.00.032";
7351 if ( CheckVersion($DBversion) ) {
7352 $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus varchar(16) DEFAULT 'new' AFTER parent_ordernumber");
7353 $dbh->do("UPDATE aqorders SET orderstatus='ordered' WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)");
7355 UPDATE aqorders SET orderstatus='partial'
7356 WHERE quantity > quantityreceived
7357 AND quantityreceived > 0
7358 AND ordernumber IN (
7359 SELECT parent_ordernumber
7361 SELECT DISTINCT(parent_ordernumber)
7363 WHERE ordernumber != parent_ordernumber
7366 AND basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)
7368 $dbh->do("UPDATE aqorders SET orderstatus='complete' WHERE quantity=quantityreceived");
7369 $dbh->do("UPDATE aqorders SET orderstatus='cancelled' WHERE datecancellationprinted IS NOT NULL");
7370 print "Upgrade to $DBversion done (Bug 5336: Add the new column aqorders.orderstatus)\n";
7371 SetVersion($DBversion);
7374 $DBversion = "3.13.00.033";
7375 if ( CheckVersion($DBversion) ) {
7377 DROP TABLE IF EXISTS subscription_frequencies
7380 CREATE TABLE subscription_frequencies (
7381 id INTEGER NOT NULL AUTO_INCREMENT,
7382 description TEXT NOT NULL,
7383 displayorder INT DEFAULT NULL,
7384 unit ENUM('day','week','month','year') DEFAULT NULL,
7385 unitsperissue INTEGER NOT NULL DEFAULT '1',
7386 issuesperunit INTEGER NOT NULL DEFAULT '1',
7388 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7392 DROP TABLE IF EXISTS subscription_numberpatterns
7395 CREATE TABLE subscription_numberpatterns (
7396 id INTEGER NOT NULL AUTO_INCREMENT,
7397 label VARCHAR(255) NOT NULL,
7398 displayorder INTEGER DEFAULT NULL,
7399 description TEXT NOT NULL,
7400 numberingmethod VARCHAR(255) NOT NULL,
7401 label1 VARCHAR(255) DEFAULT NULL,
7402 add1 INTEGER DEFAULT NULL,
7403 every1 INTEGER DEFAULT NULL,
7404 whenmorethan1 INTEGER DEFAULT NULL,
7405 setto1 INTEGER DEFAULT NULL,
7406 numbering1 VARCHAR(255) DEFAULT NULL,
7407 label2 VARCHAR(255) DEFAULT NULL,
7408 add2 INTEGER DEFAULT NULL,
7409 every2 INTEGER DEFAULT NULL,
7410 whenmorethan2 INTEGER DEFAULT NULL,
7411 setto2 INTEGER DEFAULT NULL,
7412 numbering2 VARCHAR(255) DEFAULT NULL,
7413 label3 VARCHAR(255) DEFAULT NULL,
7414 add3 INTEGER DEFAULT NULL,
7415 every3 INTEGER DEFAULT NULL,
7416 whenmorethan3 INTEGER DEFAULT NULL,
7417 setto3 INTEGER DEFAULT NULL,
7418 numbering3 VARCHAR(255) DEFAULT NULL,
7420 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7424 INSERT INTO subscription_frequencies (description, unit, unitsperissue, issuesperunit, displayorder)
7426 ('2/day', 'day', 1, 2, 1),
7427 ('1/day', 'day', 1, 1, 2),
7428 ('3/week', 'week', 1, 3, 3),
7429 ('1/week', 'week', 1, 1, 4),
7430 ('1/2 weeks', 'week', 2, 1, 5),
7431 ('1/3 weeks', 'week', 3, 1, 6),
7432 ('1/month', 'month', 1, 1, 7),
7433 ('1/2 months', 'month', 2, 1, 8),
7434 ('1/3 months', 'month', 3, 1, 9),
7435 ('2/year', 'month', 6, 1, 10),
7436 ('1/year', 'year', 1, 1, 11),
7437 ('1/2 year', 'year', 2, 1, 12),
7438 ('Irregular', NULL, 1, 1, 13)
7441 # Used to link existing subscription to newly created frequencies
7442 my $frequencies_mapping = { # keys are old frequency numbers, values are the new ones
7443 1 => 2, # daily (n/week)
7448 6 => 8, # 1/2 months (6/year)
7449 7 => 9, # 1/3 months (1/quarter)
7450 8 => 9, # 1/quarter (seasonal)
7453 11 => 12, # 1/2 years
7455 16 => 13, # Without periodicity
7456 32 => 13, # Irregular
7461 INSERT INTO subscription_numberpatterns
7462 (label, displayorder, description, numberingmethod,
7463 label1, add1, every1, whenmorethan1, setto1, numbering1,
7464 label2, add2, every2, whenmorethan2, setto2, numbering2,
7465 label3, add3, every3, whenmorethan3, setto3, numbering3)
7467 ('Number', 1, 'Simple Numbering method', 'No.{X}',
7468 'Number', 1, 1, 99999, 1, NULL,
7469 NULL, NULL, NULL, NULL, NULL, NULL,
7470 NULL, NULL, NULL, NULL, NULL, NULL),
7472 ('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
7473 'Volume', 1, 48, 99999, 1, NULL,
7474 'Number', 1, 4, 12, 1, NULL,
7475 'Issue', 1, 1, 4, 1, NULL),
7477 ('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
7478 'Volume', 1, 12, 99999, 1, NULL,
7479 'Number', 1, 1, 12, 1, NULL,
7480 NULL, NULL, NULL, NULL, NULL, NULL),
7482 ('Seasonal', 4, 'Season Year', '{X} {Y}',
7483 'Season', 1, 1, 3, 0, 'season',
7484 'Year', 1, 4, 99999, 1, NULL,
7485 NULL, NULL, NULL, NULL, NULL, NULL)
7489 ALTER TABLE subscription
7490 MODIFY COLUMN numberpattern INTEGER DEFAULT NULL,
7491 MODIFY COLUMN periodicity INTEGER DEFAULT NULL
7494 # Update existing subscriptions
7497 SELECT subscriptionid, periodicity, numberingmethod,
7498 add1, every1, whenmorethan1, setto1,
7499 add2, every2, whenmorethan2, setto2,
7500 add3, every3, whenmorethan3, setto3
7502 ORDER BY subscriptionid
7504 my $sth = $dbh->prepare($query);
7506 my $insert_numberpatterns_sth = $dbh->prepare(qq|
7507 INSERT INTO subscription_numberpatterns
7508 (label, displayorder, description, numberingmethod,
7509 label1, add1, every1, whenmorethan1, setto1, numbering1,
7510 label2, add2, every2, whenmorethan2, setto2, numbering2,
7511 label3, add3, every3, whenmorethan3, setto3, numbering3)
7513 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
7515 my $check_numberpatterns_sth = $dbh->prepare(qq|
7516 SELECT * FROM subscription_numberpatterns
7517 WHERE (add1 = ? OR (add1 IS NULL AND ? IS NULL)) AND (add2 = ? OR (add2 IS NULL AND ? IS NULL))
7518 AND (add3 = ? OR (add3 IS NULL AND ? IS NULL)) AND (every1 = ? OR (every1 IS NULL AND ? IS NULL))
7519 AND (every2 = ? OR (every2 IS NULL AND ? IS NULL)) AND (every3 = ? OR (every3 IS NULL AND ? IS NULL))
7520 AND (whenmorethan1 = ? OR (whenmorethan1 IS NULL AND ? IS NULL)) AND (whenmorethan2 = ? OR (whenmorethan2 IS NULL AND ? IS NULL))
7521 AND (whenmorethan3 = ? OR (whenmorethan3 IS NULL AND ? IS NULL)) AND (setto1 = ? OR (setto1 IS NULL AND ? IS NULL))
7522 AND (setto2 = ? OR (setto2 IS NULL AND ? IS NULL)) AND (setto3 = ? OR (setto3 IS NULL AND ? IS NULL))
7523 AND (numberingmethod = ? OR (numberingmethod IS NULL AND ? IS NULL))
7526 my $update_subscription_sth = $dbh->prepare(qq|
7528 SET numberpattern = ?,
7530 WHERE subscriptionid = ?
7534 while(my $sub = $sth->fetchrow_hashref) {
7535 $check_numberpatterns_sth->execute(
7536 $sub->{add1}, $sub->{add1}, $sub->{add2}, $sub->{add2}, $sub->{add3}, $sub->{add3},
7537 $sub->{every1}, $sub->{every1}, $sub->{every2}, $sub->{every2}, $sub->{every3}, $sub->{every3},
7538 $sub->{whenmorethan1}, $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan2},
7539 $sub->{whenmorethan3}, $sub->{whenmorethan3}, $sub->{setto1}, $sub->{setto1}, $sub->{setto2},
7540 $sub->{setto2}, $sub->{setto3}, $sub->{setto3}, $sub->{numberingmethod}, $sub->{numberingmethod}
7542 my $p = $check_numberpatterns_sth->fetchrow_hashref;
7544 # Pattern already exists, link to it
7545 $update_subscription_sth->execute($p->{id},
7546 $frequencies_mapping->{$sub->{periodicity}},
7547 $sub->{subscriptionid});
7549 # Create a new numbering pattern for this subscription
7550 my $ok = $insert_numberpatterns_sth->execute(
7551 "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
7552 "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
7553 "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
7554 "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
7557 my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
7558 # Link to subscription_numberpatterns and subscription_frequencies
7559 $update_subscription_sth->execute($id,
7560 $frequencies_mapping->{$sub->{periodicity}},
7561 $sub->{subscriptionid});
7567 # Remove now useless columns
7569 ALTER TABLE subscription
7570 DROP COLUMN numberingmethod,
7573 DROP COLUMN whenmorethan1,
7577 DROP COLUMN whenmorethan2,
7581 DROP COLUMN whenmorethan3,
7584 DROP COLUMN issuesatonce,
7585 DROP COLUMN hemisphere,
7586 ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
7587 ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
7588 ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
7589 ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
7590 ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
7593 # Set firstacquidate if not already set (firstacquidate is now mandatory)
7594 my $get_first_planneddate_sth = $dbh->prepare(qq|
7597 WHERE subscriptionid = ?
7601 my $update_firstacquidate_sth = $dbh->prepare(qq|
7603 SET firstacquidate = ?
7604 WHERE subscriptionid = ?
7606 my $get_subscriptions_sth = $dbh->prepare(qq|
7607 SELECT subscriptionid, startdate
7609 WHERE firstacquidate IS NULL
7610 OR firstacquidate = '0000-00-00'
7612 $get_subscriptions_sth->execute;
7613 while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) {
7614 # Try to get the planned date of the first serial
7615 $get_first_planneddate_sth->execute($subscriptionid);
7616 my ($first_planneddate) = $get_first_planneddate_sth->fetchrow;
7617 if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) {
7618 $update_firstacquidate_sth->execute($first_planneddate, $subscriptionid);
7620 # Defaults to subscription start date
7621 $update_firstacquidate_sth->execute($startdate, $subscriptionid);
7625 print "Upgrade to $DBversion done (Bug 7688: add subscription_frequencies and subscription_numberpatterns tables)\n";
7626 SetVersion($DBversion);
7629 $DBversion = "3.13.00.034";
7630 if ( CheckVersion($DBversion) ) {
7632 ALTER TABLE `import_batches`
7633 CHANGE `item_action` `item_action`
7634 ENUM( 'always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore', 'replace' )
7635 NOT NULL DEFAULT 'always_add'
7637 print "Upgrade to $DBversion done (Bug 7131 - way to overlay items in in marc import)\n";
7638 SetVersion($DBversion);
7641 $DBversion ="3.13.00.035";
7642 if ( CheckVersion($DBversion) ) {
7644 CREATE TABLE borrower_debarments (
7645 borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT,
7646 borrowernumber int(11) NOT NULL,
7647 expiration date DEFAULT NULL,
7648 `type` enum('SUSPENSION','OVERDUES','MANUAL') NOT NULL DEFAULT 'MANUAL',
7650 manager_id int(11) DEFAULT NULL,
7651 created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
7652 updated timestamp NULL DEFAULT NULL,
7653 PRIMARY KEY (borrower_debarment_id),
7654 KEY borrowernumber (borrowernumber) ,
7655 CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
7656 ON DELETE CASCADE ON UPDATE CASCADE
7657 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7660 # debarments with end date
7662 INSERT INTO borrower_debarments ( borrowernumber, expiration, comment ) SELECT borrowernumber, debarred, debarredcomment FROM borrowers WHERE debarred IS NOT NULL AND debarred <> '9999-12-31'
7664 # debarments with no end date
7666 INSERT INTO borrower_debarments ( borrowernumber, comment ) SELECT borrowernumber, debarredcomment FROM borrowers WHERE debarred = '9999-12-31'
7670 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
7671 ('AutoRemoveOverduesRestrictions','0','Defines whether an OVERDUES debarment should be lifted automatically if all overdue items are returned by the patron.','YesNo')
7674 print "Upgrade to $DBversion done (Bug 2720 - Overdues which debar automatically should undebar automatically when returned)\n";
7675 SetVersion($DBversion);
7678 $DBversion = "3.13.00.036";
7679 if ( CheckVersion($DBversion) ) {
7681 INSERT INTO systempreferences (variable, value, explanation, options, type)
7682 VALUES ('StaffDetailItemSelection', '1', 'Enable item selection in record detail page', NULL, 'YesNo')
7684 print "Upgrade to $DBversion done (Add system preference StaffDetailItemSelection)\n";
7685 SetVersion($DBversion);
7688 $DBversion = "3.13.00.037";
7689 if ( CheckVersion($DBversion) ) {
7690 #add phone if it is not there already (explains the ignore option)
7692 INSERT IGNORE INTO message_transport_types (message_transport_type) values ('phone');
7694 print "Upgrade to $DBversion done (Bug 10572: Add phone to message_transport_types table for new installs)\n";
7695 SetVersion($DBversion);
7698 $DBversion = "3.13.00.038";
7699 if ( CheckVersion($DBversion) ) {
7700 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
7701 print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
7702 SetVersion($DBversion);
7705 $DBversion = "3.13.00.039";
7706 if ( CheckVersion($DBversion) ) {
7708 ALTER TABLE aqbasket ADD branch varchar(10) default NULL
7711 ALTER TABLE aqbasket
7712 ADD CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch)
7713 REFERENCES branches (branchcode)
7714 ON UPDATE CASCADE ON DELETE SET NULL
7717 DROP TABLE IF EXISTS aqbasketusers
7720 CREATE TABLE aqbasketusers (
7721 basketno int(11) NOT NULL,
7722 borrowernumber int(11) NOT NULL,
7723 PRIMARY KEY (basketno,borrowernumber),
7724 CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON DELETE CASCADE ON UPDATE CASCADE,
7725 CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7726 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7729 INSERT INTO permissions (module_bit, code, description)
7730 VALUES (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them')
7733 print "Upgrade to $DBversion done (Add branch and users list to baskets. "
7734 . "New permission order_manage_all)\n";
7735 SetVersion($DBversion);
7738 $DBversion = "3.13.00.040";
7739 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7740 $dbh->do("CREATE TABLE IF NOT EXISTS marc_modification_templates (
7741 template_id int(11) NOT NULL auto_increment,
7743 PRIMARY KEY (template_id)
7744 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
7748 CREATE TABLE IF NOT EXISTS marc_modification_template_actions (
7749 mmta_id int(11) NOT NULL auto_increment,
7750 template_id int(11) NOT NULL,
7751 ordering int(3) NOT NULL,
7752 action enum('delete_field','update_field','move_field','copy_field') NOT NULL,
7753 field_number smallint(6) NOT NULL default '0',
7754 from_field varchar(3) NOT NULL,
7755 from_subfield varchar(1) NULL,
7756 field_value varchar(100) default NULL,
7757 to_field varchar(3) default NULL,
7758 to_subfield varchar(1) default NULL,
7759 to_regex_search text,
7760 to_regex_replace text,
7761 to_regex_modifiers varchar(8) default '',
7762 conditional enum('if','unless') default NULL,
7763 conditional_field varchar(3) default NULL,
7764 conditional_subfield varchar(1) default NULL,
7765 conditional_comparison enum('exists','not_exists','equals','not_equals') default NULL,
7766 conditional_value text,
7767 conditional_regex tinyint(1) NOT NULL default '0',
7769 PRIMARY KEY (mmta_id),
7770 CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
7771 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7774 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'marc_modification_templates', 'Manage marc modification templates')");
7776 print "Upgrade to $DBversion done ( Bug 8015: Added tables for MARC Modification Framework )\n";
7777 SetVersion($DBversion);
7780 $DBversion = "3.13.00.041";
7781 if(CheckVersion($DBversion)) {
7783 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AcqItemSetSubfieldsWhenReceived','','Set subfields for item when items are created when receiving (e.g. o=5|a="foo bar")','','Free');
7785 print "Upgrade to $DBversion done (Bug 10986: Added AcqItemSetSubfieldsWhenReceived syspref)\n";
7786 SetVersion($DBversion);
7789 $DBversion = "3.13.00.042";
7790 if(CheckVersion($DBversion)) {
7791 print "Upgrade to $DBversion done (Koha 3.14 beta)\n";
7792 SetVersion($DBversion);
7795 $DBversion = "3.13.00.043";
7796 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7797 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
7798 print "Upgrade to $DBversion done (Bug 11196: Add system preference SearchEngine if missing )\n";
7799 SetVersion($DBversion);
7802 $DBversion = "3.14.00.000";
7803 if ( CheckVersion($DBversion) ) {
7804 print "Upgrade to $DBversion done (3.14.0 release)\n";
7805 SetVersion ($DBversion);
7808 $DBversion = '3.15.00.000';
7809 if ( CheckVersion($DBversion) ) {
7810 print "Upgrade to $DBversion done (the road goes ever on)\n";
7811 SetVersion ($DBversion);
7814 $DBversion = "3.15.00.001";
7815 if ( CheckVersion($DBversion) ) {
7816 $dbh->do("UPDATE systempreferences SET value='clear' where variable = 'CircAutoPrintQuickSlip' and value = '0'");
7817 $dbh->do("UPDATE systempreferences SET value='qslip' where variable = 'CircAutoPrintQuickSlip' and value = '1'");
7818 $dbh->do("UPDATE systempreferences SET explanation = 'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.', type = 'Choice' where variable = 'CircAutoPrintQuickSlip'");
7819 print "Upgrade to $DBversion done (Bug 11040: Add option to print full slip when checking out a null barcode)\n";
7820 SetVersion($DBversion);
7823 $DBversion = "3.15.00.002";
7824 if(CheckVersion($DBversion)) {
7825 $dbh->do("ALTER TABLE deleteditems MODIFY materials text;");
7826 print "Upgrade to $DBversion done (Bug 11275: alter deleteditems.materials from varchar(10) to text)\n";
7827 SetVersion($DBversion);
7830 $DBversion = "3.15.00.003";
7831 if ( CheckVersion($DBversion) ) {
7834 SET description = ''
7835 WHERE description IN (
7840 ' Account Management fee',
7841 'Payment,thanks', 'Payment,thanks - ',
7845 print "Upgrade to $DBversion done (Bug 2546: Update fine descriptions)\n";
7846 SetVersion($DBversion);
7849 $DBversion = "3.15.00.004";
7850 if ( CheckVersion($DBversion) ) {
7851 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
7853 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
7854 kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link,
7855 defaultvalue) VALUES
7856 ('015', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7857 ('020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7858 ('024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7859 ('027', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7860 ('800', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7861 ('810', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7862 ('811', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7863 ('830', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL);
7866 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
7867 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
7868 ('', '020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', ''),
7869 ('', '024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', '');
7872 print "Upgrade to $DBversion done (Bug 10970 - Update MARC21 frameworks to Update Nr. 17 - DB update)\n";
7873 SetVersion($DBversion);
7876 $DBversion = "3.15.00.005";
7877 if ( CheckVersion($DBversion) ) {
7878 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo');");
7879 print "Upgrade to $DBversion done (Bug 8230: Add AcquisitionDetails system preference)\n";
7880 SetVersion ($DBversion);
7883 $DBversion = "3.15.00.006";
7884 if(CheckVersion($DBversion)) {
7886 ALTER TABLE `borrowers`
7887 ADD KEY `surname_idx` (`surname`(255)),
7888 ADD KEY `firstname_idx` (`firstname`(255)),
7889 ADD KEY `othernames_idx` (`othernames`(255))
7891 print "Upgrade to $DBversion done (Bug 11249 - Add DB indexes on borrower names)\n";
7892 SetVersion($DBversion);
7895 $DBversion = "3.15.00.007";
7896 if ( CheckVersion($DBversion) ) {
7897 $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7898 $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7899 $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7900 $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7901 print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7902 SetVersion ($DBversion);
7905 $DBversion = "3.15.00.008";
7906 if ( CheckVersion($DBversion) ) {
7908 ALTER TABLE collections_tracking CHANGE ctId collections_tracking_id integer(11) NOT NULL auto_increment;
7910 print "Upgrade to $DBversion done (Bug 11384) - change name of collections_tracker.ctId column)\n";
7911 SetVersion ($DBversion);
7914 $DBversion = "3.15.00.009";
7915 if ( CheckVersion($DBversion) ) {
7917 ALTER TABLE suggestions MODIFY suggesteddate DATE NOT NULL
7919 print "Upgrade to $DBversion done (Bug 11391) - drop default value on suggestions.suggesteddate column)\n";
7920 SetVersion ($DBversion);
7923 $DBversion = "3.15.00.010";
7924 if(CheckVersion($DBversion)) {
7925 $dbh->do("ALTER TABLE deleteditems DROP COLUMN marc");
7926 print "Upgrade to $DBversion done (Bug 6331: remove obsolete column in deleteditems.marc)\n";
7927 SetVersion ($DBversion);
7930 $DBversion = "3.15.00.011";
7931 if(CheckVersion($DBversion)) {
7932 $dbh->do("UPDATE marc_subfield_structure SET maxlength=9999 WHERE maxlength IS NULL OR maxlength=0;");
7933 print "Upgrade to $DBversion done (Bug 8018: set 9999 as default max length for subfields)\n";
7934 SetVersion ($DBversion);
7937 $DBversion = "3.15.00.012";
7938 if ( CheckVersion($DBversion) ) {
7940 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'force_checkout', 'Force checkout if a limitation exists')
7943 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_restrictions', 'Manage restrictions for accounts')
7946 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7947 SELECT user_permissions.borrowernumber, 1, 'force_checkout'
7948 FROM user_permissions
7949 LEFT JOIN borrowers USING(borrowernumber)
7950 WHERE borrowers.flags & (1 << 1)
7953 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7954 SELECT user_permissions.borrowernumber, 1, 'manage_restrictions'
7955 FROM user_permissions
7956 LEFT JOIN borrowers USING(borrowernumber)
7957 WHERE borrowers.flags & (1 << 1)
7960 print "Upgrade to $DBversion done (Bug 10863 - Add permissions force_checkout and manage_restrictions)\n";
7961 SetVersion($DBversion);
7964 $DBversion = "3.15.00.013";
7965 if(CheckVersion($DBversion)) {
7967 UPDATE systempreferences
7968 SET explanation = 'Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")'
7969 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7973 UPDATE systempreferences
7975 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7978 print "Upgrade to $DBversion done (Bug 11237: Update explanation and default value for AcqItemSetSubfieldsWhenReceived syspref)\n";
7979 SetVersion($DBversion);
7982 $DBversion = "3.15.00.014";
7983 if (CheckVersion($DBversion)) {
7984 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('SelfCheckReceiptPrompt', '1', 'NULL', 'If ON, print receipt dialog pops up when self checkout is finished.', 'YesNo');");
7985 print "Upgrade to $DBversion done (Bug 11415: add system preference for automatic self checkout receipt printing)\n";
7986 SetVersion($DBversion);
7989 $DBversion = "3.15.00.015";
7990 if (CheckVersion($DBversion)) {
7991 $dbh->do("INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
7992 ('OpacSuggestionManagedBy',1,'','Show the name of the staff member who managed a suggestion in OPAC','YesNo');");
7993 print "Upgrade to $DBversion done (Bug 10907: Add OpacSuggestionManagedBy system preference)\n";
7994 SetVersion($DBversion);
7997 $DBversion = "3.15.00.016";
7998 if (CheckVersion($DBversion)) {
7999 $dbh->do("ALTER TABLE biblioitems CHANGE url url TEXT NULL DEFAULT NULL");
8000 $dbh->do("ALTER TABLE deletedbiblioitems CHANGE url url TEXT NULL DEFAULT NULL");
8001 print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n";
8002 SetVersion($DBversion);
8005 $DBversion = "3.15.00.017";
8006 if(CheckVersion($DBversion)) {
8008 UPDATE systempreferences
8009 SET explanation = 'Define the contents of UNIMARC authority control field 100 position 08-35'
8010 WHERE variable = "UNIMARCAuthorityField100"
8013 UPDATE systempreferences
8014 SET explanation = 'Define the contents of MARC21 authority control field 008 position 06-39'
8015 WHERE variable = "MARCAuthorityControlField008"
8018 UPDATE systempreferences
8019 SET explanation = 'Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html'
8020 WHERE variable = "MARCOrgCode"
8022 print "Upgrade to $DBversion done (Bug 11611 - fix possible confusion between UNIMARC and MARC21 in some sysprefs)\n";
8023 SetVersion($DBversion);
8026 $DBversion = "3.15.00.018";
8027 if ( CheckVersion($DBversion) ) {
8028 $dbh->{AutoCommit} = 0;
8029 $dbh->{RaiseError} = 1;
8032 $dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|);
8035 my $av_added = $dbh->do(q|
8036 INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
8037 SELECT 'ROADTYPE', roadtypeid, road_type, road_type
8041 my $rt_deleted = $dbh->do(q|
8042 DELETE FROM roadtype
8045 if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
8047 DROP TABLE roadtype;
8050 print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
8051 SetVersion($DBversion);
8053 print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
8057 $dbh->{AutoCommit} = 1;
8058 $dbh->{RaiseError} = 0;
8061 $DBversion = "3.15.00.019";
8062 if ( CheckVersion($DBversion) ) {
8063 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer')");
8064 print "Upgrade to $DBversion done (Bug 11256: Add system preference OpacMaxItemsToDisplay)\n";
8065 SetVersion($DBversion);
8068 $DBversion = "3.15.00.020";
8069 if ( CheckVersion($DBversion) ) {
8071 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('MaxItemsForBatch','1000',NULL,'Max number of items record to process in a batch (modification or deletion)','Integer')
8073 print "Upgrade to $DBversion done (Bug 11343: Add system preference MaxItemsForBatch )\n";
8074 SetVersion($DBversion);
8077 $DBversion = "3.15.00.021";
8078 if(CheckVersion($DBversion)) {
8080 ALTER TABLE `action_logs`
8082 ADD KEY `timestamp_idx` (`timestamp`),
8083 ADD KEY `user_idx` (`user`),
8084 ADD KEY `module_idx` (`module`(255)),
8085 ADD KEY `action_idx` (`action`(255)),
8086 ADD KEY `object_idx` (`object`),
8087 ADD KEY `info_idx` (`info`(255))
8089 print "Upgrade to $DBversion done (Bug 3445: Add indexes to action_logs table)\n";
8090 SetVersion($DBversion);
8093 $DBversion = "3.15.00.022";
8094 if (CheckVersion($DBversion)) {
8096 DELETE FROM systempreferences WHERE variable= "memberofinstitution"
8098 print "Upgrade to $DBversion done (Bug 11751: Remove memberofinstitytion system preference)\n";
8099 SetVersion($DBversion);
8102 $DBversion = "3.15.00.023";
8103 if ( CheckVersion($DBversion) ) {
8105 INSERT INTO systempreferences (variable,value,options,explanation,type)
8106 VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free');
8108 print "Upgrade to $DBversion done (Bug 10861: Add CardnumberLength syspref)\n";
8109 SetVersion ($DBversion);
8112 $DBversion = "3.15.00.024";
8113 if ( CheckVersion($DBversion) ) {
8115 DELETE FROM systempreferences WHERE variable = 'NoZebraIndexes'
8117 print "Upgrade to $DBversion done (Bug 10012 - remove last vestiges of NoZebra)\n";
8118 SetVersion($DBversion);
8121 $DBversion = "3.15.00.025";
8122 if ( CheckVersion($DBversion) ) {
8124 DROP TABLE aqorderdelivery;
8126 print "Upgrade to $DBversion done (Bug 11928 - remove unused table)\n";
8127 SetVersion($DBversion);
8130 $DBversion = "3.15.00.026";
8131 if ( CheckVersion($DBversion) ) {
8133 UPDATE language_descriptions SET description = 'Հայերեն' WHERE subtag = 'hy' AND lang = 'hy';
8135 print "Upgrade to $DBversion done (Bug 11973 - Fix Armenian language description)\n";
8136 SetVersion($DBversion);
8139 $DBversion = "3.15.00.027";
8140 if (CheckVersion($DBversion)) {
8142 ALTER TABLE opac_news ADD branchcode varchar(10) DEFAULT NULL
8144 ADD CONSTRAINT opac_news_branchcode_ibfk
8145 FOREIGN KEY (branchcode)
8146 REFERENCES branches (branchcode)
8147 ON DELETE CASCADE ON UPDATE CASCADE;
8149 print "Upgrade to $DBversion done (Bug 7567: Add branchcode to opac_news)\n";
8150 SetVersion($DBversion);
8153 $DBversion = "3.15.00.028";
8154 if(CheckVersion($DBversion)) {
8156 ALTER TABLE issuingrules ADD norenewalbefore int(4) default NULL AFTER renewalperiod
8158 print "Upgrade to $DBversion done (Bug 7413: Allow OPAC renewal x days before due date)\n";
8159 SetVersion($DBversion);
8162 $DBversion = "3.15.00.029";
8163 if ( CheckVersion($DBversion) ) {
8165 UPDATE borrower_debarments SET expiration = NULL WHERE expiration = '9999-12-31'
8167 print "Upgrade to $DBversion done (Bug 11846 - correct borrower_debarments with expiration 9999-12-31)\n";
8168 SetVersion($DBversion);
8171 $DBversion = "3.15.00.030";
8172 if(CheckVersion($DBversion)) {
8174 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACMySummaryNote','','','Note to display on the patron summary page. This note only appears if the patron is connected.','Free')
8176 print "Upgrade to $DBversion done (Bug 12052: Add OPACMySummaryNote syspref)\n";
8177 SetVersion($DBversion);
8180 $DBversion = "3.15.00.031";
8181 if ( CheckVersion($DBversion) ) {
8182 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'writeoff', 'Write off fines and fees')");
8183 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'remaining_permissions', 'Remaining permissions for managing fines and fees')");
8184 print "Upgrade to $DBversion done (Bug 9448 - Add separate permission for writing off fees)\n";
8185 SetVersion ($DBversion);
8188 $DBversion = "3.15.00.032";
8189 if ( CheckVersion($DBversion) ) {
8190 $dbh->do("ALTER TABLE aqorders CHANGE notes order_internalnote MEDIUMTEXT;");
8191 $dbh->do("ALTER TABLE aqorders ADD COLUMN order_vendornote MEDIUMTEXT AFTER order_internalnote;");
8192 print "Upgrade to $DBversion done (Bug 9416 - In each order, add a new note made for the vendor)\n";
8193 SetVersion ($DBversion);
8196 $DBversion = "3.15.00.033";
8197 if ( CheckVersion($DBversion) ) {
8198 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea')");
8199 print "Upgrade to $DBversion done (Bug 10951: Add NoLoginInstructions pref)\n";
8200 SetVersion($DBversion);
8203 $DBversion = "3.15.00.034";
8204 if ( CheckVersion($DBversion) ) {
8205 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an advanced search option. Example: eng|fra|ita','Textarea')");
8206 print "Upgrade to $DBversion done (Bug 10986: system preferences to limit languages in advanced search )\n";
8207 SetVersion ($DBversion);
8210 $DBversion = "3.15.00.035";
8211 if ( CheckVersion($DBversion) ) {
8212 #insert a notice for sharing a list and accepting a share
8214 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8215 VALUES ( 'members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
8217 One of our patrons, <<borrowers.firstname>> <<borrowers.surname>>, invites you to share a list <<listname>> in our library catalog.
8219 To access this shared list, please click on the following URL or copy-and-paste it into your browser address bar.
8223 In case you are not a patron in our library or do not want to accept this invitation, please ignore this mail. Note also that this invitation expires within two weeks.
8230 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8231 VALUES ( 'members', 'SHARE_ACCEPT', '', 'Notification about an accepted share', '0', 'Share on list <<listname>> accepted', 'Dear patron,
8233 We want to inform you that <<borrowers.firstname>> <<borrowers.surname>> accepted your invitation to share your list <<listname>> in our library catalog.
8239 print "Upgrade to $DBversion done (Bug 9032: Share a list)\n";
8240 SetVersion($DBversion);
8243 $DBversion = "3.15.00.036";
8244 if ( CheckVersion($DBversion) ) {
8246 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
8247 VALUES('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo')
8250 print "Upgrade to $DBversion done (Bug 10859 - Add system preference AllowMultipleIssuesOnABiblio)\n";
8251 SetVersion($DBversion);
8254 $DBversion = "3.15.00.037";
8255 if(CheckVersion($DBversion)) {
8257 ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) DEFAULT NULL AFTER checkinmsgtype
8260 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
8261 ('SIP_MEDIA_TYPE', '000', 'Other'),
8262 ('SIP_MEDIA_TYPE', '001', 'Book'),
8263 ('SIP_MEDIA_TYPE', '002', 'Magazine'),
8264 ('SIP_MEDIA_TYPE', '003', 'Bound journal'),
8265 ('SIP_MEDIA_TYPE', '004', 'Audio tape'),
8266 ('SIP_MEDIA_TYPE', '005', 'Video tape'),
8267 ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'),
8268 ('SIP_MEDIA_TYPE', '007', 'Diskette'),
8269 ('SIP_MEDIA_TYPE', '008', 'Book with diskette'),
8270 ('SIP_MEDIA_TYPE', '009', 'Book with CD'),
8271 ('SIP_MEDIA_TYPE', '010', 'Book with audio tape')
8273 print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n";
8274 SetVersion($DBversion);
8277 $DBversion = '3.15.00.038';
8278 if ( CheckVersion($DBversion) ) {
8280 INSERT INTO systempreferences (
8288 'DisplayLibraryFacets', 'holding', 'home|holding|both', 'Defines which library facets to display.', 'Choice'
8291 print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n";
8292 SetVersion ($DBversion);
8295 $DBversion = "3.15.00.039";
8296 if ( CheckVersion($DBversion) ) {
8299 ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
8303 ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
8307 ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
8311 CREATE TABLE overduerules_transport_types(
8312 id INT(11) NOT NULL AUTO_INCREMENT,
8313 branchcode varchar(10) NOT NULL DEFAULT '',
8314 categorycode VARCHAR(10) NOT NULL DEFAULT '',
8315 letternumber INT(1) NOT NULL DEFAULT 1,
8316 message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
8318 CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
8319 CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
8320 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8323 my $sth = $dbh->prepare( q{
8324 SELECT * FROM overduerules;
8328 my $sth_insert_mtt = $dbh->prepare( q{
8329 INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
8331 while ( my $row = $sth->fetchrow_hashref ) {
8332 my $branchcode = $row->{branchcode};
8333 my $categorycode = $row->{categorycode};
8334 for my $letternumber ( 1 .. 3 ) {
8335 next unless $row->{"letter$letternumber"};
8336 $sth_insert_mtt->execute(
8337 $branchcode, $categorycode, $letternumber, 'email'
8342 print "Upgrade done (Bug 9016: Adds multi transport types management for notices)\n";
8343 SetVersion($DBversion);
8346 $DBversion = "3.15.00.040";
8347 if ( CheckVersion($DBversion) ) {
8349 UPDATE message_transports SET letter_code='HOLD' WHERE letter_code='HOLD_PHONE' OR letter_code='HOLD_PRINT'
8352 UPDATE letter SET code='HOLD', message_transport_type='print' WHERE code='HOLD_PRINT'
8355 UPDATE letter SET code='HOLD', message_transport_type='phone' WHERE code='HOLD_PHONE'
8357 print "Upgrade to $DBversion done (Bug 10845: Multi transport types for holds)\n";
8358 SetVersion($DBversion);
8361 $DBversion = "3.15.00.041";
8362 if ( CheckVersion($DBversion) ) {
8363 my ( $name ) = $dbh->selectrow_array(q|
8364 SELECT name FROM letter WHERE code="HOLD"
8369 message_transport_type="phone",
8371 WHERE code="HOLD_PHONE"
8374 ( $name ) = $dbh->selectrow_array(q|
8375 SELECT name FROM letter WHERE code="PREDUE"
8380 message_transport_type="phone",
8382 WHERE code="PREDUE_PHONE"
8385 ( $name ) = $dbh->selectrow_array(q|
8386 SELECT name FROM letter WHERE code="OVERDUE"
8391 message_transport_type="phone",
8393 WHERE code="OVERDUE_PHONE"
8396 print "Upgrade to $DBversion done (Bug 11867: Update letters *_PHONE)\n";
8397 SetVersion($DBversion);
8400 $DBversion = "3.15.00.042";
8401 if ( CheckVersion($DBversion) ) {
8403 INSERT INTO systempreferences
8404 (variable,value,explanation,options,type)
8406 ('SpecifyReturnDate',0,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
8408 print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
8409 SetVersion($DBversion);
8412 $DBversion = "3.15.00.043";
8413 if ( CheckVersion($DBversion) ) {
8414 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MarcFieldsToOrder','','Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.', NULL, 'textarea')");
8415 print "Upgrade to $DBversion done (Bug 7180: Added MarcFieldsToOrder syspref)\n";
8416 SetVersion ($DBversion);
8419 $DBversion = "3.15.00.044";
8420 if ( CheckVersion($DBversion) ) {
8421 $dbh->do("ALTER TABLE currency ADD isocode VARCHAR(5) default NULL AFTER symbol;");
8422 print "Upgrade to $DBversion done (Added isocode to the currency table)\n";
8423 SetVersion($DBversion);
8426 $DBversion = "3.15.00.045";
8427 if ( CheckVersion($DBversion) ) {
8429 INSERT INTO systempreferences (variable,value,explanation,options,type)
8431 'BlockExpiredPatronOpacActions',
8433 'Set whether an expired patron can perform opac actions such as placing holds or renew books, can be overridden on a per patron-type basis',
8438 $dbh->do("ALTER TABLE `categories` ADD COLUMN `BlockExpiredPatronOpacActions` TINYINT(1) DEFAULT -1 NOT NULL AFTER category_type");
8439 print "Upgraded to $DBversion done (Bug 6739 - expired patrons not blocked from opac actions)\n";
8440 SetVersion ($DBversion);
8443 $DBversion = "3.15.00.046";
8444 if ( CheckVersion($DBversion) ) {
8446 ALTER TABLE search_history ADD COLUMN type VARCHAR(16) NOT NULL DEFAULT 'biblio' AFTER query_cgi
8448 print "Upgrade to $DBversion done (Bug 10807 - Add db field search_history.type)\n";
8449 SetVersion($DBversion);
8452 $DBversion = "3.15.00.047";
8453 if ( CheckVersion($DBversion) ) {
8455 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableSearchHistory','0','','Enable or disable search history','YesNo')
8457 print "Upgrade to $DBversion done (Bug 10862: Add EnableSearchHistory syspref)\n";
8458 SetVersion($DBversion);
8461 $DBversion = "3.15.00.048";
8462 if ( CheckVersion($DBversion) ) {
8463 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo')");
8464 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacSuppressionMessage', '','Display this message on the redirect page for suppressed biblios','70|10','Textarea')");
8465 print "Upgrade to $DBversion done (Bug 10195: Records hidden with OpacSuppression can still be accessed)\n";
8466 SetVersion($DBversion);
8469 $DBversion = "3.15.00.049";
8470 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8471 $dbh->do("ALTER TABLE biblioitems DROP INDEX isbn");
8472 $dbh->do("ALTER TABLE biblioitems DROP INDEX issn");
8473 $dbh->do("ALTER TABLE biblioitems DROP INDEX issn_idx");
8474 $dbh->do("ALTER TABLE biblioitems
8475 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8476 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8478 $dbh->do("ALTER TABLE biblioitems
8479 ADD INDEX isbn ( isbn ( 255 ) ),
8480 ADD INDEX issn ( issn ( 255 ) )
8483 $dbh->do("ALTER TABLE deletedbiblioitems DROP INDEX isbn");
8484 $dbh->do("ALTER TABLE deletedbiblioitems
8485 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8486 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8488 $dbh->do("ALTER TABLE deletedbiblioitems
8489 ADD INDEX isbn ( isbn ( 255 ) )
8492 print "Upgrade to $DBversion done (Bug 5377 - Biblioitems isbn and issn fields too small for multiple ISBN and ISSN)\n";
8493 SetVersion($DBversion);
8496 $DBversion = "3.15.00.050";
8497 if ( CheckVersion($DBversion) ) {
8499 INSERT INTO systempreferences (
8505 'AggressiveMatchOnISBN',
8507 'If enabled, attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records when matching on ISBN with the record import tool',
8512 print "Upgrade to $DBversion done (Bug 10500 - Improve isbn matching when importing records)\n";
8513 SetVersion($DBversion);
8516 $DBversion = "3.15.00.051";
8517 if ( CheckVersion($DBversion) ) {
8518 print "Upgrade to $DBversion done (Koha 3.16 beta)\n";
8519 SetVersion($DBversion);
8522 $DBversion = "3.15.00.052";
8523 if ( CheckVersion($DBversion) ) {
8524 print "Upgrade to $DBversion done (Koha 3.16 RC)\n";
8525 SetVersion($DBversion);
8528 $DBversion = "3.16.00.000";
8529 if ( CheckVersion($DBversion) ) {
8530 print "Upgrade to $DBversion done (3.16.0 release)\n";
8531 SetVersion ($DBversion);
8534 $DBversion = '3.17.00.000';
8535 if ( CheckVersion($DBversion) ) {
8536 print "Upgrade to $DBversion done (there is no time to rest on our laurels)\n";
8537 SetVersion ($DBversion);
8540 $DBversion = '3.17.00.001';
8541 if ( CheckVersion($DBversion) ) {
8542 $dbh->do("UPDATE systempreferences SET variable = 'AuthoritySeparator' WHERE variable = 'authoritysep'");
8543 print "Upgrade to $DBversion done (Bug 10330 - Rename system preference authoritysep to AuthoritySeparator)\n";
8544 SetVersion ($DBversion);
8547 $DBversion = "3.17.00.002";
8548 if (CheckVersion($DBversion)) {
8549 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('AcqEnableFiles','0','If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo')");
8551 CREATE TABLE IF NOT EXISTS `misc_files` (
8552 `file_id` int(11) NOT NULL AUTO_INCREMENT,
8553 `table_tag` varchar(255) NOT NULL,
8554 `record_id` int(11) NOT NULL,
8555 `file_name` varchar(255) NOT NULL,
8556 `file_type` varchar(255) NOT NULL,
8557 `file_description` varchar(255) DEFAULT NULL,
8558 `file_content` longblob NOT NULL, -- file content
8559 `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8560 PRIMARY KEY (`file_id`),
8561 KEY `table_tag` (`table_tag`),
8562 KEY `record_id` (`record_id`)
8563 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8565 print "Upgrade to $DBversion done (Bug 3050 - Add an option to upload scanned invoices)\n";
8566 SetVersion($DBversion);
8569 $DBversion = "3.17.00.003";
8570 if (CheckVersion($DBversion)) {
8571 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = '0|1|force' WHERE variable = 'OPACItemHolds'");
8572 print "Upgrade to $DBversion done (Bug 7825 - Changed OPACItemHolds syspref to Choice)\n";
8573 SetVersion($DBversion);
8576 $DBversion = "3.17.00.004";
8577 if (CheckVersion($DBversion)) {
8578 $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER category_type");
8579 print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
8580 SetVersion($DBversion);
8583 $DBversion = "3.17.00.005";
8584 if (CheckVersion($DBversion)) {
8586 ALTER TABLE issuingrules
8587 ADD maxsuspensiondays INT(11) DEFAULT NULL AFTER finedays;
8589 print "Upgrade to $DBversion done (Bug 12230: Add new issuing rule maxsuspensiondays)\n";
8590 SetVersion($DBversion);
8593 $DBversion = "3.17.00.006";
8594 if ( CheckVersion($DBversion) ) {
8595 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacLocationBranchToDisplay', 'holding', 'holding|home|both', 'In the OPAC, under location show which branch for Location in the record details.', 'Choice')");
8596 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacLocationBranchToDisplayShelving', 'holding', 'holding|home|both', 'In the OPAC, display the shelving location under which which column', 'Choice')");
8597 print "Upgrade to $DBversion done (Bug 7720 - Ambiguity in OPAC Details location.)\n";
8598 SetVersion($DBversion);
8601 $DBversion = "3.17.00.007";
8602 if (CheckVersion($DBversion)) {
8603 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free');");
8604 print "Upgrade to $DBversion done (Bug 11629 - Add ability to update not for loan status on checkin)\n";
8605 SetVersion($DBversion);
8608 $DBversion = "3.17.00.008";
8609 if ( CheckVersion($DBversion) ) {
8611 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACAcquisitionDetails','0', '','Show the acquisition details at the OPAC','YesNo')
8613 print "Upgrade to $DBversion done (Bug 11169 - Add OPACAcquisitionDetails syspref)\n";
8614 SetVersion($DBversion);
8617 $DBversion = "3.17.00.009";
8618 if ( CheckVersion($DBversion) ) {
8620 DELETE FROM systempreferences WHERE variable = 'UseTablesortForCirc'
8623 print "Upgrade to $DBversion done (Bug 11703 - Remove UseTablesortForCirc syspref)\n";
8624 SetVersion($DBversion);
8627 $DBversion = "3.17.00.010";
8628 if ( CheckVersion($DBversion) ) {
8629 $dbh->do("DELETE FROM systempreferences WHERE variable='opacsmallimage'");
8630 print "Upgrade to $DBversion done (Bug 11347 - PROG/CCSR deprecation: Remove opacsmallimage system preference)\n";
8631 SetVersion($DBversion);
8634 $DBversion = "3.17.00.011";
8635 if ( CheckVersion($DBversion) ) {
8636 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'hr', 'language', 'Croatian','2014-07-24' )");
8637 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'hr','hrv')");
8638 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'hr', 'Hrvatski')");
8639 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'en', 'Croatian')");
8640 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'fr', 'Croate')");
8641 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'de', 'Kroatisch')");
8642 print "Upgrade to $DBversion done (Bug 12649: Add Croatian language)\n";
8643 SetVersion ($DBversion);
8646 $DBversion = "3.17.00.012";
8647 if ( CheckVersion($DBversion) ) {
8648 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowFiltersPulldownMobile'");
8649 print "Upgrade to $DBversion done ( Bug 12512 - PROG/CCSR deprecation: Remove OpacShowFiltersPulldownMobile system preference )\n";
8650 SetVersion ($DBversion);
8653 $DBversion = "3.17.00.013";
8654 if ( CheckVersion($DBversion) ) {
8655 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('maxreserves',50,'System-wide maximum number of holds a patron can place','','Integer')");
8656 print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n";
8657 SetVersion ($DBversion);
8660 $DBversion = '3.17.00.014';
8661 if ( CheckVersion($DBversion) ) {
8663 INSERT INTO systempreferences (variable,value,explanation,type) VALUES
8664 ('OverdueNoticeCalendar',0,'Take calendar into consideration when working out sending overdue notices','YesNo')
8666 print "Upgrade to $DBversion done (Bug 12529 - Adding a syspref to allow the overdue notices to consider the calendar when generating notices)\n";
8667 SetVersion($DBversion);
8670 $DBversion = "3.17.00.015";
8671 if ( CheckVersion($DBversion) ) {
8673 CREATE TABLE IF NOT EXISTS columns_settings (
8674 module varchar(255) NOT NULL,
8675 page varchar(255) NOT NULL,
8676 tablename varchar(255) NOT NULL,
8677 columnname varchar(255) NOT NULL,
8678 cannot_be_toggled int(1) NOT NULL DEFAULT 0,
8679 is_hidden int(1) NOT NULL DEFAULT 0,
8680 PRIMARY KEY(module, page, tablename, columnname)
8681 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
8683 print "Upgrade to $DBversion done (Bug 10212 - Create new table columns_settings)\n";
8684 SetVersion ($DBversion);
8687 $DBversion = "3.17.00.016";
8688 if ( CheckVersion($DBversion) ) {
8689 $dbh->do("CREATE TABLE aqcontacts (
8690 id int(11) NOT NULL auto_increment,
8691 name varchar(100) default NULL,
8692 position varchar(100) default NULL,
8693 phone varchar(100) default NULL,
8694 altphone varchar(100) default NULL,
8695 fax varchar(100) default NULL,
8696 email varchar(100) default NULL,
8698 claimacquisition BOOLEAN NOT NULL DEFAULT 0,
8699 claimissues BOOLEAN NOT NULL DEFAULT 0,
8700 acqprimary BOOLEAN NOT NULL DEFAULT 0,
8701 serialsprimary BOOLEAN NOT NULL DEFAULT 0,
8702 booksellerid int(11) not NULL,
8704 CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
8705 REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8706 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8707 $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8708 email, notes, booksellerid, claimacquisition, claimissues, acqprimary, serialsprimary)
8709 SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8710 contnotes, id, 1, 1, 1, 1 FROM aqbooksellers;");
8711 $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8712 DROP COLUMN contpos, DROP COLUMN contphone,
8713 DROP COLUMN contaltphone, DROP COLUMN contfax,
8714 DROP COLUMN contemail, DROP COLUMN contnotes;");
8715 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
8716 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
8717 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
8718 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
8719 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
8720 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
8721 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
8722 print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8723 SetVersion($DBversion);
8726 $DBversion = "3.17.00.017";
8727 if ( CheckVersion($DBversion) ) {
8728 # Correct invalid recordtypes (should be very exceptional)
8730 UPDATE z3950servers set recordtype='biblio' WHERE recordtype NOT IN ('authority','biblio')
8732 # Correct invalid server types (should also be very exceptional)
8734 UPDATE z3950servers set type='zed' WHERE type <> 'zed'
8738 ALTER TABLE z3950servers
8740 DROP COLUMN description,
8741 DROP COLUMN position,
8742 MODIFY COLUMN id int NOT NULL AUTO_INCREMENT FIRST,
8743 MODIFY COLUMN recordtype enum('authority','biblio') NOT NULL DEFAULT 'biblio',
8744 CHANGE COLUMN name servername mediumtext NOT NULL,
8745 CHANGE COLUMN type servertype enum('zed','sru') NOT NULL DEFAULT 'zed',
8746 ADD COLUMN sru_options varchar(255) default NULL,
8747 ADD COLUMN sru_fields mediumtext default NULL,
8748 ADD COLUMN add_xslt mediumtext default NULL
8750 print "Upgrade to $DBversion done (Bug 6536: Z3950 improvements)\n";
8751 SetVersion ($DBversion);
8754 $DBversion = "3.17.00.018";
8755 if ( CheckVersion($DBversion) ) {
8756 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('HoldsInNoissuesCharge', '0', 'Hold charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
8757 print "Upgrade to $DBversion done (Bug 12205: Add HoldsInNoissuesCharge systempreference)\n";
8758 SetVersion($DBversion);
8761 $DBversion = "3.17.00.019";
8762 if ( CheckVersion($DBversion) ) {
8763 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHighlightedWords is enabled','free')"
8765 print "Upgrade to $DBversion done (Bug 6149: Operator highlighted in search results)\n";
8766 SetVersion($DBversion);
8769 $DBversion = "3.17.00.020";
8770 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8771 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesOnHolidays', '1', NULL, 'If false, reserves at a library will not be canceled on days the library is not open.', 'YesNo')");
8772 print "Upgrade to $DBversion done (Bug 8735 - Expire holds waiting only on days the library is open)\n";
8773 SetVersion ($DBversion);
8776 $DBversion = "3.17.00.021";
8777 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8778 my $pref = C4::Context->preference('HomeOrHoldingBranch');
8779 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
8780 VALUES ('StaffSearchResultsDisplayBranch', ?,'homebranch|holdingbranch','Controls the display of the home or holding branch for staff search results','choice')", undef, $pref);
8781 print "Upgrade to $DBversion done (Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch)\n";
8782 SetVersion ($DBversion);
8785 $DBversion = '3.17.00.022';
8786 if ( CheckVersion($DBversion) ) {
8787 my @temp= $dbh->selectrow_array(qq|
8789 FROM marc_subfield_structure
8790 WHERE kohafield='permanent_location' OR kohafield='items.permanent_location'
8792 print "Upgrade to $DBversion done (Bug 7817: Check for permanent_location)\n";
8794 print "WARNING for Koha administrator: Your database contains one or more mappings for permanent_location to the MARC structure. This item field however is for internal use and should not be linked to a MARC (sub)field. Please correct it. See also Bugzilla reports 7817 and 12818.\n";
8796 SetVersion($DBversion);
8799 $DBversion = "3.17.00.023";
8800 if ( CheckVersion($DBversion) ) {
8802 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('AcqItemSetSubfieldsWhenReceiptIsCancelled','', '','Upon cancelling a receipt, update the items subfields if they were created when placing an order (e.g. o=5|a="bar foo")', 'Free')
8804 print "Upgrade to $DBversion done (Bug 11169 - Add AcqItemSetSubfieldsWhenReceiptIsCancelled syspref)\n";
8805 SetVersion($DBversion);
8808 $DBversion = "3.17.00.024";
8809 if(CheckVersion($DBversion)) {
8811 ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8814 ALTER TABLE old_issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8817 ALTER TABLE issuingrules ADD auto_renew BOOLEAN default FALSE AFTER norenewalbefore
8819 print "Upgrade to $DBversion done (Bug 11577: [ENH] Automatic renewal feature)\n";
8820 SetVersion($DBversion);
8823 $DBversion = '3.17.00.025';
8824 if ( CheckVersion($DBversion) ) {
8826 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('StatisticsFields','location|itype|ccode','Define fields (from the items table) used for statistics members',NULL,'Free')
8828 print "Upgrade to $DBversion done (Bug 12728: Checked syspref StatisticsFields)\n";
8831 $DBversion = "3.17.00.026";
8832 if ( CheckVersion($DBversion) ) {
8833 if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
8834 $dbh->do("UPDATE marc_subfield_structure SET liblibrarian = 'Encoded bitrate', libopac = 'Encoded bitrate' WHERE tagfield = '347' AND tagsubfield = 'f'");
8835 $dbh->do("UPDATE marc_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','610','611','710','711','810','811') AND tagsubfield = 'c'");
8836 $dbh->do("UPDATE auth_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','410','411','510','511','710','711') AND tagsubfield = 'c'");
8837 print "Upgrade to $DBversion done (Bug 12435 - Update MARC21 frameworks to Update No. 18 (April 2014))\n";
8839 SetVersion($DBversion);
8842 $DBversion = "3.17.00.027";
8843 if ( CheckVersion($DBversion) ) {
8845 DELETE FROM systempreferences WHERE variable = 'SearchEngine'
8847 print "Upgrade to $DBversion done (Bug 12538 - Remove SearchEngine syspref)\n";
8848 SetVersion($DBversion);
8851 $DBversion = "3.17.00.028";
8852 if ( CheckVersion($DBversion) ) {
8854 INSERT INTO systempreferences (variable,value) VALUES('OpacCustomSearch','');
8856 print "Upgrade to $DBversion done (Bug 12296 - search box replaceable with a system preference)\n";
8857 SetVersion($DBversion);
8860 $DBversion = "3.17.00.029";
8861 if ( CheckVersion($DBversion) ) {
8862 $dbh->do("ALTER TABLE `items` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8863 $dbh->do("ALTER TABLE `deleteditems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8864 $dbh->do("ALTER TABLE `biblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8865 $dbh->do("ALTER TABLE `deletedbiblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8866 print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
8867 SetVersion ($DBversion);
8870 $DBversion = "3.17.00.030";
8871 if ( CheckVersion($DBversion) ) {
8874 INSERT INTO systempreferences (variable, value, options, explanation, type )
8876 ('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'Choice'),
8877 ('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8878 ('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8879 ('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
8880 ('UsageStatsLibraryType', 'public', 'public|university', 'The library type to be shown on the Hea Koha community website', 'Choice'),
8881 ('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
8882 ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo')
8884 print "Upgrade to $DBversion done (Bug 11926: Add UsageStats systempreferences (HEA))\n";
8885 SetVersion ($DBversion);
8888 $DBversion = "3.17.00.031";
8889 if ( CheckVersion($DBversion) ) {
8890 $dbh->do("ALTER TABLE saved_sql CHANGE report_name report_name VARCHAR( 255 ) NOT NULL DEFAULT '' ");
8891 print "Upgrade to $DBversion done (Bug 2969: Report Name should be mandatory for saved reports)\n";
8892 SetVersion ($DBversion);
8895 $DBversion = "3.17.00.032";
8896 if ( CheckVersion($DBversion) ) {
8898 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReplytoDefault', '', NULL, 'The default email address to be set as replyto.', 'Free')"
8901 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReturnpathDefault', '', NULL, 'The default email address to be set as return-path', 'Free')"
8903 $dbh->do("ALTER TABLE branches ADD branchreplyto mediumtext AFTER branchemail");
8904 $dbh->do("ALTER TABLE branches ADD branchreturnpath mediumtext AFTER branchreplyto");
8905 print "Upgrade to $DBversion done (Bug 9530: Adding replyto and returnpath addresses.)\n";
8906 SetVersion($DBversion);
8909 $DBversion = "3.17.00.033";
8910 if ( CheckVersion($DBversion) ) {
8912 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
8913 VALUES('FacetMaxCount', '20','Specify the max facet count for each category',NULL,'Integer')
8915 print "Upgrade to $DBversion done (Bug 13088 - Allow the user to specify a max amount of facets to show)\n";
8916 SetVersion($DBversion);
8919 $DBversion = "3.17.00.034";
8920 if ( CheckVersion($DBversion) ) {
8922 ALTER TABLE aqorders DROP COLUMN cancelledby;
8925 print "Upgrade to $DBversion done (Bug 11007 - DROP column aqorders.cancelledby)\n";
8926 SetVersion($DBversion);
8929 $DBversion = "3.17.00.035";
8930 if ( CheckVersion($DBversion) ) {
8932 ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0 after claimdate
8936 SET claims_count = 1
8937 WHERE claimdate IS NOT NULL
8939 print "Upgrade to $DBversion done (Bug 5342: Add claims_count field in serial table)\n";
8940 SetVersion($DBversion);
8943 $DBversion = "3.17.00.036";
8944 if ( CheckVersion($DBversion) ) {
8945 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowLibrariesPulldownMobile'");
8946 print "Upgrade to $DBversion done ( Bug 12513 - PROG/CCSR deprecation: Remove OpacShowLibrariesPulldownMobile system preference )\n";
8947 SetVersion ($DBversion);
8950 $DBversion = "3.17.00.037";
8951 if ( CheckVersion($DBversion) ) {
8952 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlockMobile'");
8953 print "Upgrade to $DBversion done ( Bug 12246 - PROG/CCSR deprecation: Remove OpacMainUserBlockMobile system preference )\n";
8954 SetVersion ($DBversion);
8957 $DBversion = "3.17.00.038";
8958 if ( CheckVersion($DBversion) ) {
8959 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACMobileUserCSS'");
8960 print "Upgrade to $DBversion done ( Bug 12245 - PROG/CCSR deprecation: Remove OPACMobileUserCSS system preference )\n";
8961 SetVersion ($DBversion);
8964 $DBversion = "3.17.00.039";
8965 if ( CheckVersion($DBversion) ) {
8966 $dbh->do("INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
8967 ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes')");
8968 print "Upgrade to $DBversion done (Bug 12539 - PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm)\n";
8969 SetVersion ($DBversion);
8972 $DBversion = "3.17.00.040";
8973 if ( CheckVersion($DBversion) ) {
8974 my $opac_theme = C4::Context->preference( 'opacthemes' );
8975 if ( !defined $opac_theme || $opac_theme eq 'prog' || $opac_theme eq 'ccsr' ) {
8976 $dbh->do("UPDATE systempreferences SET value='bootstrap' WHERE variable='opacthemes'");
8978 print "Upgrade to $DBversion done (Bug 12223: 'prog' and 'ccsr' themes removed)\n";
8979 SetVersion($DBversion);
8982 $DBversion = "3.17.00.041";
8983 if ( CheckVersion($DBversion) ) {
8984 print "Upgrade to $DBversion done (Bug 11346: Deprecate the 'prog' and 'CCSR' themes)\n";
8985 SetVersion($DBversion);
8988 $DBversion = "3.17.00.042";
8989 if ( CheckVersion($DBversion) ) {
8990 $dbh->do("DELETE FROM systempreferences WHERE variable='yuipath'");
8991 print "Upgrade to $DBversion done (Bug 12494: Remove yuipath system preference)\n";
8992 SetVersion ($DBversion);
8995 $DBversion = "3.17.00.043";
8996 if ( CheckVersion($DBversion) ) {
8998 ALTER TABLE aqorders
8999 ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted
9001 print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n";
9002 SetVersion ($DBversion);
9005 $DBversion = "3.17.00.044";
9006 if ( CheckVersion($DBversion) ) {
9008 INSERT IGNORE INTO systempreferences
9009 (variable,value,explanation,options,type)
9010 VALUES('OnSiteCheckouts','0','Enable/Disable the on-site checkouts feature','','YesNo');
9013 INSERT IGNORE INTO systempreferences
9014 (variable,value,explanation,options,type)
9015 VALUES('OnSiteCheckoutsForce','0','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','','YesNo');
9018 ALTER TABLE issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9021 ALTER TABLE old_issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9023 print "Upgrade to $DBversion done (Bug 10860: Add new system preference OnSiteCheckouts + fields [old_]issues.onsite_checkout)\n";
9024 SetVersion($DBversion);
9027 $DBversion = "3.17.00.045";
9028 if ( CheckVersion($DBversion) ) {
9030 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9031 ('LocalHoldsPriority', '0', NULL, 'Enables the LocalHoldsPriority feature', 'YesNo'),
9032 ('LocalHoldsPriorityItemControl', 'holdingbranch', 'holdingbranch|homebranch', 'decides if the feature operates using the item''s home or holding library.', 'Choice'),
9033 ('LocalHoldsPriorityPatronControl', 'PickupLibrary', 'HomeLibrary|PickupLibrary', 'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.', 'Choice')
9035 print "Upgrade to $DBversion done (Bug 11126 - Make the holds system optionally give precedence to local holds)\n";
9036 SetVersion($DBversion);
9039 $DBversion = "3.17.00.046";
9040 if ( CheckVersion($DBversion) ) {
9042 CREATE TABLE IF NOT EXISTS items_search_fields (
9043 name VARCHAR(255) NOT NULL,
9044 label VARCHAR(255) NOT NULL,
9045 tagfield CHAR(3) NOT NULL,
9046 tagsubfield CHAR(1) NULL DEFAULT NULL,
9047 authorised_values_category VARCHAR(16) NULL DEFAULT NULL,
9049 CONSTRAINT items_search_fields_authorised_values_category
9050 FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
9051 ON DELETE SET NULL ON UPDATE CASCADE
9052 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9054 print "Upgrade to $DBversion done (Bug 11425: Add items_search_fields table)\n";
9055 SetVersion($DBversion);
9058 $DBversion = "3.17.00.047";
9059 if ( CheckVersion($DBversion) ) {
9061 ALTER TABLE collections
9062 CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL,
9063 ADD INDEX ( colBranchcode ),
9064 ADD CONSTRAINT collections_ibfk_1 FOREIGN KEY (colBranchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
9066 print "Upgrade to $DBversion done (Bug 8836 - Resurrect Rotating Collections)\n";
9067 SetVersion($DBversion);
9070 $DBversion = "3.17.00.048";
9071 if ( CheckVersion($DBversion) ) {
9073 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('RentalFeesCheckoutConfirmation', '0', NULL , 'Allow user to confirm when checking out an item with rental fees.', 'YesNo')
9075 print "Upgrade to $DBversion done (Bug 12448 - Add RentalFeesCheckoutConfirmation syspref)\n";
9076 SetVersion($DBversion);
9079 $DBversion = "3.17.00.049";
9080 if ( CheckVersion($DBversion) ) {
9081 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'am', 'language', 'Amharic','2014-10-29')");
9082 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'am','amh')");
9083 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'am', 'አማርኛ')");
9084 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'en', 'Amharic')");
9086 $dbh->do("UPDATE language_descriptions SET description = 'لعربية' WHERE subtag = 'ar' AND type = 'language' AND lang = 'ar'");
9088 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'az', 'language', 'Azerbaijani','2014-10-30')");
9089 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'az','aze')");
9090 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'az', 'Azərbaycan dili')");
9091 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'en', 'Azerbaijani')");
9093 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'be', 'language', 'Byelorussian','2014-10-30')");
9094 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'be','bel')");
9095 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'be', 'Беларуская мова')");
9096 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'en', 'Byelorussian')");
9098 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'bn', 'language', 'Bengali','2014-10-30')");
9099 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'bn','ben')");
9100 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'bn', 'বাংলা')");
9101 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'en', 'Bengali')");
9103 $dbh->do("UPDATE language_descriptions SET description = 'Български' WHERE subtag = 'bg' AND type = 'language' AND lang = 'bg'");
9104 $dbh->do("UPDATE language_descriptions SET description = 'Ceština' WHERE subtag = 'cs' AND type = 'language' AND lang = 'cs'");
9105 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικά' WHERE subtag = 'el' AND type = 'language' AND lang = 'el'");
9106 $dbh->do("UPDATE language_descriptions SET description = 'Español' WHERE subtag = 'es' AND type = 'language' AND lang = 'es'");
9108 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'eu', 'language', 'Basque','2014-10-30')");
9109 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'eu','eus')");
9110 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'eu', 'Euskera')");
9111 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'en', 'Basque')");
9113 $dbh->do("UPDATE language_descriptions SET description = 'فارسى' WHERE subtag = 'fa' AND type = 'language' AND lang = 'fa'");
9114 $dbh->do("UPDATE language_descriptions SET description = 'Suomi' WHERE subtag = 'fi' AND type = 'language' AND lang = 'fi'");
9116 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'fo', 'language', 'Faroese','2014-10-30')");
9117 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'fo','fao')");
9118 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'fo', 'Føroyskt')");
9119 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'en', 'Faroese')");
9121 $dbh->do("UPDATE language_descriptions SET description = 'Français' WHERE subtag = 'fr' AND type = 'language' AND lang = 'fr'");
9122 $dbh->do("UPDATE language_descriptions SET description = 'עִבְרִית' WHERE subtag = 'he' AND type = 'language' AND lang = 'he'");
9123 $dbh->do("UPDATE language_descriptions SET description = 'हिन्दी' WHERE subtag = 'hi' AND type = 'language' AND lang = 'hi'");
9125 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'is', 'language', 'Icelandic','2014-10-30')");
9126 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'is','ice')");
9127 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'is', 'Íslenska')");
9128 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'en', 'Icelandic')");
9130 $dbh->do("UPDATE language_descriptions SET description = '日本語' WHERE subtag = 'ja' AND type = 'language' AND lang = 'ja'");
9132 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Kannada','2014-10-30')");
9133 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka','kan')");
9134 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ಕನ್ನಡ')");
9135 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Kannada')");
9137 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'km', 'language', 'Khmer','2014-10-30')");
9138 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'km','khm')");
9139 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'km', 'language', 'km', 'ភាសាខ្មែរ')");
9140 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'km', 'language', 'en', 'Khmer')");
9142 $dbh->do("UPDATE language_descriptions SET description = '한국어' WHERE subtag = 'ko' AND type = 'language' AND lang = 'ko'");
9144 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ku', 'language', 'Kurdish','2014-05-13')");
9145 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ku','kur')");
9146 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'ku', 'کوردی')");
9147 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'en', 'Kurdish')");
9148 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'fr', 'Kurde')");
9149 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'de', 'Kurdisch')");
9150 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'es', 'Kurdo')");
9152 $dbh->do("UPDATE language_descriptions SET description = 'ພາສາລາວ' WHERE subtag = 'lo' AND type = 'language' AND lang = 'lo'");
9154 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mi', 'language', 'Maori','2014-10-30')");
9155 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mi','mri')");
9156 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'mi', 'Te Reo Māori')");
9157 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'en', 'Maori')");
9159 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mn', 'language', 'Mongolian','2014-10-30')");
9160 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mn','mon')");
9161 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'mn', 'Mонгол')");
9162 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'en', 'Mongolian')");
9164 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mr', 'language', 'Marathi','2014-10-30')");
9165 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mr','mar')");
9166 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'mr', 'मराठी')");
9167 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'en', 'Marathi')");
9169 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ms', 'language', 'Malay','2014-10-30')");
9170 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ms','may')");
9171 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'ms', 'Bahasa melayu')");
9172 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'en', 'Malay')");
9174 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'nb'");
9175 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'en'");
9176 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'fr'");
9177 $dbh->do("UPDATE language_descriptions SET description = 'Norwegisch bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'de'");
9179 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ne', 'language', 'Nepali','2014-10-30')");
9180 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ne','nep')");
9181 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)VALUES ( 'ne', 'language', 'ne', 'नेपाली')");
9182 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ne', 'language', 'en', 'Nepali')");
9184 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'pbr', 'language', 'Pangwa','2014-10-30')");
9185 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'pbr','pbr')");
9186 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'pbr', 'Ekipangwa')");
9187 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'en', 'Pangwa')");
9189 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'prs', 'language', 'Dari','2014-10-30')");
9190 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'prs','prs')");
9191 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'prs', 'درى')");
9192 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'en', 'Dari')");
9194 $dbh->do("UPDATE language_descriptions SET description = 'Português' WHERE subtag = 'pt' AND type = 'language' AND lang = 'pt'");
9195 $dbh->do("UPDATE language_descriptions SET description = 'Român' WHERE subtag = 'ro' AND type = 'language' AND lang = 'ro'");
9196 $dbh->do("UPDATE language_descriptions SET description = 'Русский' WHERE subtag = 'ru' AND type = 'language' AND lang = 'ru'");
9198 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'rw', 'language', 'Kinyarwanda','2014-10-30')");
9199 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'rw','kin')");
9200 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'rw', 'Ikinyarwanda')");
9201 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'en', 'Kinyarwanda')");
9203 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sd', 'language', 'Sindhi','2014-10-30')");
9204 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sd','snd')");
9205 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'sd', 'سنڌي')");
9206 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'en', 'Sindhi')");
9208 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sk', 'language', 'Slovak','2014-10-30')");
9209 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sk','slk')");
9210 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'sk', 'Slovenčina')");
9211 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'en', 'Slovak')");
9213 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sl', 'language', 'Slovene','2014-10-30')");
9214 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sl','slv')");
9215 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'sl', 'Slovenščina')");
9216 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'en', 'Slovene')");
9218 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sq', 'language', 'Albanian','2014-10-30')");
9219 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sq','sqi')");
9220 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'sq', 'Shqip')");
9221 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'en', 'Albanian')");
9223 $dbh->do("UPDATE language_descriptions SET description = 'Cрпски' WHERE subtag = 'sr' AND type = 'language' AND lang = 'sr'");
9225 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sw', 'language', 'Swahili','2014-10-30')");
9226 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sw','swa')");
9227 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'sw', 'Kiswahili')");
9228 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'en', 'Swahili')");
9230 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ta', 'language', 'Tamil','2014-10-30')");
9231 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ta','tam')");
9232 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'ta', 'தமிழ்')");
9233 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'en', 'Tamil')");
9235 $dbh->do("UPDATE language_descriptions SET description = 'Tetun' WHERE subtag = 'tet' AND type = 'language' AND lang = 'tet'");
9236 $dbh->do("UPDATE language_descriptions SET description = 'ภาษาไทย' WHERE subtag = 'th' AND type = 'language' AND lang = 'th'");
9238 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'tl', 'language', 'Tagalog','2014-10-30')");
9239 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'tl','tgl')");
9240 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'tl', 'Tagalog')");
9241 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'en', 'Tagalog')");
9243 $dbh->do("UPDATE language_descriptions SET description = 'Türkçe' WHERE subtag = 'tr' AND type = 'language' AND lang = 'tr'");
9244 $dbh->do("UPDATE language_descriptions SET description = 'Українська' WHERE subtag = 'uk' AND type = 'language' AND lang = 'uk'");
9245 $dbh->do("UPDATE language_descriptions SET description = 'اردو' WHERE subtag = 'ur' AND type = 'language' AND lang = 'ur'");
9247 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'vi', 'language', 'Vietnamese','2014-10-30')");
9248 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'vi','vie')");
9249 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'vi', '㗂越')");
9250 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'en', 'Vietnamese')");
9252 $dbh->do("UPDATE language_descriptions SET description = '中文' WHERE subtag = 'zh' AND type = 'language' AND lang = 'zh'");
9253 $dbh->do("UPDATE language_descriptions SET description = '' WHERE subtag = 'Arab,script' AND type = 'Arab' AND lang = 'العربية'");
9255 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Armn', 'script', 'Armenian','2014-10-30')");
9256 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Armn', 'script', 'Armn', 'Հայոց այբուբեն')");
9257 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Armn', 'script', 'en', 'Armenian')");
9259 $dbh->do("UPDATE language_descriptions SET description = 'Кирилица' WHERE subtag = 'Cyrl' AND type = 'script' AND lang = 'Cyrl'");
9261 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Ethi', 'script', 'Ethiopic','2014-10-30')");
9262 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Ethi', 'script', 'Ethi', 'ግዕዝ')");
9263 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Ethi', 'script', 'en', 'Ethiopic')");
9265 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικό αλφάβητο' WHERE subtag = 'Grek' AND type = 'script' AND lang = 'Grek'");
9266 $dbh->do("UPDATE language_descriptions SET description = '简体字' WHERE subtag = 'Hans' AND type = 'script' AND lang = 'Hans'");
9267 $dbh->do("UPDATE language_descriptions SET description = '繁體字' WHERE subtag = 'Hant' AND type = 'script' AND lang = 'Hant'");
9268 $dbh->do("UPDATE language_descriptions SET description = 'אָלֶף־בֵּית עִבְרִי' WHERE subtag = 'Hebr' AND type = 'script' AND lang = 'Hebr'");
9270 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Jpan', 'script', 'Japanese','2014-10-30')");
9271 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Jpan', 'script', 'Jpan', '漢字')");
9272 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Jpan', 'script', 'en', 'Japanese')");
9274 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Knda', 'script', 'Kannada','2014-10-30')");
9275 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Knda', 'script', 'Knda', 'ಕನ್ನಡ ಲಿಪಿ')");
9276 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Knda', 'script', 'en', 'Kannada')");
9278 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Kore', 'script', 'Korean','2014-10-30')");
9279 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Kore', 'script', 'Kore', '한글')");
9280 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Kore', 'script', 'en', 'Korean')");
9282 $dbh->do("UPDATE language_descriptions SET description = 'ອັກສອນລາວ' WHERE subtag = 'Laoo' AND type = 'script' AND lang = 'Laoo'");
9284 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AL', 'region', 'Albania','2014-10-30')");
9285 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'en', 'Albania')");
9286 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'sq', 'Shqipërisë')");
9288 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AZ', 'region', 'Azerbaijan','2014-10-30')");
9289 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'en', 'Azerbaijan')");
9290 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'az', 'Azərbaycan')");
9292 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BE', 'region', 'Belgium','2014-10-30')");
9293 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'en', 'Belgium')");
9294 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'nl', 'België')");
9296 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BR', 'region', 'Brazil','2014-10-30')");
9297 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'en', 'Brazil')");
9298 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'pt', 'Brasil')");
9300 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BY', 'region', 'Belarus','2014-10-30')");
9301 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'en', 'Belarus')");
9302 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'be', 'Беларусь')");
9304 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CA', 'region', 'fr', 'Canada')");
9306 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CH', 'region', 'Switzerland','2014-10-30')");
9307 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'en', 'Switzerland')");
9308 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'de', 'Schweiz')");
9310 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CN', 'region', 'China','2014-10-30')");
9311 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'en', 'China')");
9312 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'zh', '中国')");
9314 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CZ', 'region', 'Czech Republic','2014-10-30')");
9315 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'en', 'Czech Republic')");
9316 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'cs', 'Česká republika')");
9318 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'DE', 'region', 'Germany','2014-10-30')");
9319 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'en', 'Germany')");
9320 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'de', 'Deutschland')");
9322 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DK', 'region', 'en', 'Denmark')");
9324 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ES', 'region', 'Spain','2014-10-30')");
9325 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'en', 'Spain')");
9326 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'es', 'España')");
9328 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FI', 'region', 'Finland','2014-10-30')");
9329 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'en', 'Finland')");
9330 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'fi', 'Suomi')");
9332 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FO', 'region', 'Faroe Islands','2014-10-30')");
9333 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'en', 'Faroe Islands')");
9334 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'fo', 'Føroyar')");
9336 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'GR', 'region', 'Greece','2014-10-30')");
9337 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'en', 'Greece')");
9338 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'el', 'Ελλάδα')");
9340 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HR', 'region', 'Croatia','2014-10-30')");
9341 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'en', 'Croatia')");
9342 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'hr', 'Hrvatska')");
9344 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HU', 'region', 'Hungary','2014-10-30')");
9345 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'en', 'Hungary')");
9346 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'hu', 'Magyarország')");
9348 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ID', 'region', 'Indonesia','2014-10-30')");
9349 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'en', 'Indonesia')");
9350 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'id', 'Indonesia')");
9352 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IS', 'region', 'Iceland','2014-10-30')");
9353 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'en', 'Iceland')");
9354 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'is', 'Ísland')");
9356 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IT', 'region', 'Italy','2014-10-30')");
9357 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'en', 'Italy')");
9358 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'it', 'Italia')");
9360 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'JP', 'region', 'Japan','2014-10-30')");
9361 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'en', 'Japan')");
9362 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'ja', '日本')");
9364 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KE', 'region', 'Kenya','2014-10-30')");
9365 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'en', 'Kenya')");
9366 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'rw', 'Kenya')");
9368 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KH', 'region', 'Cambodia','2014-10-30')");
9369 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'en', 'Cambodia')");
9370 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'km', 'កម្ពុជា')");
9372 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KP', 'region', 'North Korea','2014-10-30')");
9373 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'en', 'North Korea')");
9374 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'ko', '조선민주주의인민공화국')");
9376 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'LK', 'region', 'Sri Lanka','2014-10-30')");
9377 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'en', 'Sri Lanka')");
9378 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'ta', 'இலங்கை')");
9380 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'MY', 'region', 'Malaysia','2014-10-30')");
9381 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'en', 'Malaysia')");
9382 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'ms', 'Malaysia')");
9384 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NE', 'region', 'Niger','2014-10-30')");
9385 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'en', 'Niger')");
9386 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'ne', 'Niger')");
9388 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NL', 'region', 'Netherlands','2014-10-30')");
9389 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'en', 'Netherlands')");
9390 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'nl', 'Nederland')");
9392 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NO', 'region', 'Norway','2014-10-30')");
9393 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'en', 'Norway')");
9394 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'ne', 'Noreg')");
9395 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'nn', 'Noreg')");
9397 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PH', 'region', 'Philippines','2014-10-30')");
9398 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'en', 'Philippines')");
9399 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'tl', 'Pilipinas')");
9401 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PK', 'region', 'Pakistan','2014-10-30')");
9402 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'en', 'Pakistan')");
9403 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'sd', 'پاكستان')");
9405 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PL', 'region', 'Poland','2014-10-30')");
9406 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'en', 'Poland')");
9407 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'pl', 'Polska')");
9409 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PT', 'region', 'Portugal','2014-10-30')");
9410 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'en', 'Portugal')");
9411 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'pt', 'Portugal')");
9413 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RO', 'region', 'Romania','2014-10-30')");
9414 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'en', 'Romania')");
9415 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'ro', 'România')");
9417 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RU', 'region', 'Russia','2014-10-30')");
9418 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'en', 'Russia')");
9419 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'ru', 'Россия')");
9421 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RW', 'region', 'Rwanda','2014-10-30')");
9422 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'en', 'Rwanda')");
9423 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'rw', 'Rwanda')");
9425 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SE', 'region', 'Sweden','2014-10-30')");
9426 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'en', 'Sweden')");
9427 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'sv', 'Sverige')");
9429 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SI', 'region', 'Slovenia','2014-10-30')");
9430 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'en', 'Slovenia')");
9431 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'sl', 'Slovenija')");
9433 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SK', 'region', 'Slovakia','2014-10-30')");
9434 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'en', 'Slovakia')");
9435 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'sk', 'Slovensko')");
9437 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TH', 'region', 'Thailand','2014-10-30')");
9438 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'en', 'Thailand')");
9439 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'th', 'ประเทศไทย')");
9441 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TR', 'region', 'Turkey','2014-10-30')");
9442 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'en', 'Turkey')");
9443 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'tr', 'Türkiye')");
9445 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TW', 'region', 'Taiwan','2014-10-30')");
9446 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'en', 'Taiwan')");
9447 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'zh', '台灣')");
9449 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'UA', 'region', 'Ukraine','2014-10-30')");
9450 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'en', 'Ukraine')");
9451 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'uk', 'Україна')");
9453 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'VN', 'region', 'Vietnam','2014-10-30')");
9454 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'en', 'Vietnam')");
9455 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'vi', 'Việt Nam')");
9457 print "Upgrade to $DBversion done (Bug 12250: Update descriptions for languages, scripts and regions)\n";
9458 SetVersion($DBversion);
9461 $DBversion = "3.17.00.050";
9462 if ( CheckVersion($DBversion) ) {
9464 INSERT INTO permissions (module_bit, code, description) VALUES
9465 (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)')
9467 print "Upgrade to $DBversion done (Bug 12403: Add permission tools_records_batchdelitem)\n";
9468 SetVersion($DBversion);
9471 $DBversion = "3.17.00.051";
9472 if ( CheckVersion($DBversion) ) {
9473 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('GoogleIndicTransliteration','0','','GoogleIndicTransliteration on the OPAC.','YesNo')");
9474 print "Upgrade to $DBversion done (Bug 13211: Added system preferences GoogleIndicTransliteration on the OPAC)\n";
9475 SetVersion($DBversion);
9478 $DBversion = "3.17.00.052";
9479 if ( CheckVersion($DBversion) ) {
9481 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearchOptions','pubdate|itemtype|language|sorting|location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple');
9485 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearchMoreOptions','pubdate|itemtype|language|subtype|sorting|location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple');
9487 print "Upgrade to $DBversion done (Bug 9043: Add system preference OpacAdvSearchOptions and OpacAdvSearchMoreOptions)\n";
9488 SetVersion ($DBversion);
9491 $DBversion = "3.17.00.053";
9492 if ( CheckVersion($DBversion) ) {
9494 INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)');
9498 INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
9502 INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'items_batchmod_restricted', 'Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)');
9505 # The delete_all_items permission should be added to users having the edit_items permission.
9507 INSERT INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, module_bit, "delete_all_items" FROM user_permissions WHERE code="edit_items";
9512 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j','','Free');
9516 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j','','Free');
9519 print "Upgrade to $DBversion done (Bug 7673: Adds 2 new prefs (SubfieldsToAllowForRestrictedEditing and SubfieldsToAllowForRestrictedBatchmod) and 3 new permissions (edit_items_restricted and delete_all_items and items_batchmod_restricted))\n";
9520 SetVersion($DBversion);
9523 $DBversion = "3.17.00.054";
9524 if (CheckVersion($DBversion)) {
9526 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9527 ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo')
9529 print "Upgrade to $DBversion done (Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds)\n";
9530 SetVersion($DBversion);
9533 $DBversion = "3.17.00.055";
9534 if ( CheckVersion($DBversion) ) {
9535 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEnable', '0', NULL, 'Enable communication with the Norwegian national patron database.', 'YesNo')");
9536 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEndpoint', '', NULL, 'Which NL endpoint to use.', 'Free')");
9537 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBUsername', '', NULL, 'Username for communication with the Norwegian national patron database.', 'Free')");
9538 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBPassword', '', NULL, 'Password for communication with the Norwegian national patron database.', 'Free')");
9539 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBSearchNLAfterLocalHit','0',NULL,'Search NL if a search has already given one or more local hits?.','YesNo')");
9541 CREATE TABLE borrower_sync (
9542 borrowersyncid int(11) NOT NULL AUTO_INCREMENT,
9543 borrowernumber int(11) NOT NULL,
9544 synctype varchar(32) NOT NULL,
9545 sync tinyint(1) NOT NULL DEFAULT '0',
9546 syncstatus varchar(10) DEFAULT NULL,
9547 lastsync varchar(50) DEFAULT NULL,
9548 hashed_pin varchar(64) DEFAULT NULL,
9549 PRIMARY KEY (borrowersyncid),
9550 KEY borrowernumber (borrowernumber),
9551 CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9552 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
9554 print "Upgrade to $DBversion done (Bug 11401 - Add support for Norwegian national library card)\n";
9555 SetVersion($DBversion);
9558 $DBversion = "3.17.00.056";
9559 if ( CheckVersion($DBversion) ) {
9561 UPDATE systempreferences SET value = 'pubdate,itemtype,language,sorting,location' WHERE variable='OpacAdvSearchOptions'
9565 UPDATE systempreferences SET value = 'pubdate,itemtype,language,subtype,sorting,location' WHERE variable='OpacAdvSearchMoreOptions'
9568 print "Upgrade to $DBversion done (Bug 9043 - Update the values for OpacAdvSearchOptions and OpacAdvSearchOptions)\n";
9569 SetVersion($DBversion);
9572 $DBversion = "3.17.00.057";
9573 if ( CheckVersion($DBversion) ) {
9574 print "Upgrade to $DBversion done (Koha 3.18 beta)\n";
9575 SetVersion ($DBversion);
9578 $DBversion = "3.17.00.058";
9579 if( CheckVersion($DBversion) ){
9580 $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueChargeValue','Charge a lost item to the borrower account when the LOST value of the item changes to n', 'integer')");
9581 $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueLostValue', 'Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.', 'integer')");
9582 $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueDays', 'Set the LOST value of an item when the item has been overdue for more than n days.', 'integer')");
9583 print "Upgrade to $DBversion done (Bug 8337: System preferences for longoverdue cron)\n";
9584 SetVersion($DBversion);
9587 $DBversion = "3.17.00.059";
9588 if ( CheckVersion($DBversion) ) {
9590 UPDATE permissions SET description = "Add and delete budgets (but can't modifiy budgets)" WHERE description = "Add and delete budgets (but cant modify budgets)";
9592 print "Upgrade to $DBversion done (Bug 10749: Fix typo in budget_add_del permission description)\n";
9593 SetVersion ($DBversion);
9596 $DBversion = "3.17.00.060";
9597 if ( CheckVersion($DBversion) ) {
9598 my $count_l = $dbh->selectcol_arrayref(q|
9599 SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
9601 my $count_mq = $dbh->selectcol_arrayref(q|
9602 SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
9604 my $count_ott = $dbh->selectcol_arrayref(q|
9605 SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
9607 my $count_mt = $dbh->selectcol_arrayref(q|
9608 SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
9610 my $count_bmtp = $dbh->selectcol_arrayref(q|
9611 SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
9615 if ( $count_l->[0] == 0 and $count_mq->[0] == 0 and $count_ott->[0] == 0 and $count_mt->[0] == 0 and $count_bmtp->[0] == 0 ) {
9616 $deleted = $dbh->do(q|
9617 DELETE FROM message_transport_types where message_transport_type='feed'
9619 $deleted = $deleted ne '0E0' ? 1 : 0;
9622 print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
9623 SetVersion($DBversion);
9626 $DBversion = "3.18.00.000";
9627 if ( CheckVersion($DBversion) ) {
9628 print "Upgrade to $DBversion done (3.18.0 release)\n";
9629 SetVersion($DBversion);
9632 $DBversion = "3.19.00.000";
9633 if ( CheckVersion($DBversion) ) {
9634 print "Upgrade to $DBversion done (there's life after 3.18)\n";
9635 SetVersion ($DBversion);
9638 $DBversion = "3.19.00.001";
9639 if ( CheckVersion($DBversion) ) {
9641 UPDATE systempreferences
9642 SET options = 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription'
9643 WHERE variable = 'UsageStatsLibraryType'
9645 if ( C4::Context->preference("UsageStatsLibraryType") eq "university" ) {
9646 C4::Context->set_preference("UsageStatsLibraryType", "academic")
9648 print "Upgrade to $DBversion done (Bug 13436: Add more options to UsageStatsLibraryType)\n";
9649 SetVersion ($DBversion);
9652 $DBversion = "3.19.00.002";
9653 if ( CheckVersion($DBversion) ) {
9655 UPDATE suggestions SET branchcode="" WHERE branchcode="__ANY__"
9657 print "upgrade to $DBversion done (Bug 10753: replace __ANY__ with empty string in suggestions.branchcode)\n";
9658 SetVersion ($DBversion);
9661 $DBversion = "3.19.00.003";
9662 if ( CheckVersion($DBversion) ) {
9663 my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1");
9666 print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n";
9667 print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n";
9668 print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)";
9671 ALTER TABLE borrowers
9673 ADD UNIQUE userid (userid)
9675 print "Upgrade to $DBversion done (Bug 1861: Unique patrons logins not (totally) enforced)\n";
9677 SetVersion ($DBversion);
9680 $DBversion = "3.19.00.004";
9681 if ( CheckVersion($DBversion) ) {
9682 my $pref_value = C4::Context->preference('OpacExportOptions');
9683 $pref_value =~ s/\|/,/g; # multiple is separated by ,
9685 UPDATE systempreferences
9688 WHERE variable = 'OpacExportOptions'
9689 }, {}, $pref_value );
9690 print "Upgrade to $DBversion done (Bug 13346: OpacExportOptions is now multiple)\n";
9691 SetVersion ($DBversion);
9694 $DBversion = "3.19.00.005";
9695 if(CheckVersion($DBversion)) {
9697 ALTER TABLE authorised_values MODIFY COLUMN category VARCHAR(32) NOT NULL DEFAULT ''
9701 ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
9704 print "Upgrade to $DBversion done (Bug 13379: Modify authorised_values.category to varchar(32))\n";
9705 SetVersion($DBversion);
9708 $DBversion = "3.19.00.006";
9709 if ( CheckVersion($DBversion) ) {
9710 $dbh->do(q|SET foreign_key_checks = 0|);
9711 my $sth = $dbh->table_info( '','','','TABLE' );
9712 my ( $cat, $schema, $name, $type, $remarks );
9713 while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
9714 my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
9715 $table_sth->execute;
9716 my @table = $table_sth->fetchrow_array;
9717 unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
9718 if ( $name eq 'marc_subfield_structure' ) {
9720 ALTER TABLE marc_subfield_structure
9721 MODIFY COLUMN tagfield varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9722 MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '',
9723 MODIFY COLUMN liblibrarian varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9724 MODIFY COLUMN libopac varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9725 MODIFY COLUMN kohafield varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
9726 MODIFY COLUMN authorised_value varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9727 MODIFY COLUMN authtypecode varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9728 MODIFY COLUMN value_builder varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL,
9729 MODIFY COLUMN frameworkcode varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9730 MODIFY COLUMN seealso varchar(1100) COLLATE utf8_unicode_ci DEFAULT NULL,
9731 MODIFY COLUMN link varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL
9733 $dbh->do(qq|ALTER TABLE $name CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9736 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9740 $dbh->do(q|SET foreign_key_checks = 1|);;
9742 print "Upgrade to $DBversion done (Bug 11944: Convert DB tables to utf8_unicode_ci)\n";
9743 SetVersion($DBversion);
9746 $DBversion = "3.19.00.007";
9747 if ( CheckVersion($DBversion) ) {
9748 my $orphan_budgets = $dbh->selectall_arrayref(q|
9749 SELECT budget_id, budget_name, budget_code
9751 WHERE budget_parent_id IS NOT NULL
9752 AND budget_parent_id NOT IN (
9753 SELECT DISTINCT budget_id FROM aqbudgets
9755 |, { Slice => {} } );
9757 if ( @$orphan_budgets ) {
9758 for my $b ( @$orphan_budgets ) {
9759 print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n";
9761 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n";
9763 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n";
9765 SetVersion ($DBversion);
9768 $DBversion = "3.19.00.008";
9769 if ( CheckVersion($DBversion) ) {
9770 my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
9776 WHERE b.budget_id = o.budget_id
9780 if ( $number_of_orders_not_linked->[0] > 0 ) {
9782 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)
9784 my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
9786 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 );
9788 my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
9791 SET budget_id = $budget_id
9795 WHERE b.budget_id = o.budget_id
9801 ALTER TABLE aqorders
9802 ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
9805 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";
9806 SetVersion($DBversion);
9809 $DBversion = "3.19.00.009";
9810 if ( CheckVersion($DBversion) ) {
9812 UPDATE suggestions s SET s.budgetid = NULL
9816 WHERE b.budget_id = s.budgetid
9821 ALTER TABLE suggestions
9822 ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9825 print "Upgrade to $DBversion done (Bug 13007: Add new foreign key suggestions.budgetid)\n";
9826 SetVersion($DBversion);
9829 $DBversion = "3.19.00.010";
9830 if ( CheckVersion($DBversion) ) {
9832 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
9833 VALUES('SessionRestrictionByIP','1','Check for Change in Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')
9835 print "Upgrade to $DBversion done (Bug 5511: SessionRestrictionByIP)\n";
9836 SetVersion ($DBversion);
9839 $DBversion = "3.19.00.011";
9840 if ( CheckVersion($DBversion) ) {
9842 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
9843 (20, 'lists', 'Lists', 0)
9846 INSERT INTO permissions (module_bit, code, description) VALUES
9847 (20, 'delete_public_lists', 'Delete public lists')
9849 print "Upgrade to $DBversion done (Bug 13417: Add permission to delete public lists)\n";
9850 SetVersion ($DBversion);
9853 $DBversion = "3.19.00.012";
9854 if(CheckVersion($DBversion)) {
9856 ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext
9860 ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext
9863 print "Upgrade to $DBversion done (Bug 13523 Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n";
9864 SetVersion ($DBversion);
9867 $DBversion = "3.19.00.013";
9868 if ( CheckVersion($DBversion) ) {
9870 INSERT INTO permissions (module_bit, code, description) VALUES
9871 (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)')
9873 print "Upgrade to $DBversion done (Bug 11395: Add permission tools_records_batchmod)\n";
9874 SetVersion($DBversion);
9877 $DBversion = "3.19.00.014";
9878 if ( CheckVersion($DBversion) ) {
9880 CREATE TABLE aqorder_users (
9881 ordernumber int(11) NOT NULL,
9882 borrowernumber int(11) NOT NULL,
9883 PRIMARY KEY (ordernumber, borrowernumber),
9884 CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9885 CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9886 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9890 INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
9891 VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
9893 print "Upgrade to $DBversion done (Bug 12648: Add letter ACQ_NOTIF_ON_RECEIV )\n";
9894 SetVersion ($DBversion);
9897 $DBversion = "3.19.00.015";
9898 if ( CheckVersion($DBversion) ) {
9900 ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id);
9902 print "Upgrade to $DBversion done (Bug 11430: Add primary key for search_history)\n";
9903 SetVersion ($DBversion);
9906 $DBversion = "3.19.00.016";
9907 if(CheckVersion($DBversion)) {
9908 my @order_cancellation_reason = $dbh->selectrow_array("SELECT count(*) FROM authorised_values WHERE category='ORDER_CANCELLATION_REASON'");
9909 if ($order_cancellation_reason[0] == 0) {
9911 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9912 ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'),
9913 ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'),
9914 ('ORDER_CANCELLATION_REASON', 2, 'Restocking')
9917 my $already_existing_reasons = $dbh->selectcol_arrayref(q{
9918 SELECT DISTINCT( cancellationreason )
9920 }, { Slice => {} });
9922 my $update_orders_sth = $dbh->prepare(q{
9924 SET cancellationreason = ?
9925 WHERE cancellationreason = ?
9928 my $insert_av_sth = $dbh->prepare(q{
9929 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9930 ('ORDER_CANCELLATION_REASON', ?, ?)
9933 for my $reason ( @$already_existing_reasons ) {
9934 next unless $reason;
9935 $insert_av_sth->execute( $i, $reason );
9936 $update_orders_sth->execute( $i, $reason );
9939 print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n";
9942 print "Upgrade to $DBversion done (Bug 13380: ORDER_CANCELLATION_REASON authorised value already existed from earlier update!)\n";
9945 SetVersion($DBversion);
9948 $DBversion = '3.19.00.017';
9949 if ( CheckVersion($DBversion) ) {
9950 # First create the column
9951 $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL");
9952 # Now update the column
9953 if (C4::Context->preference("AllowOnShelfHolds")){
9954 # Pref is on, set allow for all rules
9955 $dbh->do("UPDATE issuingrules SET onshelfholds=1");
9957 # If the preference is not set, leave off
9958 $dbh->do("UPDATE issuingrules SET onshelfholds=0");
9960 # Remove from the systempreferences table
9961 $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'");
9963 # First create the column
9964 $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL");
9965 # Now update the column
9966 my $opacitemholds = C4::Context->preference("OPACItemHolds") || '';
9967 if (lc ($opacitemholds) eq 'force') {
9968 $opacitemholds = 'F';
9971 $opacitemholds = $opacitemholds ? 'Y' : 'N';
9973 # Set allow for all rules
9974 $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'");
9976 # Remove from the systempreferences table
9977 $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'");
9979 print "Upgrade to $DBversion done (Bug 5786: Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n";
9980 SetVersion ($DBversion);
9984 $DBversion = "3.19.00.018";
9985 if ( CheckVersion($DBversion) ) {
9987 UPDATE systempreferences set variable="OpacAdditionalStylesheet" WHERE variable="opaccolorstylesheet"
9989 print "Upgrade to $DBversion done (Bug 10328: Rename opaccolorstylesheet to OpacAdditionalStylesheet\n";
9990 SetVersion ($DBversion);
9993 $DBversion = "3.19.00.019";
9994 if ( CheckVersion($DBversion) ) {
9996 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
9997 VALUES('Coce','0', 'If on, enables cover retrieval from the configured Coce server', NULL, 'YesNo')
10000 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
10001 VALUES('CoceHost', NULL, 'Coce server URL', NULL,'Free')
10004 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
10005 VALUES('CoceProviders', NULL, 'Coce providers', 'aws,gb,ol', 'multiple')
10007 print "Upgrade to $DBversion done (Bug 9580: Cover image from Coce, a remote image URL cache)\n";
10008 SetVersion($DBversion);
10011 $DBversion = "3.19.00.020";
10012 if ( CheckVersion($DBversion) ) {
10014 ALTER TABLE aqorders DROP COLUMN supplierreference;
10017 print "Upgrade to $DBversion done (Bug 11008: DROP column aqorders.supplierreference)\n";
10018 SetVersion($DBversion);
10021 $DBversion = "3.19.00.021";
10022 if ( CheckVersion($DBversion) ) {
10024 ALTER TABLE issues DROP COLUMN issuingbranch
10027 ALTER TABLE old_issues DROP COLUMN issuingbranch
10029 print "Upgrade to $DBversion done (Bug 2806: Remove issuingbranch columns)\n";
10030 SetVersion ($DBversion);
10033 $DBversion = '3.19.00.022';
10034 if ( CheckVersion($DBversion) ) {
10036 ALTER TABLE suggestions DROP COLUMN mailoverseeing;
10038 print "Upgrade to $DBversion done (Bug 13006: Drop column suggestion.mailoverseeing)\n";
10039 SetVersion($DBversion);
10042 $DBversion = "3.19.00.023";
10043 if ( CheckVersion($DBversion) ) {
10045 DELETE FROM systempreferences where variable = 'AddPatronLists'
10047 print "Upgrade to $DBversion done (Bug 13497: Remove the AddPatronLists system preferences)\n";
10048 SetVersion ($DBversion);
10051 $DBversion = "3.19.00.024";
10052 if ( CheckVersion($DBversion) ) {
10053 $dbh->do(qq|DROP table patroncards;|);
10054 print "Upgrade to $DBversion done (Bug 13539: Remove table patroncards from database as it's no longer in use)\n";
10055 SetVersion ($DBversion);
10058 $DBversion = "3.19.00.025";
10059 if ( CheckVersion($DBversion) ) {
10061 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
10062 ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo')
10064 print "Upgrade to $DBversion done (Bug 13528: Add the SearchWithISBNVariations syspref)\n";
10065 SetVersion ($DBversion);
10068 $DBversion = "3.19.00.026";
10069 if( CheckVersion($DBversion) ) {
10070 if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
10072 INSERT IGNORE INTO auth_tag_structure (authtypecode, tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value) VALUES
10073 ('', '388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL);
10077 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10078 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10079 ('', '388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10080 ('', '388', '2', 'Source of term', 'Source of term', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10081 ('', '388', '3', 'Materials specified', 'Materials specified', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10082 ('', '388', '6', 'Linkage', 'Linkage', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10083 ('', '388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10084 ('', '388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', '');
10088 UPDATE IGNORE auth_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND tagfield IN
10089 ('100','110','111','130','400','410','411','430','500','510','511','530','700','710','730');
10093 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10094 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10095 ('', '150', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10096 ('', '151', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10097 ('', '450', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10098 ('', '451', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10099 ('', '550', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10100 ('', '551', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10101 ('', '750', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10102 ('', '751', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10103 ('', '748', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10104 ('', '755', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10105 ('', '780', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10106 ('', '781', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10107 ('', '782', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10108 ('', '785', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10109 ('', '710', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10110 ('', '730', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10111 ('', '748', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10112 ('', '750', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10113 ('', '751', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10114 ('', '755', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10115 ('', '762', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10116 ('', '780', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10117 ('', '781', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10118 ('', '782', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10119 ('', '785', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10120 ('', '788', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', '');
10124 UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship information', libopac = 'Relationship information'
10125 WHERE tagsubfield = 'i' AND tagfield IN ('700','710','730','750','751','762');
10129 UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship code', libopac = 'Relationship code'
10130 WHERE tagsubfield = '4' AND tagfield IN ('700','710');
10134 INSERT IGNORE INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) VALUES
10135 ('370', 'ASSOCIATED PLACE', 'ASSOCIATED PLACE', 1, 0, NULL, ''),
10136 ('388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL, '');
10140 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
10141 kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
10142 ('370', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10143 ('370', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10144 ('370', '6', 'Linkage', 'Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10145 ('370', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10146 ('370', 'c', 'Associated country', 'Associated country', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10147 ('370', 'f', 'Other associated place', 'Other associated place', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10148 ('370', 'g', 'Place of origin of work', 'Place of origin of work', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10149 ('370', 's', 'Start period', 'Start period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10150 ('370', 't', 'End period', 'End period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10151 ('370', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10152 ('370', 'v', 'Source of information', 'Source of information', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10153 ('377', 'l', 'Language term', 'Language term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10154 ('382', 's', 'Total number of performers', 'Total number of performers', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10155 ('388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10156 ('388', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10157 ('388', '3', ' Materials specified', ' Materials specified', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10158 ('388', '6', ' Linkage', ' Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10159 ('388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10160 ('388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10161 ('650', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL),
10162 ('651', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL);
10166 UPDATE IGNORE marc_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND
10167 tagfield IN ('100','110','111','130','240','243','246','247','600','610','611','630','700','710','711','730','800','810','811','830');
10171 print "Upgrade to $DBversion done (Bug 13322: Update MARC21 frameworks to Update No. 19 - October 2014)\n";
10172 SetVersion($DBversion);
10175 $DBversion = '3.19.00.027';
10176 if ( CheckVersion($DBversion) ) {
10177 $dbh->do("ALTER TABLE items ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10178 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10179 print "Upgrade to $DBversion done (Bug 4222: Nonpublic note not appearing in the staff client) <b>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 </b>)\n";
10180 SetVersion($DBversion);
10183 $DBversion = "3.19.00.028";
10184 if( CheckVersion($DBversion) ) {
10186 local $dbh->{PrintError} = 0;
10188 ALTER TABLE issues DROP PRIMARY KEY
10193 ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10197 ALTER TABLE old_issues CHANGE issue_id issue_id INT( 11 ) NOT NULL
10201 ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10205 UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
10208 my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max();
10209 if ($max_issue_id) {
10212 ALTER TABLE issues AUTO_INCREMENT = $max_issue_id
10216 print "Upgrade to $DBversion done (Bug 13790: Add unique id issue_id to issues and oldissues tables)\n";
10217 SetVersion($DBversion);
10220 $DBversion = "3.19.00.029";
10221 if ( CheckVersion($DBversion) ) {
10223 ALTER TABLE sessions CHANGE COLUMN a_session a_session MEDIUMTEXT
10225 print "Upgrade to $DBversion done (Bug 13606: Upgrade sessions.a_session to MEDIUMTEXT)\n";
10226 SetVersion($DBversion);
10229 $DBversion = "3.19.00.030";
10230 if ( CheckVersion($DBversion) ) {
10232 UPDATE language_subtag_registry SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10235 UPDATE language_rfc4646_to_iso639 SET rfc4646_subtag = 'kn' WHERE rfc4646_subtag = 'ka' AND iso639_2_code = 'kan';
10238 UPDATE language_descriptions SET subtag = 'kn', lang = 'kn' WHERE subtag = 'ka' AND lang = 'ka' AND description = 'ಕನ್ನಡ';
10241 UPDATE language_descriptions SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10244 INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Georgian','2015-04-20');
10247 DELETE FROM language_subtag_registry
10250 (SELECT MIN(id) as id,subtag,type,description,added
10251 FROM language_subtag_registry
10252 GROUP BY subtag,type,description,added)
10256 INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka', 'geo');
10259 DELETE FROM language_rfc4646_to_iso639
10262 (SELECT MIN(id) as id,rfc4646_subtag,iso639_2_code
10263 FROM language_rfc4646_to_iso639
10264 GROUP BY rfc4646_subtag,iso639_2_code)
10268 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ქართული');
10271 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Georgian');
10274 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'fr', 'Géorgien');
10277 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'de', 'Georgisch');
10280 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'es', 'Georgiano');
10283 DELETE FROM language_descriptions
10286 (SELECT MIN(id) as id,subtag,type,lang,description
10287 FROM language_descriptions GROUP BY subtag,type,lang,description)
10290 print "Upgrade to $DBversion done (Bug 14030: Add Georgian language and fix Kannada language code)\n";
10291 SetVersion($DBversion);
10294 $DBversion = "3.19.00.031";
10295 if ( CheckVersion($DBversion) ) {
10297 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10298 VALUES('IdRef','0','Disable/enable the IdRef webservice from the OPAC detail page.',NULL,'YesNo')
10300 print "Upgrade to $DBversion done (Bug 8992: Add system preference IdRef))\n";
10301 SetVersion($DBversion);
10304 $DBversion = "3.19.00.032";
10305 if ( CheckVersion($DBversion) ) {
10307 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10308 VALUES('AddressFormat','us','Choose format to display postal addresses','','Choice')
10310 print "Upgrade to $DBversion done (Bug 4041: Address Format as a I18N/L10N system preference\n";
10311 SetVersion ($DBversion);
10314 $DBversion = "3.19.00.033";
10315 if ( CheckVersion($DBversion) ) {
10317 ALTER TABLE auth_header
10318 CHANGE COLUMN datemodified modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP
10321 ALTER TABLE auth_header
10322 CHANGE COLUMN modification_time modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
10324 print "Upgrade to $DBversion done (Bug 11165: Update auth_header.datemodified when updated)\n";
10325 SetVersion ($DBversion);
10328 $DBversion = "3.19.00.034";
10329 if ( CheckVersion($DBversion) ) {
10331 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10332 VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free')
10334 print "Upgrade to $DBversion done (Bug 13984: CardnumberLength syspref missing on some setups\n";
10335 SetVersion ($DBversion);
10338 $DBversion = "3.19.00.035";
10339 if ( CheckVersion($DBversion) ) {
10341 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('useDischarge','','Allows librarians to discharge borrowers and borrowers to request a discharge','','YesNo')
10344 INSERT IGNORE INTO letter (module, code, name, title, content) VALUES('members', 'DISCHARGE', 'Discharge', 'Discharge for <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Discharge</h1>\r\n\r\nThe library <<borrowers.branchcode>> certifies that the following borrower :\r\n\r\n <<borrowers.firstname>> <<borrowers.surname>>\r\n Cardnumber : <<borrowers.cardnumber>>\r\n\r\nreturned all his documents.')
10348 ALTER TABLE borrower_debarments CHANGE type type ENUM('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL'
10352 CREATE TABLE discharges (
10353 borrower int(11) DEFAULT NULL,
10354 needed timestamp NULL DEFAULT NULL,
10355 validated timestamp NULL DEFAULT NULL,
10356 KEY borrower_discharges_ibfk1 (borrower),
10357 CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
10358 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10361 print "Upgrade to $DBversion done (Bug 8007: Add System Preferences useDischarge, the discharge notice and the new table discharges)\n";
10362 SetVersion($DBversion);
10365 $DBversion = "3.19.00.036";
10366 if ( CheckVersion($DBversion) ) {
10368 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10369 VALUES ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo')
10371 print "Upgrade to $DBversion done (Bug 13889: Add cron jobs information to system log)\n";
10372 SetVersion ($DBversion);
10375 $DBversion = "3.19.00.037";
10376 if ( CheckVersion($DBversion) ) {
10378 ALTER TABLE marc_subfield_structure
10379 MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT ''
10381 print "Upgrade to $DBversion done (Bug 13810: Change collate for tagsubfield (utf8_bin))\n";
10382 SetVersion ($DBversion);
10385 $DBversion = "3.19.00.038";
10386 if ( CheckVersion($DBversion) ) {
10388 ALTER TABLE virtualshelves
10389 ADD COLUMN created_on DATETIME NOT NULL AFTER lastmodified
10391 # Set created_on = lastmodified
10392 # I would say it's better than 0000-00-00
10393 # Set modified to the existing value (do not get the current ts!)
10395 UPDATE virtualshelves
10396 SET created_on = lastmodified, lastmodified = lastmodified
10398 print "Upgrade to $DBversion done (Bug 13421: Add DB field virtualshelves.created_on)\n";
10399 SetVersion ($DBversion);
10402 $DBversion = "3.19.00.039";
10403 if ( CheckVersion($DBversion) ) {
10404 print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
10405 SetVersion ($DBversion);
10408 $DBversion = "3.19.00.040";
10409 if ( CheckVersion($DBversion) ) {
10411 ALTER TABLE aqorders DROP COLUMN totalamount
10413 print "Upgrade to $DBversion done (Bug 11006: Drop column aqorders.totalamount)\n";
10414 SetVersion ($DBversion);
10417 $DBversion = "3.19.00.041";
10418 if ( CheckVersion($DBversion) ) {
10419 unless ( index_exists( 'suggestions', 'status' ) ) {
10421 ALTER TABLE suggestions ADD KEY status (STATUS)
10424 unless ( index_exists( 'suggestions', 'biblionumber' ) ) {
10426 ALTER TABLE suggestions ADD KEY biblionumber (biblionumber)
10429 unless ( index_exists( 'suggestions', 'branchcode' ) ) {
10431 ALTER TABLE suggestions ADD KEY branchcode (branchcode)
10434 print "Upgrade to $DBversion done (Bug 14132: suggestions table is missing indexes)\n";
10435 SetVersion ($DBversion);
10438 $DBversion = "3.19.00.042";
10439 if ( CheckVersion($DBversion) ) {
10442 FROM auth_subfield_structure AS ass
10443 LEFT JOIN auth_types USING(authtypecode)
10444 WHERE auth_types.authtypecode IS NULL
10447 unless ( foreign_key_exists( 'auth_subfield_structure', 'auth_subfield_structure_ibfk_1' ) ) {
10449 ALTER TABLE auth_subfield_structure
10450 ADD CONSTRAINT auth_subfield_structure_ibfk_1
10451 FOREIGN KEY (authtypecode) REFERENCES auth_types(authtypecode)
10452 ON DELETE CASCADE ON UPDATE CASCADE
10456 print "Upgrade to $DBversion done (Bug 8480: Add foreign key on auth_subfield_structure.authtypecode)\n";
10457 SetVersion($DBversion);
10460 $DBversion = "3.19.00.043";
10461 if ( CheckVersion($DBversion) ) {
10463 INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
10464 ('REPORT_GROUP', 'SER', 'Serials')
10467 print "Upgrade to $DBversion done (Bug 5338: Add Serial to the report groups if does not exist)\n";
10468 SetVersion ($DBversion);
10471 $DBversion = "3.20.00.000";
10472 if ( CheckVersion($DBversion) ) {
10473 print "Upgrade to $DBversion done (Koha 3.20)\n";
10474 SetVersion ($DBversion);
10477 $DBversion = "3.21.00.000";
10478 if ( CheckVersion($DBversion) ) {
10479 print "Upgrade to $DBversion done (El tiempo vuela, un nuevo ciclo comienza.)\n";
10480 SetVersion ($DBversion);
10483 $DBversion = "3.21.00.001";
10484 if ( CheckVersion($DBversion) ) {
10486 UPDATE systempreferences SET variable='IntranetUserJS' where variable='intranetuserjs'
10488 print "Upgrade to $DBversion done (Bug 12160: Rename intranetuserjs to IntranetUserJS)\n";
10489 SetVersion ($DBversion);
10492 $DBversion = "3.21.00.002";
10493 if ( CheckVersion($DBversion) ) {
10495 UPDATE systempreferences SET variable='OPACUserJS' where variable='opacuserjs'
10497 print "Upgrade to $DBversion done (Bug 12160: Rename opacuserjs to OPACUserJS)\n";
10498 SetVersion ($DBversion);
10501 $DBversion = "3.21.00.003";
10502 if ( CheckVersion($DBversion) ) {
10504 INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added)
10505 VALUES ( 'IN', 'region', 'India','2015-05-28');
10508 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10509 VALUES ( 'IN', 'region', 'en', 'India');
10512 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10513 VALUES ( 'IN', 'region', 'bn', 'ভারত');
10515 print "Upgrade to $DBversion done (Bug 14285: Add new region India)\n";
10516 SetVersion ($DBversion);
10519 $DBversion = '3.21.00.004';
10520 if ( CheckVersion($DBversion) ) {
10521 my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
10522 if (defined($OPACBaseURL) && substr($OPACBaseURL,0,4) ne "http") {
10523 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.};
10524 $OPACBaseURL = 'http://' . $OPACBaseURL;
10525 my $sth_OPACBaseURL = $dbh->prepare( q{
10526 UPDATE systempreferences SET value=?,explanation=?
10527 WHERE variable='OPACBaseURL'; } );
10528 $sth_OPACBaseURL->execute($OPACBaseURL,$explanation);
10530 if (defined($OPACBaseURL)) {
10531 $dbh->do( q{ UPDATE letter
10532 SET content=replace(content,
10533 'http://<<OPACBaseURL>>',
10535 WHERE content LIKE "%http://<<OPACBaseURL>>%"; } );
10538 print "Upgrade to $DBversion done (Bug 5010: Fix OPACBaseURL to include protocol)\n";
10539 SetVersion($DBversion);
10542 $DBversion = "3.21.00.005";
10543 if ( CheckVersion($DBversion) ) {
10545 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10546 VALUES ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo')
10548 print "Upgrade to $DBversion done (Bug 14024: Add reports to action logs)\n";
10549 SetVersion ($DBversion);
10552 $DBversion = "3.21.00.006";
10553 if ( CheckVersion($DBversion) ) {
10554 # Remove the borrow permission flag (bit 7)
10557 SET flags = flags - ( flags & (1<<7) )
10558 WHERE flags IS NOT NULL
10562 DELETE FROM userflags WHERE bit=7;
10564 print "Upgrade to $DBversion done (Bug 7976: Remove the 'borrow' permission)\n";
10565 SetVersion($DBversion);
10568 $DBversion = "3.21.00.007";
10569 if ( CheckVersion($DBversion) ) {
10570 unless ( index_exists( 'aqbasket', 'authorisedby' ) ) {
10572 ALTER TABLE aqbasket
10573 ADD KEY authorisedby (authorisedby)
10576 unless ( index_exists( 'aqbooksellers', 'name' ) ) {
10578 ALTER TABLE aqbooksellers
10579 ADD KEY name (name(255))
10582 unless ( index_exists( 'aqbudgets', 'budget_parent_id' ) ) {
10584 ALTER TABLE aqbudgets
10585 ADD KEY budget_parent_id (budget_parent_id)|);
10587 unless ( index_exists( 'aqbudgets', 'budget_code' ) ) {
10589 ALTER TABLE aqbudgets
10590 ADD KEY budget_code (budget_code)|);
10592 unless ( index_exists( 'aqbudgets', 'budget_branchcode' ) ) {
10594 ALTER TABLE aqbudgets
10595 ADD KEY budget_branchcode (budget_branchcode)|);
10597 unless ( index_exists( 'aqbudgets', 'budget_period_id' ) ) {
10599 ALTER TABLE aqbudgets
10600 ADD KEY budget_period_id (budget_period_id)|);
10602 unless ( index_exists( 'aqbudgets', 'budget_owner_id' ) ) {
10604 ALTER TABLE aqbudgets
10605 ADD KEY budget_owner_id (budget_owner_id)|);
10607 unless ( index_exists( 'aqbudgets_planning', 'budget_period_id' ) ) {
10609 ALTER TABLE aqbudgets_planning
10610 ADD KEY budget_period_id (budget_period_id)|);
10612 unless ( index_exists( 'aqorders', 'parent_ordernumber' ) ) {
10614 ALTER TABLE aqorders
10615 ADD KEY parent_ordernumber (parent_ordernumber)|);
10617 unless ( index_exists( 'aqorders', 'orderstatus' ) ) {
10619 ALTER TABLE aqorders
10620 ADD KEY orderstatus (orderstatus)|);
10622 print "Upgrade to $DBversion done (Bug 14053: Acquisition db tables are missing indexes)\n";
10623 SetVersion ($DBversion);
10626 $DBversion = "3.21.00.008";
10627 if ( CheckVersion($DBversion) ) {
10629 DELETE IGNORE FROM systempreferences
10630 WHERE variable = 'HomeOrHoldingBranchReturn';
10632 print "Upgrade to $DBversion done (Bug 7981: Transfer message on return. HomeOrHoldingBranchReturn syspref removed in favour of circulation rules.)\n";
10633 SetVersion($DBversion);
10636 $DBversion = "3.21.00.009";
10637 if ( CheckVersion($DBversion) ) {
10639 local $dbh->{PrintError} = 0;
10641 UPDATE aqorders SET orderstatus='cancelled'
10642 WHERE (datecancellationprinted IS NOT NULL OR
10643 datecancellationprinted<>'0000-00-00');
10646 print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n";
10647 SetVersion($DBversion);
10650 $DBversion = "3.21.00.010";
10651 if ( CheckVersion($DBversion) ) {
10653 ALTER TABLE message_queue
10657 ALTER TABLE message_queue
10658 ADD message_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10660 print "Upgrade to $DBversion done (Bug 7793: redefine the field message_id as PRIMARY KEY of message_queue)\n";
10661 SetVersion ($DBversion);
10664 $DBversion = "3.21.00.011";
10665 if ( CheckVersion($DBversion) ) {
10667 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10668 VALUES ('OpacLangSelectorMode','footer','top|both|footer','Select the location to display the language selector','Choice')
10670 print "Upgrade to $DBversion done (Bug 14252: Make the OPAC language switcher available in the masthead navbar, footer, or both)\n";
10671 SetVersion ($DBversion);
10674 $DBversion = "3.21.00.012";
10675 if ( CheckVersion($DBversion) ) {
10677 INSERT INTO letter (module, code, name, title, content, message_transport_type)
10679 ('suggestions','TO_PROCESS','Notify fund 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')
10681 print "Upgrade to $DBversion done (Bug 13014: Add the TO_PROCESS letter code)\n";
10682 SetVersion($DBversion);
10685 $DBversion = "3.21.00.013";
10686 if ( CheckVersion($DBversion) ) {
10688 if ( C4::Context->preference('OPACPrivacy') ) {
10689 if ( my $anonymous_patron = C4::Context->preference('AnonymousPatron') ) {
10690 my $anonymous_patron_exists = $dbh->selectcol_arrayref(q|
10693 WHERE borrowernumber=?
10694 |, {}, $anonymous_patron);
10695 unless ( $anonymous_patron_exists->[0] ) {
10696 $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not linked to an existing patron";
10700 $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not";
10704 my $patrons_have_required_anonymity = $dbh->selectcol_arrayref(q|
10709 if ( $patrons_have_required_anonymity->[0] ) {
10710 $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.";
10714 $msg //= "Privacy is correctly set";
10715 print "Upgrade to $DBversion done (Bug 9942: $msg)\n";
10716 SetVersion ($DBversion);
10719 $DBversion = "3.21.00.014";
10720 if ( CheckVersion($DBversion) ) {
10722 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10723 VALUES ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent) or might be deleted (transient)','transient|persistent','Choice')
10726 if ( foreign_key_exists( 'oai_sets_biblios', 'oai_sets_biblios_ibfk_1' ) ) {
10728 ALTER TABLE oai_sets_biblios DROP FOREIGN KEY oai_sets_biblios_ibfk_1
10731 print "Upgrade to $DBversion done (Bug 3206: OAI repository deleted record support)\n";
10732 SetVersion ($DBversion);
10735 $DBversion = "3.21.00.015";
10736 if ( CheckVersion($DBversion) ) {
10738 UPDATE systempreferences SET value='0' WHERE variable='CalendarFirstDayOfWeek' AND value='Sunday';
10741 UPDATE systempreferences SET value='1' WHERE variable='CalendarFirstDayOfWeek' AND value='Monday';
10744 UPDATE systempreferences SET options='0|1|2|3|4|5|6' WHERE variable='CalendarFirstDayOfWeek';
10747 print "Upgrade to $DBversion done (Bug 12137: Extend functionality of CalendarFirstDayOfWeek to be any day)\n";
10748 SetVersion($DBversion);
10751 $DBversion = "3.21.00.016";
10752 if ( CheckVersion($DBversion) ) {
10753 my $rs = $schema->resultset('Systempreference');
10754 $rs->find_or_create(
10756 variable => 'DumpTemplateVarsIntranet',
10758 explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',
10762 $rs->find_or_create(
10764 variable => 'DumpTemplateVarsOpac',
10766 explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',
10770 print "Upgrade to $DBversion done (Bug 13948: Add ability to dump template toolkit variables to html comment)\n";
10771 SetVersion($DBversion);
10774 $DBversion = "3.21.00.017";
10775 if ( CheckVersion($DBversion) ) {
10777 CREATE TABLE uploaded_files (
10778 id int(11) NOT NULL AUTO_INCREMENT,
10779 hashvalue CHAR(40) NOT NULL,
10780 filename TEXT NOT NULL,
10783 dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10784 categorycode tinytext,
10787 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
10790 print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
10791 print "This plugin comes with a new config variable (upload_path) and a new table (uploaded_files)\n";
10792 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";
10793 SetVersion($DBversion);
10796 $DBversion = "3.21.00.018";
10797 if ( CheckVersion($DBversion) ) {
10799 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10801 ('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: \"127.0.0,127.0.2\")','Free'),
10802 ('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
10803 ('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free')
10805 print "Upgrade to $DBversion done (Bug 13485: Add a page to display links to restricted sites)\n";
10806 SetVersion ($DBversion);
10809 $DBversion = "3.21.00.019";
10810 if ( CheckVersion($DBversion) ) {
10811 if ( column_exists( 'reserves', 'constrainttype' ) ) {
10813 ALTER TABLE reserves DROP constrainttype
10816 ALTER TABLE old_reserves DROP constrainttype
10820 DROP TABLE IF EXISTS reserveconstraints
10822 print "Upgrade to $DBversion done (Bug 9809: Get rid of reserveconstraints)\n";
10823 SetVersion ($DBversion);
10826 $DBversion = "3.21.00.020";
10827 if ( CheckVersion($DBversion) ) {
10829 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`)
10830 VALUES ('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo')
10832 print "Upgrade to $DBversion done (Bug 13697: Option to don't charge a fee, if the patron changes to a category with enrolment fee)\n";
10833 SetVersion($DBversion);
10836 $DBversion = "3.21.00.021";
10837 if ( CheckVersion($DBversion) ) {
10839 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10840 VALUES ('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo')
10842 print "Upgrade to $DBversion done (Bug 11584: Add wysiwyg editor to system preferences dealing with HTML)\n";
10843 SetVersion($DBversion);
10846 $DBversion = "3.21.00.022";
10847 if ( CheckVersion($DBversion) ) {
10850 FROM course_reserves AS cr
10851 LEFT JOIN course_items USING(ci_id)
10852 WHERE course_items.ci_id IS NULL
10855 my ($print_error) = $dbh->{PrintError};
10856 $dbh->{RaiseError} = 0;
10857 $dbh->{PrintError} = 0;
10858 if ( foreign_key_exists('course_reserves', 'course_reserves_ibfk_2') ) {
10859 $dbh->do(q{ALTER TABLE course_reserves DROP FOREIGN KEY course_reserves_ibfk_2});
10860 $dbh->do(q{ALTER TABLE course_reserves DROP INDEX course_reserves_ibfk_2});
10862 $dbh->{PrintError} = $print_error;
10865 ALTER TABLE course_reserves
10866 ADD CONSTRAINT course_reserves_ibfk_2
10867 FOREIGN KEY (ci_id) REFERENCES course_items (ci_id)
10868 ON DELETE CASCADE ON UPDATE CASCADE
10870 print "Upgrade to $DBversion done (Bug 14205: Deleting an Item/Record does not remove link to course reserve)\n";
10871 SetVersion($DBversion);
10874 $DBversion = "3.21.00.023";
10875 if ( CheckVersion($DBversion) ) {
10877 local $dbh->{PrintError} = 0;
10879 UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00'
10882 UPDATE borrowers SET dateexpiry=NULL where dateexpiry='0000-00-00'
10885 UPDATE borrowers SET dateofbirth=NULL where dateofbirth='0000-00-00'
10888 UPDATE borrowers SET dateenrolled=NULL where dateenrolled='0000-00-00'
10892 print "Upgrade to $DBversion done (Bug 14717: Prevent 0000-00-00 dates in patron data)\n";
10893 SetVersion($DBversion);
10896 $DBversion = "3.21.00.024";
10897 if ( CheckVersion($DBversion) ) {
10899 ALTER TABLE marc_modification_template_actions
10900 MODIFY COLUMN action
10901 ENUM('delete_field','update_field','move_field','copy_field','copy_and_replace_field')
10904 print "Upgrade to $DBversion done (Bug 14098: Regression in Marc Modification Templates)\n";
10905 SetVersion($DBversion);
10908 $DBversion = "3.21.00.025";
10909 if ( CheckVersion($DBversion) ) {
10911 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10912 VALUES ('RisExportAdditionalFields', '', NULL , 'Define additional RIS tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea')
10915 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10916 VALUES ('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea')
10918 print "Upgrade to $DBversion done (Bug 12357: Enhancements to RIS and BibTeX exporting)\n";
10919 SetVersion($DBversion);
10922 $DBversion = "3.21.00.026";
10923 if ( CheckVersion($DBversion) ) {
10926 SET search_index='issn'
10927 WHERE matcher_id IN (SELECT matcher_id FROM marc_matchers WHERE code = 'ISSN')
10929 print "Upgrade to $DBversion done (Bug 14472: Wrong ISSN search index in record matching rules)\n";
10930 SetVersion($DBversion);
10933 $DBversion = "3.21.00.027";
10934 if ( CheckVersion($DBversion) ) {
10936 INSERT IGNORE INTO permissions (module_bit, code, description)
10937 VALUES (1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID')
10940 my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
10946 |, undef, $AutoSelfCheckID);
10949 DELETE FROM user_permissions
10950 WHERE borrowernumber=(SELECT borrowernumber FROM borrowers WHERE userid=?)
10951 |, undef, $AutoSelfCheckID);
10954 INSERT INTO user_permissions(borrowernumber, module_bit, code)
10955 SELECT borrowernumber, 1, 'self_checkout' FROM borrowers WHERE userid=?
10956 |, undef, $AutoSelfCheckID);
10957 print "Upgrade to $DBversion done (Bug 14298: AutoSelfCheckID user should only be able to access SCO)\n";
10958 SetVersion($DBversion);
10961 $DBversion = "3.21.00.028";
10962 if ( CheckVersion($DBversion) ) {
10963 unless ( column_exists('uploaded_files', 'public') ) {
10965 ALTER TABLE uploaded_files
10966 ADD COLUMN public tinyint,
10967 ADD COLUMN permanent tinyint
10970 UPDATE uploaded_files SET public=1, permanent=1
10973 ALTER TABLE uploaded_files
10974 CHANGE COLUMN categorycode uploadcategorycode tinytext
10977 print "Upgrade to $DBversion done (Bug 14321: Merge UploadedFile and UploadedFiles into Koha::Upload)\n";
10978 SetVersion($DBversion);
10981 $DBversion = "3.21.00.029";
10982 if ( CheckVersion($DBversion) ) {
10983 unless ( column_exists('discharges', 'discharge_id') ) {
10985 ALTER TABLE discharges
10986 ADD COLUMN discharge_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10989 print "Upgrade to $DBversion done (Bug 14368: Add discharges history)\n";
10990 SetVersion($DBversion);
10993 $DBversion = "3.21.00.030";
10994 if ( CheckVersion($DBversion) ) {
10996 UPDATE marc_subfield_structure
10997 SET value_builder='marc21_leader.pl'
10998 WHERE value_builder='marc21_leader_book.pl'
11001 UPDATE marc_subfield_structure
11002 SET value_builder='marc21_leader.pl'
11003 WHERE value_builder='marc21_leader_computerfile.pl'
11006 UPDATE marc_subfield_structure
11007 SET value_builder='marc21_leader.pl'
11008 WHERE value_builder='marc21_leader_video.pl'
11010 print "Upgrade to $DBversion done (Bug 14201: Remove unused code or template from some MARC21 leader plugins )\n";
11011 SetVersion($DBversion);
11014 $DBversion = "3.21.00.031";
11015 if ( CheckVersion($DBversion) ) {
11017 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
11019 ('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'),
11020 ('SMSSendUsername', '', '', 'Username/Login used to send SMS messages', 'free')
11022 print "Upgrade to $DBversion done (Bug 14820: SMSSendUsername and SMSSendPassword are not listed in the system preferences)\n";
11023 SetVersion($DBversion);
11026 $DBversion = "3.21.00.032";
11027 if ( CheckVersion($DBversion) ) {
11029 CREATE TABLE additional_fields (
11030 id int(11) NOT NULL AUTO_INCREMENT,
11031 tablename varchar(255) NOT NULL DEFAULT '',
11032 name varchar(255) NOT NULL DEFAULT '',
11033 authorised_value_category varchar(16) NOT NULL DEFAULT '',
11034 marcfield varchar(16) NOT NULL DEFAULT '',
11035 searchable tinyint(1) NOT NULL DEFAULT '0',
11037 UNIQUE KEY fields_uniq (tablename,name)
11038 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
11041 CREATE TABLE additional_field_values (
11042 id int(11) NOT NULL AUTO_INCREMENT,
11043 field_id int(11) NOT NULL,
11044 record_id int(11) NOT NULL,
11045 value varchar(255) NOT NULL DEFAULT '',
11047 UNIQUE KEY field_record (field_id,record_id),
11048 CONSTRAINT afv_fk FOREIGN KEY (field_id) REFERENCES additional_fields (id) ON DELETE CASCADE ON UPDATE CASCADE
11049 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
11051 print "Upgrade to $DBversion done (Bug 10855: Additional fields for subscriptions)\n";
11052 SetVersion($DBversion);
11055 $DBversion = "3.21.00.033";
11056 if ( CheckVersion($DBversion) ) {
11059 my $count_ethnicity = $dbh->selectrow_arrayref(q|
11060 SELECT COUNT(*) FROM ethnicity
11062 my $count_borrower_modifications = $dbh->selectrow_arrayref(q|
11064 FROM borrower_modifications
11065 WHERE ethnicity IS NOT NULL
11066 OR ethnotes IS NOT NULL
11068 my $count_borrowers = $dbh->selectrow_arrayref(q|
11071 WHERE ethnicity IS NOT NULL
11072 OR ethnotes IS NOT NULL
11074 # We don't care about the ethnicity of the deleted borrowers, right?
11075 if ( $count_ethnicity->[0] == 0
11076 and $count_borrower_modifications->[0] == 0
11077 and $count_borrowers->[0] == 0
11080 DROP TABLE ethnicity
11083 ALTER TABLE borrower_modifications
11084 DROP COLUMN ethnicity,
11085 DROP COLUMN ethnotes
11088 ALTER TABLE borrowers
11089 DROP COLUMN ethnicity,
11090 DROP COLUMN ethnotes
11093 ALTER TABLE deletedborrowers
11094 DROP COLUMN ethnicity,
11095 DROP COLUMN ethnotes
11100 print "Upgrade to $DBversion done (Bug 10020: Drop table ethnicity and columns ethnicity and ethnotes)\n";
11103 print "Upgrade to $DBversion done (Bug 10020: This database contains data related to 'ethnicity'. No change will be done on the DB structure but note that the Koha codebase does not use it)\n";
11106 SetVersion ($DBversion);
11109 $DBversion = "3.21.00.034";
11110 if ( CheckVersion($DBversion) ) {
11112 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11113 VALUES('MembershipExpiryDaysNotice',NULL,'Send an account expiration notice that a patron''s card is about to expire after',NULL,'Integer')
11116 INSERT IGNORE INTO letter (module, code, branchcode, name, title, content, message_transport_type)
11117 VALUES('members','MEMBERSHIP_EXPIRY','','Account expiration','Account expiration','Dear <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nYour library card will expire soon, on:\r\n\r\n<<borrowers.dateexpiry>>\r\n\r\nThank you,\r\n\r\nLibrarian\r\n\r\n<<branches.branchname>>', 'email')
11119 print "Upgrade to $DBversion done (Bug 6810: Send membership expiry reminder notices)\n";
11120 SetVersion($DBversion);
11123 $DBversion = "3.21.00.035";
11124 if ( CheckVersion($DBversion) ) {
11126 ALTER TABLE branch_borrower_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11129 UPDATE branch_borrower_circ_rules SET maxonsiteissueqty = maxissueqty;
11132 ALTER TABLE default_borrower_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11135 UPDATE default_borrower_circ_rules SET maxonsiteissueqty = maxissueqty;
11138 ALTER TABLE default_branch_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11141 UPDATE default_branch_circ_rules SET maxonsiteissueqty = maxissueqty;
11144 ALTER TABLE default_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11147 UPDATE default_circ_rules SET maxonsiteissueqty = maxissueqty;
11150 ALTER TABLE issuingrules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11153 UPDATE issuingrules SET maxonsiteissueqty = maxissueqty;
11156 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11157 VALUES ('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo');
11160 print "Upgrade to $DBversion done (Bug 14045: Add DB fields maxonsiteissueqty and pref ConsiderOnSiteCheckoutsAsNormalCheckouts)\n";
11161 SetVersion ($DBversion);
11164 $DBversion = "3.21.00.036";
11165 if ( CheckVersion($DBversion) ) {
11167 ALTER TABLE authorised_values_branches
11168 DROP FOREIGN KEY authorised_values_branches_ibfk_1,
11169 DROP FOREIGN KEY authorised_values_branches_ibfk_2
11172 ALTER TABLE authorised_values_branches
11173 MODIFY av_id INT( 11 ) NOT NULL,
11174 MODIFY branchcode VARCHAR( 10 ) NOT NULL,
11175 ADD FOREIGN KEY (`av_id`) REFERENCES `authorised_values` (`id`) ON DELETE CASCADE,
11176 ADD FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
11178 print "Upgrade to $DBversion done (Bug 10363: There is no package for authorised values)\n";
11179 SetVersion($DBversion);
11182 $DBversion = "3.21.00.037";
11183 if ( CheckVersion($DBversion) ) {
11185 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11186 VALUES ('OverduesBlockRenewing','allow','If any of a patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|block','Choice')
11189 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11190 VALUES ('RestrictionBlockRenewing','0','If patron is restricted, should renewal be allowed or blocked',NULL,'YesNo')
11192 print "Upgrade to $DBversion done (Bug 8236: Prevent renewing if overdue or restriction)\n";
11193 SetVersion($DBversion);
11196 $DBversion = "3.21.00.038";
11197 if ( CheckVersion($DBversion) ) {
11199 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11200 VALUES ('BatchCheckouts','0','','Enable or disable batch checkouts','YesNo')
11203 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11204 VALUES ('BatchCheckoutsValidCategories','',NULL,'Patron categories allowed to checkout in a batch','Free')
11206 print "Upgrade to $DBversion done (Bug 11759: Add the batch checkout feature)\n";
11207 SetVersion($DBversion);
11210 $DBversion = "3.21.00.039";
11211 if ( CheckVersion($DBversion) ) {
11213 ALTER TABLE creator_layouts ADD COLUMN oblique_title INT(1) NULL DEFAULT 1 AFTER guidebox
11215 print "Upgrade to $DBversion done (Bug 12194: Add column oblique_title to layouts)\n";
11216 SetVersion($DBversion);
11219 $DBversion = "3.21.00.040";
11220 if ( CheckVersion($DBversion) ) {
11222 ALTER TABLE itemtypes
11223 ADD hideinopac TINYINT(1) NOT NULL DEFAULT 0
11224 AFTER sip_media_type,
11225 ADD searchcategory VARCHAR(80) DEFAULT NULL
11228 print "Upgrade to $DBversion done (Bug 10937: Option to hide and group itemtypes from advanced search)\n";
11229 SetVersion($DBversion);
11232 $DBversion = "3.21.00.041";
11233 if ( CheckVersion($DBversion) ) {
11235 ALTER TABLE issuingrules
11236 ADD chargeperiod_charge_at BOOLEAN NOT NULL DEFAULT '0' AFTER chargeperiod
11238 print "Upgrade to $DBversion done (Bug 13590: Add ability to charge fines at start of charge period)\n";
11239 SetVersion($DBversion);
11242 $DBversion = "3.21.00.042";
11243 if ( CheckVersion($DBversion) ) {
11245 ALTER TABLE items_search_fields
11246 MODIFY COLUMN authorised_values_category VARCHAR(32) DEFAULT NULL
11248 print "Upgrade to $DBversion done (Bug 15069: items_search_fields.authorised_values_category is still a varchar(32))\n";
11249 SetVersion($DBversion);
11252 $DBversion = "3.21.00.043";
11253 if ( CheckVersion($DBversion) ) {
11255 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11256 VALUES ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo')
11258 print "Upgrade to $DBversion done (Bug 11559: Professional cataloger's interface)\n";
11259 SetVersion($DBversion);
11262 $DBversion = "3.21.00.044";
11263 if ( CheckVersion($DBversion) ) {
11265 CREATE TABLE localization (
11266 localization_id int(11) NOT NULL AUTO_INCREMENT,
11267 entity varchar(16) COLLATE utf8_unicode_ci NOT NULL,
11268 code varchar(64) COLLATE utf8_unicode_ci NOT NULL,
11269 lang varchar(25) COLLATE utf8_unicode_ci NOT NULL,
11270 translation text COLLATE utf8_unicode_ci,
11271 PRIMARY KEY (localization_id),
11272 UNIQUE KEY entity_code_lang (entity,code,lang)
11273 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
11275 print "Upgrade to $DBversion done (Bug 14100: Generic solution for language overlay)\n";
11276 SetVersion($DBversion);
11279 $DBversion = "3.21.00.045";
11280 if ( CheckVersion($DBversion) ) {
11282 ALTER TABLE opac_news
11283 ADD borrowernumber int(11) default NULL
11287 ALTER TABLE opac_news
11288 ADD CONSTRAINT borrowernumber_fk
11289 FOREIGN KEY (borrowernumber)
11290 REFERENCES borrowers (borrowernumber)
11291 ON DELETE SET NULL ON UPDATE CASCADE
11293 print "Upgrade to $DBversion done (Bug 14246: (newsauthor) Add borrowernumber to koha_news)\n";
11294 SetVersion($DBversion);
11297 $DBversion = "3.21.00.046";
11298 if ( CheckVersion($DBversion) ) {
11300 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11301 VALUES ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice')
11303 print "Upgrade to $DBversion done (Bug 14247: (newsauthor) System preference for news author display)\n";
11304 SetVersion($DBversion);
11307 $DBversion = "3.21.00.047";
11308 if(CheckVersion($DBversion)) {
11310 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11311 VALUES ('IndependentBranchesPatronModifications','0','Show only modification request for the logged in branch','','YesNo')
11313 print "Upgrade to $DBversion done (Bug 10904: Limit patron update request management by branch)\n";
11314 SetVersion($DBversion);
11317 $DBversion = '3.21.00.048';
11318 if ( CheckVersion($DBversion) ) {
11319 my $create_table_issues = @{ $dbh->selectall_arrayref(q|SHOW CREATE TABLE issues|) }[0]->[1];
11320 if ($create_table_issues !~ m|UNIQUE KEY.*itemnumber| ) {
11321 $dbh->do(q|ALTER TABLE issues ADD CONSTRAINT UNIQUE KEY (itemnumber)|);
11323 print "Upgrade to $DBversion done (Bug 14978: Make sure issues.itemnumber is a unique key)\n";
11324 SetVersion($DBversion);
11327 $DBversion = "3.21.00.049";
11328 if ( CheckVersion($DBversion) ) {
11329 $dbh->do(q{UPDATE systempreferences SET variable = 'AudioAlerts' WHERE variable = 'soundon'});
11332 CREATE TABLE audio_alerts (
11333 id int(11) NOT NULL AUTO_INCREMENT,
11334 precedence smallint(5) unsigned NOT NULL,
11335 selector varchar(255) NOT NULL,
11336 sound varchar(255) NOT NULL,
11338 KEY precedence (precedence)
11339 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
11343 INSERT IGNORE INTO audio_alerts VALUES
11344 (1, 1, '.audio-alert-action', 'opening.ogg'),
11345 (2, 2, '.audio-alert-warning', 'critical.ogg'),
11346 (3, 3, '.audio-alert-success', 'beep.ogg');
11349 print "Upgrade to $DBversion done (Bug 11431: Add additional sound options for warnings)\n";
11350 SetVersion($DBversion);
11353 $DBversion = "3.21.00.050";
11354 if(CheckVersion($DBversion)) {
11356 INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
11357 VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
11359 <item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
11362 print "Upgrade to $DBversion done (Bug 12933: Add ability to print overdue slip from staff intranet)\n";
11363 SetVersion($DBversion);
11366 $DBversion = "3.21.00.051";
11367 if ( CheckVersion($DBversion) ) {
11369 ALTER TABLE virtualshelves
11370 CHANGE COLUMN sortfield sortfield VARCHAR(16) DEFAULT 'title'
11373 UPDATE virtualshelves
11374 SET sortfield='title'
11375 WHERE sortfield IS NULL;
11377 print "Upgrade to $DBversion done (Bug 14544: Move the list related code to Koha::Virtualshelves)\n";
11378 SetVersion($DBversion);
11381 $DBversion = "3.21.00.052";
11382 if ( CheckVersion($DBversion) ) {
11385 ADD COLUMN publisheddatetext VARCHAR(100) DEFAULT NULL AFTER publisheddate
11387 print "Upgrade to $DBversion done (Bug 8296: Add descriptive (text) published date field for serials)\n";
11388 SetVersion($DBversion);
11391 $DBversion = "3.21.00.053";
11392 if ( CheckVersion($DBversion) ) {
11393 my $query = q{ SELECT * FROM itemtypes ORDER BY description };
11394 my $sth = C4::Context->dbh->prepare($query);
11396 my $suggestion_formats = $sth->fetchall_arrayref( {} );
11398 foreach my $format (@$suggestion_formats) {
11401 INSERT IGNORE INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl)
11402 VALUES (?, ?, ?, ?, ?)
11404 'SUGGEST_FORMAT', $format->{itemtype}, $format->{description}, $format->{description},
11405 $format->{imageurl}
11408 print "Upgrade to $DBversion done (Bug 9468: create new SUGGEST_FORMAT authorised_value list)\n";
11409 SetVersion($DBversion);
11412 $DBversion = "3.21.00.054";
11413 if(CheckVersion($DBversion)) {
11415 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11416 VALUES('MergeReportFields','','Displayed fields for deleted MARC records after merge',NULL,'Free')
11418 print "Upgrade to $DBversion done (Bug 8064: Merge several biblio records)\n";
11419 SetVersion($DBversion);
11422 $DBversion = "3.21.00.055";
11423 if ( CheckVersion($DBversion) ) {
11424 print "Upgrade to $DBversion done (Koha 3.22 beta)\n";
11425 SetVersion($DBversion);
11428 $DBversion = "3.21.00.056";
11429 if(CheckVersion($DBversion)) {
11431 UPDATE systempreferences
11433 options='metric|us|iso|dmydot',
11434 explanation='Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, DMY separated by dots dd.mm.yyyy)'
11435 WHERE variable='dateformat'
11437 print "Upgrade to $DBversion done (Bug 12072: New dateformat dd.mm.yyyy)\n";
11438 SetVersion($DBversion);
11441 $DBversion = "3.22.00.000";
11442 if ( CheckVersion($DBversion) ) {
11443 print "Upgrade to $DBversion done (Koha 3.22)\n";
11444 SetVersion($DBversion);
11447 $DBversion = "3.23.00.000";
11448 if ( CheckVersion($DBversion) ) {
11449 print "Upgrade to $DBversion done (The year of the monkey will be here soon.)\n";
11450 SetVersion ($DBversion);
11453 $DBversion = "3.23.00.001";
11454 if(CheckVersion($DBversion)) {
11456 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11458 'DefaultToLoggedInLibraryCircRules', '0', NULL , 'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'
11460 'DefaultToLoggedInLibraryNoticesSlips', '0', NULL , 'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'
11464 print "Upgrade to $DBversion done (Bug 11625 - Add pref DefaultToLoggedInLibraryCircRules and DefaultToLoggedInLibraryNoticesSlips)\n";
11465 SetVersion($DBversion);
11468 $DBversion = "3.23.00.002";
11469 if(CheckVersion($DBversion)) {
11471 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11472 VALUES ('DefaultToLoggedInLibraryOverdueTriggers', '0', NULL, 'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.', 'YesNo')
11475 print "Upgrade to $DBversion done (Bug 11747 - add pref DefaultToLoggedInLibraryOverdueTriggers)\n";
11476 SetVersion($DBversion);
11479 $DBversion = "3.23.00.003";
11480 if(CheckVersion($DBversion)) {
11482 UPDATE letter SET name = "Hold Slip" WHERE name = "Reserve Slip"
11485 UPDATE letter SET title = "Hold Slip" WHERE title = "Reserve Slip";
11488 print "Upgrade to $DBversion done (Bug 8085 - Rename 'Reserve slip' to 'Hold slip')\n";
11489 SetVersion($DBversion);
11492 $DBversion = "3.23.00.004";
11493 if ( CheckVersion($DBversion) ) {
11495 DROP TABLE IF EXISTS `stopwords`;
11497 print "Upgrade to $DBversion done (Bug 9819 - stopwords related code should be removed)\n";
11498 SetVersion($DBversion);
11501 $DBversion = "3.23.00.005";
11502 if ( CheckVersion($DBversion) ) {
11504 UPDATE permissions SET description = 'Manage circulation rules' WHERE description = 'manage circulation rules'
11507 UPDATE permissions SET description = 'Manage staged MARC records, including completing and reversing imports' WHERE description = 'Managed staged MARC records, including completing and reversing imports'
11509 print "Upgrade to $DBversion done (Bug 11569 - Typo in userpermissions.sql)\n";
11510 SetVersion($DBversion);
11512 $DBversion = "3.23.00.006";
11513 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
11516 ADD serialseq_x VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq,
11517 ADD serialseq_y VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_x,
11518 ADD serialseq_z VARCHAR( 100 ) NULL DEFAULT NULL AFTER serialseq_y
11521 my $sth = $dbh->prepare("SELECT * FROM subscription");
11524 my $sth2 = $dbh->prepare("SELECT * FROM subscription_numberpatterns WHERE id = ?");
11526 my $sth3 = $dbh->prepare("UPDATE serial SET serialseq_x = ?, serialseq_y = ?, serialseq_z = ? WHERE serialid = ?");
11528 foreach my $subscription ( $sth->fetchrow_hashref() ) {
11529 next if !defined($subscription);
11530 $sth2->execute( $subscription->{numberpattern} );
11531 my $number_pattern = $sth2->fetchrow_hashref();
11533 my $numbering_method = $number_pattern->{numberingmethod};
11534 # Get all the data between the enumeration values, we need
11535 # to split each enumeration string based on these values.
11536 my @splits = split( /\{[XYZ]\}/, $numbering_method );
11537 # Get the order in which the X Y and Z values are used
11539 foreach my $i (qw(X Y Z)) {
11540 $indexes{$i} = index( $numbering_method, "{$i}" );
11541 delete $indexes{$i} if $indexes{$i} == -1;
11543 my @indexes = sort { $indexes{$a} <=> $indexes{$b} } keys(%indexes);
11546 $dbh->selectall_arrayref(
11547 "SELECT * FROM serial WHERE subscriptionid = $subscription->{subscriptionid}",
11552 foreach my $serial (@serials) {
11553 my $serialseq = $serial->{serialseq};
11554 my %enumeration_data;
11556 ## We cannot split on multiple values at once,
11557 ## so let's replace each of those values with __SPLIT__
11559 for my $split_item (@splits) {
11560 my $quoted_split = quotemeta($split_item);
11561 $serialseq =~ s/$quoted_split/__SPLIT__/;
11565 $enumeration_data{ $indexes[0] // q{} },
11566 $enumeration_data{ $indexes[1] // q{} },
11567 $enumeration_data{ $indexes[2] // q{} }
11568 ) = split( /__SPLIT__/, $serialseq );
11571 { ## Nothing to split on means the only thing in serialseq is a single placeholder e.g. {X}
11572 $enumeration_data{ $indexes[0] } = $serialseq;
11576 $enumeration_data{'X'},
11577 $enumeration_data{'Y'},
11578 $enumeration_data{'Z'},
11579 $serial->{serialid},
11584 print "Upgrade to $DBversion done ( Bug 8956 - Split serials enumeration data into separate fields )\n";
11585 SetVersion($DBversion);
11588 $DBversion = "3.23.00.007";
11589 if ( CheckVersion($DBversion) ) {
11590 $dbh->do("SET FOREIGN_KEY_CHECKS=0");
11591 $dbh->do("ALTER TABLE overduerules RENAME old_overduerules");
11592 $dbh->do("CREATE TABLE overduerules (
11593 `overduerules_id` int(11) NOT NULL AUTO_INCREMENT,
11594 `branchcode` varchar(10) NOT NULL DEFAULT '',
11595 `categorycode` varchar(10) NOT NULL DEFAULT '',
11596 `delay1` int(4) DEFAULT NULL,
11597 `letter1` varchar(20) DEFAULT NULL,
11598 `debarred1` varchar(1) DEFAULT '0',
11599 `delay2` int(4) DEFAULT NULL,
11600 `debarred2` varchar(1) DEFAULT '0',
11601 `letter2` varchar(20) DEFAULT NULL,
11602 `delay3` int(4) DEFAULT NULL,
11603 `letter3` varchar(20) DEFAULT NULL,
11604 `debarred3` int(1) DEFAULT '0',
11605 PRIMARY KEY (`overduerules_id`),
11606 UNIQUE KEY `overduerules_branch_cat` (`branchcode`,`categorycode`)
11607 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
11608 $dbh->do("INSERT INTO overduerules(branchcode, categorycode, delay1, letter1, debarred1, delay2, debarred2, letter2, delay3, letter3, debarred3) SELECT * FROM old_overduerules");
11609 $dbh->do("DROP TABLE old_overduerules");
11610 $dbh->do("ALTER TABLE overduerules_transport_types
11611 ADD COLUMN overduerules_id int(11) NOT NULL");
11612 my $mtts = $dbh->selectall_arrayref("SELECT * FROM overduerules_transport_types", { Slice => {} });
11613 $dbh->do("DELETE FROM overduerules_transport_types");
11614 $dbh->do("ALTER TABLE overduerules_transport_types
11615 DROP FOREIGN KEY overduerules_fk,
11616 ADD FOREIGN KEY overduerules_transport_types_fk (overduerules_id) REFERENCES overduerules (overduerules_id) ON DELETE CASCADE ON UPDATE CASCADE,
11617 DROP COLUMN branchcode,
11618 DROP COLUMN categorycode");
11619 my $s = $dbh->prepare("INSERT INTO overduerules_transport_types (overduerules_id, id, letternumber, message_transport_type) "
11620 ." VALUES((SELECT overduerules_id FROM overduerules WHERE branchcode = ? AND categorycode = ?),?,?,?)");
11621 foreach my $mtt(@$mtts){
11622 $s->execute($mtt->{branchcode}, $mtt->{categorycode}, $mtt->{id}, $mtt->{letternumber}, $mtt->{message_transport_type} );
11624 $dbh->do("SET FOREIGN_KEY_CHECKS=1");
11626 print "Upgrade to $DBversion done (Bug 13624 - Remove columns branchcode, categorytype from table overduerules_transport_types)\n";
11627 SetVersion($DBversion);
11630 $DBversion = "3.23.00.008";
11631 if ( CheckVersion($DBversion) ) {
11633 $dbh->do(q{ALTER TABLE borrowers ADD privacy_guarantor_checkouts BOOLEAN NOT NULL DEFAULT '0' AFTER privacy});
11635 $dbh->do(q{ALTER TABLE deletedborrowers ADD privacy_guarantor_checkouts BOOLEAN NOT NULL DEFAULT '0' AFTER privacy});
11638 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type )
11640 'AllowStaffToSetCheckoutsVisibilityForGuarantor', '0', NULL,
11641 'If enabled, library staff can set a patron''s checkouts to be visible to linked patrons from the opac.', 'YesNo'
11643 'AllowPatronToSetCheckoutsVisibilityForGuarantor', '0', NULL,
11644 'If enabled, the patron can set checkouts to be visible to his or her guarantor', 'YesNo'
11648 print "Upgrade to $DBversion done (Bug 9303 - relative's checkouts in the opac)\n";
11649 SetVersion($DBversion);
11652 $DBversion = "3.23.00.009";
11653 if ( CheckVersion($DBversion) ) {
11655 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES
11656 ( 'EnablePayPalOpacPayments', '0', NULL , 'Enables the ability to pay fees and fines from the OPAC via PayPal', 'YesNo' ),
11657 ( 'PayPalChargeDescription', 'Koha fee payment', NULL , 'This preference defines what the user will see the charge listed as in PayPal', 'Free' ),
11658 ( 'PayPalPwd', '', NULL , 'Your PayPal API password', 'Free' ),
11659 ( 'PayPalSandboxMode', '1', NULL , 'If enabled, the system will use PayPal''s sandbox server for testing, rather than the production server.', 'YesNo' ),
11660 ( 'PayPalSignature', '', NULL , 'Your PayPal API signature', 'Free' ),
11661 ( 'PayPalUser', '', NULL , 'Your PayPal API username ( email address )', 'Free' )
11664 print "Upgrade to $DBversion done (Bug 11622 - Add ability to pay fees and fines from OPAC via PayPal)\n";
11665 SetVersion($DBversion);
11668 $DBversion = "3.23.00.010";
11669 if ( CheckVersion($DBversion) ) {
11671 ALTER TABLE issuingrules ADD cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0' AFTER overduefinescap
11674 print "Upgrade to $DBversion done (Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price)\n";
11675 SetVersion($DBversion);
11678 $DBversion = "3.23.00.011";
11679 if ( CheckVersion($DBversion) ) {
11681 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('HoldFeeMode','not_always','always|not_always','Set the hold fee mode','Choice')
11684 print "Upgrade to $DBversion done (Bug 13592 - Hold fee not being applied on placing a hold)\n";
11685 SetVersion($DBversion);
11688 $DBversion = "3.23.00.012";
11689 if ( CheckVersion($DBversion) ) {
11691 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `explanation`, `options`, `type` ) VALUES('MaxSearchResultsItemsPerRecordStatusCheck','20','Max number of items per record for which to check transit and hold status','','Integer')
11694 print "Upgrade to $DBversion done (Bug 15380 - Move the authority types related code to Koha::Authority::Type[s] - part 1)\n";
11695 SetVersion($DBversion);
11698 $DBversion = "3.23.00.013";
11699 if ( CheckVersion($DBversion) ) {
11701 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo')
11704 CREATE TABLE IF NOT EXISTS `items_last_borrower` (
11705 `id` int(11) NOT NULL AUTO_INCREMENT,
11706 `itemnumber` int(11) NOT NULL,
11707 `borrowernumber` int(11) NOT NULL,
11708 `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
11709 PRIMARY KEY (`id`),
11710 UNIQUE KEY `itemnumber` (`itemnumber`),
11711 KEY `borrowernumber` (`borrowernumber`),
11712 CONSTRAINT `items_last_borrower_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
11713 CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
11714 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
11717 print "Upgrade to $DBversion done (Bug 14945 - Add the ability to store the last patron to return an item)\n";
11718 SetVersion($DBversion);
11722 $DBversion = "3.23.00.014";
11723 if ( CheckVersion($DBversion) ) {
11725 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
11726 VALUES ('ClaimsBccCopy','0','','Bcc the ClaimAcquisition and ClaimIssues alerts','YesNo')
11729 print "Upgrade to $DBversion done (Bug 10076 - Add Bcc syspref for claimacquisition and clamissues)\n";
11730 SetVersion($DBversion);
11733 $DBversion = "3.23.00.015";
11734 if ( CheckVersion($DBversion) ) {
11736 UPDATE letter SET code = "HOLD_SLIP" WHERE code = "RESERVESLIP";
11739 print "Upgrade to $DBversion done (Bug 15443 - Re-code RESERVESLIP as HOLD_SLIP)\n";
11740 SetVersion($DBversion);
11743 $DBversion = "3.23.00.016";
11744 if ( CheckVersion($DBversion) ) {
11746 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
11747 VALUES ('OpacResetPassword', '0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo');
11750 CREATE TABLE IF NOT EXISTS borrower_password_recovery (
11751 borrowernumber int(11) NOT NULL,
11752 uuid varchar(128) NOT NULL,
11753 valid_until timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
11754 PRIMARY KEY (borrowernumber),
11755 KEY borrowernumber (borrowernumber)
11756 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
11759 INSERT IGNORE INTO `letter` (module, code, branchcode, name, is_html, title, content, message_transport_type)
11760 VALUES ('members','PASSWORD_RESET','','Online password reset',1,'Koha password recovery','<html>\r\n<p>This email has been sent in response to your password recovery request for the account <strong><<user>></strong>.\r\n</p>\r\n<p>\r\nYou can now create your new password using the following link:\r\n<br/><a href=\"<<passwordreseturl>>\"><<passwordreseturl>></a>\r\n</p>\r\n<p>This link will be valid for 2 days from this email\'s reception, then you must reapply if you do not change your password.</p>\r\n<p>Thank you.</p>\r\n</html>\r\n','email');
11764 print "Upgrade to $DBversion done (Bug 8753 - Add forgot password link to OPAC)\n";
11765 SetVersion($DBversion);
11768 $DBversion = "3.23.00.017";
11769 if ( CheckVersion($DBversion) ) {
11772 DELETE FROM uploaded_files
11773 WHERE COALESCE(permanent,0)=0 AND dir='koha_upload'
11776 my $tmp = C4::Context->temporary_directory . '/koha_upload';
11777 remove_tree( $tmp ) if -d $tmp;
11779 print "Upgrade to $DBversion done (Bug 14893 - Separate temporary storage per instance in Upload.pm)\n";
11780 SetVersion($DBversion);
11784 $DBversion = "3.23.00.018";
11785 if ( CheckVersion($DBversion) ) {
11787 UPDATE systempreferences SET value="0" where type="YesNo" and value="";
11790 print "Upgrade to $DBversion done (Bug 15446 - Fix systempreferences rows where type=YesNo and value='')\n";
11791 SetVersion($DBversion);
11794 $DBversion = "3.23.00.019";
11795 if ( CheckVersion($DBversion) ) {
11797 UPDATE `authorised_values` SET `lib`='Non-fiction' WHERE `lib`='Non Fiction';
11800 print "Upgrade to $DBversion done (Bug 15411 - Change Non Fiction to Non-fiction in authorised_values)\n";
11801 SetVersion($DBversion);
11804 $DBversion = "3.23.00.020";
11805 if ( CheckVersion($DBversion) ) {
11807 CREATE TABLE sms_providers (
11808 id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
11809 name VARCHAR( 255 ) NOT NULL ,
11810 domain VARCHAR( 255 ) NOT NULL ,
11814 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
11818 ALTER TABLE borrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber;
11821 ALTER TABLE borrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL;
11824 ALTER TABLE deletedborrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber;
11827 print "Upgrade to $DBversion done (Bug 9021 - Add SMS via email as an alternative to SMS services via SMS::Send drivers)\n";
11828 SetVersion($DBversion);
11831 $DBversion = "3.23.00.021";
11832 if ( CheckVersion($DBversion) ) {
11834 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ShowAllCheckins', '0', '', 'Show all checkins', 'YesNo');
11837 print "Upgrade to $DBversion done (Bug 15736 - Add a preference to control whether all items should be shown in checked-in items list)\n";
11838 SetVersion($DBversion);
11841 $DBversion = "3.23.00.022";
11842 if ( CheckVersion($DBversion) ) {
11843 $dbh->do(q{ ALTER TABLE tags_all MODIFY COLUMN borrowernumber INT(11) });
11844 $dbh->do(q{ ALTER TABLE tags_all drop FOREIGN KEY tags_borrowers_fk_1 });
11845 $dbh->do(q{ ALTER TABLE tags_all ADD CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE });
11846 $dbh->do(q{ ALTER TABLE tags_approval DROP FOREIGN KEY tags_approval_borrowers_fk_1 });
11847 $dbh->do(q{ ALTER TABLE tags_approval ADD CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE });
11849 print "Upgrade to $DBversion done (Bug 13534 - Deleting staff patron will delete tags approved by this patron)\n";
11850 SetVersion($DBversion);
11853 $DBversion = "3.23.00.023";
11854 if ( CheckVersion($DBversion) ) {
11856 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11857 VALUES('OpenLibrarySearch','0','If Yes Open Library search results will show in OPAC',NULL,'YesNo');
11860 print "Upgrade to $DBversion done (Bug 6624 - Allow Koha to use the new read API from OpenLibrary)\n";
11861 SetVersion($DBversion);
11864 $DBversion = "3.23.00.024";
11865 if ( CheckVersion($DBversion) ) {
11867 ALTER TABLE deletedborrowers MODIFY COLUMN userid VARCHAR(75) DEFAULT NULL;
11871 ALTER TABLE deletedborrowers MODIFY COLUMN password VARCHAR(60) DEFAULT NULL;
11874 print "Upgrade to $DBversion done (Bug 15517 - Tables borrowers and deletedborrowers differ again)\n";
11875 SetVersion($DBversion);
11878 $DBversion = "3.23.00.025";
11879 if ( CheckVersion($DBversion) ) {
11881 DROP TABLE IF EXISTS nozebra;
11884 print "Upgrade to $DBversion done (Bug 15526 - Drop nozebra database table)\n";
11885 SetVersion($DBversion);
11888 $DBversion = "3.23.00.026";
11889 if ( CheckVersion($DBversion) ) {
11891 UPDATE systempreferences SET value = CONCAT_WS('|', IF(value='', NULL, value), "password") WHERE variable="PatronSelfRegistrationBorrowerUnwantedField" AND value NOT LIKE "%password%";
11894 print "Upgrade to $DBversion done (Bug 15343 - Allow patrons to choose their own password on self registration)\n";
11895 SetVersion($DBversion);
11898 $DBversion = "3.23.00.027";
11899 if ( CheckVersion($DBversion) ) {
11900 my ( $db_value ) = $dbh->selectrow_array(q|SELECT count(*) FROM branches|);
11901 my $pref_value = C4::Context->preference("singleBranchMode") || 0;
11902 if ( $db_value > 1 and $pref_value == 1 ) {
11903 warn "WARNING: You have more than 1 libraries in your branches tables but the singleBranchMode system preference is on.\n";
11904 warn "This configuration does not make sense. The system preference is going to be deleted,\n";
11905 warn "and this parameter will be based on the number of libraries defined.\n";
11907 $dbh->do(q|DELETE FROM systempreferences WHERE variable="singleBranchMode"|);
11909 print "Upgrade to $DBversion done (Bug 4941 - Can't set branch in staff client when singleBranchMode is enabled)\n";
11910 SetVersion($DBversion);
11913 $DBversion = "3.23.00.028";
11914 if ( CheckVersion($DBversion) ) {
11916 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) SELECT 'PatronSelfModificationBorrowerUnwantedField',value,NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free' FROM systempreferences WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField';
11919 print "Upgrade to $DBversion done (Bug 14658 - Split PatronSelfRegistrationBorrowerUnwantedField into two preferences for creating and editing)\n";
11920 SetVersion($DBversion);
11923 $DBversion = "3.23.00.029";
11924 if ( CheckVersion($DBversion) ) {
11926 # move marc21_field_003.pl 040c and 040d to marc21_orgcode.pl
11928 update marc_subfield_structure set value_builder='marc21_orgcode.pl' where value_builder IN ( 'marc21_field_003.pl', 'marc21_field_040c.pl', 'marc21_field_040d.pl' );
11931 update auth_subfield_structure set value_builder='marc21_orgcode.pl' where value_builder IN ( 'marc21_field_003.pl', 'marc21_field_040c.pl', 'marc21_field_040d.pl' );
11934 print "Upgrade to $DBversion done (Bug 14199 - Unify all organization code plugins)\n";
11935 SetVersion($DBversion);
11938 $DBversion = "3.23.00.030";
11939 if(CheckVersion($DBversion)) {
11941 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
11942 VALUES ('OpacMaintenanceNotice','','','A user-defined block of HTML to appear on screen when OpacMaintenace is enabled','Textarea')
11945 print "Upgrade to $DBversion done (Bug 15311: Let libraries set text to display when OpacMaintenance = on)\n";
11946 SetVersion($DBversion);
11949 $DBversion = "3.23.00.031";
11950 if(CheckVersion($DBversion)) {
11952 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11953 VALUES ('NoRenewalBeforePrecision', 'date', 'Calculate "No renewal before" based on date or exact time. Only relevant for loans calculated in days, hourly loans are not affected.', 'date|exact_time', 'Choice')
11956 print "Upgrade to $DBversion done (Bug 14395 - Two different ways to calculate 'No renewal before')\n";
11957 SetVersion($DBversion);
11960 $DBversion = "3.23.00.032";
11961 if ( CheckVersion($DBversion) ) {
11963 -- Add issue_id to accountlines table
11964 ALTER TABLE accountlines ADD issue_id INT(11) NULL DEFAULT NULL AFTER accountlines_id;
11967 ## Close out any accruing fines with no current issue
11969 UPDATE accountlines LEFT JOIN issues USING ( itemnumber, borrowernumber ) SET accounttype = 'F' WHERE accounttype = 'FU' and issues.issue_id IS NULL;
11972 ## Close out any extra not really accruing fines, keep only the latest accring fine
11974 UPDATE accountlines a1
11975 LEFT JOIN (SELECT MAX(accountlines_id) AS keeper,
11979 WHERE accounttype = 'FU'
11980 GROUP BY borrowernumber, itemnumber
11981 ) a2 USING ( borrowernumber, itemnumber )
11982 SET a1.accounttype = 'F'
11983 WHERE a1.accounttype = 'FU'
11984 AND a1.accountlines_id != a2.keeper;
11987 ## Update the unclosed fines to add the current issue_id to them
11989 UPDATE accountlines LEFT JOIN issues USING ( itemnumber ) SET accountlines.issue_id = issues.issue_id WHERE accounttype = 'FU';
11992 print "Upgrade to $DBversion done (Bug 15675 - Add issue_id column to accountlines and use it for updating fines)\n";
11993 SetVersion($DBversion);
11996 $DBversion = "3.23.00.033";
11997 if ( CheckVersion($DBversion) ) {
11999 UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'cardnumber') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%cardnumber%';
12003 UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'categorycode') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%categorycode%';
12006 print "Upgrade to $DBversion done (Bug 14659 - Allow patrons to enter card number and patron category on OPAC registration page)\n";
12007 SetVersion($DBversion);
12010 $DBversion = "3.23.00.034";
12011 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12013 ALTER TABLE `items` ADD `new` VARCHAR(32) NULL AFTER `stocknumber`;
12016 ALTER TABLE `deleteditems` ADD `new` VARCHAR(32) NULL AFTER `stocknumber`;
12018 print "Upgrade to $DBversion done (Bug 11023: Adds field 'new' in items and deleteditems tables)\n";
12019 SetVersion($DBversion);
12022 $DBversion = "3.23.00.035";
12023 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12025 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo');
12027 print "Upgrade to $DBversion done (Bug 14168 - enhance streaming cataloging to include youtube)\n";
12029 SetVersion($DBversion);
12032 $DBversion = "3.23.00.036";
12033 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12035 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES ('HoldsQueueSkipClosed', '0', 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo');
12037 print "Upgrade to $DBversion done (Bug 12803 - Add ability to skip closed libraries when generating the holds queue)\n";
12038 SetVersion($DBversion);
12041 $DBversion = "3.23.00.037";
12042 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12043 ## Add the new currency.archived column
12045 ALTER TABLE currency ADD column archived tinyint(1) DEFAULT 0;
12047 ## Set currency=NULL if empty (just in case)
12049 UPDATE aqorders SET currency=NULL WHERE currency="";
12051 ## Insert the missing currency and mark them as archived before adding the FK
12053 INSERT INTO currency(currency, archived) SELECT distinct currency, 1 FROM aqorders WHERE currency NOT IN (SELECT currency FROM currency);
12055 ## Correct the field length in aqorders before adding FK too
12056 $dbh->do(q{ ALTER TABLE aqorders MODIFY COLUMN currency varchar(10) default NULL; });
12057 ## And finally add the FK
12059 ALTER TABLE aqorders ADD FOREIGN KEY (currency) REFERENCES currency(currency) ON DELETE SET NULL ON UPDATE SET null;
12062 print "Upgrade to $DBversion done (Bug 15084 - Move the currency related code to Koha::Acquisition::Currenc[y|ies])\n";
12063 SetVersion($DBversion);
12066 $DBversion = "3.23.00.038";
12067 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12069 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('decreaseLoanHighHoldsControl', 'static', 'static|dynamic', "Chooses between static and dynamic high holds checking", 'Choice'), ('decreaseLoanHighHoldsIgnoreStatuses', '', 'damaged|itemlost|notforloan|withdrawn', "Ignore items with these statuses for dynamic high holds checking", 'Choice');
12071 print "Upgrade to $DBversion done (Bug 14694 - Make decreaseloanHighHolds more flexible)\n";
12072 SetVersion($DBversion);
12075 $DBversion = "3.23.00.039";
12076 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12079 ALTER TABLE suggestions
12080 MODIFY COLUMN currency varchar(10) default NULL;
12083 ALTER TABLE aqbooksellers
12084 MODIFY COLUMN currency varchar(10) default NULL;
12086 print "Upgrade to $DBversion done (Bug 15084 - Move the currency related code to Koha::Acquisition::Currenc[y|ies])\n";
12087 SetVersion($DBversion);
12091 $DBversion = "3.23.00.040";
12092 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12094 my $c = $dbh->selectrow_array('SELECT COUNT(*) FROM systempreferences WHERE variable="intranetcolorstylesheet" AND value="blue.css"');
12097 print "WARNING: You are using a stylesheeet which has been removed from the Koha codebase.\n";
12098 print "Update your intranetcolorstylesheet.\n";
12100 print "Upgrade to $DBversion done (Bug 16019 - Check intranetcolorstylesheet for blue.css)\n";
12101 SetVersion($DBversion);
12104 $DBversion = "3.23.00.041";
12105 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12107 my $dbh = C4::Context->dbh;
12108 my ($print_error) = $dbh->{PrintError};
12109 $dbh->{RaiseError} = 0;
12110 $dbh->{PrintError} = 0;
12111 $dbh->do("ALTER TABLE overduerules_transport_types ADD COLUMN letternumber INT(1) NOT NULL DEFAULT 1 AFTER id");
12112 $dbh->{PrintError} = $print_error;
12114 print "Upgrade to $DBversion done (Bug 16007: Make sure overduerules_transport_types.letternumber exists)\n";
12115 SetVersion($DBversion);
12118 $DBversion = "3.23.00.042";
12119 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12122 ALTER TABLE items CHANGE new new_status VARCHAR(32) NULL;
12125 ALTER TABLE deleteditems CHANGE new new_status VARCHAR(32) NULL;
12128 UPDATE systempreferences SET value=REPLACE(value, '"items.new"', '"items.new_status"') WHERE variable="automatic_item_modification_by_age_configuration";
12131 print "Upgrade to $DBversion done (Bug 16004 - Replace items.new with items.new_status)\n";
12132 SetVersion($DBversion);
12135 $DBversion = "3.23.00.043";
12136 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12138 UPDATE systempreferences SET value="" WHERE value IS NULL;
12141 print "Upgrade to $DBversion done (Bug 16070 - Empty (undef) system preferences may cause some issues in combination with memcache)\n";
12142 SetVersion($DBversion);
12145 $DBversion = "3.23.00.044";
12146 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12148 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
12149 ('GoogleOpenIDConnect', '0', NULL, 'if ON, allows the use of Google OpenID Connect for login', 'YesNo'),
12150 ('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with Google', 'Free'),
12151 ('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with Google', 'Free'),
12152 ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free');
12155 print "Upgrade to $DBversion done (Bug 10988 - Allow login via Google OAuth2 (OpenID Connect))\n";
12156 SetVersion($DBversion);
12159 $DBversion = "3.23.00.045";
12160 if ( CheckVersion($DBversion) ) {
12161 ## Holds details for vendors supplying goods by EDI
12163 CREATE TABLE IF NOT EXISTS vendor_edi_accounts (
12164 id INT(11) NOT NULL auto_increment,
12165 description TEXT NOT NULL,
12167 username VARCHAR(40),
12168 password VARCHAR(40),
12169 last_activity DATE,
12170 vendor_id INT(11) REFERENCES aqbooksellers( id ),
12171 download_directory TEXT,
12172 upload_directory TEXT,
12174 id_code_qualifier VARCHAR(3) default '14',
12175 transport VARCHAR(6) default 'FTP',
12176 quotes_enabled TINYINT(1) not null default 0,
12177 invoices_enabled TINYINT(1) not null default 0,
12178 orders_enabled TINYINT(1) not null default 0,
12179 responses_enabled TINYINT(1) not null default 0,
12180 auto_orders TINYINT(1) not null default 0,
12181 shipment_budget INTEGER(11) REFERENCES aqbudgets( budget_id ),
12183 KEY vendorid (vendor_id),
12184 KEY shipmentbudget (shipment_budget),
12185 CONSTRAINT vfk_vendor_id FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
12186 CONSTRAINT vfk_shipment_budget FOREIGN KEY ( shipment_budget ) REFERENCES aqbudgets ( budget_id )
12187 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
12190 ## Hold the actual edifact messages with links to associated baskets
12192 CREATE TABLE IF NOT EXISTS edifact_messages (
12193 id INT(11) NOT NULL auto_increment,
12194 message_type VARCHAR(10) NOT NULL,
12195 transfer_date DATE,
12196 vendor_id INT(11) REFERENCES aqbooksellers( id ),
12197 edi_acct INTEGER REFERENCES vendor_edi_accounts( id ),
12199 basketno INT(11) REFERENCES aqbasket( basketno),
12200 raw_msg MEDIUMTEXT,
12202 deleted BOOLEAN NOT NULL DEFAULT 0,
12204 KEY vendorid ( vendor_id),
12205 KEY ediacct (edi_acct),
12206 KEY basketno ( basketno),
12207 CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
12208 CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ),
12209 CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno )
12210 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
12213 ## invoices link back to the edifact message it was generated from
12215 ALTER TABLE aqinvoices ADD COLUMN message_id INT(11) REFERENCES edifact_messages( id );
12218 ## clean up link on deletes
12220 ALTER TABLE aqinvoices ADD CONSTRAINT edifact_msg_fk FOREIGN KEY ( message_id ) REFERENCES edifact_messages ( id ) ON DELETE SET NULL;
12223 ## Hold the supplier ids from quotes for ordering
12224 ## although this is an EAN-13 article number the standard says 35 characters ???
12226 ALTER TABLE aqorders ADD COLUMN line_item_id VARCHAR(35);
12229 ## The suppliers unique reference usually a quotation line number ('QLI')
12230 ## Otherwise Suppliers unique orderline reference ('SLI')
12232 ALTER TABLE aqorders ADD COLUMN suppliers_reference_number VARCHAR(35);
12235 ALTER TABLE aqorders ADD COLUMN suppliers_reference_qualifier VARCHAR(3);
12238 ALTER TABLE aqorders ADD COLUMN suppliers_report text;
12241 ## hold the EAN/SAN used in ordering
12243 CREATE TABLE IF NOT EXISTS edifact_ean (
12244 ee_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
12245 description VARCHAR(128) NULL DEFAULT NULL,
12246 branchcode VARCHAR(10) NOT NULL REFERENCES branches (branchcode),
12247 ean VARCHAR(15) NOT NULL,
12248 id_code_qualifier VARCHAR(3) NOT NULL DEFAULT '14',
12249 CONSTRAINT efk_branchcode FOREIGN KEY ( branchcode ) REFERENCES branches ( branchcode )
12250 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
12253 ## Add a permission for managing EDI
12255 INSERT INTO permissions (module_bit, code, description) values (11, 'edi_manage', 'Manage EDIFACT transmissions');
12258 print "Upgrade to $DBversion done (Bug 7736 - Edifact QUOTE and ORDER functionality))\n";
12259 SetVersion($DBversion);
12262 $DBversion = "3.23.00.046";
12263 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12266 ALTER TABLE vendor_edi_accounts ADD COLUMN plugin VARCHAR(256) NOT NULL DEFAULT "";
12269 print "Upgrade to $DBversion done (Bug 15630 - Make Edifact module pluggable))\n";
12270 SetVersion($DBversion);
12273 $DBversion = "3.23.00.047";
12274 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12277 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('IntranetReportsHomeHTML', '', 'Show the following HTML in a div on the bottom of the reports home page', NULL, 'Free');
12280 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('IntranetCirculationHomeHTML', '', 'Show the following HTML in a div on the bottom of the reports home page', NULL, 'Free');
12283 print "Upgrade to $DBversion done (Bug 15008 - Add custom HTML areas to circulation and reports home pages)\n";
12284 SetVersion($DBversion);
12287 $DBversion = "3.23.00.048";
12288 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12290 INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type) SELECT 'OPACISBD', value, '70|10', 'Allows to define ISBD view in OPAC', 'Textarea' FROM `systempreferences` WHERE variable = 'ISBD';
12293 print "Upgrade to $DBversion done (Bug 5979 - Add separate OPACISBD system preference)\n";
12294 SetVersion($DBversion);
12299 $DBversion = "3.23.00.049";
12300 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
12301 my $dbh = C4::Context->dbh;
12302 my ( $column_has_been_used ) = $dbh->selectrow_array(q|
12304 FROM borrower_attributes
12305 WHERE password IS NOT NULL
12308 if ( $column_has_been_used ) {
12309 print q|WARNING: The columns borrower_attribute_types.password_allowed and borrower_attributes.password have been removed from the Koha codebase. They were not used. However your installation has at least one borrower_attributes.password defined. In order not to alter your data, the columns have been kept, please save the information elsewhere and remove these columns manually.|;
12312 ALTER TABLE borrower_attribute_types DROP column password_allowed
12315 ALTER TABLE borrower_attributes DROP column password;
12318 print "Upgrade to $DBversion done (Bug 12267 - Allow password option in Patron Attribute non functional)\n";
12319 SetVersion($DBversion);
12323 $DBversion = "3.23.00.050";
12324 if ( CheckVersion($DBversion) ) {
12326 $dbh->do(q|INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
12327 VALUES('SearchEngine','Zebra','Choose Search Engine','','Choice')|);
12330 $dbh->do(q|DROP TABLE IF EXISTS search_marc_to_field|);
12331 $dbh->do(q|DROP TABLE IF EXISTS search_marc_map|);
12332 $dbh->do(q|DROP TABLE IF EXISTS search_field|);
12334 # This specifies the fields that will be stored in the search engine.
12336 CREATE TABLE `search_field` (
12337 `id` int(11) NOT NULL AUTO_INCREMENT,
12338 `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine',
12339 `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display',
12340 `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine',
12341 PRIMARY KEY (`id`),
12342 UNIQUE KEY (`name`)
12343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
12345 # This contains a MARC field specifier for a given index, marc type, and marc
12348 CREATE TABLE `search_marc_map` (
12349 id int(11) NOT NULL AUTO_INCREMENT,
12350 index_name ENUM('biblios','authorities') NOT NULL COMMENT 'what storage index this map is for',
12351 marc_type ENUM('marc21', 'unimarc', 'normarc') NOT NULL COMMENT 'what MARC type this map is for',
12352 marc_field VARCHAR(255) NOT NULL COMMENT 'the MARC specifier for this field',
12354 unique key( index_name, marc_field, marc_type),
12355 INDEX (`index_name`)
12356 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
12359 # This joins the two search tables together. We can have any combination:
12360 # one marc field could have many search fields (maybe you want one value
12361 # to go to 'author' and 'corporate-author) and many marc fields could go
12362 # to one search field (e.g. all the various author fields going into
12365 # a note about the sort field:
12366 # * if all the entries for a mapping are 'null', nothing special is done with that mapping.
12367 # * if any of the entries are not null, then a __sort field is created in ES for this mapping. In this case:
12368 # * any mapping with sort == false WILL NOT get copied into a __sort field
12369 # * any mapping with sort == true or is null WILL get copied into a __sort field
12370 # * any sorts on the field name will be applied to $fieldname.'__sort' instead.
12371 # this means that we can have search for author that includes 1xx, 245$c, and 7xx, but the sort only applies to 1xx.
12374 CREATE TABLE `search_marc_to_field` (
12375 search_marc_map_id int(11) NOT NULL,
12376 search_field_id int(11) NOT NULL,
12377 facet boolean DEFAULT FALSE COMMENT 'true if a facet field should be generated for this',
12378 suggestible boolean DEFAULT FALSE COMMENT 'true if this field can be used to generate suggestions for browse',
12379 sort boolean DEFAULT NULL COMMENT 'true/false creates special sort handling, null doesn''t',
12380 PRIMARY KEY(search_marc_map_id, search_field_id),
12381 FOREIGN KEY(search_marc_map_id) REFERENCES search_marc_map(id) ON DELETE CASCADE ON UPDATE CASCADE,
12382 FOREIGN KEY(search_field_id) REFERENCES search_field(id) ON DELETE CASCADE ON UPDATE CASCADE
12383 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
12386 print "WARNING: If you plan to use Elasticsearch you should go to 'Home › Administration › Search engine configuration' and reset the mappings\n";
12387 print "Upgrade to $DBversion done (Bug 12478 - Elasticsearch support for Koha)\n";
12388 SetVersion($DBversion);
12392 $DBversion = "3.23.00.051";
12393 if ( CheckVersion($DBversion) ) {
12395 ALTER TABLE edifact_messages
12396 DROP FOREIGN KEY emfk_vendor,
12397 DROP FOREIGN KEY emfk_edi_acct,
12398 DROP FOREIGN KEY emfk_basketno;
12402 ALTER TABLE edifact_messages
12403 ADD CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
12404 ADD CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ) ON DELETE CASCADE ON UPDATE CASCADE,
12405 ADD CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno ) ON DELETE CASCADE ON UPDATE CASCADE;
12408 print "Upgrade to $DBversion done (Bug 16354 - Fix FK constraints for edifact_messages table)\n";
12409 SetVersion($DBversion);
12413 $DBversion = "3.23.00.052";
12414 if ( CheckVersion($DBversion) ) {
12415 ## Insert permission
12418 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
12419 (13, 'upload_general_files', 'Upload any file'),
12420 (13, 'upload_manage', 'Manage uploaded files');
12422 ## Update user_permissions for current users (check count in uploaded_files)
12423 ## Note 9 == edit_catalogue and 13 == tools
12424 ## We do not insert if someone is superlibrarian, does not have edit_catalogue,
12425 ## or already has all tools
12428 INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
12429 SELECT borrowernumber, 13, 'upload_general_files'
12431 WHERE flags<>1 AND flags & POW(2,13) = 0 AND
12432 ( flags & POW(2,9) > 0 OR
12433 (SELECT COUNT(*) FROM user_permissions
12434 WHERE borrowernumber=bo.borrowernumber AND module_bit=9 ) > 0 )
12435 AND ( SELECT COUNT(*) FROM uploaded_files ) > 0
12438 print "Upgrade to $DBversion done (Bug 14686 - New menu option and permission for file uploading)\n";
12439 SetVersion($DBversion);
12442 $DBversion = "3.23.00.053";
12443 if ( CheckVersion($DBversion) ) {
12444 my $letters = $dbh->selectall_arrayref(
12448 WHERE message_transport_type="email"
12451 for my $letter (@$letters) {
12457 AND message_transport_type <> "email"
12458 |, undef, $letter->{name}, $letter->{code}
12462 print "Upgrade to $DBversion done (Bug 16217 - Notice' names may have diverged)\n";
12463 SetVersion($DBversion);
12466 $DBversion = "3.23.00.054";
12467 if ( CheckVersion($DBversion) ) {
12469 ALTER TABLE branch_item_rules ADD COLUMN hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any' AFTER holdallowed;
12472 ALTER TABLE default_branch_circ_rules ADD COLUMN hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any' AFTER holdallowed;
12475 ALTER TABLE default_branch_item_rules ADD COLUMN hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any' AFTER holdallowed;
12478 ALTER TABLE default_circ_rules ADD COLUMN hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any' AFTER holdallowed;
12481 print "Upgrade to $DBversion done (Bug 15532 - Add ability to allow only items whose home/holding branch matches the hold's pickup branch to fill a given hold)\n";
12482 SetVersion($DBversion);
12485 $DBversion = "3.23.00.055";
12486 if ( CheckVersion($DBversion) ) {
12488 ALTER TABLE reserves ADD COLUMN itemtype VARCHAR(10) NULL DEFAULT NULL AFTER suspend_until;
12491 ALTER TABLE reserves ADD KEY `itemtype` (`itemtype`);
12494 ALTER TABLE reserves ADD CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE;
12497 ALTER TABLE old_reserves ADD COLUMN itemtype VARCHAR(10) NULL DEFAULT NULL AFTER suspend_until;
12500 ALTER TABLE old_reserves ADD KEY `itemtype` (`itemtype`);
12503 ALTER TABLE old_reserves ADD CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE;
12507 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
12508 ('AllowHoldItemTypeSelection','0','','If enabled, patrons and staff will be able to select the itemtype when placing a hold','YesNo');
12511 print "Upgrade to $DBversion done (Bug 15533 - Allow patrons and librarians to select itemtype when placing hold)\n";
12512 SetVersion($DBversion);
12515 $DBversion = "3.23.00.056";
12516 if ( CheckVersion($DBversion) ) {
12518 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
12519 ('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer');
12522 print "Upgrade to $DBversion done (Bug 14577 - Allow restriction of checkouts based on fines of guarantor/guarantee)\n";
12523 SetVersion($DBversion);
12526 $DBversion = "3.23.00.057";
12527 if ( CheckVersion($DBversion) ) {
12529 ALTER TABLE aqbasket ADD COLUMN is_standing TINYINT(1) NOT NULL DEFAULT 0 AFTER branch;
12532 print "Upgrade to $DBversion done (Bug 15531 - Add support for standing orders)\n";
12533 SetVersion($DBversion);
12536 $DBversion = "3.23.00.058";
12537 if ( CheckVersion($DBversion) ) {
12539 my ($count_imageurl) = $dbh->selectrow_array(q|
12541 FROM authorised_values
12542 WHERE imageurl IS NOT NULL
12546 unless ($count_imageurl) {
12547 if ( C4::Context->preference('AuthorisedValueImages')
12548 or C4::Context->preference('StaffAuthorisedValueImages') )
12551 UPDATE systempreferences
12553 WHERE variable = "AuthorisedValueImages"
12554 or variable = "StaffAuthorisedValueImages"
12556 warn "The system preferences AuthorisedValueImages and StaffAuthorisedValueImages have been turned off\n";
12557 warn "authorised_values.imageurl is not populated, that means you are not using this feature\n";
12561 warn "At least one authorised value has an icon defined (imageurl)\n";
12562 warn "The system preference AuthorisedValueImages or StaffAuthorisedValueImages could be turned off if you are not aware of this feature\n";
12565 print "Upgrade to $DBversion done (Bug 16041 - StaffAuthorisedValueImages & AuthorisedValueImages preferences - impact on search performance)\n";
12566 SetVersion($DBversion);
12569 $DBversion = "3.23.00.059";
12570 if ( CheckVersion($DBversion) ) {
12572 DELETE FROM systempreferences WHERE variable="AuthorisedValueImages" OR variable="StaffAuthorisedValueImages";
12575 print "Upgrade to $DBversion done (Bug 16167 - Remove prefs to drive authorised value images)\n";
12576 SetVersion($DBversion);
12579 $DBversion = "3.23.00.060";
12580 if ( CheckVersion($DBversion) ) {
12582 INSERT IGNORE INTO systempreferences ( value, variable, options, explanation,type )
12583 SELECT value ,'EnhancedMessagingPreferencesOPAC', NULL, 'If ON, allows patrons to select to receive additional messages about items due or nearly due.', 'YesNo' FROM systempreferences WHERE variable = 'EnhancedMessagingPreferences';
12586 print "Upgrade to $DBversion done (Bug 12528 - Enable staff to deny message setting access to patrons on the OPAC)\n";
12587 SetVersion($DBversion);
12590 $DBversion = "3.23.00.061";
12591 if ( CheckVersion($DBversion) ) {
12592 my ( $cnt ) = $dbh->selectrow_array( q|
12593 SELECT COUNT(*) FROM items it
12594 LEFT JOIN biblio bi ON bi.biblionumber=it.biblionumber
12595 LEFT JOIN biblioitems bii USING (biblioitemnumber)
12596 WHERE bi.biblionumber IS NULL
12599 print "WARNING: You have corrupted data in your items table!! The table contains $cnt references to biblio records that do not exist.\nPlease correct your data IMMEDIATELY after this upgrade and manually add the foreign key constraint for biblionumber in the items table.\n";
12604 ADD FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
12606 print "Upgrade to $DBversion done (Bug 16170 - Add FK for biblionumber in items)\n";
12608 SetVersion($DBversion);
12611 $DBversion = "3.23.00.062";
12612 if ( CheckVersion($DBversion) ) {
12614 ALTER TABLE aqorders DROP COLUMN budgetgroup_id;
12616 print "Upgrade to $DBversion done (Bug 16414 - aqorders.budgetgroup_id has never been used and can be removed)\n";
12617 SetVersion($DBversion);
12620 $DBversion = "3.23.00.063";
12621 if ( CheckVersion($DBversion) ) {
12623 UPDATE letter SET branchcode='' WHERE branchcode IS NULL;
12626 ALTER TABLE letter MODIFY COLUMN branchcode varchar(10) NOT NULL DEFAULT ''
12629 ALTER TABLE permissions MODIFY COLUMN code varchar(64) NOT NULL DEFAULT '';
12631 print "Upgrade to $DBversion done (Bug 16402: Fix DB structure to work on MySQL 5.7)\n";
12632 SetVersion($DBversion);
12635 $DBversion = "3.23.00.064";
12636 if ( CheckVersion($DBversion) ) {
12638 ALTER TABLE creator_layouts MODIFY layout_name char(25) NOT NULL DEFAULT 'DEFAULT';
12640 print "Upgrade to $DBversion done (Bug 15086 - Creators layout and template sql has warnings)\n";
12641 SetVersion($DBversion);
12644 $DBversion = "16.05.00.000";
12645 if ( CheckVersion($DBversion) ) {
12646 print "Upgrade to $DBversion done (Koha 16.05)\n";
12647 SetVersion($DBversion);
12650 $DBversion = "16.06.00.000";
12651 if ( CheckVersion($DBversion) ) {
12652 print "Upgrade to $DBversion done (Koha 16.06 - starting a new dev line at KohaCon16 in Thessaloniki, Greece! Koha is great!)\n";
12653 SetVersion($DBversion);
12656 $DBversion = "16.06.00.001";
12657 if ( CheckVersion($DBversion) ) {
12659 UPDATE accountlines SET accounttype='HE', description=itemnumber WHERE (description REGEXP '^Hold waiting too long [0-9]+') AND accounttype='F';
12662 print "Upgrade to $DBversion done (Bug 16200 - 'Hold waiting too long' fee has a translation problem)\n";
12663 SetVersion($DBversion);
12666 $DBversion = "16.06.00.002";
12667 if ( CheckVersion($DBversion) ) {
12668 unless ( column_exists('borrowers', 'updated_on') ) {
12670 ALTER TABLE borrowers
12671 ADD COLUMN updated_on timestamp NULL DEFAULT CURRENT_TIMESTAMP
12672 ON UPDATE CURRENT_TIMESTAMP
12673 AFTER privacy_guarantor_checkouts;
12676 ALTER TABLE deletedborrowers
12677 ADD COLUMN updated_on timestamp NULL DEFAULT CURRENT_TIMESTAMP
12678 ON UPDATE CURRENT_TIMESTAMP
12679 AFTER privacy_guarantor_checkouts;
12683 print "Upgrade to $DBversion done (Bug 10459 - borrowers should have a timestamp)\n";
12684 SetVersion($DBversion);
12687 $DBversion = "16.06.00.003";
12688 if ( CheckVersion($DBversion) ) {
12690 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
12691 SELECT 'MaxItemsToProcessForBatchMod', value, NULL, 'Process up to a given number of items in a single item modification batch.', 'Integer' FROM systempreferences WHERE variable='MaxItemsForBatch';
12694 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
12695 SELECT 'MaxItemsToDisplayForBatchDel', value, NULL, 'Display up to a given number of items in a single item deletionbatch.', 'Integer' FROM systempreferences WHERE variable='MaxItemsForBatch';
12698 DELETE FROM systempreferences WHERE variable="MaxItemsForBatch";
12701 print "Upgrade to $DBversion done (Bug 11490 - MaxItemsForBatch should be split into two new prefs)\n";
12702 SetVersion($DBversion);
12705 $DBversion = '16.06.00.004';
12706 if ( CheckVersion($DBversion) ) {
12708 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
12709 SELECT 'OPACXSLTListsDisplay', COALESCE(value,''), '', 'Enable XSLT stylesheet control over lists pages display on OPAC', 'Free'
12710 FROM systempreferences WHERE variable='OPACXSLTResultsDisplay';
12714 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
12715 SELECT 'XSLTListsDisplay', COALESCE(value,''), '', 'Enable XSLT stylesheet control over lists pages display on intranet', 'Free'
12716 FROM systempreferences WHERE variable='XSLTResultsDisplay';
12719 print "Upgrade to $DBversion done (Bug 15485: Allow choosing different XSLTs for lists)\n";
12720 SetVersion($DBversion);
12723 $DBversion = '16.06.00.005';
12724 if ( CheckVersion($DBversion) ) {
12726 UPDATE `systempreferences` set options = 'US|FR|CH' where variable = 'CurrencyFormat';
12729 print "Upgrade to $DBversion done (Bug 16768 - Add official number format for Switzerland: 1'234'567.89)\n";
12730 SetVersion($DBversion);
12733 $DBversion = "16.06.00.006";
12734 if ( CheckVersion($DBversion) ) {
12736 CREATE TABLE `refund_lost_item_fee_rules` (
12737 `branchcode` varchar(10) NOT NULL default '',
12738 `refund` tinyint(1) NOT NULL default 0,
12739 PRIMARY KEY (`branchcode`)
12740 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
12743 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
12744 VALUES( 'RefundLostOnReturnControl',
12746 'If a lost item is returned, choose which branch to pick rules for refunding.',
12747 'CheckinLibrary|PatronLibrary|ItemHomeBranch|ItemHoldingbranch',
12750 # Pick the old syspref as the default rule
12752 INSERT INTO refund_lost_item_fee_rules (branchcode,refund)
12753 SELECT '*', COALESCE(value,'1') FROM systempreferences WHERE variable='RefundLostItemFeeOnReturn'
12755 # Delete the old syspref
12757 DELETE IGNORE FROM systempreferences
12758 WHERE variable='RefundLostItemFeeOnReturn'
12761 print "Upgrade to $DBversion done (Bug 14048: Change RefundLostItemFeeOnReturn to be branch specific)\n";
12762 SetVersion($DBversion);
12765 $DBversion = '16.06.00.007';
12766 if ( CheckVersion($DBversion) ) {
12768 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
12769 VALUES ('PatronQuickAddFields', '', 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry', NULL, 'Free');
12772 print "Upgrade to $DBversion done (Bug 3534 - Patron quick add form)\n";
12773 SetVersion($DBversion);
12776 $DBversion = '16.06.00.008';
12777 if ( CheckVersion($DBversion) ) {
12779 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
12780 VALUES('CheckPrevCheckout','hardno','hardyes|softyes|softno|hardno','By default, for every item checked out, should we warn if the patron has checked out that item in the past?','Choice');
12783 ALTER TABLE categories
12784 ADD COLUMN `checkprevcheckout` varchar(7) NOT NULL default 'inherit'
12785 AFTER `default_privacy`;
12788 ALTER TABLE borrowers
12789 ADD COLUMN `checkprevcheckout` varchar(7) NOT NULL default 'inherit'
12790 AFTER `privacy_guarantor_checkouts`;
12793 ALTER TABLE deletedborrowers
12794 ADD COLUMN `checkprevcheckout` varchar(7) NOT NULL default 'inherit'
12795 AFTER `privacy_guarantor_checkouts`;
12798 print "Upgrade to $DBversion done (Bug 6906 - show 'Borrower has previously issued \$ITEM' alert on checkout)\n";
12799 SetVersion($DBversion);
12802 $DBversion = '16.06.00.009';
12803 if ( CheckVersion($DBversion) ) {
12805 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
12806 VALUES ('IntranetCatalogSearchPulldown','0',NULL,'Show a search field pulldown for \"Search the catalog\" boxes. ','YesNo');
12809 print "Upgrade to $DBversion done (Bug 14902 - Add qualifier menu to staff side 'Search the Catalog')\n";
12810 SetVersion($DBversion);
12813 $DBversion = '16.06.00.010';
12814 if ( CheckVersion($DBversion) ) {
12816 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
12817 VALUES ('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once, unlimited if blank','Integer')
12820 print "Upgrade to $DBversion done (Bug 15128 - Add ability to limit the number of open purchase suggestions a patron can make)\n";
12821 SetVersion($DBversion);
12824 $DBversion = '16.06.00.011';
12825 if ( CheckVersion($DBversion) ) {
12827 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
12828 ('NovelistSelectStaffEnabled','0',NULL,'Enable Novelist Select content to the Staff Interface (requires that you have entered in a user profile and password, which can be seen in image links)','YesNo'),
12829 ('NovelistSelectStaffView','tab','tab|above|below','Where to display Novelist Select content','Choice');
12832 print "Upgrade to $DBversion done (Bug 11606 - Novelist Select in Staff Client)\n";
12833 SetVersion($DBversion);
12836 $DBversion = '16.06.00.012';
12837 if ( CheckVersion($DBversion) ) {
12839 ALTER TABLE virtualshelves MODIFY COLUMN created_on DATETIME not NULL;
12842 print "Upgrade to $DBversion done (Bug 16573 - Web installer fails to load structure and sample data on MySQL 5.7)\n";
12843 SetVersion($DBversion);
12846 $DBversion = '16.06.00.013';
12847 if ( CheckVersion($DBversion) ) {
12849 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
12850 ('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice');
12853 print "Upgrade to $DBversion done (Bug 7441 - Search results showing wrong branch)\n";
12854 SetVersion($DBversion);
12857 $DBversion = "16.06.00.014";
12858 if ( CheckVersion($DBversion) ) {
12860 ALTER TABLE `action_logs` ADD COLUMN `interface` VARCHAR(30) DEFAULT NULL AFTER `info`;
12864 ALTER TABLE `action_logs` ADD KEY `interface` (`interface`);
12867 print "Upgrade to $DBversion done (Bug 16829: action_logs should have an 'interface' column)\n";
12868 SetVersion($DBversion);
12871 $DBversion = "16.06.00.015";
12872 if ( CheckVersion($DBversion) ) {
12874 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES
12875 ('HoldsLog','0',NULL,'If ON, log create/cancel/suspend/resume actions on holds.','YesNo');
12878 print "Upgrade to $DBversion done (Bug 14642: Add logging of hold modifications)\n";
12879 SetVersion($DBversion);
12882 $DBversion = "16.06.00.016";
12883 if ( CheckVersion($DBversion) ) {
12885 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'YYYY', '<<YYYY>>') where defaultvalue like "%YYYY%" and defaultvalue not like "%<<YYYY>>%";
12888 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'MM', '<<MM>>') where defaultvalue like "%MM%" and defaultvalue not like "%<<MM>>%";
12891 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'DD', '<<DD>>') where defaultvalue like "%DD%" and defaultvalue not like "%<<DD>>%";
12894 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'user', '<<USER>>') where defaultvalue like "%user%" and defaultvalue not like "%<<USER>>%";
12897 print "Upgrade to $DBversion done (Bug 7045 - Default-value substitution inconsistent)\n";
12898 SetVersion($DBversion);
12901 $DBversion = "16.06.00.017";
12902 if ( CheckVersion($DBversion) ) {
12904 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACSuggestionMandatoryFields','title','','Define the mandatory fields for a patron purchase suggestions made via OPAC.','multiple');
12907 print "Upgrade to $DBversion done (Bug 10848 - Allow configuration of mandatory/required fields on the suggestion form in OPAC)\n";
12908 SetVersion($DBversion);
12911 $DBversion = "16.06.00.018";
12912 if ( CheckVersion($DBversion) ) {
12914 ALTER TABLE issuingrules ADD COLUMN holds_per_record SMALLINT(6) NOT NULL DEFAULT 1 AFTER reservesallowed;
12917 print "Upgrade to $DBversion done (Bug 14695 - Add ability to place multiple item holds on a given record per patron)\n";
12918 SetVersion($DBversion);
12921 $DBversion = "16.06.00.019";
12922 if ( CheckVersion($DBversion) ) {
12924 ALTER TABLE reviews CHANGE COLUMN approved approved tinyint(4) DEFAULT 0;
12927 UPDATE reviews SET approved=0 WHERE approved IS NULL;
12930 print "Upgrade to $DBversion done (Bug 15839 - Move the reviews related code to Koha::Reviews)\n";
12931 SetVersion($DBversion);
12934 $DBversion = "16.06.00.020";
12935 if ( CheckVersion($DBversion) ) {
12937 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('SwitchOnSiteCheckouts', '0', 'Automatically switch an on-site checkout to a normal checkout', NULL, 'YesNo');
12940 print "Upgrade to $DBversion done (Bug 16272 - Transform checkout from on-site checkout to regular checkout)\n";
12941 SetVersion($DBversion);
12944 $DBversion = "16.06.00.021";
12945 if ( CheckVersion($DBversion) ) {
12947 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSelfRegistrationEmailMustBeUnique', '0', 'If set, the field borrowers.email will be considered as a unique field on self registering', NULL, 'YesNo');
12950 print "Upgrade to $DBversion done (Bug 16275 - Prevent patron self registration if the email already filled in borrowers.email)\n";
12951 SetVersion($DBversion);
12954 $DBversion = "16.06.00.022";
12955 if ( CheckVersion($DBversion) ) {
12957 INSERT IGNORE INTO `permissions`
12958 (module_bit, code, description) VALUES
12959 (16, 'delete_reports', 'Delete SQL reports');
12962 INSERT IGNORE INTO user_permissions
12963 (borrowernumber, module_bit,code)
12964 SELECT borrowernumber,module_bit,'delete_reports'
12965 FROM user_permissions
12966 WHERE module_bit=16 AND code='create_reports';
12969 print "Upgrade to $DBversion done (Bug 16978 - Add delete reports user permission)\n";
12970 SetVersion($DBversion);
12973 $DBversion = "16.06.00.023";
12974 if ( CheckVersion($DBversion) ) {
12975 my $pref = C4::Context->preference('timeout');
12976 if( !$pref || $pref eq '12000000' ) {
12977 # update if pref is null or equals old default value
12979 UPDATE systempreferences SET value = '1d', type = 'Free'
12980 WHERE variable = 'timeout'
12982 print "Upgrade to $DBversion done (Bug 17187)\nNote: Pref value for timeout has been adjusted.\n";
12984 # only update pref type
12986 UPDATE systempreferences SET type = 'Free'
12987 WHERE variable = 'timeout'
12989 print "Upgrade to $DBversion done (Bug 17187)\nNote: Pref value for timeout has not been adjusted.\n";
12991 SetVersion($DBversion);
12994 $DBversion = "16.06.00.024";
12995 if ( CheckVersion($DBversion) ) {
12997 UPDATE language_descriptions SET description = 'Română' WHERE subtag = 'ro' AND type = 'language' AND lang = 'ro';
13000 print "Upgrade to $DBversion done (Bug 16311 - Advanced search language limit typo for Romanian)\n";
13001 SetVersion($DBversion);
13004 $DBversion = "16.06.00.025";
13005 if ( CheckVersion($DBversion) ) {
13007 ALTER TABLE `subscription` ADD `itemtype` VARCHAR( 10 ) NULL AFTER reneweddate, ADD `previousitemtype` VARCHAR( 10 ) NULL AFTER itemtype;
13010 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
13011 ('makePreviousSerialAvailable','0','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','','YesNo');
13014 print "Upgrade to $DBversion done (Bug 7677 - Subscriptions: Ability to define default itemtype and automatically change itemtype of older issues on receive of next issue)\n";
13015 SetVersion($DBversion);
13018 $DBversion = "16.06.00.026";
13019 if ( CheckVersion($DBversion) ) {
13021 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSelfRegistrationLibraryList', '', 'Only display libraries listed. If empty, all libraries are displayed.', NULL, 'Free');
13024 print "Upgrade to $DBversion done (Bug 16274 - Make the selfregistration branchcode selection configurable)\n";
13025 SetVersion($DBversion);
13028 $DBversion = "16.06.00.027";
13029 if ( CheckVersion($DBversion) ) {
13030 unless ( column_exists('borrowers', 'lastseen') ) {
13032 ALTER TABLE borrowers ADD COLUMN lastseen datetime default NULL AFTER updated_on;
13035 ALTER TABLE deletedborrowers ADD COLUMN lastseen datetime default NULL AFTER updated_on;
13039 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('TrackLastPatronActivity', '0', 'If set, the field borrowers.lastseen will be updated everytime a patron is seen', NULL, 'YesNo');
13042 print "Upgrade to $DBversion done (Bug 16276: Add a new pref TrackLastPatronActivity and new column borrowers.lastseen)\n";
13043 SetVersion($DBversion);
13046 $DBversion = '16.06.00.028';
13047 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
13049 print "Attempting upgrade to $DBversion (Bug 17135) ...\n";
13050 my $maintenance_script = C4::Context->config("intranetdir") . "/installer/data/mysql/fix_unclosed_nonaccruing_fines_bug17135.pl";
13051 system("perl $maintenance_script --confirm");
13053 print "Upgrade to $DBversion done (Bug 17135 - Fine for the previous overdue may get overwritten by the next one)\n";
13055 unless ($original_version < TransformToNum("3.23.00.032")) { ## Bug 15675
13056 print "WARNING: There is a possibility (= just a possibility, it's configuration dependent etc.) that - due to regression introduced by Bug 15675 - some old fine records for overdued items (items which got renewed 1+ time while being overdue) may have been overwritten in your production 16.05+ database. See Bugzilla reports for Bug 14390 and Bug 17135 for more details.\n";
13057 print "WARNING: Please note that this upgrade does not try to recover such overwitten old fine records (if any) - it's just an follow-up for Bug 14390, its sole purpose is preventing eventual further-on overwrites from happening in the future. Optional recovery of the overwritten fines (again, if any) is like, totally outside of the scope of this particular upgrade!\n";
13059 SetVersion ($DBversion);
13063 $DBversion = "16.06.00.029";
13064 if ( CheckVersion($DBversion) ) {
13066 UPDATE systempreferences SET type="Choice" WHERE variable="UsageStatsLibraryType";
13069 UPDATE systempreferences SET value="Canada" WHERE variable="UsageStatsCountry" AND value="CANADA";
13072 UPDATE systempreferences SET value="Czech Republic" WHERE variable="UsageStatsCountry" AND value="CZ";
13075 UPDATE systempreferences SET value="United Kingdom" WHERE variable="UsageStatsCountry" AND (value="England" OR value="UK");
13078 UPDATE systempreferences SET value="Spain" WHERE variable="UsageStatsCountry" AND value="España";
13081 UPDATE systempreferences SET value="Greece" WHERE variable="UsageStatsCountry" AND value="GR";
13084 UPDATE systempreferences SET value="Ireland" WHERE variable="UsageStatsCountry" AND value="Irelanbd";
13087 UPDATE systempreferences SET value="Mexico" WHERE variable="UsageStatsCountry" AND value="México";
13090 UPDATE systempreferences SET value="Peru" WHERE variable="UsageStatsCountry" AND value="Perú";
13093 UPDATE systempreferences SET value="Dominican Rep." WHERE variable="UsageStatsCountry" AND value="República Dominicana";
13096 UPDATE systempreferences SET value="Trinidad & Tob." WHERE variable="UsageStatsCountry" AND value="Trinidad";
13099 UPDATE systempreferences SET value="Turkey" WHERE variable="UsageStatsCountry" AND value="Türkiye";
13102 UPDATE systempreferences SET value="USA" WHERE variable="UsageStatsCountry" AND (value="United States" OR value="United States of America" OR value="US");
13105 UPDATE systempreferences SET value="Zimbabwe" WHERE variable="UsageStatsCountry" AND value="Zimbabbwe";
13108 print "Upgrade to $DBversion done (Bug 14707 - Change UsageStatsCountry from free text to a dropdown list)\n";
13109 SetVersion($DBversion);
13112 $DBversion = "16.06.00.030";
13113 if ( CheckVersion($DBversion) ) {
13115 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
13116 ('OPACHoldingsDefaultSortField','first_column','first_column|homebranch|holdingbranch','Default sort field for the holdings table at the OPAC','choice');
13119 print "Upgrade to $DBversion done (Bug 16552 - Add the ability to change the default holdings sort)\n";
13120 SetVersion($DBversion);
13123 $DBversion = "16.06.00.031";
13124 if ( CheckVersion($DBversion) ) {
13126 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSelfRegistrationPrefillForm', '1', 'Display password and prefill login form after a patron has self registered', NULL, 'YesNo');
13129 print "Upgrade to $DBversion done (Bug 16273 - Prevent selfregistration from printing the borrower password and filling the logging form)\n";
13130 SetVersion($DBversion);
13133 $DBversion = "16.06.00.032";
13134 if ( CheckVersion($DBversion) ) {
13136 UPDATE marc_subfield_structure SET authorised_value="WITHDRAWN" WHERE authorised_value="WTHDRAWN";
13139 print "Upgrade to $DBversion done (Bug 17357 - WTHDRAWN is still used in installer files)\n";
13140 SetVersion($DBversion);
13144 $DBversion = "16.06.00.033";
13145 if ( CheckVersion($DBversion) ) {
13147 CREATE TABLE authorised_value_categories (
13148 category_name VARCHAR(32) NOT NULL,
13149 primary key (category_name)
13150 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13152 ## Add authorised value categories
13154 INSERT INTO authorised_value_categories (category_name )
13155 SELECT DISTINCT category FROM authorised_values;
13158 ## Add special categories
13160 INSERT IGNORE INTO authorised_value_categories( category_name )
13170 ('REPORT_SUBGROUP'),
13173 ('SUGGEST_STATUS'),
13177 ## Add very special categories
13179 INSERT IGNORE INTO authorised_value_categories( category_name )
13187 INSERT IGNORE INTO authorised_value_categories( category_name )
13199 ALTER TABLE items_search_fields
13200 DROP FOREIGN KEY items_search_fields_authorised_values_category;
13204 ALTER TABLE items_search_fields
13205 ADD CONSTRAINT `items_search_fields_authorised_values_category` FOREIGN KEY (`authorised_values_category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE;
13209 ALTER TABLE authorised_values
13210 ADD CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE;
13214 INSERT IGNORE INTO authorised_value_categories( category_name ) SELECT DISTINCT(authorised_value) FROM marc_subfield_structure;
13218 UPDATE marc_subfield_structure SET authorised_value = NULL WHERE authorised_value = '';
13221 # If the DB has been created before 3.19.00.006, the default collate for marc_subfield_structure if not set to utf8_unicode_ci and the new FK will not be create (MariaDB or MySQL will raise err 150)
13222 my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE marc_subfield_structure|);
13223 $table_sth->execute;
13224 my @table = $table_sth->fetchrow_array;
13225 if ( $table[1] !~ /COLLATE=utf8_unicode_ci/ and $table[1] !~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
13226 $dbh->do(qq|ALTER TABLE marc_subfield_structure CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
13229 ALTER TABLE marc_subfield_structure
13230 MODIFY COLUMN authorised_value VARCHAR(32) DEFAULT NULL,
13231 ADD CONSTRAINT marc_subfield_structure_ibfk_1 FOREIGN KEY (authorised_value) REFERENCES authorised_value_categories (category_name) ON UPDATE CASCADE ON DELETE SET NULL;
13234 print "Upgrade to $DBversion done (Bug 17216 - Add a new table to store authorized value categories)\n";
13235 SetVersion($DBversion);
13238 $DBversion = "16.06.00.034";
13239 if ( CheckVersion($DBversion) ) {
13241 ALTER TABLE biblioitems DROP COLUMN marc;
13244 ALTER TABLE deletedbiblioitems DROP COLUMN marc;
13247 print "Upgrade to $DBversion done (Bug 10455 - remove redundant 'biblioitems.marc' field)\n";
13248 SetVersion($DBversion);
13251 $DBversion = '16.06.00.035';
13252 if ( CheckVersion($DBversion) ) {
13254 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
13255 SELECT 'AllowItemsOnHoldCheckoutSCO',COALESCE(value,0),'','Do not generate RESERVE_WAITING and RESERVED warning in the SCO module when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'
13256 FROM systempreferences WHERE variable='AllowItemsOnHoldCheckout';
13259 print "Upgrade to $DBversion done (Bug 15131: Give SCO separate control for AllowItemsOnHoldCheckout)\n";
13260 SetVersion($DBversion);
13263 $DBversion = '16.06.00.036';
13264 if ( CheckVersion($DBversion) ) {
13266 CREATE TABLE IF NOT EXISTS `housebound_profile` (
13267 `borrowernumber` int(11) NOT NULL, -- Number of the borrower associated with this profile.
13268 `day` text NOT NULL, -- The preferred day of the week for delivery.
13269 `frequency` text NOT NULL, -- The Authorised_Value definining the pattern for delivery.
13270 `fav_itemtypes` text default NULL, -- Free text describing preferred itemtypes.
13271 `fav_subjects` text default NULL, -- Free text describing preferred subjects.
13272 `fav_authors` text default NULL, -- Free text describing preferred authors.
13273 `referral` text default NULL, -- Free text indicating how the borrower was added to the service.
13274 `notes` text default NULL, -- Free text for additional notes.
13275 PRIMARY KEY (`borrowernumber`),
13276 CONSTRAINT `housebound_profile_bnfk`
13277 FOREIGN KEY (`borrowernumber`)
13278 REFERENCES `borrowers` (`borrowernumber`)
13279 ON UPDATE CASCADE ON DELETE CASCADE
13280 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13283 CREATE TABLE IF NOT EXISTS `housebound_visit` (
13284 `id` int(11) NOT NULL auto_increment, -- ID of the visit.
13285 `borrowernumber` int(11) NOT NULL, -- Number of the borrower, & the profile, linked to this visit.
13286 `appointment_date` date default NULL, -- Date of visit.
13287 `day_segment` varchar(10), -- Rough time frame: 'morning', 'afternoon' 'evening'
13288 `chooser_brwnumber` int(11) default NULL, -- Number of the borrower to choose items for delivery.
13289 `deliverer_brwnumber` int(11) default NULL, -- Number of the borrower to deliver items.
13290 PRIMARY KEY (`id`),
13291 CONSTRAINT `houseboundvisit_bnfk`
13292 FOREIGN KEY (`borrowernumber`)
13293 REFERENCES `housebound_profile` (`borrowernumber`)
13294 ON UPDATE CASCADE ON DELETE CASCADE,
13295 CONSTRAINT `houseboundvisit_bnfk_1`
13296 FOREIGN KEY (`chooser_brwnumber`)
13297 REFERENCES `borrowers` (`borrowernumber`)
13298 ON UPDATE CASCADE ON DELETE CASCADE,
13299 CONSTRAINT `houseboundvisit_bnfk_2`
13300 FOREIGN KEY (`deliverer_brwnumber`)
13301 REFERENCES `borrowers` (`borrowernumber`)
13302 ON UPDATE CASCADE ON DELETE CASCADE
13303 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13306 CREATE TABLE IF NOT EXISTS `housebound_role` (
13307 `borrowernumber_id` int(11) NOT NULL, -- borrowernumber link
13308 `housebound_chooser` tinyint(1) NOT NULL DEFAULT 0, -- set to 1 to indicate this patron is a housebound chooser volunteer
13309 `housebound_deliverer` tinyint(1) NOT NULL DEFAULT 0, -- set to 1 to indicate this patron is a housebound deliverer volunteer
13310 PRIMARY KEY (`borrowernumber_id`),
13311 CONSTRAINT `houseboundrole_bnfk`
13312 FOREIGN KEY (`borrowernumber_id`)
13313 REFERENCES `borrowers` (`borrowernumber`)
13314 ON UPDATE CASCADE ON DELETE CASCADE
13315 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13318 INSERT IGNORE INTO systempreferences
13319 (variable,value,options,explanation,type) VALUES
13320 ('HouseboundModule',0,'',
13321 'If ON, enable housebound module functionality.','YesNo');
13324 INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES
13328 INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
13329 ('HSBND_FREQ','EW','Every week');
13332 print "Upgrade to $DBversion done (Bug 5670 - Housebound Readers Module)\n";
13333 SetVersion($DBversion);
13336 $DBversion = "16.06.00.037";
13337 if ( CheckVersion($DBversion) ) {
13339 ALTER TABLE `issuingrules` ADD `article_requests` ENUM( 'no', 'yes', 'bib_only', 'item_only' ) NOT NULL DEFAULT 'no' AFTER `opacitemholds`;
13342 INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES
13343 ('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'),
13344 ('ArticleRequestsMandatoryFields', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''yes''', 'multiple'),
13345 ('ArticleRequestsMandatoryFieldsItemsOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''item_only''', 'multiple'),
13346 ('ArticleRequestsMandatoryFieldsRecordOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''bib_only''', 'multiple');
13349 CREATE TABLE IF NOT EXISTS `article_requests` (
13350 `id` int(11) NOT NULL AUTO_INCREMENT,
13351 `borrowernumber` int(11) NOT NULL,
13352 `biblionumber` int(11) NOT NULL,
13353 `itemnumber` int(11) DEFAULT NULL,
13354 `branchcode` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
13362 `patron_notes` text,
13363 `status` enum('PENDING','PROCESSING','COMPLETED','CANCELED') NOT NULL DEFAULT 'PENDING',
13365 `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
13366 `updated_on` timestamp NULL DEFAULT NULL,
13367 PRIMARY KEY (`id`),
13368 KEY `borrowernumber` (`borrowernumber`),
13369 KEY `biblionumber` (`biblionumber`),
13370 KEY `itemnumber` (`itemnumber`),
13371 KEY `branchcode` (`branchcode`),
13372 CONSTRAINT `article_requests_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
13373 CONSTRAINT `article_requests_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
13374 CONSTRAINT `article_requests_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
13375 CONSTRAINT `article_requests_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
13376 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13379 INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES
13380 ('circulation', 'AR_CANCELED', '', 'Article Request - Email - Canceled', 0, 'Article Request Canceled', '<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nYour request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason:\r\n\r\n<<article_requests.notes>>\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n', 'email'),
13381 ('circulation', 'AR_COMPLETED', '', 'Article Request - Email - Completed', 0, 'Article Request Completed', '<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nWe are have completed your request for an article from <<biblio.title>> (<<items.barcode>>).\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n\r\nYou may pick your article up at <<branches.branchname>>.\r\n\r\nThank you!', 'email'),
13382 ('circulation', 'AR_PENDING', '', 'Article Request - Email - Open', 0, 'Article Request Received', '<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nWe have received your request for an article from <<biblio.title>> (<<items.barcode>>).\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n\r\n\r\nThank you!', 'email'),
13383 ('circulation', 'AR_SLIP', '', 'Article Request - Print Slip', 0, 'Test', 'Article Request:\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nTitle: <<biblio.title>>\r\nBarcode: <<items.barcode>>\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n', 'print'),
13384 ('circulation', 'AR_PROCESSING', '', 'Article Request - Email - Processing', 0, 'Article Request Processing', '<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nWe are now processing your request for an article from <<biblio.title>> (<<items.barcode>>).\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n\r\nThank you!', 'email');
13387 print "Upgrade to $DBversion done (Bug 14610 - Add ability to place article requests in Koha)\n";
13388 SetVersion($DBversion);
13391 $DBversion = '16.06.00.038';
13392 if ( CheckVersion($DBversion) ) {
13394 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('DefaultPatronSearchFields','surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search','free');
13397 print "Upgrade to $DBversion done (Bug 14874 - Add ability to search for patrons by date of birth from checkout and patron quick searches)\n";
13398 SetVersion($DBversion);
13401 $DBversion = "16.06.00.039";
13402 if ( CheckVersion($DBversion) ) {
13404 my $sth = $dbh->prepare(q{
13405 SELECT s.itemnumber, i.itype, b.itemtype
13407 ( SELECT DISTINCT itemnumber
13409 WHERE ( type = "return" OR type = "localuse" ) AND
13413 ( SELECT itemnumber,biblionumber, itype
13416 SELECT itemnumber,biblionumber, itype
13419 ON (s.itemnumber=i.itemnumber)
13421 ( SELECT biblionumber, itemtype
13424 SELECT biblionumber, itemtype
13425 FROM deletedbiblioitems
13427 ON (i.biblionumber=b.biblionumber);
13431 my $update_sth = $dbh->prepare(q{
13434 WHERE itemnumber=? AND itemtype IS NULL
13436 my $ilevel_itypes = C4::Context->preference('item-level_itypes');
13438 while ( my ($itemnumber,$item_itype,$biblio_itype) = $sth->fetchrow_array ) {
13440 my $effective_itemtype = $ilevel_itypes
13441 ? $item_itype // $biblio_itype
13443 warn "item-level_itypes set but no itype defined for item ($itemnumber)"
13444 if $ilevel_itypes and !defined $item_itype;
13445 $update_sth->execute( $effective_itemtype, $itemnumber );
13448 print "Upgrade to $DBversion done (Bug 14598: itemtype is not set on statistics by C4::Circulation::AddReturn)\n";
13449 SetVersion($DBversion);
13452 $DBversion = '16.06.00.040';
13453 if ( CheckVersion($DBversion) ) {
13455 ALTER TABLE `aqcontacts` ADD `orderacquisition` BOOLEAN NOT NULL DEFAULT 0 AFTER `notes`;
13458 INSERT IGNORE INTO `letter` (module, code, name, title, content, message_transport_type) VALUES
13459 ('orderacquisition','ACQORDER','Acquisition order','Order','<<aqbooksellers.name>>\r\n<<aqbooksellers.address1>>\r\n<<aqbooksellers.address2>>\r\n<<aqbooksellers.address3>>\r\n<<aqbooksellers.address4>>\r\n<<aqbooksellers.phone>>\r\n\r\nPlease order for the library:\r\n\r\n<order>Ordernumber <<aqorders.ordernumber>> (<<biblio.title>>) (quantity: <<aqorders.quantity>>) ($<<aqorders.listprice>> each).</order>\r\n\r\nThank you,\n\n<<branches.branchname>>', 'email');
13462 print "Upgrade to $DBversion done (Bug 5260 - Add option to send an order by e-mail to the acquisition module)\n";
13463 SetVersion($DBversion);
13466 $DBversion = '16.06.00.041';
13467 if ( CheckVersion($DBversion) ) {
13469 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AggressiveMatchOnISSN','0','If enabled, attempt to match aggressively by trying all variations of the ISSNs in the imported record as a phrase in the ISSN fields of already cataloged records when matching on ISSN with the record import tool','','YesNo')
13472 print "Upgrade to $DBversion done (Bug 14629 - Add aggressive ISSN matching feature equivalent to the aggressive ISBN matcher)\n";
13473 SetVersion($DBversion);
13476 $DBversion = '16.06.00.042';
13477 if ( CheckVersion($DBversion) ) {
13479 ALTER TABLE aqorders
13480 ADD COLUMN unitprice_tax_excluded decimal(28,6) default NULL AFTER unitprice,
13481 ADD COLUMN unitprice_tax_included decimal(28,6) default NULL AFTER unitprice_tax_excluded,
13482 ADD COLUMN rrp_tax_excluded decimal(28,6) default NULL AFTER rrp,
13483 ADD COLUMN rrp_tax_included decimal(28,6) default NULL AFTER rrp_tax_excluded,
13484 ADD COLUMN ecost_tax_excluded decimal(28,6) default NULL AFTER ecost,
13485 ADD COLUMN ecost_tax_included decimal(28,6) default NULL AFTER ecost_tax_excluded,
13486 ADD COLUMN tax_value decimal(6,4) default NULL AFTER gstrate
13489 # rename gstrate with tax_rate
13490 $dbh->do(q|ALTER TABLE aqorders CHANGE COLUMN gstrate tax_rate decimal(6,4) DEFAULT NULL|);
13491 $dbh->do(q|ALTER TABLE aqbooksellers CHANGE COLUMN gstrate tax_rate decimal(6,4) DEFAULT NULL|);
13493 # Fill the new columns
13494 my $orders = $dbh->selectall_arrayref(q|
13495 SELECT * FROM aqorders
13496 |, { Slice => {} } );
13498 my $sth_update_order = $dbh->prepare(q|
13500 SET unitprice_tax_excluded = ?,
13501 unitprice_tax_included = ?,
13502 rrp_tax_excluded = ?,
13503 rrp_tax_included = ?,
13504 ecost_tax_excluded = ?,
13505 ecost_tax_included = ?,
13507 WHERE ordernumber = ?
13510 my $sth_get_bookseller = $dbh->prepare(q|
13511 SELECT aqbooksellers.*
13513 LEFT JOIN aqbasket ON aqbasket.booksellerid = aqbooksellers.id
13514 LEFT JOIN aqorders ON aqorders.basketno = aqbasket.basketno
13515 WHERE ordernumber = ?
13518 require Number::Format;
13519 my $format = Number::Format->new;
13521 for my $order ( @$orders ) {
13522 $sth_get_bookseller->execute( $order->{ordernumber} );
13523 my ( $bookseller ) = $sth_get_bookseller->fetchrow_hashref;
13524 $order->{rrp} = $format->round( $order->{rrp}, $precision );
13525 $order->{ecost} = $format->round( $order->{ecost}, $precision );
13526 $order->{tax_rate} ||= 0 ; # tax_rate can be NULL in DB
13528 if ( $bookseller->{listincgst} ) {
13529 $order->{rrp_tax_included} = $order->{rrp};
13530 $order->{rrp_tax_excluded} = $format->round(
13531 $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
13532 $order->{ecost_tax_included} = $order->{ecost};
13533 $order->{ecost_tax_excluded} = $format->round(
13534 $order->{ecost} / ( 1 + $order->{tax_rate} ), $precision );
13537 $order->{rrp_tax_excluded} = $order->{rrp};
13538 $order->{rrp_tax_included} = $format->round(
13539 $order->{rrp} * ( 1 + $order->{tax_rate} ), $precision );
13540 $order->{ecost_tax_excluded} = $order->{ecost};
13541 $order->{ecost_tax_included} = $format->round(
13542 $order->{ecost} * ( 1 + $order->{tax_rate} ), $precision );
13546 if ( $bookseller->{listincgst} ) {
13547 $order->{unitprice_tax_included} = $format->round( $order->{unitprice}, $precision );
13548 $order->{unitprice_tax_excluded} = $format->round(
13549 $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ), $precision );
13552 $order->{unitprice_tax_excluded} = $format->round( $order->{unitprice}, $precision );
13553 $order->{unitprice_tax_included} = $format->round(
13554 $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ), $precision );
13557 # If the order is received, the tax is calculated from the unit price
13558 if ( $order->{orderstatus} eq 'complete' ) {
13559 $order->{tax_value} = $format->round(
13560 ( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
13561 * $order->{quantity}, $precision );
13563 # otherwise the ecost is used
13564 $order->{tax_value} = $format->round(
13565 ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
13566 $order->{quantity}, $precision );
13569 $sth_update_order->execute(
13570 $order->{unitprice_tax_excluded},
13571 $order->{unitprice_tax_included},
13572 $order->{rrp_tax_excluded},
13573 $order->{rrp_tax_included},
13574 $order->{ecost_tax_excluded},
13575 $order->{ecost_tax_included},
13576 $order->{tax_value},
13577 $order->{ordernumber},
13581 print "Upgrade to $DBversion done (Bug 13321 - Tax and prices calculation need to be fixed)\n";
13582 SetVersion($DBversion);
13585 $DBversion = '16.06.00.043';
13586 if ( CheckVersion($DBversion) ) {
13587 # Add the new columns
13589 ALTER TABLE aqorders
13590 ADD COLUMN tax_rate_on_ordering decimal(6,4) default NULL AFTER tax_rate,
13591 ADD COLUMN tax_rate_on_receiving decimal(6,4) default NULL AFTER tax_rate_on_ordering,
13592 ADD COLUMN tax_value_on_ordering decimal(28,6) default NULL AFTER tax_value,
13593 ADD COLUMN tax_value_on_receiving decimal(28,6) default NULL AFTER tax_value_on_ordering
13596 my $orders = $dbh->selectall_arrayref(q|
13597 SELECT * FROM aqorders
13598 |, { Slice => {} } );
13600 my $sth_update_order = $dbh->prepare(q|
13602 SET tax_rate_on_ordering = tax_rate,
13603 tax_rate_on_receiving = tax_rate,
13604 tax_value_on_ordering = ?,
13605 tax_value_on_receiving = ?
13606 WHERE ordernumber = ?
13609 for my $order (@$orders) {
13610 my $tax_value_on_ordering =
13611 $order->{quantity} *
13612 $order->{ecost_tax_excluded} *
13613 $order->{tax_rate};
13615 my $tax_value_on_receiving =
13616 ( defined $order->{unitprice_tax_excluded} )
13617 ? $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate}
13620 $sth_update_order->execute( $tax_value_on_ordering,
13621 $tax_value_on_receiving, $order->{ordernumber} );
13624 # Remove the old columns
13626 ALTER TABLE aqorders
13627 CHANGE COLUMN tax_value tax_value_bak decimal(28,6) default NULL,
13628 CHANGE COLUMN tax_rate tax_rate_bak decimal(6,4) default NULL
13631 print "Upgrade to $DBversion done (Bug 13323 - Change the tax rate on receiving)\n";
13632 SetVersion($DBversion);
13635 $DBversion = '16.06.00.044';
13636 if ( CheckVersion($DBversion) ) {
13638 ALTER TABLE `messages`
13639 ADD `manager_id` int(11) NULL,
13640 ADD FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL;
13643 print "Upgrade to $DBversion done (Bug 17397 - Show name of librarian who created circulation message)\n";
13644 SetVersion($DBversion);
13647 $DBversion = '16.06.00.045';
13648 if ( CheckVersion($DBversion) ) {
13650 UPDATE systempreferences SET options = "now|dateexpiry|combination", explanation = "Set whether the borrower renewal date should be counted from the dateexpiry, from the current date or by combination: if the dateexpiry is in future use dateexpiry, else use current date " WHERE variable = "BorrowerRenewalPeriodBase";
13653 print "Upgrade to $DBversion done (Bug 17443 - Make possible to renew patron by later of expiry and current date)\n";
13654 SetVersion($DBversion);
13657 $DBversion = '16.06.00.046';
13658 if ( CheckVersion($DBversion) ) {
13660 ALTER TABLE issuingrules ADD COLUMN no_auto_renewal_after INT(4) DEFAULT NULL AFTER auto_renew;
13663 print "Upgrade to $DBversion done (Bug 15581 - Add a circ rule to not allow auto-renewals after defined loan period)\n";
13664 SetVersion($DBversion);
13667 $DBversion = '16.06.00.047';
13668 if ( CheckVersion($DBversion) ) {
13670 UPDATE language_descriptions SET description = 'Čeština' WHERE subtag = 'cs' AND type = 'language' AND lang = 'cs'
13673 print "Upgrade to $DBversion done (Bug 17518: Displayed language name for Czech is wrong)\n";
13674 SetVersion($DBversion);
13677 $DBversion = '16.06.00.048';
13678 if( CheckVersion( $DBversion ) ) {
13680 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
13681 (13, 'upload_general_files', 'Upload any file'),
13682 (13, 'upload_manage', 'Manage uploaded files');
13685 # Update user_permissions for current users (check count in uploaded_files)
13686 # Note 9 == edit_catalogue and 13 == tools
13687 # We do not insert if someone is superlibrarian, does not have edit_catalogue,
13688 # or already has all tools
13690 INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
13691 SELECT borrowernumber, 13, 'upload_general_files'
13693 WHERE flags<>1 AND flags & POW(2,13) = 0 AND
13694 ( flags & POW(2,9) > 0 OR (
13695 SELECT COUNT(*) FROM user_permissions
13696 WHERE borrowernumber=bo.borrowernumber AND module_bit=9 ) > 0 )
13697 AND ( SELECT COUNT(*) FROM uploaded_files ) > 0;
13700 SetVersion( $DBversion );
13701 print "Upgrade to $DBversion done (Bug 17663 - Forgotten userpermissions)\n";
13704 $DBversion = '16.06.00.049';
13705 if( CheckVersion( $DBversion ) ) {
13707 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
13708 VALUES ('ReplytoDefault', '', NULL, 'The default email address to be set as replyto.', 'Free');
13712 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
13713 VALUES ('ReturnpathDefault', '', NULL, 'The default email address to be set as return-path', 'Free');
13716 SetVersion( $DBversion );
13717 print "Upgrade to $DBversion done (Bug 17391 - ReturnpathDefault and ReplyToDefault missing from syspref.sql)\n";
13720 $DBversion = "16.06.00.050";
13721 if ( CheckVersion($DBversion) ) {
13723 # If index issn_idx still exists, we assume that dbrev 3.15.00.049 failed,
13724 # and we repeat it (partially).
13725 # Note: the db rev only pertains to biblioitems and is not needed for
13726 # deletedbiblioitems.
13728 my $temp = $dbh->selectall_arrayref( "SHOW INDEXES FROM biblioitems WHERE key_name = 'issn_idx'" );
13731 $dbh->do( "ALTER TABLE biblioitems DROP INDEX isbn" );
13732 $dbh->do( "ALTER TABLE biblioitems DROP INDEX issn" );
13733 $dbh->do( "ALTER TABLE biblioitems DROP INDEX issn_idx" );
13734 $dbh->do( "ALTER TABLE biblioitems CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL, CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL" );
13735 $dbh->do( "ALTER TABLE biblioitems ADD INDEX isbn ( isbn ( 255 ) ), ADD INDEX issn ( issn ( 255 ) )" );
13736 print "Upgrade to $DBversion done (Bug 8835). Removed issn_idx.\n";
13738 print "Upgrade to $DBversion done (Bug 8835). Everything is fine.\n";
13741 SetVersion($DBversion);
13744 $DBversion = "16.11.00.000";
13745 if ( CheckVersion($DBversion) ) {
13746 print "Upgrade to $DBversion done (Koha 16.11)\n";
13747 SetVersion($DBversion);
13750 $DBversion = "16.12.00.000";
13751 if ( CheckVersion($DBversion) ) {
13752 print "Upgrade to $DBversion done (Koha 16.12 - Our battered suitcases were piled on the sidewalk again; we had longer ways to go. But no matter, the road is life.)\n";
13753 SetVersion($DBversion);
13756 $DBversion = "16.12.00.001";
13757 if ( CheckVersion($DBversion) ) {
13759 ALTER TABLE borrower_modifications
13760 ADD COLUMN extended_attributes text DEFAULT NULL
13764 print "Upgrade to $DBversion done (Bug 17767 - Let Koha::Patron::Modification handle extended attributes)\n";
13765 SetVersion($DBversion);
13768 $DBversion = '16.12.00.002';
13769 if ( CheckVersion($DBversion) ) {
13770 unless (column_exists( 'branchtransfers', 'branchtransfer_id' )
13771 and index_exists( 'branchtransfers', 'PRIMARY' ) )
13774 "ALTER TABLE branchtransfers
13775 ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);"
13779 SetVersion($DBversion);
13780 print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n";
13783 $DBversion = '16.12.00.003';
13784 if ( CheckVersion($DBversion) ) {
13785 $dbh->do(q{DELETE FROM systempreferences WHERE variable="Persona"});
13786 SetVersion($DBversion);
13787 print "Upgrade to $DBversion done (Bug 17486 - Remove 'Mozilla Persona' as an authentication method)\n";
13790 $DBversion = '16.12.00.004';
13791 if ( CheckVersion($DBversion) ) {
13793 CREATE TABLE biblio_metadata (
13794 `id` INT(11) NOT NULL AUTO_INCREMENT,
13795 `biblionumber` INT(11) NOT NULL,
13796 `format` VARCHAR(16) NOT NULL,
13797 `marcflavour` VARCHAR(16) NOT NULL,
13798 `metadata` LONGTEXT NOT NULL,
13800 UNIQUE KEY `biblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`),
13801 CONSTRAINT `biblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
13802 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13805 CREATE TABLE deletedbiblio_metadata (
13806 `id` INT(11) NOT NULL AUTO_INCREMENT,
13807 `biblionumber` INT(11) NOT NULL,
13808 `format` VARCHAR(16) NOT NULL,
13809 `marcflavour` VARCHAR(16) NOT NULL,
13810 `metadata` LONGTEXT NOT NULL,
13812 UNIQUE KEY `deletedbiblio_metadata_uniq_key` (`biblionumber`,`format`,`marcflavour`),
13813 CONSTRAINT `deletedbiblio_metadata_fk_1` FOREIGN KEY (biblionumber) REFERENCES deletedbiblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
13814 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13817 INSERT INTO biblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM biblioitems;
13820 INSERT INTO deletedbiblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM deletedbiblioitems;
13823 UPDATE biblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour");
13826 UPDATE deletedbiblio_metadata SET marcflavour = (SELECT value FROM systempreferences WHERE variable="marcflavour");
13829 ALTER TABLE biblioitems DROP COLUMN marcxml;
13832 ALTER TABLE deletedbiblioitems DROP COLUMN marcxml;
13834 SetVersion($DBversion);
13835 print "Upgrade to $DBversion done (Bug 17196 - Move marcxml out of the biblioitems table)\n";
13838 $DBversion = '16.12.00.005';
13839 if( CheckVersion( $DBversion ) ) {
13840 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('AuthorityMergeMode','loose','loose|strict','Authority merge mode','Choice')");
13842 SetVersion( $DBversion );
13843 print "Upgrade to $DBversion done (Bug 17913 - AuthorityMergeMode)\n";
13846 $DBversion = "16.12.00.006";
13847 if ( CheckVersion($DBversion) ) {
13848 unless ( column_exists( 'borrower_attributes', 'id' )
13849 and index_exists( 'borrower_attributes', 'PRIMARY' ) )
13852 ALTER TABLE `borrower_attributes`
13853 ADD `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
13857 print "Upgrade to $DBversion done (Bug 17813: Table borrower_attributes needs a primary key\n";
13858 SetVersion($DBversion);
13861 $DBversion = "16.12.00.007";
13862 if( CheckVersion( $DBversion ) ) {
13864 if ( column_exists('opac_news', 'new' ) ) {
13865 $dbh->do(q|ALTER TABLE opac_news CHANGE COLUMN new content text NOT NULL|);
13869 UPDATE letter SET content = REPLACE(content, "<<opac_news.new>>", "<<opac_news.content>>") WHERE content LIKE "%<<opac_news.new>>%"
13872 SetVersion( $DBversion );
13873 print "Upgrade to $DBversion done (Bug 17960 - Rename opac_news with opac_news.content (template notices have been updated!))\n";
13876 $DBversion = "16.12.00.008";
13877 if( CheckVersion( $DBversion ) ) {
13879 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
13880 ('MarcItemFieldsToOrder','','Set the mapping values for new item records created from a MARC record in a staged file. In a YAML format.', NULL, 'textarea');
13883 SetVersion( $DBversion );
13884 print "Upgrade to $DBversion done (Bug 15503 - Grab Item Information from Order Files)\n";
13887 $DBversion = "16.12.00.009";
13888 if( CheckVersion( $DBversion ) ) {
13890 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
13891 ('OPACHoldsIfAvailableAtPickup','1','','Allow to pickup up holds at libraries where the item is available','YesNo');
13895 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
13896 ('OPACHoldsIfAvailableAtPickupExceptions','','','List the patron categories not affected by OPACHoldsIfAvailableAtPickup if off','Free');
13899 SetVersion( $DBversion );
13900 print "Upgrade to $DBversion done (Bug 17453 - Inter-site holds improvement)\n";
13903 $DBversion = "16.12.00.010";
13904 if( CheckVersion( $DBversion ) ) {
13906 ALTER TABLE borrowers ADD overdrive_auth_token text default NULL AFTER lastseen;
13910 ALTER TABLE deletedborrowers ADD overdrive_auth_token text default NULL AFTER lastseen;
13914 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
13915 VALUES ('OverDriveCirculation','0','Enable client to see their OverDrive account','','YesNo');
13918 SetVersion( $DBversion );
13919 print "Upgrade to $DBversion done (Bug 16034 - Integration with OverDrive Patron API)\n";
13922 $DBversion = "16.12.00.011";
13923 if( CheckVersion( $DBversion ) ) {
13925 ALTER TABLE search_field CHANGE COLUMN type type ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL
13926 COMMENT 'what type of data this holds, relevant when storing it in the search engine';
13929 SetVersion( $DBversion );
13930 print "Upgrade to $DBversion done (Bug 17260 - updatedatabase.pl fails on invalid entries in ENUM and BOOLEAN columns)\n";
13933 $DBversion = "16.12.00.012";
13934 if( CheckVersion( $DBversion ) ) {
13936 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`)
13937 VALUES ('OpacNewsLibrarySelect', '0', '', 'Show selector for branches on OPAC news page', 'YesNo');
13940 SetVersion( $DBversion );
13941 print "Upgrade to $DBversion done (Bug 14764 - Add OPAC News branch selector)\n";
13944 $DBversion = "16.12.00.013";
13945 if( CheckVersion( $DBversion ) ) {
13947 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
13948 VALUES ('CircSidebar','0','','Activate or deactivate the navigation sidebar on all Circulation pages','YesNo');
13951 SetVersion( $DBversion );
13952 print "Upgrade to $DBversion done (Bug 16530 - Add a circ sidebar navigation menu)\n";
13955 $DBversion = "16.12.00.014";
13956 if( CheckVersion( $DBversion ) ) {
13958 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
13959 ('LoadSearchHistoryToTheFirstLoggedUser', '1', NULL, 'If ON, the next user will automatically get the last searches in his history', 'YesNo');
13961 SetVersion( $DBversion );
13962 print "Upgrade to $DBversion done (Bug 8010 - Search history can be added to the wrong patron)\n";
13965 $DBversion = "16.12.00.015";
13966 if( CheckVersion( $DBversion ) ) {
13967 unless( column_exists( 'branches', 'geolocation' ) ) {
13969 ALTER TABLE branches ADD COLUMN geolocation VARCHAR(255) DEFAULT NULL after opac_info
13974 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsGeolocation', '', NULL, 'Geolocation of the main library', 'Free');
13977 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsLibrariesInfo', '', NULL, 'Share libraries information', 'YesNo');
13980 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsPublicID', '', NULL, 'Public ID for Hea website', 'Free');
13983 SetVersion( $DBversion );
13984 print "Upgrade to $DBversion done (Bug 18066 - Hea version 2)\n";
13987 $DBversion = "16.12.00.016";
13988 if ( CheckVersion($DBversion) ) {
13989 unless ( column_exists( 'borrower_attribute_types', 'opac_editable' ) )
13992 ALTER TABLE borrower_attribute_types
13993 ADD COLUMN `opac_editable` tinyint(1) NOT NULL default 0 AFTER `opac_display`
13997 print "Upgrade to $DBversion done (Bug 13757: Make patron attributes editable in the opac if set to 'editable in OPAC)'\n";
13998 SetVersion($DBversion);
14001 $DBversion = "16.12.00.017";
14002 if ( CheckVersion($DBversion) ) {
14004 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
14005 VALUES ('CumulativeRestrictionPeriods', 0, NULL, 'Cumulate the restriction periods instead of keeping the highest', 'YesNo')
14008 print "Upgrade to $DBversion done (Bug 14146 - Additional days are not added to restriction period when checking-in several overdues for same patron)'\n";
14009 SetVersion($DBversion);
14012 $DBversion = "16.12.00.018";
14013 if ( CheckVersion($DBversion) ) {
14015 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
14016 SELECT 'ExportCircHistory', COUNT(*), NULL, "Display the export circulation options", 'YesNo'
14017 FROM systempreferences
14018 WHERE ( variable = 'ExportRemoveFields' AND value != "" AND value IS NOT NULL )
14019 OR ( variable = 'ExportWithCsvProfile' AND value != "" AND value IS NOT NULL );
14023 DELETE FROM systempreferences WHERE variable="ExportWithCsvProfile";
14026 print "Upgrade to $DBversion done (Bug 15498 - Replace ExportWithCsvProfile with ExportCircHistory)'\n";
14027 SetVersion($DBversion);
14030 $DBversion = "16.12.00.019";
14031 if( CheckVersion( $DBversion ) ) {
14032 if ( column_exists( 'issues', 'return' ) ) {
14033 $dbh->do(q|ALTER TABLE issues DROP column `return`|);
14036 if ( column_exists( 'old_issues', 'return' ) ) {
14037 $dbh->do(q|ALTER TABLE old_issues DROP column `return`|);
14040 SetVersion( $DBversion );
14041 print "Upgrade to $DBversion done (Bug 18173 - Remove issues.return DB field)\n";
14044 $DBversion = "16.12.00.020";
14045 if( CheckVersion( $DBversion ) ) {
14047 UPDATE systempreferences SET options="any_time_is_placed|not_always|any_time_is_collected" WHERE variable="HoldFeeMode";
14051 UPDATE systempreferences SET value="any_time_is_placed" WHERE variable="HoldFeeMode" AND value="always";
14054 SetVersion( $DBversion );
14055 print "Upgrade to $DBversion done (Bug 17560 - Hold fee placement at point of checkout)\n";
14058 $DBversion = "16.12.00.021";
14059 if( CheckVersion( $DBversion ) ) {
14061 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14062 ('RenewalLog','0','','If ON, log information about renewals','YesNo');
14065 SetVersion( $DBversion );
14066 print "Upgrade to $DBversion done (Bug 17708 - Renewal log seems empty)\n";
14069 $DBversion = "16.12.00.022";
14070 if( CheckVersion( $DBversion ) ) {
14071 print "NOTE: The sender for claim notifications has been corrected. The email address of the staff member is no longer used. We will use the branch email address or KohaAdminEmailAddress, as is done for other notices.\n";
14072 SetVersion( $DBversion );
14073 print "Upgrade to $DBversion done (Bug 17866 - Change sender for serial claim notifications)\n";
14076 $DBversion = '16.12.00.023';
14077 if( CheckVersion( $DBversion ) ) {
14078 my $oldval = C4::Context->preference('dontmerge');
14079 my $newval = $oldval ? 0 : 50;
14081 # Remove dontmerge, add AuthorityMergeLimit
14083 DELETE FROM systempreferences WHERE variable = 'dontmerge';
14086 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('AuthorityMergeLimit','$newval',NULL,'Maximum number of biblio records updated immediately when an authority record has been modified.','integer');
14090 ALTER TABLE need_merge_authorities
14091 ADD COLUMN authid_new BIGINT AFTER authid,
14092 ADD COLUMN reportxml text AFTER authid_new,
14093 ADD COLUMN timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
14097 UPDATE need_merge_authorities SET authid_new=authid WHERE done <> 1
14100 SetVersion( $DBversion );
14101 if( $newval == 0 ) {
14102 print "NOTE: Since dontmerge was enabled, we have initialized AuthorityMergeLimit to 0 records. Please consider raising this value. This will allow for performing smaller merges directly and only postponing larger merges.\n";
14104 print "IMPORTANT NOTE: If you are not using a Debian package install, please verify that you no longer use misc/migration_tools/merge_authority.pl in your cron files AND add misc/cronjobs/merge_authorities.pl to cron now. This job is no longer optional! You need it to perform larger authority merges.\n";
14105 print "Upgrade to $DBversion done (Bug 9988 - Add AuthorityMergeLimit)\n";
14108 $DBversion = '16.12.00.024';
14109 if( CheckVersion( $DBversion ) ) {
14111 UPDATE systempreferences SET variable="NoticeBcc" WHERE variable="OverdueNoticeBcc";
14114 SetVersion( $DBversion );
14115 print "Upgrade to $DBversion done (Bug 14537 - The system preference 'OverdueNoticeBcc' is mis-named.)\n";
14118 $DBversion = '16.12.00.025';
14119 if( CheckVersion( $DBversion ) ) {
14121 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
14122 VALUES ('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer');
14125 my ( $cnt ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM uploaded_files WHERE permanent IS NULL or permanent=0" );
14127 print "NOTE: You have $cnt temporary uploads. You could benefit from setting pref UploadPurgeTemporaryFilesDays now to automatically delete them.\n";
14130 SetVersion( $DBversion );
14131 print "Upgrade to $DBversion done (Bug 17669 - Introduce preference for deleting temporary uploads)\n";
14134 $DBversion = '16.12.00.026';
14135 if( CheckVersion( $DBversion ) ) {
14137 # In order to be overcomplete, we check if the situation is what we expect
14138 if( !index_exists( 'serialitems', 'PRIMARY' ) ) {
14139 if( index_exists( 'serialitems', 'serialitemsidx' ) ) {
14141 ALTER TABLE serialitems ADD PRIMARY KEY (itemnumber), DROP INDEX serialitemsidx;
14144 $dbh->do(q|ALTER TABLE serialitems ADD PRIMARY KEY (itemnumber)|);
14148 SetVersion( $DBversion );
14149 print "Upgrade to $DBversion done (Bug 18427 - Add a primary key to serialitems)\n";
14152 $DBversion = '16.12.00.027';
14153 if( CheckVersion( $DBversion ) ) {
14156 CREATE TABLE IF NOT EXISTS club_templates (
14157 id int(11) NOT NULL AUTO_INCREMENT,
14158 `name` tinytext NOT NULL,
14160 is_enrollable_from_opac tinyint(1) NOT NULL DEFAULT '0',
14161 is_email_required tinyint(1) NOT NULL DEFAULT '0',
14162 branchcode varchar(10) NULL DEFAULT NULL,
14163 date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14164 date_updated timestamp NULL DEFAULT NULL,
14165 is_deletable tinyint(1) NOT NULL DEFAULT '1',
14167 KEY ct_branchcode (branchcode),
14168 CONSTRAINT `club_templates_ibfk_1` FOREIGN KEY (branchcode) REFERENCES `branches` (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
14169 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14173 CREATE TABLE IF NOT EXISTS clubs (
14174 id int(11) NOT NULL AUTO_INCREMENT,
14175 club_template_id int(11) NOT NULL,
14176 `name` tinytext NOT NULL,
14178 date_start date DEFAULT NULL,
14179 date_end date DEFAULT NULL,
14180 branchcode varchar(10) NULL DEFAULT NULL,
14181 date_created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14182 date_updated timestamp NULL DEFAULT NULL,
14184 KEY club_template_id (club_template_id),
14185 KEY branchcode (branchcode),
14186 CONSTRAINT clubs_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE,
14187 CONSTRAINT clubs_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
14188 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14192 CREATE TABLE IF NOT EXISTS club_enrollments (
14193 id int(11) NOT NULL AUTO_INCREMENT,
14194 club_id int(11) NOT NULL,
14195 borrowernumber int(11) NOT NULL,
14196 date_enrolled timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14197 date_canceled timestamp NULL DEFAULT NULL,
14198 date_created timestamp NULL DEFAULT NULL,
14199 date_updated timestamp NULL DEFAULT NULL,
14200 branchcode varchar(10) NULL DEFAULT NULL,
14202 KEY club_id (club_id),
14203 KEY borrowernumber (borrowernumber),
14204 KEY branchcode (branchcode),
14205 CONSTRAINT club_enrollments_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
14206 CONSTRAINT club_enrollments_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
14207 CONSTRAINT club_enrollments_ibfk_3 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE
14208 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14212 CREATE TABLE IF NOT EXISTS club_template_enrollment_fields (
14213 id int(11) NOT NULL AUTO_INCREMENT,
14214 club_template_id int(11) NOT NULL,
14215 `name` tinytext NOT NULL,
14217 authorised_value_category varchar(16) DEFAULT NULL,
14219 KEY club_template_id (club_template_id),
14220 CONSTRAINT club_template_enrollment_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
14221 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14225 CREATE TABLE IF NOT EXISTS club_enrollment_fields (
14226 id int(11) NOT NULL AUTO_INCREMENT,
14227 club_enrollment_id int(11) NOT NULL,
14228 club_template_enrollment_field_id int(11) NOT NULL,
14229 `value` text NOT NULL,
14231 KEY club_enrollment_id (club_enrollment_id),
14232 KEY club_template_enrollment_field_id (club_template_enrollment_field_id),
14233 CONSTRAINT club_enrollment_fields_ibfk_1 FOREIGN KEY (club_enrollment_id) REFERENCES club_enrollments (id) ON DELETE CASCADE ON UPDATE CASCADE,
14234 CONSTRAINT club_enrollment_fields_ibfk_2 FOREIGN KEY (club_template_enrollment_field_id) REFERENCES club_template_enrollment_fields (id) ON DELETE CASCADE ON UPDATE CASCADE
14235 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14239 CREATE TABLE IF NOT EXISTS club_template_fields (
14240 id int(11) NOT NULL AUTO_INCREMENT,
14241 club_template_id int(11) NOT NULL,
14242 `name` tinytext NOT NULL,
14244 authorised_value_category varchar(16) DEFAULT NULL,
14246 KEY club_template_id (club_template_id),
14247 CONSTRAINT club_template_fields_ibfk_1 FOREIGN KEY (club_template_id) REFERENCES club_templates (id) ON DELETE CASCADE ON UPDATE CASCADE
14248 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14252 CREATE TABLE IF NOT EXISTS club_fields (
14253 id int(11) NOT NULL AUTO_INCREMENT,
14254 club_template_field_id int(11) NOT NULL,
14255 club_id int(11) NOT NULL,
14258 KEY club_template_field_id (club_template_field_id),
14259 KEY club_id (club_id),
14260 CONSTRAINT club_fields_ibfk_3 FOREIGN KEY (club_template_field_id) REFERENCES club_template_fields (id) ON DELETE CASCADE ON UPDATE CASCADE,
14261 CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE
14262 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14266 INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (21, 'clubs', 'Patron clubs', '0');
14270 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
14271 (21, 'edit_templates', 'Create and update club templates'),
14272 (21, 'edit_clubs', 'Create and update clubs'),
14273 (21, 'enroll', 'Enroll patrons in clubs')
14277 SetVersion( $DBversion );
14278 print "Upgrade to $DBversion done (Bug 12461 - Add patron clubs feature)\n";
14281 $DBversion = '16.12.00.028';
14282 if( CheckVersion( $DBversion ) ) {
14284 UPDATE systempreferences SET options = 'us|de|fr' WHERE variable = 'AddressFormat';
14287 SetVersion( $DBversion );
14288 print "Upgrade to $DBversion done (Bug 18110 - Adds FR to the syspref AddressFormat)\n";
14291 $DBversion = '16.12.00.029';
14292 if( CheckVersion( $DBversion ) ) {
14293 unless( column_exists( 'issues', 'note' ) ) {
14294 $dbh->do(q|ALTER TABLE issues ADD note mediumtext default NULL AFTER onsite_checkout|);
14296 unless( column_exists( 'issues', 'notedate' ) ) {
14297 $dbh->do(q|ALTER TABLE issues ADD notedate datetime default NULL AFTER note|);
14299 unless( column_exists( 'old_issues', 'note' ) ) {
14300 $dbh->do(q|ALTER TABLE old_issues ADD note mediumtext default NULL AFTER onsite_checkout|);
14302 unless( column_exists( 'old_issues', 'notedate' ) ) {
14303 $dbh->do(q|ALTER TABLE old_issues ADD notedate datetime default NULL AFTER note|);
14307 INSERT IGNORE INTO letter (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
14308 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');
14312 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`)
14313 VALUES ('AllowCheckoutNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo');
14316 SetVersion( $DBversion );
14317 print "Upgrade to $DBversion done (Bug 14224: Add column issues.note and issues.notedate)\n";
14320 $DBversion = '16.12.00.030';
14321 if( CheckVersion( $DBversion ) ) {
14322 unless( column_exists( 'issuingrules', 'no_auto_renewal_after_hard_limit' ) ) {
14324 ALTER TABLE issuingrules ADD COLUMN no_auto_renewal_after_hard_limit DATE DEFAULT NULL AFTER no_auto_renewal_after;
14328 SetVersion( $DBversion );
14329 print "Upgrade to $DBversion done (Bug 16344 - Add a circ rule to limit the auto renewals given a specific date)\n";
14332 $DBversion = '16.12.00.031';
14333 if( CheckVersion( $DBversion ) ) {
14334 if ( !index_exists( 'biblioitems', 'timestamp' ) ) {
14335 $dbh->do("ALTER TABLE biblioitems ADD KEY `timestamp` (`timestamp`);");
14337 if ( !index_exists( 'deletedbiblioitems', 'timestamp' ) ) {
14338 $dbh->do("ALTER TABLE deletedbiblioitems ADD KEY `timestamp` (`timestamp`);");
14340 if ( !index_exists( 'items', 'timestamp' ) ) {
14341 $dbh->do("ALTER TABLE items ADD KEY `timestamp` (`timestamp`);");
14343 if ( !index_exists( 'deleteditems', 'timestamp' ) ) {
14344 $dbh->do("ALTER TABLE deleteditems ADD KEY `timestamp` (`timestamp`);");
14347 SetVersion( $DBversion );
14348 print "Upgrade to $DBversion done (Bug 15108: OAI-PMH provider improvements)\n";
14351 $DBversion = '16.12.00.032';
14352 if( CheckVersion( $DBversion ) ) {
14353 require Koha::Calendar;
14356 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
14357 VALUES ('ExcludeHolidaysFromMaxPickUpDelay', '0', 'If ON, reserves max pickup delay takes into account the closed days.', NULL, 'Integer');
14360 my $waiting_holds = $dbh->selectall_arrayref(q|
14361 SELECT expirationdate, waitingdate, branchcode
14363 WHERE found = 'W' AND priority = 0
14364 |, { Slice => {} });
14365 my $update_sth = $dbh->prepare(q|
14367 SET expirationdate = ?
14368 WHERE reserve_id = ?
14370 my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
14371 for my $hold ( @$waiting_holds ) {
14373 my $requested_expiration;
14374 if ($hold->{expirationdate}) {
14375 $requested_expiration = dt_from_string($hold->{expirationdate});
14378 my $expirationdate = dt_from_string($hold->{waitingdate});
14379 if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
14380 my $calendar = Koha::Calendar->new( branchcode => $hold->{branchcode}, days_mode => C4::Context->preference('useDaysMode') );
14381 $expirationdate = $calendar->days_forward( $expirationdate, $max_pickup_delay );
14383 $expirationdate->add( days => $max_pickup_delay );
14386 my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
14387 $update_sth->execute($cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd, $hold->{reserve_id});
14390 SetVersion( $DBversion );
14391 print "Upgrade to $DBversion done (Bug 12063 - Update reserves.expirationdate)\n";
14394 $DBversion = '16.12.00.033';
14395 if( CheckVersion( $DBversion ) ) {
14397 if( !column_exists( 'letter', 'lang' ) ) {
14398 $dbh->do( "ALTER TABLE letter ADD COLUMN lang VARCHAR(25) NOT NULL DEFAULT 'default' AFTER message_transport_type" );
14401 if( !column_exists( 'borrowers', 'lang' ) ) {
14402 $dbh->do( "ALTER TABLE borrowers ADD COLUMN lang VARCHAR(25) NOT NULL DEFAULT 'default' AFTER lastseen" );
14403 $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN lang VARCHAR(25) NOT NULL DEFAULT 'default' AFTER lastseen" );
14406 # Add test on existene of this key
14407 $dbh->do( "ALTER TABLE message_transports DROP FOREIGN KEY message_transports_ibfk_3 ");
14408 $dbh->do( "ALTER TABLE letter DROP PRIMARY KEY ");
14409 $dbh->do( "ALTER TABLE letter ADD PRIMARY KEY (`module`, `code`, `branchcode`, `message_transport_type`, `lang`) ");
14411 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
14412 VALUES ('TranslateNotices', '0', NULL, 'Allow notices to be translated', 'YesNo') ");
14414 SetVersion( $DBversion );
14415 print "Upgrade to $DBversion done (Bug 17762 - Add columns letter.lang and borrowers.lang to allow translation of notices)\n";
14418 $DBversion = '16.12.00.034';
14419 if( CheckVersion( $DBversion ) ) {
14421 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
14422 VALUES ('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than OPACFineNoRenewals','YesNo')
14425 SetVersion( $DBversion );
14426 print "Upgrade to $DBversion done (Bug 15582 - Ability to block auto renewals if the OPACFineNoRenewals amount is reached)\n";
14429 $DBversion = '16.12.00.035';
14430 if( CheckVersion( $DBversion ) ) {
14431 if( !column_exists( 'issues', 'auto_renew_error' ) ) {
14433 ALTER TABLE issues ADD COLUMN auto_renew_error VARCHAR(32) DEFAULT NULL AFTER auto_renew;
14437 if( !column_exists( 'old_issues', 'auto_renew_error' ) ) {
14439 ALTER TABLE old_issues ADD COLUMN auto_renew_error VARCHAR(32) DEFAULT NULL AFTER auto_renew;
14444 INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS', 'Notification of automatic renewal', 'Automatic renewal notice',
14445 "Dear [% borrower.firstname %] [% borrower.surname %],
14446 [% IF checkout.auto_renew_error %]
14447 The following item, [% biblio.title %], has not been renewed because:
14448 [% IF checkout.auto_renew_error == 'too_many' %]
14449 You have reached the maximum number of checkouts possible.
14450 [% ELSIF checkout.auto_renew_error == 'on_reserve' %]
14451 This item is on hold for another patron.
14452 [% ELSIF checkout.auto_renew_error == 'restriction' %]
14453 You are currently restricted.
14454 [% ELSIF checkout.auto_renew_error == 'overdue' %]
14455 You have overdue items.
14456 [% ELSIF checkout.auto_renew_error == 'auto_too_late' %]
14457 It\'s too late to renew this item.
14458 [% ELSIF checkout.auto_renew_error == 'auto_too_much_oweing' %]
14459 Your total unpaid fines are too high.
14462 The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]
14463 [% END %]", 'email');
14466 SetVersion( $DBversion );
14467 print "Upgrade to $DBversion done (Bug 15705 - Notify the user on auto renewing)\n";
14470 $DBversion = '16.12.00.036';
14471 if( CheckVersion( $DBversion ) ) {
14473 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
14474 VALUES ('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer');
14477 SetVersion( $DBversion );
14478 print "Upgrade to $DBversion done (Bug 17465 - Add a System Preference to control number of Saved Reports displayed)\n";
14481 $DBversion = '16.12.00.037';
14482 if( CheckVersion( $DBversion ) ) {
14484 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
14485 VALUES ('FailedLoginAttempts','','','Number of login attempts before lockout the patron account','Integer');
14488 unless( column_exists( 'borrowers', 'login_attempts' ) ) {
14490 ALTER TABLE borrowers ADD COLUMN login_attempts INT(4) DEFAULT 0 AFTER lastseen
14493 ALTER TABLE deletedborrowers ADD COLUMN login_attempts INT(4) DEFAULT 0 AFTER lastseen
14497 SetVersion( $DBversion );
14498 print "Upgrade to $DBversion done (Bug 18314 - Add FailedLoginAttempts and borrowers.login_attempts)\n";
14501 $DBversion = '16.12.00.038';
14502 if( CheckVersion( $DBversion ) ) {
14504 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14505 ('ExportRemoveFields','',NULL,'List of fields for non export in circulation.pl (separated by a space)','Free');
14508 SetVersion( $DBversion );
14509 print "Upgrade to $DBversion done (Bug 18663 - Missing db update for ExportRemoveFields)\n";
14512 $DBversion = '16.12.00.039';
14513 if( CheckVersion( $DBversion ) ) {
14515 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14516 ('TalkingTechItivaPhoneNotification','0',NULL,'If ON, enables Talking Tech I-tiva phone notifications','YesNo');
14519 SetVersion( $DBversion );
14520 print "Upgrade to $DBversion done (Bug 18600 - Missing db update for TalkingTechItivaPhoneNotification)\n";
14523 $DBversion = '17.05.00.000';
14524 if( CheckVersion( $DBversion ) ) {
14526 SetVersion( $DBversion );
14527 print "Upgrade to $DBversion done (Koha 17.05)\n";
14530 $DBversion = '17.06.00.000';
14531 if( CheckVersion( $DBversion ) ) {
14532 SetVersion( $DBversion );
14533 print "Upgrade to $DBversion done (He pai ake te iti i te kore)\n";
14536 $DBversion = '17.06.00.001';
14537 if( CheckVersion( $DBversion ) ) {
14539 unless ( column_exists( 'export_format', 'used_for' ) ) {
14540 $dbh->do(q|ALTER TABLE export_format ADD used_for varchar(255) DEFAULT 'export_records' AFTER type|);
14542 $dbh->do(q|UPDATE export_format SET used_for = 'late_issues' WHERE type = 'sql'|);
14543 $dbh->do(q|UPDATE export_format SET used_for = 'export_records' WHERE type = 'marc'|);
14545 SetVersion( $DBversion );
14546 print "Upgrade to $DBversion done (Bug 8612 - Add new column export_format.used_for)\n";
14549 $DBversion = '17.06.00.002';
14550 if ( CheckVersion($DBversion) ) {
14552 unless ( column_exists('virtualshelves', 'allow_change_from_owner' ) ) {
14554 ALTER TABLE virtualshelves
14555 ADD COLUMN allow_change_from_owner tinyint(1) default 1,
14556 ADD COLUMN allow_change_from_others tinyint(1) default 0
14560 # Since we had no readonly lists, change_from_owner is set to true.
14561 # When adding or delete_other was granted, change_from_others is true.
14562 # Note: In my opinion the best choice; there is no exact match.
14564 UPDATE virtualshelves
14565 SET allow_change_from_owner = 1,
14566 allow_change_from_others = CASE WHEN allow_add=1 OR allow_delete_other=1 THEN 1 ELSE 0 END
14569 # Remove the old columns
14571 ALTER TABLE virtualshelves
14572 DROP COLUMN allow_add,
14573 DROP COLUMN allow_delete_own,
14574 DROP COLUMN allow_delete_other
14578 SetVersion($DBversion);
14579 print "Upgrade to $DBversion done (Bug 18228 - Alter table virtualshelves to simplify permissions)\n";
14582 $DBversion = '17.06.00.003';
14583 if ( CheckVersion($DBversion) ) {
14585 # Fetch all auth types
14586 my $authtypes = $dbh->selectcol_arrayref(q|SELECT authtypecode FROM auth_types|);
14588 if ( grep { $_ eq 'Default' } @$authtypes ) {
14590 # If this exists as an authtypecode, we don't do anything
14593 # Replace the incorrect Default by empty string
14595 UPDATE auth_header SET authtypecode='' WHERE authtypecode='Default'
14599 SetVersion($DBversion);
14600 print "Upgrade to $DBversion done (Bug 18801 - Update incorrect Default auth type codes)\n";
14603 $DBversion = '17.06.00.004';
14604 if( CheckVersion( $DBversion ) ) {
14606 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14607 ('GoogleOpenIDConnectAutoRegister', '0',NULL,' Google OpenID Connect logins to auto-register patrons.','YesNo'),
14608 ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'),
14609 ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea');
14612 SetVersion( $DBversion );
14613 print "Upgrade to $DBversion done (Bug 16892: Add automatic patron registration via OAuth2 login)\n";
14616 $DBversion = '17.06.00.005';
14617 if( CheckVersion( $DBversion ) ) {
14619 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')
14622 SetVersion( $DBversion );
14623 print "Upgrade to $DBversion done (Bug 18718 - Language selector in staff header menu similar to OPAC )\n";
14626 $DBversion = '17.06.00.006';
14627 if( CheckVersion( $DBversion ) ) {
14628 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.};
14631 SetVersion( $DBversion );
14632 print "Upgrade to $DBversion done (Bug 18811 - Visibility settings inconsistent between framework and authority editor)\n";
14635 $DBversion = '17.06.00.007';
14636 if( CheckVersion( $DBversion ) ) {
14637 if( !column_exists( 'branches', 'marcorgcode' ) ) {
14638 $dbh->do( "ALTER TABLE branches ADD COLUMN marcorgcode VARCHAR(16) default NULL AFTER geolocation" );
14641 SetVersion( $DBversion );
14642 print "Upgrade to $DBversion done (Bug 10132 - MARCOrgCode on branch level (branches.marcorgcode))\n";
14645 $DBversion = '17.06.00.008';
14646 if( CheckVersion( $DBversion ) ) {
14647 unless ( column_exists( 'borrowers', 'date_renewed' ) ) {
14649 ALTER TABLE borrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
14653 unless ( column_exists( 'deletedborrowers', 'date_renewed' ) ) {
14655 ALTER TABLE deletedborrowers ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
14659 unless ( column_exists( 'borrower_modifications', 'date_renewed' ) ) {
14661 ALTER TABLE borrower_modifications ADD COLUMN date_renewed DATE NULL DEFAULT NULL AFTER dateexpiry;
14665 SetVersion( $DBversion );
14666 print "Upgrade to $DBversion done (Bug 6758 - Capture membership renewal date for reporting purposes (borrowers.date_renewed))\n";
14669 $DBversion = '17.06.00.009';
14670 if( CheckVersion( $DBversion ) ) {
14672 ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) DEFAULT 0 AFTER lang;
14675 ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) DEFAULT 0 AFTER lang;
14678 SetVersion( $DBversion );
14679 print "Upgrade to $DBversion done (Bug 19344 - Reorder lang and login_attempts in the [deleted]borrowers tables)\n";
14682 $DBversion = '17.06.00.010';
14683 if ( CheckVersion($DBversion) ) {
14685 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
14687 'DefaultCountryField008','','',
14688 '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')
14690 SetVersion($DBversion);
14691 print "Upgrade to $DBversion done (Bug 13912 - System preference for default place of publication (country code) for field 008, range 15-17)\n";
14694 $DBversion = '17.06.00.011';
14695 if ( CheckVersion($DBversion) ) {
14696 # Drop index that might exist because of bug 5337
14697 if( index_exists('biblioitems', 'ean')) {
14698 $dbh->do(q{ ALTER TABLE biblioitems DROP INDEX ean });
14700 if( index_exists('deletedbiblioitems', 'ean')) {
14701 $dbh->do(q{ ALTER TABLE deletedbiblioitems DROP INDEX ean });
14704 # Change data type of column
14705 $dbh->do(q{ ALTER TABLE biblioitems MODIFY COLUMN ean MEDIUMTEXT default NULL });
14706 $dbh->do(q{ ALTER TABLE deletedbiblioitems MODIFY COLUMN ean MEDIUMTEXT default NULL });
14709 $dbh->do(q{ ALTER TABLE biblioitems ADD INDEX ean ( ean(255) )});
14710 $dbh->do(q{ ALTER TABLE deletedbiblioitems ADD INDEX ean ( ean(255 ) )});
14712 SetVersion($DBversion);
14713 print "Upgrade to $DBversion done (Bug 13766 - Make ean mediumtext and add ean indexes)\n";
14716 $DBversion = '17.06.00.012';
14717 if( CheckVersion( $DBversion ) ) {
14718 my $where = q|host='clio-db.cc.columbia.edu' AND port=7090|;
14719 my $sql = "SELECT COUNT(*) FROM z3950servers WHERE $where";
14720 my ( $cnt ) = $dbh->selectrow_array( $sql );
14722 $dbh->do( "DELETE FROM z3950servers WHERE $where" );
14723 print "Removed $cnt Z39.50 target(s) for Columbia University\n";
14726 SetVersion( $DBversion );
14727 print "Upgrade to $DBversion done (Bug 19043 - Z39.50 target for Columbia University is no longer publicly available.)\n";
14730 $DBversion = '17.06.00.013';
14731 if( CheckVersion( $DBversion ) ) {
14732 $dbh->do( "UPDATE systempreferences SET value = CONCAT('http://', value) WHERE variable = 'staffClientBaseURL' AND value <> '' AND value NOT LIKE 'http%'" );
14734 my ( $staffClientBaseURL_used_in_notices ) = $dbh->selectrow_array(q|
14735 SELECT COUNT(*) FROM letter where content like "%staffClientBaseURL%"
14737 if ( $staffClientBaseURL_used_in_notices ) {
14738 warn "\tYou may need to update one or more notice templates if they contain 'staffClientBaseURL'\n";
14741 SetVersion( $DBversion );
14742 print "Upgrade to $DBversion done (Bug 16401 - fix potentialy bad set staffClientBaseURL preference)\n";
14745 $DBversion = '17.06.00.014';
14746 if( CheckVersion( $DBversion ) ) {
14747 unless( column_exists('aqbasket','create_items') ){
14749 ALTER TABLE aqbasket
14750 ADD COLUMN create_items ENUM('ordering', 'receiving', 'cataloguing') default NULL AFTER is_standing
14754 SetVersion( $DBversion );
14755 print "Upgrade to $DBversion done (Bug 15685 - Allow creation of items (AcqCreateItem) to be customizable per-basket)\n";
14758 $DBversion = '17.06.00.015';
14759 if( CheckVersion( $DBversion ) ) {
14761 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
14762 ('SelfCheckoutByLogin','0',NULL,'Have patrons login into the web-based self checkout system with their username/password or their cardnumber','YesNo')
14765 SetVersion( $DBversion );
14766 print "Upgrade to $DBversion done (Bug 19186 - Insert system preference SelfCheckoutByLogin if missing)\n";
14769 $DBversion = '17.06.00.016';
14770 if( CheckVersion( $DBversion ) ) {
14772 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
14773 VALUES ('RequireStrongPassword','0','','Require a strong login password for staff and patrons','YesNo');
14776 SetVersion( $DBversion );
14777 print "Upgrade to $DBversion done (Bug 18298 - Allow enforcing password complexity (system preference RequireStrongPassword))\n";
14780 $DBversion = '17.06.00.017';
14781 if( CheckVersion( $DBversion ) ) {
14782 unless (TableExists('account_offsets')) {
14784 DROP TABLE IF EXISTS `accountoffsets`;
14788 CREATE TABLE IF NOT EXISTS `account_offset_types` (
14789 `type` varchar(16) NOT NULL, -- The type of offset this is
14790 PRIMARY KEY (`type`)
14791 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14795 CREATE TABLE IF NOT EXISTS `account_offsets` (
14796 `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
14797 `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
14798 `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
14799 `type` varchar(16) NOT NULL, -- The type of offset this is
14800 `amount` decimal(26,6) NOT NULL, -- The amount of the change
14801 `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
14802 PRIMARY KEY (`id`),
14803 CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
14804 CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
14805 CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE
14806 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
14810 INSERT IGNORE INTO account_offset_types ( type ) VALUES
14814 ('Processing Fee'),
14816 ('Reverse Payment'),
14825 SetVersion( $DBversion );
14826 print "Upgrade to $DBversion done (Bug 14826 - Resurrect account offsets table (Add new tables account_offsets and account_offset_types))\n";
14829 $DBversion = '17.06.00.018';
14830 if( CheckVersion( $DBversion ) ) {
14832 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES ('useDefaultReplacementCost',0,'default replacement cost defined in item type','YesNo');
14835 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');
14838 ALTER TABLE `itemtypes` MODIFY COLUMN `rentalcharge` DECIMAL(28,6) NULL DEFAULT NULL;
14840 unless ( column_exists( 'itemtypes', 'defaultreplacecost' ) ) {
14842 ALTER TABLE `itemtypes` ADD `defaultreplacecost` DECIMAL(28,6) NULL DEFAULT NULL AFTER `rentalcharge`;
14845 unless ( column_exists( 'itemtypes', 'processfee' ) ) {
14847 ALTER TABLE `itemtypes` ADD `processfee` DECIMAL(28,6) NULL DEFAULT NULL AFTER `defaultreplacecost`;
14851 SetVersion( $DBversion );
14852 print "Upgrade to $DBversion done (Bug 12768 - Insert system preferences useDefaultReplacementCost and ProcessingFeeNote + Add new columns defaultreplacecost and processfee to the itemtypes table)\n";
14855 $DBversion = '17.06.00.019';
14856 if( CheckVersion( $DBversion ) ) {
14858 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Processing Fee' );
14861 SetVersion( $DBversion );
14862 print "Upgrade to $DBversion done (Bug 12768 - Add 'Processing Fee' to the account_offset_types table if missing)\n";
14865 $DBversion = '17.06.00.020';
14866 if( CheckVersion( $DBversion ) ) {
14868 UPDATE systempreferences
14870 variable='OpacLocationOnDetail',
14871 options='holding|home|both|column',
14872 explanation='In the OPAC detail, display the shelving location on its own column or under a library columns.'
14874 variable='OpacLocationBranchToDisplayShelving'
14877 SetVersion( $DBversion );
14878 print "Upgrade to $DBversion done (Bug 19028: Add 'shelving location' to holdings table in detail page (Rename syspref OpacLocationBranchToDisplayShelving with OpacLocationOnDetail))\n";
14881 $DBversion = '17.06.00.021';
14882 if( CheckVersion( $DBversion ) ) {
14884 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')
14887 SetVersion( $DBversion );
14888 print "Upgrade to $DBversion done (Bug 17381 - Add system preference SCOMainUserBlock)\n";
14891 $DBversion = '17.06.00.022';
14892 if( CheckVersion( $DBversion ) ) {
14893 my $hide_barcode = C4::Context->preference('OPACShowBarcode') ? 0 : 1;
14895 DELETE FROM systempreferences
14897 variable='OPACShowBarcode'
14900 # Configure column visibility if it isn't
14902 INSERT IGNORE INTO columns_settings
14903 (module,page,tablename,columnname,cannot_be_toggled,is_hidden)
14905 ('opac','biblio-detail','holdingst','item_barcode',0,?)
14906 }, undef, $hide_barcode);
14908 SetVersion( $DBversion );
14909 print "Upgrade to $DBversion done (Bug 19038: Remove OPACShowBarcode syspref)\n";
14912 $DBversion = '17.06.00.023';
14913 if( CheckVersion( $DBversion ) ) {
14915 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14916 ('MarkLostItemsAsReturned','1','','Mark items as returned when flagged as lost','YesNo');
14919 SetVersion( $DBversion );
14920 print "Upgrade to $DBversion done (Bug 12363 - Add system preference MarkLostItemsAsReturned)\n";
14923 $DBversion = '17.06.00.024';
14924 if( CheckVersion( $DBversion ) ) {
14926 INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES
14927 ('OPACUserSummary', 1, NULL, "Show the summary of a logged in user's checkouts, overdues, holds and fines on the mainpage", 'YesNo');
14930 SetVersion( $DBversion );
14931 print "Upgrade to $DBversion done (Bug 2093 - Add system preference OPACUserSummary)\n";
14934 $DBversion = '17.06.00.025';
14935 if( CheckVersion( $DBversion ) ) {
14937 ALTER TABLE borrowers MODIFY cardnumber varchar(32);
14940 ALTER TABLE borrower_modifications MODIFY cardnumber varchar(32);
14943 ALTER TABLE deletedborrowers MODIFY cardnumber varchar(32);
14946 ALTER TABLE pending_offline_operations MODIFY cardnumber varchar(32);
14949 ALTER TABLE tmp_holdsqueue MODIFY cardnumber varchar(32);
14952 SetVersion( $DBversion );
14953 print "Upgrade to $DBversion done (Bug 13178 - Increase cardnumber fields to VARCHAR(32))\n";
14956 $DBversion = '17.06.00.026';
14957 if( CheckVersion( $DBversion ) ) {
14959 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
14960 ('BlockReturnOfLostItems','0','0','If enabled, items that are marked as lost cannot be returned.','YesNo');
14963 SetVersion( $DBversion );
14964 print "Upgrade to $DBversion done (Bug 10748 - Add system preference BlockReturnOfLostItems)\n";
14967 $DBversion = '17.06.00.027';
14968 if( CheckVersion( $DBversion ) ) {
14969 if ( !column_exists( 'statistics', 'location' ) ) {
14970 $dbh->do('ALTER TABLE statistics ADD COLUMN location VARCHAR(80) default NULL AFTER itemtype');
14973 SetVersion($DBversion);
14974 print "Upgrade to $DBversion done (Bug 18882 - Add location code to statistics table for checkouts and renewals)\n";
14977 $DBversion = '17.06.00.028';
14978 if( CheckVersion( $DBversion ) ) {
14979 if ( !TableExists( 'illrequests' ) ) {
14981 CREATE TABLE illrequests (
14982 illrequest_id serial PRIMARY KEY, -- ILL request number
14983 borrowernumber integer DEFAULT NULL, -- Patron associated with request
14984 biblio_id integer DEFAULT NULL, -- Potential bib linked to request
14985 branchcode varchar(50) NOT NULL, -- The branch associated with the request
14986 status varchar(50) DEFAULT NULL, -- Current Koha status of request
14987 placed date DEFAULT NULL, -- Date the request was placed
14988 replied date DEFAULT NULL, -- Last API response
14989 updated timestamp DEFAULT CURRENT_TIMESTAMP -- Last modification to request
14990 ON UPDATE CURRENT_TIMESTAMP,
14991 completed date DEFAULT NULL, -- Date the request was completed
14992 medium varchar(30) DEFAULT NULL, -- The Koha request type
14993 accessurl varchar(500) DEFAULT NULL, -- Potential URL for accessing item
14994 cost varchar(20) DEFAULT NULL, -- Cost of request
14995 notesopac text DEFAULT NULL, -- Patron notes attached to request
14996 notesstaff text DEFAULT NULL, -- Staff notes attached to request
14997 orderid varchar(50) DEFAULT NULL, -- Backend id attached to request
14998 backend varchar(20) DEFAULT NULL, -- The backend used to create request
14999 CONSTRAINT `illrequests_bnfk`
15000 FOREIGN KEY (`borrowernumber`)
15001 REFERENCES `borrowers` (`borrowernumber`)
15002 ON UPDATE CASCADE ON DELETE CASCADE,
15003 CONSTRAINT `illrequests_bcfk_2`
15004 FOREIGN KEY (`branchcode`)
15005 REFERENCES `branches` (`branchcode`)
15006 ON UPDATE CASCADE ON DELETE CASCADE
15007 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
15011 if ( !TableExists( 'illrequestattributes' ) ) {
15013 CREATE TABLE illrequestattributes (
15014 illrequest_id bigint(20) unsigned NOT NULL, -- ILL request number
15015 type varchar(200) NOT NULL, -- API ILL property name
15016 value text NOT NULL, -- API ILL property value
15017 PRIMARY KEY (`illrequest_id`,`type`),
15018 CONSTRAINT `illrequestattributes_ifk`
15019 FOREIGN KEY (illrequest_id)
15020 REFERENCES `illrequests` (`illrequest_id`)
15021 ON UPDATE CASCADE ON DELETE CASCADE
15022 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
15026 # System preferences
15028 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
15029 ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo');
15033 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
15034 ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea');
15038 INSERT IGNORE INTO userflags (bit,flag,flagdesc,defaulton) VALUES
15039 (22,'ill','The Interlibrary Loans Module',0);
15042 SetVersion( $DBversion );
15043 print "Upgrade to $DBversion done (Bug 7317 - Add an Interlibrary Loan Module to Circulation and OPAC)\n";
15046 $DBversion = '17.11.00.000';
15047 if( CheckVersion( $DBversion ) ) {
15048 SetVersion( $DBversion );
15049 print "Upgrade to $DBversion done (Koha 17.11)\n";
15052 $DBversion = '17.12.00.000';
15053 if( CheckVersion( $DBversion ) ) {
15054 SetVersion( $DBversion );
15055 print "Upgrade to $DBversion done (Tē tōia, tē haumatia)\n";
15058 $DBversion = '17.12.00.001';
15059 if( CheckVersion( $DBversion ) ) {
15060 foreach my $table (qw(biblio_metadata deletedbiblio_metadata)) {
15061 if (!column_exists($table, 'timestamp')) {
15063 ALTER TABLE `$table`
15064 ADD COLUMN `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `metadata`,
15065 ADD KEY `timestamp` (`timestamp`)
15068 UPDATE $table metadata
15069 LEFT JOIN biblioitems ON (biblioitems.biblionumber = metadata.biblionumber)
15070 LEFT JOIN biblio ON (biblio.biblionumber = metadata.biblionumber)
15071 SET metadata.timestamp = GREATEST(biblioitems.timestamp, biblio.timestamp);
15076 SetVersion( $DBversion );
15077 print "Upgrade to $DBversion done (Bug 19724 - Add [deleted]biblio_metadata.timestamp)\n";
15080 $DBversion = '17.12.00.002';
15081 if( CheckVersion( $DBversion ) ) {
15083 my $msss = $dbh->selectall_arrayref(q|
15084 SELECT kohafield, tagfield, tagsubfield, frameworkcode
15085 FROM marc_subfield_structure
15086 WHERE frameworkcode != ''
15087 |, { Slice => {} });
15090 my $sth = $dbh->prepare(q|
15092 FROM marc_subfield_structure
15093 WHERE frameworkcode = ''
15095 AND tagsubfield = ?
15099 for my $mss ( @$msss ) {
15100 $sth->execute($mss->{tagfield}, $mss->{tagsubfield} );
15101 my ( $default_kohafield ) = $sth->fetchrow_array();
15102 if( $mss->{kohafield} ) {
15103 push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => $mss->{kohafield} } if not $default_kohafield or $default_kohafield ne $mss->{kohafield};
15105 push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => q{} } if $default_kohafield;
15110 print "WARNING: The Default framework is now considered as authoritative for Koha to MARC mappings. We have found that your additional frameworks contained "
15111 . scalar(@exceptions)
15112 . " 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";
15113 for my $exception (@exceptions) {
15115 . $exception->{tagfield} . '$'
15116 . $exception->{tagsubfield}
15118 . $exception->{frameworkcode} . ': ';
15119 if ( $exception->{kohafield} ) {
15120 print "Mapping to "
15121 . $exception->{kohafield}
15122 . " has been adjusted.\n";
15125 print "Mapping has been reset.\n";
15131 # Clear the destination frameworks first
15133 UPDATE marc_subfield_structure
15134 SET kohafield = NULL
15135 WHERE frameworkcode > ''
15139 # Now copy from Default
15140 my $msss = $dbh->selectall_arrayref(q|
15141 SELECT kohafield, tagfield, tagsubfield
15142 FROM marc_subfield_structure
15143 WHERE frameworkcode = ''
15145 |, { Slice => {} });
15146 my $sth = $dbh->prepare(q|
15147 UPDATE marc_subfield_structure
15149 WHERE frameworkcode > ''
15151 AND tagsubfield = ?
15153 for my $mss (@$msss) {
15154 $sth->execute( $mss->{kohafield}, $mss->{tagfield},
15155 $mss->{tagsubfield} );
15159 my @frameworkcodes = $dbh->selectall_arrayref(q|
15160 SELECT frameworkcode FROM biblio_framework WHERE frameworkcode > ''
15162 for my $frameworkcode (@frameworkcodes) {
15163 Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
15165 Koha::Caches->get_instance->clear_from_cache("default_value_for_mod_marc-");
15168 SetVersion( $DBversion );
15169 print "Upgrade to $DBversion done (Bug 19096 - Make Default authoritative for Koha to MARC mappings)\n";
15172 $DBversion = '17.12.00.003';
15173 if( CheckVersion( $DBversion ) ) {
15174 $dbh->do(q|DROP TABLE IF EXISTS notifys|);
15176 if( column_exists( 'accountlines', 'notify_id' ) ) {
15177 $dbh->do(q|ALTER TABLE accountlines DROP COLUMN notify_id|);
15178 $dbh->do(q|ALTER TABLE accountlines DROP COLUMN notify_level|);
15181 SetVersion( $DBversion );
15182 print "Upgrade to $DBversion done (Bug 10021 - Drop notifys-related table and columns)\n";
15185 $DBversion = '17.12.00.004';
15186 if( CheckVersion( $DBversion ) ) {
15188 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
15190 ('RESTdefaultPageSize','20','','Set the default number of results returned by the REST API endpoints','Integer')
15193 SetVersion( $DBversion );
15194 print "Upgrade to $DBversion done (Bug 19278 - Add a configurable default page size for REST endpoints)\n";
15197 $DBversion = '17.12.00.005';
15198 if( CheckVersion( $DBversion ) ) {
15199 # For installations having the note already
15202 SET code = 'CHECKOUT_NOTE',
15203 name = 'Checkout note on item set by patron',
15204 title = 'Checkout note',
15205 content = REPLACE(content, "<<biblio.item>>", "<<biblio.title>>")
15206 WHERE code = 'PATRON_NOTE'
15208 # For installations coming from 17.11
15210 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
15211 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')
15214 SetVersion( $DBversion );
15215 print "Upgrade to $DBversion done (Bug 18915 - Correct CHECKOUT_NOTE notice template)\n";
15218 $DBversion = '17.12.00.006';
15219 if( CheckVersion( $DBversion ) ) {
15221 UPDATE systempreferences SET value=replace(value, "http://www.scholar", "https://scholar") WHERE variable='OPACSearchForTitleIn';
15224 SetVersion( $DBversion );
15225 print "Upgrade to $DBversion done (Bug 17682 - Update URL for Google Scholar in OPACSearchForTitleIn)\n";
15228 $DBversion = '17.12.00.007';
15229 if( CheckVersion( $DBversion ) ) {
15231 unless ( TableExists( 'library_groups' ) ) {
15233 CREATE TABLE library_groups (
15234 id INT(11) NOT NULL auto_increment, -- unique id for each group
15235 parent_id INT(11) NULL DEFAULT NULL, -- if this is a child group, the id of the parent group
15236 branchcode VARCHAR(10) NULL DEFAULT NULL, -- The branchcode of a branch belonging to the parent group
15237 title VARCHAR(100) NULL DEFAULT NULL, -- Short description of the goup
15238 description TEXT NULL DEFAULT NULL, -- Longer explanation of the group, if necessary
15239 created_on TIMESTAMP NULL, -- Date and time of creation
15240 updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Date and time of last
15241 PRIMARY KEY id ( id ),
15242 FOREIGN KEY (parent_id) REFERENCES library_groups(id) ON UPDATE CASCADE ON DELETE CASCADE,
15243 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE,
15244 UNIQUE KEY title ( title )
15245 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
15249 SetVersion( $DBversion );
15250 print "Upgrade to $DBversion done (Bug 15707 - Add new table library_groups)\n";
15253 $DBversion = '17.12.00.008';
15254 if ( CheckVersion($DBversion) ) {
15256 if ( TableExists( 'branchcategories' ) and TableExists('branchrelations' )) {
15258 INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups', NOW() )
15260 my $search_groups_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15262 my $sth = $dbh->prepare("SELECT * FROM branchcategories");
15264 my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
15266 my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
15268 my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
15271 while ( my $lc = $sth->fetchrow_hashref ) {
15272 my $description = $lc->{categorycode};
15273 $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
15275 $sth2->execute($search_groups_root_id, $lc->{categoryname}, $description);
15277 my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15279 $sth3->execute( $lc->{categorycode} );
15281 while ( my $l = $sth3->fetchrow_hashref ) {
15282 $sth4->execute( $subgroup_id, $l->{branchcode} );
15286 $dbh->do("DROP TABLE branchrelations");
15287 $dbh->do("DROP TABLE branchcategories");
15290 print "Upgrade to $DBversion done (Bug 16735 - Migrate library search groups into the new hierarchical groups)\n";
15291 SetVersion($DBversion);
15294 $DBversion = '17.12.00.009';
15295 if ( CheckVersion($DBversion) ) {
15297 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
15298 (4, 'edit_borrowers', 'Add, modify and view patron information'),
15299 (4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries');
15302 # We are lucky here, there is nothing else to do: flags 4-borrowers did not contain sub permissions
15304 SetVersion( $DBversion );
15305 print "Upgrade to $DBversion done (Bug 18403 - Add the view_borrower_infos_from_any_libraries permission )\n";
15308 $DBversion = '17.12.00.010';
15309 if( CheckVersion( $DBversion ) ) {
15311 if( !column_exists( 'library_groups', 'ft_hide_patron_info' ) ) {
15312 $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_hide_patron_info tinyint(1) NOT NULL DEFAULT 0 AFTER description" );
15315 SetVersion( $DBversion );
15316 print "Upgrade to $DBversion done (Bug 20133 - Add library_groups.ft_hide_patron_info)\n";
15319 $DBversion = '17.12.00.011';
15320 if( CheckVersion( $DBversion ) ) {
15322 if( !column_exists( 'library_groups', 'ft_search_groups_opac' ) ) {
15323 $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0 AFTER ft_hide_patron_info" );
15324 $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_opac" );
15325 $dbh->do( "UPDATE library_groups SET ft_search_groups_staff = 1 AND ft_search_groups_opac = 1 WHERE title = '__SEARCH_GROUPS__'" );
15328 SetVersion( $DBversion );
15329 print "Upgrade to $DBversion done (Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality)\n";
15332 $DBversion = '17.12.00.012';
15333 if( CheckVersion( $DBversion ) ) {
15336 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15337 VALUES ('AutoSwitchPatron', '0', '', 'Auto switch to patron', 'YesNo');
15340 SetVersion( $DBversion );
15341 print "Upgrade to $DBversion done (Bug 15752 - Add system preference AutoSwitchPatron)\n";
15344 $DBversion = '17.12.00.013';
15345 if( CheckVersion( $DBversion ) ) {
15348 ALTER TABLE club_enrollments MODIFY date_created timestamp NULL DEFAULT NULL;
15351 SetVersion( $DBversion );
15352 print "Upgrade to $DBversion done (Bug 20175 - Set DEFAULT NULL value for club_enrollments.date_created)\n";
15355 $DBversion = '17.12.00.014';
15356 if( CheckVersion( $DBversion ) ) {
15357 $dbh->do( "UPDATE marc_subfield_structure SET kohafield=NULL where kohafield='additionalauthors.author'" );
15358 SetVersion( $DBversion );
15359 print "Upgrade to $DBversion done (Bug 19790 - Remove additionalauthors.author from installer files)\n";
15362 $DBversion = '17.12.00.015';
15363 if( CheckVersion( $DBversion ) ) {
15365 ALTER TABLE borrowers
15366 MODIFY surname MEDIUMTEXT,
15367 MODIFY address MEDIUMTEXT,
15368 MODIFY city MEDIUMTEXT
15371 ALTER TABLE deletedborrowers
15372 MODIFY surname MEDIUMTEXT,
15373 MODIFY address MEDIUMTEXT,
15374 MODIFY city MEDIUMTEXT
15378 ALTER TABLE export_format
15379 MODIFY csv_separator VARCHAR(2) NOT NULL DEFAULT ',',
15380 MODIFY field_separator VARCHAR(2),
15381 MODIFY subfield_separator VARCHAR(2)
15384 ALTER TABLE export_format MODIFY encoding VARCHAR(255) NOT NULL DEFAULT 'utf8'
15388 ALTER TABLE reserves MODIFY lowestPriority tinyint(1) NOT NULL DEFAULT 0
15391 ALTER TABLE old_reserves MODIFY lowestPriority tinyint(1) NOT NULL DEFAULT 0
15394 SetVersion( $DBversion );
15395 print "Upgrade to $DBversion done (Bug 20144 - Adapt DB structure to work with new SQL modes)\n";
15398 $DBversion = '17.12.00.016';
15399 if( CheckVersion( $DBversion ) ) {
15400 $dbh->do(q|SET foreign_key_checks = 0|);
15401 my $sth = $dbh->table_info( '','','','TABLE' );
15403 while ( my ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
15404 my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
15405 $table_sth->execute;
15406 my @table = $table_sth->fetchrow_array;
15407 unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) {
15408 # Some users might have done the upgrade to utf8mb4 on their own
15409 # to support supplemental chars (japanese, chinese, etc)
15410 if ( $name eq 'additional_fields' ) {
15413 DROP KEY `fields_uniq`,
15414 ADD UNIQUE KEY `fields_uniq` (`tablename` (191), `name` (191))
15416 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15418 elsif ( $name eq 'authorised_values' ) {
15422 ADD KEY `lib` (`lib` (191))
15424 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15426 elsif ( $name eq 'borrower_modifications' ) {
15430 DROP KEY `verification_token`,
15431 ADD PRIMARY KEY (`verification_token` (191),`borrowernumber`),
15432 ADD KEY `verification_token` (`verification_token` (191))
15434 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15436 elsif ( $name eq 'columns_settings' ) {
15440 ADD PRIMARY KEY (`module` (191), `page` (191), `tablename` (191), `columnname` (191))
15442 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15444 elsif ( $name eq 'illrequestattributes' ) {
15448 ADD PRIMARY KEY (`illrequest_id`, `type` (191))
15450 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15452 elsif ( $name eq 'items_search_fields' ) {
15456 ADD PRIMARY KEY (`name` (191))
15458 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15460 elsif ( $name eq 'marc_subfield_structure' ) {
15461 # In this case we convert each column explicitly
15462 # to preserve 'tagsubield' collation (utf8mb4_bin)
15465 MODIFY COLUMN tagfield
15466 VARCHAR(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
15467 MODIFY COLUMN tagsubfield
15468 VARCHAR(1) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
15469 MODIFY COLUMN liblibrarian
15470 VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
15471 MODIFY COLUMN libopac
15472 VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
15473 MODIFY COLUMN kohafield
15474 VARCHAR(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15475 MODIFY COLUMN authorised_value
15476 VARCHAR(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15477 MODIFY COLUMN authtypecode
15478 VARCHAR(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15479 MODIFY COLUMN value_builder
15480 VARCHAR(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15481 MODIFY COLUMN frameworkcode
15482 VARCHAR(4) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
15483 MODIFY COLUMN seealso
15484 VARCHAR(1100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15486 VARCHAR(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
15487 MODIFY COLUMN defaultvalue
15488 MEDIUMTEXT COLLATE utf8mb4_unicode_ci default NULL
15490 $dbh->do(qq|ALTER TABLE $name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15492 elsif ( $name eq 'plugin_data' ) {
15496 ADD PRIMARY KEY (`plugin_class` (191), `plugin_key` (191))
15498 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15500 elsif ( $name eq 'search_field' ) {
15504 ADD UNIQUE KEY `name` (`name` (191))
15506 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15508 elsif ( $name eq 'search_marc_map' ) {
15511 DROP KEY `index_name`,
15512 ADD UNIQUE KEY `index_name` (`index_name`, `marc_field` (191), `marc_type`)
15514 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15516 elsif ( $name eq 'sms_providers' ) {
15520 ADD UNIQUE KEY `name` (`name` (191))
15522 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15524 elsif ( $name eq 'tags' ) {
15528 ADD PRIMARY KEY (`entry` (191))
15530 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15532 elsif ( $name eq 'tags_approval' ) {
15535 MODIFY COLUMN `term` VARCHAR(191) NOT NULL
15537 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15539 elsif ( $name eq 'tags_index' ) {
15542 MODIFY COLUMN `term` VARCHAR(191) NOT NULL
15544 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15547 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci|);
15551 $dbh->do(q|SET foreign_key_checks = 1|);
15553 print "Upgrade to $DBversion done (Bug 18336 - Convert DB tables to utf8mb4 🎁)\n";
15554 SetVersion($DBversion);
15558 $DBversion = '17.12.00.017';
15559 if( CheckVersion( $DBversion ) ) {
15561 if( !column_exists( 'items', 'damaged_on' ) ) {
15562 $dbh->do( "ALTER TABLE items ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
15564 if( !column_exists( 'deleteditems', 'damaged_on' ) ) {
15565 $dbh->do( "ALTER TABLE deleteditems ADD COLUMN damaged_on DATETIME NULL AFTER damaged");
15568 SetVersion( $DBversion );
15569 print "Upgrade to $DBversion done (Bug 17672 - Add damaged_on to items and deleteditems tables)\n";
15572 $DBversion = '17.12.00.018';
15573 if( CheckVersion( $DBversion ) ) {
15576 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo')
15579 SetVersion( $DBversion );
15580 print "Upgrade to $DBversion done (Bug 19290 - Add system preference BrowseResultSelection)\n";
15583 $DBversion = '17.12.00.019';
15584 if( CheckVersion( $DBversion ) ) {
15586 $dbh->do(q|UPDATE auth_subfield_structure SET hidden=1 WHERE hidden<>0|);
15588 SetVersion( $DBversion );
15589 print "Upgrade to $DBversion done (Bug 20074 - Auth_subfield_structure changes hidden attribute)\n";
15592 $DBversion = '17.12.00.020';
15593 if( CheckVersion( $DBversion ) ) {
15596 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
15597 VALUES ('vi', 'language', 'de', 'Vietnamesisch')
15601 UPDATE language_descriptions SET description = 'Tiếng Việt'
15602 WHERE subtag = 'vi' and type = 'language' and lang = 'vi'
15605 SetVersion( $DBversion );
15606 print "Upgrade to $DBversion done (Bug 20082 - Update descriptions of Vietnamese language)\n";
15609 $DBversion = '17.12.00.021';
15610 if( CheckVersion( $DBversion ) ) {
15613 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
15614 ('PurgeSuggestionsOlderThan', '', NULL, 'Default value for cronjob purge_suggestions.pl', 'Integer');
15617 SetVersion( $DBversion );
15618 print "Upgrade to $DBversion done (Bug 13287 - Add system preference PurgeSuggestionsOlderThan)\n";
15621 $DBversion = '17.12.00.022';
15622 if( CheckVersion( $DBversion ) ) {
15624 if( !column_exists( 'currency', 'p_sep_by_space' ) ) {
15626 ALTER TABLE currency ADD COLUMN p_sep_by_space tinyint(1) default 0 after archived
15630 SetVersion( $DBversion );
15631 print "Upgrade to $DBversion done (Bug 4078 - Add column currency.p_sep_by_space)\n";
15634 $DBversion = '17.12.00.023';
15635 if( CheckVersion( $DBversion ) ) {
15637 DELETE FROM systempreferences
15638 WHERE variable='checkdigit'
15641 SetVersion( $DBversion );
15642 print "Upgrade to $DBversion done (Bug 20264 - Remove system preference 'checkdigit')\n";
15645 $DBversion = '17.12.00.024';
15646 if( CheckVersion( $DBversion ) ) {
15649 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15650 VALUES ('SelfCheckInMainUserBlock', '', '70|10', 'Add a block of HTML that will display on the self check-in screen.', 'Textarea');
15654 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15655 VALUES ('SelfCheckInModule', 0, NULL, 'Enable the standalone self-checkin module.', 'YesNo');
15659 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15660 VALUES ('SelfCheckInModuleUserID', NULL, NULL, 'Patron ID (borrowernumber) to be allowed on the self-checkin module.', 'Integer');
15664 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15665 VALUES ('SelfCheckInTimeout', 120, NULL, 'Define the number of seconds before the self check-in module times out.', 'Integer');
15669 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15670 VALUES ('SelfCheckInUserCSS', '', NULL, 'Add CSS to be included in the self check-in module in an embedded <style> tag.', 'free');
15674 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
15675 VALUES ('SelfCheckInUserJS', '', NULL, 'Define custom javascript for inclusion in the self check-in module.', 'free');
15678 # Add new userflag for self check
15680 INSERT IGNORE INTO userflags (bit,flag,flagdesc,defaulton) VALUES
15681 (23,'self_check','Self check modules',0);
15684 # Add self check-in module subpermission
15686 INSERT IGNORE INTO permissions (module_bit,code,description)
15687 VALUES (23, 'self_checkin_module', 'Log into the self check-in module');
15690 # Add self check-in module subpermission
15692 INSERT IGNORE INTO permissions (module_bit,code,description)
15693 VALUES (23, 'self_checkout_module', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID');
15696 # Update patrons with self_checkout permission
15697 # IMPORTANT: Needs to happen before removing the old subpermission
15699 UPDATE user_permissions
15700 SET module_bit = 23,
15701 code = 'self_checkout_module'
15702 WHERE module_bit = 1 AND code = 'self_checkout';
15705 # Remove old self_checkout permission
15707 DELETE IGNORE FROM permissions
15708 WHERE code='self_checkout';
15711 SetVersion( $DBversion );
15712 print "Upgrade to $DBversion done (Bug 15492 - Add a standalone self-checkin module)\n";
15715 $DBversion = '17.12.00.025';
15716 if( CheckVersion( $DBversion ) ) {
15718 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
15719 VALUES ('StaffLoginInstructions','','HTML to go into the login box for the staff client',NULL,'Free')
15722 UPDATE systempreferences
15723 SET variable = 'OpacLoginInstructions'
15724 WHERE variable = 'NoLoginInstructions'
15727 SetVersion( $DBversion );
15728 print "Upgrade to $DBversion done (Bug 20291 - Add StaffLoginInstructions system preference and rename NoLoginInstructions with OpacLoginInstructions)\n";
15731 $DBversion = '17.12.00.026';
15732 if( CheckVersion( $DBversion ) ) {
15733 if( !column_exists( 'issuingrules', 'suspension_chargeperiod' ) ) {
15735 ALTER TABLE issuingrules ADD COLUMN suspension_chargeperiod int(11) DEFAULT '1' AFTER maxsuspensiondays;
15739 SetVersion( $DBversion );
15740 print "Upgrade to $DBversion done (Bug 19804 - Add issuingrules.suspension_chargeperiod)\n";
15743 $DBversion = '17.12.00.027';
15744 if( CheckVersion( $DBversion ) ) {
15746 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
15747 VALUES ('UseACQFrameworkForBiblioRecords','0','','Use the ACQ framework for the catalog details','YesNo')
15750 SetVersion( $DBversion );
15751 print "Upgrade to $DBversion done (Bug 19289 - Add system preference UseACQFrameworkForBiblioRecords)\n";
15754 $DBversion = '17.12.00.028';
15755 if( CheckVersion( $DBversion ) ) {
15756 if( !column_exists( 'marc_tag_structure', 'ind1_defaultvalue' ) ) {
15758 ALTER TABLE marc_tag_structure
15759 ADD COLUMN ind2_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value,
15760 ADD COLUMN ind1_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value;
15764 SetVersion( $DBversion );
15765 print "Upgrade to $DBversion done (Bug 9701 - Add default indicators (marc_tag_structure.indX_defaultvalue))\n";
15768 $DBversion = '17.12.00.029';
15769 if( CheckVersion( $DBversion ) ) {
15771 q|# PERSO_NAME 100 600 696 700 796 800 896
15772 marc21, 100, ind1:auth1
15773 marc21, 600, ind1:auth1, ind2:thesaurus
15774 marc21, 696, ind1:auth1
15775 marc21, 700, ind1:auth1
15776 marc21, 796, ind1:auth1
15777 marc21, 800, ind1:auth1
15778 marc21, 896, ind1:auth1
15779 # CORPO_NAME 110 610 697 710 797 810 897
15780 marc21, 110, ind1:auth1
15781 marc21, 610, ind1:auth1, ind2:thesaurus
15782 marc21, 697, ind1:auth1
15783 marc21, 710, ind1:auth1
15784 marc21, 797, ind1:auth1
15785 marc21, 810, ind1:auth1
15786 marc21, 897, ind1:auth1
15787 # MEETI_NAME 111 611 698 711 798 811 898
15788 marc21, 111, ind1:auth1
15789 marc21, 611, ind1:auth1, ind2:thesaurus
15790 marc21, 698, ind1:auth1
15791 marc21, 711, ind1:auth1
15792 marc21, 798, ind1:auth1
15793 marc21, 811, ind1:auth1
15794 marc21, 898, ind1:auth1
15795 # UNIF_TITLE 130 440 630 699 730 799 830 899 / 240
15796 marc21, 130, ind1:auth2
15797 marc21, 240, , ind2:auth2
15798 marc21, 440, , ind2:auth2
15799 marc21, 630, ind1:auth2, ind2:thesaurus
15800 marc21, 699, ind1:auth2
15801 marc21, 730, ind1:auth2
15802 marc21, 799, ind1:auth2
15803 marc21, 830, , ind2:auth2
15804 marc21, 899, ind1:auth2
15806 marc21, 648, , ind2:thesaurus
15807 # TOPIC_TERM 650 654 656 657 658 690
15808 marc21, 650, , ind2:thesaurus
15809 # GEOGR_NAME 651 662 691 / 751
15810 marc21, 651, , ind2:thesaurus
15812 marc21, 655, , ind2:thesaurus
15814 # UNIMARC: Always copy the indicators from the authority
15815 unimarc, *, ind1:auth1, ind2:auth2|;
15818 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
15819 VALUES ( 'AuthorityControlledIndicators', ?, 'Authority controlled indicators per biblio field', NULL, 'Free' );
15822 SetVersion( $DBversion );
15823 print "Upgrade to $DBversion done (Bug 14769 - Authorities merge: Set correct indicators in biblio field (new system preference AuthorityControlledIndicators))\n";
15826 $DBversion = '17.12.00.030';
15827 if( CheckVersion( $DBversion ) ) {
15829 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
15830 VALUES ('NovelistSelectStaffProfile',NULL,'Novelist staff client user Profile',NULL,'free')
15833 SetVersion( $DBversion );
15834 print "Upgrade to $DBversion done (Bug 19882 - Add system preference NovelistSelectStaffProfile)\n";
15837 $DBversion = '17.12.00.031';
15838 if( CheckVersion( $DBversion ) ) {
15840 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
15841 VALUES ('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. \"MARC21\" or \"UNIMARC\". {FIELD} = field number, eg. \"000\" or \"048\". {LANG} = user language, eg. \"en\" or \"fi-FI\"', 'free')
15844 SetVersion( $DBversion );
15845 print "Upgrade to $DBversion done (Bug 11674 - Add system preference MarcFieldDocURL)\n";
15848 $DBversion = '17.12.00.032';
15849 if( CheckVersion( $DBversion ) ) {
15851 UPDATE letter SET code = "SERIAL_ALERT" WHERE code = "RLIST";
15854 UPDATE letter SET name = "New serial issue" WHERE name = "Routing List";
15857 UPDATE subscription SET letter = "SERIAL_ALERT" WHERE letter = "RLIST";
15860 SetVersion( $DBversion );
15861 print "Upgrade to $DBversion done (Bug 19794 - Rename RLIST notice to SERIAL_ALERT)\n";
15864 $DBversion = '17.12.00.033';
15865 if( CheckVersion( $DBversion ) ) {
15866 if ( !column_exists( 'accountlines', 'payment_type' ) ) {
15868 ALTER TABLE accountlines ADD payment_type varchar(80) default NULL AFTER accounttype
15873 INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('PAYMENT_TYPE')
15876 SetVersion( $DBversion );
15877 print "Upgrade to $DBversion done (Bug 18786 - Add ability to create custom payment types)\n";
15880 $DBversion = '17.12.00.034';
15881 if( CheckVersion( $DBversion ) ) {
15884 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('Void Payment')
15887 SetVersion( $DBversion );
15888 print "Upgrade to $DBversion done (Bug 18790 - Add ability to void payment)\n";
15891 $DBversion = '17.12.00.035';
15892 if( CheckVersion( $DBversion ) ) {
15893 my ( $original_value ) = $dbh->selectrow_array(q|
15894 SELECT value FROM systempreferences WHERE variable="MarkLostItemsAsReturned"
15896 if ( $original_value and $original_value eq '1' ) {
15898 UPDATE systempreferences
15899 SET type="multiple",
15900 options="batchmod|moredetail|cronjob|additem",
15901 value="batchmod,moredetail,cronjob,additem"
15902 WHERE variable="MarkLostItemsAsReturned"
15906 UPDATE systempreferences
15907 SET type="multiple",
15908 options="batchmod|moredetail|cronjob|additem",
15910 WHERE variable="MarkLostItemsAsReturned"
15914 SetVersion( $DBversion );
15915 print "Upgrade to $DBversion done (Bug 19974 - Make MarkLostItemsAsReturned multiple)\n";
15918 $DBversion = '17.12.00.036';
15919 if( CheckVersion( $DBversion ) ) {
15922 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('CanMarkHoldsToPullAsLost','do_not_allow','do_not_allow|allow|allow_and_notify','Add a button to the "Holds to pull" screen to mark an item as lost and notify the patron.','Choice');
15925 INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('reserves', 'CANCEL_HOLD_ON_LOST', '', 'Hold has been cancelled', 0, "Hold has been cancelled", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nWe regret to inform you, that the following item can not be provided due to it being missing. Your hold was cancelled.\n\nTitle: [% biblio.title %]\nAuthor: [% biblio.author %]\nCopy: [% item.copynumber %]\nLocation: [% branch.branchname %]", 'email', 'default');
15928 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('UpdateItemWhenLostFromHoldList','',NULL,'This is a list of values to update an item when it is marked as lost from the holds to pull screen','Free');
15931 UPDATE systempreferences SET options="batchmod|moredetail|cronjob|additem|pendingreserves" WHERE variable="MarkLostItemsAsReturned";
15934 SetVersion( $DBversion );
15935 print "Upgrade to $DBversion done (Bug 19287 - Add ability to mark an item 'Lost' from 'Holds to pull' list (CanMarkHoldsToPullAsLost, UpdateItemWhenLostFromHoldList and CANCEL_HOLD_ON_LOST))\n";
15938 $DBversion = '17.12.00.037';
15939 if( CheckVersion( $DBversion ) ) {
15941 SetVersion( $DBversion );
15942 print "Upgrade to $DBversion done (This change has been reverted, nothing done!)\n";
15945 $DBversion = '17.12.00.038';
15946 if( CheckVersion( $DBversion ) ) {
15949 UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'slo' WHERE iso639_2_code = 'slk' AND rfc4646_subtag = 'sk';
15952 SetVersion( $DBversion );
15953 print "Upgrade to $DBversion done (Bug 20245 - Use Bibliographic code value for Slovak language)\n";
15956 $DBversion = '17.12.00.039';
15957 if( CheckVersion( $DBversion ) ) {
15960 UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'baq' WHERE iso639_2_code = 'eus' AND rfc4646_subtag = 'eu';
15963 UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'mao' WHERE iso639_2_code = 'mri' AND rfc4646_subtag = 'mi';
15966 UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'alb' WHERE iso639_2_code = 'sqi' AND rfc4646_subtag = 'sq';
15969 SetVersion( $DBversion );
15970 print "Upgrade to $DBversion done (Bug 20482 - Use Bibliographic code value for Basque, Maori and Albanian languages)\n";
15973 $DBversion = '17.12.00.040';
15974 if( CheckVersion( $DBversion ) ) {
15977 INSERT IGNORE INTO systempreferences ( value, variable, options, explanation, type )
15978 VALUES ( '0', 'ProtectSuperlibrarianPrivileges', NULL, 'If enabled, non-superlibrarians cannot set superlibrarian privileges', 'YesNo' )
15981 SetVersion( $DBversion );
15982 print "Upgrade to $DBversion done (Bug 20100 - Add new system preference ProtectSuperlibrarianPrivileges)\n";
15985 $DBversion = '17.12.00.041';
15986 if( CheckVersion( $DBversion ) ) {
15989 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
15992 SetVersion( $DBversion );
15993 print "Upgrade to $DBversion done (Bug 11317 - Add a new permission to access files stored on the server)\n";
15996 $DBversion = '17.12.00.042';
15997 if( CheckVersion( $DBversion ) ) {
15999 if (!TableExists('oauth_access_tokens')) {
16001 CREATE TABLE oauth_access_tokens (
16002 `access_token` VARCHAR(191) NOT NULL,
16003 `client_id` VARCHAR(191) NOT NULL,
16004 `expires` INT NOT NULL,
16005 PRIMARY KEY (`access_token`)
16006 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
16010 SetVersion( $DBversion );
16011 print "Upgrade to $DBversion done (Bug 20402 - Implement OAuth2 authentication for REST API)\n";
16014 $DBversion = '17.12.00.043';
16015 if(CheckVersion($DBversion)) {
16017 if (!TableExists('api_keys')) {
16019 CREATE TABLE `api_keys` (
16020 `client_id` VARCHAR(191) NOT NULL,
16021 `secret` VARCHAR(191) NOT NULL,
16022 `description` VARCHAR(255) NOT NULL,
16023 `patron_id` INT(11) NOT NULL,
16024 `active` TINYINT(1) DEFAULT 1 NOT NULL,
16025 PRIMARY KEY `client_id` (`client_id`),
16026 UNIQUE KEY `secret` (`secret`),
16027 KEY `patron_id` (`patron_id`),
16028 CONSTRAINT `api_keys_fk_patron_id`
16029 FOREIGN KEY (`patron_id`)
16030 REFERENCES `borrowers` (`borrowernumber`)
16031 ON DELETE CASCADE ON UPDATE CASCADE
16032 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16036 print "Upgrade to $DBversion done (Bug 20568 - Add API key management interface for patrons)\n";
16037 SetVersion($DBversion);
16040 $DBversion = '17.12.00.044';
16041 if(CheckVersion($DBversion)) {
16044 INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`)
16046 ('RESTOAuth2ClientCredentials','0',NULL,'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo');
16049 print "Upgrade to $DBversion done (Bug 20624 - Disable OAuth2 client credentials grant by default)\n";
16050 SetVersion($DBversion);
16053 $DBversion = '18.05.00.000';
16054 if( CheckVersion( $DBversion ) ) {
16055 SetVersion( $DBversion );
16056 print "Upgrade to $DBversion done (Koha 18.05)\n";
16059 $DBversion = '18.06.00.000';
16060 if( CheckVersion( $DBversion ) ) {
16061 SetVersion( $DBversion );
16062 print "Upgrade to $DBversion done (Koha 18.06 - It's Adventure time!)\n";
16065 $DBversion = '18.06.00.001';
16066 if( CheckVersion( $DBversion ) ) {
16067 $dbh->do(q{UPDATE permissions SET description = 'Manage budgets' WHERE code = 'period_manage';});
16068 $dbh->do(q{UPDATE permissions SET description = 'Manage funds' WHERE code = 'budget_manage';});
16069 $dbh->do(q{UPDATE permissions SET description = 'Modify funds (can''t create lines, but can modify existing ones)' WHERE code = 'budget_modify';});
16070 $dbh->do(q{UPDATE permissions SET description = 'Manage baskets and order lines' WHERE code = 'order_manage';});
16071 $dbh->do(q{UPDATE permissions SET description = 'Manage all baskets and order lines, regardless of restrictions on them' WHERE code = 'order_manage_all';});
16072 $dbh->do(q{UPDATE permissions SET description = 'Manage basket groups' WHERE code = 'group_manage';});
16073 $dbh->do(q{UPDATE permissions SET description = 'Receive orders and manage shipments' WHERE code = 'order_receive';});
16074 $dbh->do(q{UPDATE permissions SET description = 'Add and delete funds (but can''t modify funds)' WHERE code = 'budget_add_del';});
16075 $dbh->do(q{UPDATE permissions SET description = 'Manage all funds' WHERE code = 'budget_manage_all';});
16076 SetVersion( $DBversion );
16077 print "Upgrade to $DBversion done (Bug 3849- Improve descriptions of granular acquisition permissions)\n";
16080 $DBversion = '18.06.00.002';
16081 if( CheckVersion( $DBversion ) ) {
16082 $dbh->do(q{DELETE FROM userflags WHERE bit = 12 AND flag = 'management';});
16083 $dbh->do(q{UPDATE borrowers SET flags = flags - ( flags & (1<<12) ) WHERE flags & (1 << 12);});
16084 SetVersion( $DBversion );
16085 print "Upgrade to $DBversion done (Bug 2426 - Remove deprecated management permission)\n";
16088 $DBversion = '18.06.00.003';
16089 if( CheckVersion( $DBversion ) ) {
16090 $dbh->do( "ALTER TABLE search_field CHANGE COLUMN type type ENUM('', 'string', 'date', 'number', 'boolean', 'sum', 'isbn', 'stdno') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine'" );
16091 SetVersion( $DBversion );
16092 print "Upgrade to $DBversion done (Bug 20073 - Add new types for Elasticsearch fields)\n";
16095 $DBversion = '18.06.00.004';
16096 if( CheckVersion( $DBversion ) ) {
16098 # Add 'Manual Credit' offset type
16100 INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Manual Credit');
16103 # Fix wrong account offsets / Manual credits
16105 UPDATE account_offsets
16106 SET credit_id=debit_id,
16108 type='Manual Credit'
16109 WHERE amount < 0 AND
16110 type='Manual Debit' AND
16112 (SELECT accountlines_id AS debit_id
16114 WHERE accounttype='C');
16117 # Fix wrong account offsets / Manually forgiven amounts
16119 UPDATE account_offsets
16120 SET credit_id=debit_id,
16123 WHERE amount < 0 AND
16124 type='Manual Debit' AND
16126 (SELECT accountlines_id AS debit_id
16128 WHERE accounttype='FOR');
16131 SetVersion( $DBversion );
16132 print "Upgrade to $DBversion done (Bug 20980 - Manual credit offsets are stored as debits)\n";
16135 $DBversion = '18.06.00.005';
16136 if( CheckVersion( $DBversion ) ) {
16137 unless ( column_exists('aqorders', 'created_by') ) {
16138 $dbh->do( "ALTER TABLE aqorders ADD COLUMN created_by int(11) NULL DEFAULT NULL AFTER quantityreceived;" );
16139 unless ( foreign_key_exists('aqorders', 'aqorders_created_by') ) {
16140 $dbh->do( "ALTER TABLE aqorders ADD CONSTRAINT aqorders_created_by FOREIGN KEY (created_by) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;" );
16142 $dbh->do( "UPDATE aqbasket LEFT JOIN borrowers ON ( aqbasket.authorisedby = borrowers.borrowernumber ) SET aqbasket.authorisedby = NULL WHERE borrowers.borrowernumber IS NULL;" );
16143 $dbh->do( "UPDATE aqorders LEFT JOIN aqbasket ON ( aqorders.basketno = aqbasket.basketno ) SET aqorders.created_by = aqbasket.authorisedby WHERE aqorders.created_by IS NULL;" );
16145 SetVersion( $DBversion );
16146 print "Upgrade to $DBversion done (Bug 12395 - Save order line's creator)\n";
16149 $DBversion = '18.06.00.006';
16150 if( CheckVersion( $DBversion ) ) {
16151 unless ( column_exists('patron_lists', 'shared') ) {
16152 $dbh->do( "ALTER TABLE patron_lists ADD COLUMN shared tinyint(1) default 0 AFTER owner;" );
16154 SetVersion( $DBversion );
16155 print "Upgrade to $DBversion done (Bug 19524 - Share patron lists between staff)\n";
16158 $DBversion = '18.06.00.007';
16159 if( CheckVersion( $DBversion ) ) {
16160 $dbh->do( "INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (11, 'currencies_manage', 'Manage currencies and exchange rates');" );
16162 INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code)
16163 SELECT borrowernumber, 11, 'currencies_manage' FROM borrowers WHERE flags & (1 << 3) OR borrowernumber IN
16164 (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16166 SetVersion( $DBversion );
16167 print "Upgrade to $DBversion done (Bug 7651 - Add separate permission for managing currencies and exchange rates)\n";
16170 $DBversion = '18.06.00.008';
16171 if( CheckVersion( $DBversion ) ) {
16172 $dbh->do( "ALTER TABLE marc_modification_template_actions CHANGE action action ENUM('delete_field','add_field','update_field','move_field','copy_field','copy_and_replace_field')" );
16173 SetVersion( $DBversion );
16174 print "Upgrade to $DBversion done (Bug 13560 - need an add option in marc modification templates)\n";
16177 $DBversion = '18.06.00.009';
16178 if( CheckVersion( $DBversion ) ) {
16180 CREATE TABLE IF NOT EXISTS aqinvoice_adjustments (
16181 adjustment_id int(11) NOT NULL AUTO_INCREMENT,
16182 invoiceid int(11) NOT NULL,
16183 adjustment decimal(28,6),
16184 reason varchar(80) default NULL,
16185 note mediumtext default NULL,
16186 budget_id int(11) default NULL,
16187 encumber_open smallint(1) NOT NULL default 1,
16188 timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
16189 PRIMARY KEY (adjustment_id),
16190 CONSTRAINT aqinvoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE,
16191 CONSTRAINT aqinvoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
16192 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
16194 $dbh->do("INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ADJ_REASON')");
16195 SetVersion( $DBversion );
16196 print "Upgrade to $DBversion done (Bug 19166 - Add the ability to add adjustments to an invoice)\n";
16199 $DBversion = '18.06.00.010';
16200 if( CheckVersion( $DBversion ) ) {
16202 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`)
16204 ('circulation', 'ACCOUNT_PAYMENT', '', 'Account payment', 0, 'Account payment', '[%- USE Price -%]\r\nA payment of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis payment affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default'),
16205 ('circulation', 'ACCOUNT_WRITEOFF', '', 'Account writeoff', 0, 'Account writeoff', '[%- USE Price -%]\r\nAn account writeoff of [% credit.amount * -1 | $Price %] has been applied to your account.\r\n\r\nThis writeoff affected the following fees:\r\n[%- FOREACH o IN offsets %]\r\nDescription: [% o.debit.description %]\r\nAmount paid: [% o.amount * -1 | $Price %]\r\nAmount remaining: [% o.debit.amountoutstanding | $Price %]\r\n[% END %]', 'email', 'default');
16208 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`)
16209 VALUES ('UseEmailReceipts','0','','Send email receipts for payments and write-offs','YesNo')
16211 SetVersion( $DBversion );
16212 print "Upgrade to $DBversion done (Bug 19191 - Add ability to email receipts for account payments and write-offs)\n";
16215 $DBversion = '18.06.00.011';
16216 if( CheckVersion( $DBversion ) ) {
16217 unless( column_exists( 'issues', 'noteseen' ) ) {
16218 $dbh->do(q|ALTER TABLE issues ADD COLUMN noteseen int(1) default NULL AFTER notedate|);
16221 unless( column_exists( 'old_issues', 'noteseen' ) ) {
16222 $dbh->do(q|ALTER TABLE old_issues ADD COLUMN noteseen int(1) default NULL AFTER notedate|);
16224 $dbh->do(q|INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_checkout_notes', 'Mark checkout notes as seen/not seen');|);
16225 SetVersion( $DBversion );
16226 print "Upgrade to $DBversion done (Bug 17698: Add column issues.noteseen and old_issues.noteseen)\n";
16229 $DBversion = '18.06.00.012';
16230 if( CheckVersion( $DBversion ) ) {
16231 $dbh->do(q|INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (11, 'suggestions_manage', 'Manage purchase suggestions');|);
16232 $dbh->do(q|INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, 11, 'suggestions_manage' FROM borrowers WHERE flags & (1 << 2);|);
16233 SetVersion( $DBversion );
16234 print "Upgrade to $DBversion done (Bug 11911 - Add separate permission for managing suggestions)\n";
16237 $DBversion = '18.06.00.013';
16238 if( CheckVersion( $DBversion ) ) {
16240 INSERT IGNORE INTO `account_offset_types` (`type`) VALUES ('Credit Applied');
16242 SetVersion( $DBversion );
16243 print "Upgrade to $DBversion done (Bug 20997 - Add Koha::Account::Line::apply)\n";
16246 $DBversion = '18.06.00.014';
16247 if( CheckVersion( $DBversion ) ) {
16249 INSERT IGNORE INTO systempreferences (variable, value, options, explanation) VALUES ('HidePersonalPatronDetailOnCirculation', 0, 'YesNo', 'Hide patrons phone number, email address, street address and city in the circulation page');
16251 SetVersion( $DBversion );
16252 print "Upgrade to $DBversion done (Bug 21121 - New syspref to allow hiding of private patron data in circulation page)\n";
16255 $DBversion = '18.06.00.015';
16256 if( CheckVersion( $DBversion ) ) {
16257 $dbh->do(q{DELETE FROM systempreferences where variable="OCLCAffiliateID";});
16258 $dbh->do(q{DELETE FROM systempreferences where variable="XISBN";});
16259 $dbh->do(q{DELETE FROM systempreferences where variable="XISBNDailyLimit";});
16260 SetVersion( $DBversion );
16261 print "Upgrade to $DBversion done (Bug 21226 - Remove prefs OCLCAffiliateID, XISBN and XISBNDailyLimit)\n";
16264 $DBversion = '18.06.00.016';
16265 if( CheckVersion( $DBversion ) ) {
16266 my $dtf = Koha::Database->new->schema->storage->datetime_parser;
16267 my $days = C4::Context->preference('MaxPickupDelay') || 7;
16268 my $date = dt_from_string()->add( days => $days );
16269 my $sql = q|UPDATE reserves SET expirationdate = ? WHERE expirationdate IS NULL AND waitingdate IS NOT NULL|;
16270 $dbh->do( $sql, undef, $dtf->format_datetime($date) );
16271 SetVersion( $DBversion );
16272 print "Upgrade to $DBversion done (Bug 20773 - expirationdate filled for waiting holds)\n";
16275 $DBversion = '18.06.00.017';
16276 if( CheckVersion( $DBversion ) ) {
16277 $dbh->do(q|INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('ROADTYPE');|);
16278 SetVersion( $DBversion );
16279 print "Upgrade to $DBversion done (Bug 21144: Add ROADTYPE to default authorised values categories)\n";
16282 $DBversion = '18.06.00.018';
16283 if( CheckVersion( $DBversion ) ) {
16285 UPDATE items LEFT JOIN issues USING (itemnumber)
16286 SET items.onloan = NULL
16287 WHERE issues.itemnumber IS NULL
16289 SetVersion( $DBversion );
16290 print "Upgrade to $DBversion done (Bug 20487: Clear items.onloan for unissued items)\n";
16293 $DBversion = '18.06.00.019';
16294 if( CheckVersion( $DBversion ) ) {
16296 INSERT IGNORE INTO columns_settings (module, page, tablename, columnname, cannot_be_toggled, is_hidden) VALUES
16297 ("circ", "circulation", "issues-table", "collection", 0, 1),
16298 ("members", "moremember", "issues-table", "collection", 0, 1);
16300 SetVersion( $DBversion );
16301 print "Upgrade to $DBversion done (Bug 19719: Default to hiding collection code column)\n";
16304 $DBversion = '18.06.00.020';
16305 if( CheckVersion( $DBversion ) ) {
16306 if( !column_exists( 'branch_borrower_circ_rules', 'max_holds' ) ) {
16308 ALTER TABLE branch_borrower_circ_rules ADD COLUMN max_holds INT(4) NULL DEFAULT NULL AFTER maxonsiteissueqty
16311 if( !column_exists( 'default_borrower_circ_rules', 'max_holds' ) ) {
16313 ALTER TABLE default_borrower_circ_rules ADD COLUMN max_holds INT(4) NULL DEFAULT NULL AFTER maxonsiteissueqty
16316 SetVersion( $DBversion );
16317 print "Upgrade to $DBversion done (Bug 15524 - Set limit on maximum possible holds per patron by category)\n";
16320 $DBversion = '18.06.00.021';
16321 if( CheckVersion( $DBversion ) ) {
16322 my $dbh = C4::Context->dbh;
16323 unless ( C4::Context->preference('NorwegianPatronDBEnable') ) {
16325 DELETE FROM systempreferences
16326 WHERE variable IN ('NorwegianPatronDBEnable', 'NorwegianPatronDBEndpoint', 'NorwegianPatronDBUsername', 'NorwegianPatronDBPassword', 'NorwegianPatronDBSearchNLAfterLocalHit')
16328 if ( TableExists('borrower_sync') ) {
16329 $dbh->do(q|DROP TABLE borrower_sync|);
16332 SetVersion( $DBversion );
16333 print "Upgrade to $DBversion done (Bug 21068 - Remove system preferences NorwegianPatronDB*)\n";
16336 $DBversion = '18.06.00.022';
16337 if( CheckVersion( $DBversion ) ) {
16338 my $dbh = C4::Context->dbh;
16340 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
16341 ('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'),
16342 ('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo')
16344 SetVersion( $DBversion );
16345 print "Upgrade to $DBversion done (Bug 19383 - Add ability to print hold receipts automatically)\n";
16348 $DBversion = '18.06.00.023';
16349 if( CheckVersion( $DBversion ) ) {
16350 if( !column_exists( 'aqorders', 'replacementprice' ) ){
16351 $dbh->do( "ALTER TABLE aqorders ADD COLUMN replacementprice DECIMAL(28,6)" );
16352 $dbh->do( "UPDATE aqorders set replacementprice = rrp WHERE replacementprice IS NULL" );
16354 SetVersion( $DBversion );
16355 print "Upgrade to $DBversion done (Bug 18639 - Add replacementprice field to aqorders table)\n";
16358 $DBversion = '18.06.00.024';
16359 if( CheckVersion( $DBversion ) ) {
16360 if( !column_exists( 'branches', 'pickup_location' ) ){
16361 $dbh->do( "ALTER TABLE branches ADD COLUMN pickup_location TINYINT(1) not null default 1" );
16363 SetVersion( $DBversion );
16364 print "Upgrade to $DBversion done (Bug 7534 - Let libraries have configuration for pickup locations)\n";
16367 $DBversion = '18.06.00.025';
16368 if( CheckVersion( $DBversion ) ) {
16370 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
16371 ('KohaManualBaseURL','https://koha-community.org/manual/','','Where is the Koha manual/documentation located?','Free'),
16372 ('KohaManualLanguage','en','en|ar|cs|es|de|fr|it|pt_BR|tr|zh_TW','What is the language of the online manual you want to use?','Choice')
16374 SetVersion( $DBversion );
16375 print "Upgrade to $DBversion done (Bug 19817: Add pref KohaManualLanguage and KohaManualBaseURL)\n";
16378 $DBversion = '18.06.00.026';
16379 if( CheckVersion( $DBversion ) ) {
16381 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('ArticleRequestsLinkControl', 'always', 'always\|calc', 'Control display of article request link on search results', 'Choice')
16383 SetVersion( $DBversion );
16384 print "Upgrade to $DBversion done (Bug 17530 - Add pref ArticleRequestsLinkControl)\n";
16387 $DBversion = '18.06.00.027';
16388 if( CheckVersion( $DBversion ) ) {
16389 $dbh->do( "DROP TABLE IF EXISTS services_throttle" );
16390 SetVersion( $DBversion );
16391 print "Upgrade to $DBversion done (Bug 21235: Remove table services_throttle)\n";
16394 $DBversion = '18.06.00.028';
16395 if( CheckVersion( $DBversion ) ) {
16397 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
16398 ('HoldsSplitQueue','nothing','nothing|branch|itemtype|branch_itemtype','In the staff client, split the holds view by the given criteria','Choice'),
16399 ('HoldsSplitQueueNumbering', 'actual', 'actual|virtual', 'If the holds queue is split, decide if the acual priorities should be displayed', 'Choice');
16401 SetVersion( $DBversion );
16402 print "Upgrade to $DBversion done (Bug 19469 - Add ability to split view of holds view on record by pickup library and/or itemtype)\n";
16405 $DBversion = '18.06.00.029';
16406 if( CheckVersion( $DBversion ) ) {
16407 unless ( index_exists( 'subscription', 'by_biblionumber' ) ) {
16409 CREATE INDEX `by_biblionumber` ON `subscription` (`biblionumber`)
16412 SetVersion( $DBversion );
16413 print "Upgrade to $DBversion done (Bug 21288: Slowness in acquisition caused by GetInvoices\n";
16416 $DBversion = '18.06.00.030';
16417 if( CheckVersion( $DBversion ) ) {
16418 if ( column_exists( 'accountlines', 'dispute' ) ) {
16420 ALTER TABLE `accountlines`
16421 DROP COLUMN `dispute`
16424 SetVersion( $DBversion );
16425 print "Upgrade to $DBversion done (Bug 20777 - Remove unused field accountlines.dispute)\n";
16428 $DBversion = '18.06.00.031';
16429 if( CheckVersion( $DBversion ) ) {
16430 # Add table and add column
16431 unless (TableExists('patron_consent')) {
16433 CREATE TABLE patron_consent (id int AUTO_INCREMENT, borrowernumber int NOT NULL, type enum('GDPR_PROCESSING' ), given_on datetime, refused_on datetime, PRIMARY KEY (id), FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE )
16436 unless ( column_exists( 'borrower_modifications', 'gdpr_proc_consent' ) ) {
16438 ALTER TABLE borrower_modifications ADD COLUMN gdpr_proc_consent datetime
16441 # Add two sysprefs too
16443 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('PrivacyPolicyURL','',NULL,'This URL is used in messages about GDPR consents.', 'Free')
16446 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('GDPR_Policy','','Enforced\|Permissive\|Disabled','General Data Protection Regulation - policy', 'Choice')
16448 SetVersion( $DBversion );
16449 print "Upgrade to $DBversion done (Bug 20819: Add patron_consent)\n";
16452 $DBversion = '18.06.00.032';
16453 if( CheckVersion( $DBversion ) ) {
16454 $dbh->do(q|ALTER TABLE items CHANGE COLUMN ccode ccode varchar(80) default NULL|);
16455 $dbh->do(q|ALTER TABLE deleteditems CHANGE COLUMN ccode ccode varchar(80) default NULL|);
16456 $dbh->do(q|ALTER TABLE branch_transfer_limits CHANGE COLUMN ccode ccode varchar(80) default NULL|);
16457 $dbh->do(q|ALTER TABLE course_items CHANGE COLUMN ccode ccode varchar(80) default NULL|);
16458 SetVersion( $DBversion );
16459 print "Upgrade to $DBversion done (Bug 5458: length of items.ccode disagrees with authorised_values.authorised_value)\n";
16462 $DBversion = '18.06.00.033';
16463 if( CheckVersion( $DBversion ) ) {
16465 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdditionalFieldsInZ3950ResultSearch', '', 'NULL', 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free')
16467 SetVersion( $DBversion );
16468 print "Upgrade to $DBversion done (Bug 12747 - Add AdditionalFieldsInZ3950ResultSearch system preference)\n";
16471 $DBversion = '18.06.00.034';
16472 if( CheckVersion( $DBversion ) ) {
16474 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
16475 VALUES ('RecordedBooksClientSecret','','30','Client key for RecordedBooks integration','YesNo'),
16476 ('RecordedBooksLibraryID','','','Library ID for RecordedBooks integration','Integer'),
16477 ('RecordedBooksDomain','','','RecordedBooks domain','Free');
16479 SetVersion( $DBversion );
16480 print "Upgrade to $DBversion done (Bug 17602 - Integrate support for OneClickdigital/Recorded Books API)\n";
16483 $DBversion = '18.06.00.035';
16484 if( CheckVersion( $DBversion ) ) {
16486 UPDATE `systempreferences` SET options = 'US|CA|DE|FR|IN|JP|UK' WHERE variable = 'AmazonLocale' AND options='US|CA|DE|FR|JP|UK';
16488 SetVersion( $DBversion );
16489 print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n";
16493 $DBversion = '18.06.00.036';
16494 if( CheckVersion( $DBversion ) ) {
16495 unless (TableExists('circulation_rules')){
16497 CREATE TABLE `circulation_rules` (
16498 `id` int(11) NOT NULL auto_increment,
16499 `branchcode` varchar(10) NULL default NULL,
16500 `categorycode` varchar(10) NULL default NULL,
16501 `itemtype` varchar(10) NULL default NULL,
16502 `rule_name` varchar(32) NOT NULL,
16503 `rule_value` varchar(32) NOT NULL,
16504 PRIMARY KEY (`id`),
16505 CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
16506 CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
16507 CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
16508 KEY `rule_name` (`rule_name`),
16509 UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
16510 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16513 if (column_exists('branch_borrower_circ_rules', 'max_holds') ){
16515 INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
16516 SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules
16519 ALTER TABLE branch_borrower_circ_rules DROP COLUMN max_holds
16522 if (column_exists('default_borrower_circ_rules', 'max_holds') ){
16524 INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
16525 SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules
16528 ALTER TABLE default_borrower_circ_rules DROP COLUMN max_holds
16531 SetVersion( $DBversion );
16532 print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n";
16535 $DBversion = '18.06.00.037';
16536 if( CheckVersion( $DBversion ) ) {
16537 unless (TableExists('branches_overdrive')){
16539 CREATE TABLE branches_overdrive (
16540 `branchcode` VARCHAR( 10 ) NOT NULL ,
16541 `authname` VARCHAR( 255 ) NOT NULL ,
16542 PRIMARY KEY (`branchcode`) ,
16543 CONSTRAINT `branches_overdrive_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
16544 ) ENGINE = INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
16547 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveAuthname', '', 'Authname for OverDrive Patron Authentication, will be used as fallback if individual branch authname not set', NULL, 'Free');");
16548 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveWebsiteID','', 'WebsiteID provided by OverDrive', NULL, 'Free');");
16549 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDrivePasswordRequired','', 'Does the library require passwords for OverDrive SIP authentication', NULL, 'YesNo');");
16550 SetVersion( $DBversion );
16551 print "Upgrade to $DBversion done (Bug 21082 - Add overdrive patron auth method)\n";
16554 $DBversion = '18.06.00.038';
16555 if( CheckVersion( $DBversion ) ) {
16556 $dbh->do( "ALTER TABLE edifact_ean MODIFY branchcode VARCHAR(10) NULL DEFAULT NULL" );
16557 SetVersion( $DBversion );
16558 print "Upgrade to $DBversion done (Bug 21417 - EDI ordering fails when basket and EAN libraries do not match)\n";
16561 $DBversion = '18.06.00.039';
16562 if( CheckVersion( $DBversion ) ) {
16564 INSERT IGNORE INTO `permissions` (module_bit, code, description) VALUES(3, 'manage_circ_rules_from_any_libraries', 'Manage circ rules for any libraries');
16566 SetVersion( $DBversion );
16567 print "Upgrade to $DBversion done (Bug 15520 - Add more granular permission for only editing own library's circ rules)\n";
16570 $DBversion = '18.06.00.040';
16571 if( CheckVersion( $DBversion ) ) {
16572 # Stock Rotation Rotas
16573 unless (TableExists('stockrotationrotas')){
16575 CREATE TABLE `stockrotationrotas` (
16576 `rota_id` int(11) auto_increment, -- Stockrotation rota ID
16577 `title` varchar(100) NOT NULL, -- Title for this rota
16578 `description` text NOT NULL, -- Description for this rota
16579 `cyclical` tinyint(1) NOT NULL default 0, -- Should items on this rota keep cycling?
16580 `active` tinyint(1) NOT NULL default 0, -- Is this rota currently active?
16581 PRIMARY KEY (`rota_id`),
16582 CONSTRAINT `stockrotationrotas_title`
16584 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16587 # Stock Rotation Stages
16588 unless (TableExists('stockrotationstages')){
16590 CREATE TABLE `stockrotationstages` (
16591 `stage_id` int(11) auto_increment, -- Unique stage ID
16592 `position` int(11) NOT NULL, -- The position of this stage within its rota
16593 `rota_id` int(11) NOT NULL, -- The rota this stage belongs to
16594 `branchcode_id` varchar(10) NOT NULL, -- Branch this stage relates to
16595 `duration` int(11) NOT NULL default 4, -- The number of days items shoud occupy this stage
16596 PRIMARY KEY (`stage_id`),
16597 CONSTRAINT `stockrotationstages_rifk`
16598 FOREIGN KEY (`rota_id`)
16599 REFERENCES `stockrotationrotas` (`rota_id`)
16600 ON UPDATE CASCADE ON DELETE CASCADE,
16601 CONSTRAINT `stockrotationstages_bifk`
16602 FOREIGN KEY (`branchcode_id`)
16603 REFERENCES `branches` (`branchcode`)
16604 ON UPDATE CASCADE ON DELETE CASCADE
16605 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16608 # Stock Rotation Items
16609 unless (TableExists('stockrotationitems')){
16611 CREATE TABLE `stockrotationitems` (
16612 `itemnumber_id` int(11) NOT NULL, -- Itemnumber to link to a stage & rota
16613 `stage_id` int(11) NOT NULL, -- stage ID to link the item to
16614 `indemand` tinyint(1) NOT NULL default 0, -- Should this item be skipped for rotation?
16615 `fresh` tinyint(1) NOT NULL default 0, -- Flag showing item is only just added to rota
16616 PRIMARY KEY (itemnumber_id),
16617 CONSTRAINT `stockrotationitems_iifk`
16618 FOREIGN KEY (`itemnumber_id`)
16619 REFERENCES `items` (`itemnumber`)
16620 ON UPDATE CASCADE ON DELETE CASCADE,
16621 CONSTRAINT `stockrotationitems_sifk`
16622 FOREIGN KEY (`stage_id`)
16623 REFERENCES `stockrotationstages` (`stage_id`)
16624 ON UPDATE CASCADE ON DELETE CASCADE
16625 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16628 # System preferences
16630 INSERT IGNORE INTO `systempreferences` (`variable`,`value`,`explanation`,`options`,`type`)
16631 VALUES ('StockRotation','0','If ON, enables the stock rotation module','','YesNo'),
16632 ('RotationPreventTransfers','0','If ON, prevent any transfers for items on stock rotation rotas, except for stock rotation transfers','','YesNo');
16636 INSERT IGNORE INTO `userflags` (`bit`, `flag`, `flagdesc`, `defaulton`)
16637 VALUES (24, 'stockrotation', 'Manage stockrotation operations', 0);
16640 INSERT IGNORE INTO `permissions` (`module_bit`, `code`, `description`)
16641 VALUES (24, 'manage_rotas', 'Create, edit and delete rotas'),
16642 (24, 'manage_rota_items', 'Add and remove items from rotas');
16646 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`)
16647 VALUES ('circulation', 'SR_SLIP', '', 'Stock Rotation Slip', 0, 'Stockrotation Report', 'Stockrotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason ne \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent Library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email');
16649 print "Upgrade to $DBversion done (Bug 11897 - Add Stock Rotation Feature)\n";
16650 SetVersion( $DBversion );
16653 $DBversion = '18.06.00.041';
16654 if( CheckVersion( $DBversion ) ) {
16656 if( !column_exists( 'illrequests', 'price_paid' ) ) {
16658 ALTER TABLE illrequests
16659 ADD COLUMN price_paid varchar(20) DEFAULT NULL
16664 if( !column_exists( 'illrequestattributes', 'readonly' ) ) {
16666 ALTER TABLE illrequestattributes
16667 ADD COLUMN readonly tinyint(1) NOT NULL DEFAULT 1
16671 UPDATE illrequestattributes SET readonly = 1
16675 SetVersion( $DBversion );
16676 print "Upgrade to $DBversion done (Bug 20772 - Add illrequestattributes.readonly and illrequest.price_paid columns)\n";
16679 $DBversion = '18.06.00.042';
16680 if( CheckVersion( $DBversion ) ) {
16681 $dbh->do( "alter table statistics change column ccode ccode varchar(80) default NULL" );
16683 SetVersion( $DBversion );
16684 print "Upgrade to $DBversion done (Bug 21617: Make statistics.ccode longer)\n";
16687 $DBversion = "18.06.00.043";
16688 if ( CheckVersion($DBversion) ) {
16689 if ( !column_exists( 'issuingrules', 'holds_per_day' ) ) {
16691 ALTER TABLE `issuingrules`
16692 ADD COLUMN `holds_per_day` SMALLINT(6) DEFAULT NULL
16693 AFTER `holds_per_record`
16696 print "Upgrade to $DBversion done (Bug 15486: Restrict number of holds placed by day)\n";
16697 SetVersion($DBversion);
16700 $DBversion = '18.06.00.044';
16701 if( CheckVersion( $DBversion ) ) {
16702 unless( column_exists( 'creator_batches', 'description' ) ) {
16703 $dbh->do(q|ALTER TABLE creator_batches ADD description mediumtext default NULL AFTER batch_id|);
16705 SetVersion( $DBversion );
16706 print "Upgrade to $DBversion done (Bug 15766: Add column creator_batches.description)\n";
16709 $DBversion = '18.06.00.045';
16710 if( CheckVersion( $DBversion ) ) {
16712 INSERT IGNORE INTO message_transports
16713 (message_attribute_id,message_transport_type,is_digest,letter_module,letter_code)
16715 (2, 'phone', 0, 'circulation', 'PREDUE'),
16716 (2, 'phone', 1, 'circulation', 'PREDUEDGST'),
16717 (4, 'phone', 0, 'reserves', 'HOLD')
16719 SetVersion( $DBversion );
16720 print "Upgrade to $DBversion done (Bug 21639 - Add phone transports by default)\n";
16723 $DBversion = '18.06.00.046';
16724 if( CheckVersion( $DBversion ) ) {
16725 unless (TableExists('illcomments')) {
16727 CREATE TABLE illcomments (
16728 illcomment_id int(11) NOT NULL AUTO_INCREMENT, -- Unique ID of the comment
16729 illrequest_id bigint(20) unsigned NOT NULL, -- ILL request number
16730 borrowernumber integer DEFAULT NULL, -- Link to the user who made the comment (could be librarian, patron or ILL partner library)
16731 comment text DEFAULT NULL, -- The text of the comment
16732 timestamp timestamp DEFAULT CURRENT_TIMESTAMP, -- Date and time when the comment was made
16733 PRIMARY KEY ( illcomment_id ),
16734 CONSTRAINT illcomments_bnfk
16735 FOREIGN KEY ( borrowernumber )
16736 REFERENCES borrowers ( borrowernumber )
16737 ON UPDATE CASCADE ON DELETE CASCADE,
16738 CONSTRAINT illcomments_ifk
16739 FOREIGN KEY (illrequest_id)
16740 REFERENCES illrequests ( illrequest_id )
16741 ON UPDATE CASCADE ON DELETE CASCADE
16742 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
16746 SetVersion( $DBversion );
16747 print "Upgrade to $DBversion done (Bug 18591 - Add comments to ILL requests)\n";
16750 $DBversion = '18.06.00.047';
16751 if( CheckVersion( $DBversion ) ) {
16752 # insert the authorized_value_category for CONTROL_NUM_SEQUENCE
16753 $dbh->do( "INSERT IGNORE INTO authorised_value_categories values ('CONTROL_NUM_SEQUENCE');" );
16754 SetVersion( $DBversion );
16755 print "Upgrade to $DBversion done (Bug 19263 - Advanced Editor - Rancor - Add auto control number (001) widget)\n";
16758 $DBversion = '18.06.00.048';
16759 if( CheckVersion( $DBversion ) ) {
16760 $dbh->do( "ALTER TABLE stockrotationrotas CHANGE COLUMN description description text" );
16761 SetVersion( $DBversion );
16762 print "Upgrade to $DBversion done (Bug 21682 - Remove default on stockrotationrotas.description)\n";
16765 $DBversion = '18.06.00.049';
16766 if( CheckVersion( $DBversion ) ) {
16768 UPDATE letter SET content = REPLACE(content,"item.reason ne \'in-demand\'","item.reason != \'in-demand\'")
16769 WHERE code="SR_SLIP";
16771 print "Upgrade to $DBversion done (Bug 21656 - Stock Rotation Notice, Template Toolkit Syntax Correction)\n";
16772 SetVersion( $DBversion );
16775 $DBversion = '18.06.00.050';
16776 if( CheckVersion( $DBversion ) ) {
16778 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea');
16780 print "Upgrade to $DBversion done (Bug 14385 - Add OpacHiddenItemExceptions)\n";
16781 SetVersion( $DBversion );
16784 $DBversion = '18.06.00.051';
16785 if( CheckVersion( $DBversion ) ) {
16787 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES
16788 ('AdlibrisCoversEnabled', '0', NULL, 'Display cover images in OPAC results and detail listing from Swedish retailer Adlibris.','YesNo'),
16789 ('AdlibrisCoversURL', 'http://www.adlibris.com/se/organisationer/showimagesafe.aspx', NULL, 'Base URL for Adlibris cover image web service.', 'Free');
16791 print "Upgrade to $DBversion done (Bug 8630 - Add covers from AdLibris to the OPAC and Intranet)\n";
16792 SetVersion( $DBversion );
16795 $DBversion = '18.06.00.052';
16796 if( CheckVersion( $DBversion ) ) {
16798 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
16799 ( 3, 'manage_sysprefs', 'Manage global system preferences'),
16800 ( 3, 'manage_libraries', 'Manage libraries and library groups'),
16801 ( 3, 'manage_itemtypes', 'Manage item types'),
16802 ( 3, 'manage_auth_values', 'Manage authorized values'),
16803 ( 3, 'manage_patron_categories', 'Manage patron categories'),
16804 ( 3, 'manage_patron_attributes', 'Manage extended patron attributes'),
16805 ( 3, 'manage_transfers', 'Manage library transfer limits and transport cost matrix'),
16806 ( 3, 'manage_item_circ_alerts', 'Manage item circulation alerts'),
16807 ( 3, 'manage_cities', 'Manage cities and towns'),
16808 ( 3, 'manage_marc_frameworks', 'Manage MARC bibliographic and authority frameworks'),
16809 ( 3, 'manage_keywords2koha_mappings', 'Manage keywords to Koha mappings'),
16810 ( 3, 'manage_classifications', 'Manage classification sources'),
16811 ( 3, 'manage_matching_rules', 'Manage record matching rules'),
16812 ( 3, 'manage_oai_sets', 'Manage OAI sets'),
16813 ( 3, 'manage_item_search_fields', 'Manage item search fields'),
16814 ( 3, 'manage_search_engine_config', 'Manage search engine configuration'),
16815 ( 3, 'manage_search_targets', 'Manage Z39.50 and SRU server configuration'),
16816 ( 3, 'manage_didyoumean', 'Manage Did you mean? configuration'),
16817 ( 3, 'manage_column_config', 'Manage column configuration'),
16818 ( 3, 'manage_sms_providers', 'Manage SMS cellular providers'),
16819 ( 3, 'manage_audio_alerts', 'Manage audio alerts'),
16820 ( 3, 'manage_usage_stats', 'Manage usage statistics settings');
16823 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16824 SELECT borrowernumber, 3, 'manage_sysprefs' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16827 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16828 SELECT borrowernumber, 3, 'manage_libraries' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16831 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16832 SELECT borrowernumber, 3, 'manage_itemtypes' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16835 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16836 SELECT borrowernumber, 3, 'manage_auth_values' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16839 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16840 SELECT borrowernumber, 3, 'manage_patron_categories' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16843 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16844 SELECT borrowernumber, 3, 'manage_patron_attributes' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16847 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16848 SELECT borrowernumber, 3, 'manage_transfers' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16851 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16852 SELECT borrowernumber, 3, 'manage_item_circ_alerts' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16855 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16856 SELECT borrowernumber, 3, 'manage_cities' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16859 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16860 SELECT borrowernumber, 3, 'manage_marc_frameworks' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16863 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16864 SELECT borrowernumber, 3, 'manage_keywords2koha_mappings' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16867 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16868 SELECT borrowernumber, 3, 'manage_classifications' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16871 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16872 SELECT borrowernumber, 3, 'manage_matching_rules' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16875 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16876 SELECT borrowernumber, 3, 'manage_oai_sets' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16879 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16880 SELECT borrowernumber, 3, 'manage_item_search_fields' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16883 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16884 SELECT borrowernumber, 3, 'manage_search_engine_config' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16887 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16888 SELECT borrowernumber, 3, 'manage_search_targets' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16891 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16892 SELECT borrowernumber, 3, 'manage_didyoumean' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16895 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16896 SELECT borrowernumber, 3, 'manage_column_config' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16899 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16900 SELECT borrowernumber, 3, 'manage_sms_providers' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16903 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16904 SELECT borrowernumber, 3, 'manage_audio_alerts' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16907 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16908 SELECT borrowernumber, 3, 'manage_usage_stats' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
16911 INSERT INTO user_permissions (borrowernumber, module_bit, code)
16912 SELECT borrowernumber, 3, 'manage_item_search_fields' FROM borrowers WHERE flags & (1 << 2);
16914 SetVersion( $DBversion );
16915 print "Upgrade to $DBversion done (Bug 14391: Add granular permissions to the administration module)\n";
16918 $DBversion = '18.06.00.053';
16919 if( CheckVersion( $DBversion ) ) {
16920 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ItemsDeniedRenewal','','','This syspref allows to define custom rules for denying renewal of specific items.','Textarea')" );
16921 SetVersion( $DBversion );
16922 print "Upgrade to $DBversion done (Bug 15494 - Block renewals by arbitrary item values)\n";
16925 $DBversion = '18.06.00.054';
16926 if( CheckVersion( $DBversion ) ) {
16927 if( !column_exists( 'search_field', 'weight' ) ) {
16928 $dbh->do( "ALTER TABLE `search_field` ADD COLUMN `weight` decimal(5,2) DEFAULT NULL AFTER `type`" );
16930 SetVersion( $DBversion );
16931 print "Upgrade to $DBversion done (Bug 18316 - Add column search_field.weight)\n";
16934 $DBversion = '18.06.00.055';
16935 if( CheckVersion( $DBversion ) ) {
16936 unless( column_exists( 'issuingrules', 'note' ) ) {
16937 $dbh->do(q|ALTER TABLE `issuingrules` ADD `note` varchar(100) default NULL AFTER `article_requests`|);
16939 SetVersion( $DBversion );
16940 print "Upgrade to $DBversion done (Bug 12365: Add column issuingrules.note)\n";
16943 $DBversion = '18.06.00.056';
16944 if( CheckVersion( $DBversion ) ) {
16946 # All attributes we're potentially interested in
16947 my $ff_req = $dbh->selectall_arrayref(
16948 'SELECT a.illrequest_id, a.type, a.value '.
16949 'FROM illrequests r, illrequestattributes a '.
16950 'WHERE r.illrequest_id = a.illrequest_id '.
16951 'AND r.backend = "FreeForm"',
16955 # Before we go any further, identify whether we've done
16956 # this before, we test for the presence of "container_title"
16957 # We stop as soon as we find one
16958 foreach my $req(@{$ff_req}) {
16959 if ($req->{type} eq 'container_title') {
16960 warn "Upgrade already carried out";
16964 # Transform into a hashref with the key of the request ID
16966 foreach my $request(@{$ff_req}) {
16967 my $id = $request->{illrequest_id};
16968 if (!exists $requests->{$id}) {
16969 $requests->{$id} = {};
16971 $requests->{$id}->{$request->{type}} = $request->{value};
16974 # Transform any article requests
16975 my $transformed = {};
16976 foreach my $id(keys %{$requests}) {
16977 if (lc($requests->{$id}->{type}) eq 'article') {
16978 $transformed->{$id} = $requests->{$id};
16979 $transformed->{$id}->{type} = 'article';
16980 $transformed->{$id}->{container_title} = $transformed->{$id}->{title}
16981 if defined $transformed->{$id}->{title} &&
16982 length $transformed->{$id}->{title} > 0;
16983 $transformed->{$id}->{title} = $transformed->{$id}->{article_title}
16984 if defined $transformed->{$id}->{article_title} &&
16985 length $transformed->{$id}->{article_title} > 0;
16986 $transformed->{$id}->{author} = $transformed->{$id}->{article_author}
16987 if defined $transformed->{$id}->{article_author} &&
16988 length $transformed->{$id}->{article_author} > 0;
16989 $transformed->{$id}->{pages} = $transformed->{$id}->{article_pages}
16990 if defined $transformed->{$id}->{article_pages} &&
16991 length $transformed->{$id}->{article_pages} > 0;
16995 # Now write back the transformed data
16996 # Rather than selectively replace, we just remove all attributes we've
16997 # transformed and re-write them
16998 my @changed = keys %{$transformed};
16999 my $changed_str = join(',', @changed);
17001 if (scalar @changed > 0) {
17002 my ($raise_error) = $dbh->{RaiseError};
17003 $dbh->{AutoCommit} = 0;
17004 $dbh->{RaiseError} = 1;
17006 my $del = $dbh->do(
17007 "DELETE FROM illrequestattributes ".
17008 "WHERE illrequest_id IN ($changed_str)"
17010 foreach my $reqid(keys %{$transformed}) {
17011 my $attr = $transformed->{$reqid};
17012 foreach my $key(keys %{$attr}) {
17013 my $sth = $dbh->prepare(
17014 'INSERT INTO illrequestattributes '.
17015 '(illrequest_id, type, value) '.
17030 warn "Upgrade to $DBversion failed: $@\n";
17031 eval { $dbh->rollback };
17033 SetVersion( $DBversion );
17034 print "Upgrade to $DBversion done (Bug 21079 - Unify metadata schema across backends)\n";
17037 $dbh->{AutoCommit} = 1;
17038 $dbh->{RaiseError} = $raise_error;
17043 $DBversion = '18.06.00.057';
17044 if( CheckVersion( $DBversion ) ) {
17045 # System preferences
17047 INSERT IGNORE INTO `systempreferences` (`variable`,`value`,`explanation`,`options`,`type`)
17048 VALUES ('showLastPatron','0','','If ON, enables the last patron feature in the intranet','YesNo');
17050 SetVersion( $DBversion );
17051 print "Upgrade to $DBversion done (Bug 20312 - Add showLastPatron systempreference)\n";
17054 $DBversion = '18.06.00.058';
17055 if( CheckVersion( $DBversion ) ) {
17057 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
17058 ('MarcFieldForCreatorId','',NULL,'Where to store the borrowernumber of the record''s creator','Free'),
17059 ('MarcFieldForCreatorName','',NULL,'Where to store the name of the record''s creator','Free'),
17060 ('MarcFieldForModifierId','',NULL,'Where to store the borrowernumber of the record''s last modifier','Free'),
17061 ('MarcFieldForModifierName','',NULL,'Where to store the name of the record''s last modifier','Free')
17064 SetVersion( $DBversion );
17065 print "Upgrade to $DBversion done (Bug 19349 - Add system preferences MarcFieldForCreatorId, MarcFieldForCreatorName, MarcFieldForModifierId, MarcFieldForModifierName)\n";
17068 $DBversion = '18.06.00.059';
17069 if( CheckVersion( $DBversion ) ) {
17071 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('EmailSMSSendDriverFromAddress', '', '', 'Email SMS send driver from address override', 'Free');
17073 SetVersion( $DBversion );
17074 print "Upgrade to $DBversion done (Bug 20356 - Add EmailSMSSendDriverFromAddress system preference)\n";
17077 $DBversion = '18.06.00.060';
17078 if( CheckVersion( $DBversion ) ) {
17079 unless( TableExists( 'class_split_rules' ) ) {
17081 CREATE TABLE class_split_rules (
17082 class_split_rule varchar(10) NOT NULL default '',
17083 description LONGTEXT,
17084 split_routine varchar(30) NOT NULL default '',
17085 split_regex varchar(255) NOT NULL default '',
17086 PRIMARY KEY (class_split_rule),
17087 UNIQUE KEY class_split_rule_idx (class_split_rule)
17088 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
17092 ALTER TABLE class_sources
17093 ADD COLUMN class_split_rule varchar(10) NOT NULL default ''
17094 AFTER class_sort_rule
17098 UPDATE class_sources
17099 SET class_split_rule = class_sort_rule
17103 UPDATE class_sources
17104 SET class_split_rule = 'generic'
17105 WHERE class_split_rule NOT IN('dewey', 'generic', 'lcc')
17109 INSERT INTO class_split_rules(class_split_rule, description, split_routine)
17111 ('dewey', 'Default sorting rules for DDC', 'Dewey'),
17112 ('lcc', 'Default sorting rules for LCC', 'LCC'),
17113 ('generic', 'Generic call number sorting rules', 'Generic')
17117 ALTER TABLE class_sources
17118 ADD CONSTRAINT class_source_ibfk_2 FOREIGN KEY (class_split_rule)
17119 REFERENCES class_split_rules (class_split_rule)
17123 SetVersion( $DBversion );
17124 print "Upgrade to $DBversion done (Bug 15836 - Add class_sort_rules.split_routine and split_regex)\n";
17127 $DBversion = '18.06.00.061';
17128 if ( CheckVersion($DBversion) ) {
17130 INSERT IGNORE INTO `systempreferences` (`variable`,`value`,`explanation`,`options`,`type`) VALUES
17131 ('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
17132 ('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL)
17134 SetVersion($DBversion);
17135 print "Upgrade to $DBversion done (Bug 19893 - Add elasticsearch index status preferences)\n";
17138 $DBversion = '18.06.00.062';
17139 if( CheckVersion( $DBversion ) ) {
17140 $dbh->do( "INSERT IGNORE INTO authorised_value_categories (category_name) VALUES ('PA_CLASS');");
17141 SetVersion( $DBversion );
17142 print "Upgrade to $DBversion done (Bug 21730: Add new authorised value category PA_CLASS)\n";
17145 $DBversion = '18.11.00.000';
17146 if( CheckVersion( $DBversion ) ) {
17147 SetVersion( $DBversion );
17148 print "Upgrade to $DBversion done (18.11.00 release)\n";
17151 $DBversion = '18.12.00.000';
17152 if( CheckVersion( $DBversion ) ) {
17153 SetVersion( $DBversion );
17154 print "Upgrade to $DBversion done (...and Steven!)\n";
17157 $DBversion = '18.12.00.001';
17158 if( CheckVersion( $DBversion ) ) {
17160 UPDATE permissions SET code = 'manage_didyoumean' WHERE code = 'manage_didyouean';
17163 UPDATE user_permissions SET code = 'manage_didyoumean' WHERE code = 'manage_didyouean';
17165 SetVersion( $DBversion );
17166 print "Upgrade to $DBversion (Bug 21961 - Fix typo in manage_didyoumean permission)\n";
17169 $DBversion = '18.12.00.002';
17170 if( CheckVersion( $DBversion ) ) {
17171 my $sth = $dbh->prepare(q|SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='accountlines_ibfk_1'|);
17173 if ($sth->fetchrow_hashref) {
17175 ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1;
17178 ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL;
17181 ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_borrowers FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;
17184 SetVersion( $DBversion );
17185 print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n";
17188 $DBversion = '18.12.00.003';
17189 if( CheckVersion( $DBversion ) ) {
17190 # On a new installation the class_sources.sql will have failed, so we need to add all missing data
17191 my( $sort_cnt ) = $dbh->selectrow_array( q|SELECT COUNT(*) FROM class_sort_rules|);
17193 $dbh->do(q|INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
17194 ('dewey', 'Default filing rules for DDC', 'Dewey'),
17195 ('lcc', 'Default filing rules for LCC', 'LCC'),
17196 ('generic', 'Generic call number filing rules', 'Generic')
17200 my ( $split_cnt ) = $dbh->selectrow_array( q|SELECT COUNT(*) FROM class_split_rules|);
17201 if( !$split_cnt ) {
17202 $dbh->do(q|INSERT INTO `class_split_rules` (`class_split_rule`, `description`, `split_routine`) VALUES
17203 ('dewey', 'Default splitting rules for DDC', 'Dewey'),
17204 ('lcc', 'Default splitting rules for LCC', 'LCC'),
17205 ('generic', 'Generic call number splitting rules', 'Generic')
17209 my( $source_cnt ) = $dbh->selectrow_array( q|SELECT COUNT(*) FROM class_sources|);
17210 if( !$source_cnt ) {
17211 $dbh->do(q|INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`, `class_split_rule`) VALUES
17212 ('ddc', 'Dewey Decimal Classification', 1, 'dewey', 'dewey'),
17213 ('lcc', 'Library of Congress Classification', 1, 'lcc', 'lcc'),
17214 ('udc', 'Universal Decimal Classification', 0, 'generic', 'generic'),
17215 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic', 'generic'),
17216 ('anscr', 'ANSCR (Sound Recordings)', 0, 'generic', 'generic'),
17217 ('z', 'Other/Generic Classification Scheme', 0, 'generic', 'generic')
17222 SetVersion( $DBversion );
17223 print "Upgrade to $DBversion done (Bug 22024 - Add missing splitting rule definitions)\n";
17226 $DBversion = '18.12.00.004';
17227 if( CheckVersion( $DBversion ) ) {
17228 if( !column_exists( 'accountlines', 'branchcode' ) ) {
17229 $dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
17230 $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_branches FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE");
17232 SetVersion( $DBversion );
17233 print "Upgrade to $DBversion done (Bug 19066 - Add branchcode to accountlines)\n";
17236 $DBversion = '18.12.00.005';
17237 if( CheckVersion( $DBversion ) ) {
17239 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
17240 ('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice')
17242 SetVersion( $DBversion );
17243 print "Upgrade to $DBversion done (Bug 22030: Add OverDriveUsername syspref)\n";
17246 $DBversion = '18.12.00.006';
17247 if( CheckVersion( $DBversion ) ) {
17249 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
17250 ('AccountAutoReconcile','0','If enabled, patron balances will get reconciled automatically on each transaction.',NULL,'YesNo');
17252 SetVersion($DBversion);
17253 print "Upgrade to $DBversion done (Bug 21915 - Add a way to automatically reconcile balance for patrons)\n";
17256 $DBversion = '18.12.00.007';
17257 if( CheckVersion( $DBversion ) ) {
17258 if( column_exists( 'issuingrules', 'chargename' ) ) {
17259 $dbh->do( "ALTER TABLE issuingrules DROP chargename" );
17261 SetVersion( $DBversion );
17262 print "Upgrade to $DBversion done (Bug 21753: Drop chargename from issuingrules )\n";
17265 $DBversion = '18.12.00.008';
17266 if( CheckVersion( $DBversion ) ) {
17267 if( !column_exists( 'subscription', 'mana_id' ) ) {
17268 $dbh->do( "ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL" );
17271 if( !column_exists( 'saved_sql', 'mana_id' ) ) {
17272 $dbh->do( "ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL" );
17275 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
17276 ('Mana','2',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice');
17279 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
17280 ('AutoShareWithMana','','','defines datas automatically shared with mana','multiple');
17283 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
17284 ('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea');
17286 SetVersion( $DBversion );
17287 print "Upgrade to $DBversion done (Bug 17047 - Mana knowledge base)\n";
17290 $DBversion = '18.12.00.009';
17291 if( CheckVersion( $DBversion ) ) {
17293 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('FallbackToSMSIfNoEmail', 0, 'Enable|Disable', 'Send messages by SMS if no patron email is defined', 'YesNo');
17295 SetVersion( $DBversion );
17296 print "Upgrade to $DBversion done (Bug 21241 - Add FallbackToSMSIfNoEmail syspref )\n";
17299 $DBversion = '18.12.00.010';
17300 if( CheckVersion( $DBversion ) ) {
17302 INSERT IGNORE INTO systempreferences
17303 ( variable, value, options, explanation, type )
17305 ('RESTPublicAPI','1',NULL,'If enabled, the REST API will expose the /public endpoints.','YesNo')
17308 # Always end with this (adjust the bug info)
17309 SetVersion( $DBversion );
17310 print "Upgrade to $DBversion done (Bug 22061 - Add a /public namespace that can be switched on/off)\n";
17313 $DBversion = '18.12.00.011';
17314 if( CheckVersion( $DBversion ) ) {
17315 if ( column_exists( 'biblio_metadata', 'marcflavour' ) ) {
17317 ALTER TABLE biblio_metadata
17318 CHANGE COLUMN marcflavour `schema` VARCHAR(16)
17321 if ( column_exists( 'deletedbiblio_metadata', 'marcflavour' ) ) {
17323 ALTER TABLE deletedbiblio_metadata
17324 CHANGE COLUMN marcflavour `schema` VARCHAR(16)
17327 SetVersion( $DBversion );
17328 print "Upgrade to $DBversion done (Bug 22155 - biblio_metadata.marcflavour should be renamed 'schema')\n";
17331 $DBversion = '18.12.00.012';
17332 if( CheckVersion( $DBversion ) ) {
17334 INSERT IGNORE INTO systempreferences
17335 (variable, value, options, explanation, type )
17337 ('RESTBasicAuth','0',NULL,'If enabled, Basic authentication is enabled for the REST API.','YesNo')
17339 SetVersion( $DBversion );
17340 print "Upgrade to $DBversion done (Bug 22132 - Add Basic authentication)\n";
17343 $DBversion = '18.12.00.013';
17344 if( CheckVersion( $DBversion ) ) {
17346 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_mana', 'Manage Mana KB content sharing');
17348 SetVersion( $DBversion );
17349 print "Upgrade to $DBversion done (Bug 22198 - Add ghranular permission setting for Mana KB)\n";
17352 $DBversion = '18.12.00.014';
17353 if( CheckVersion( $DBversion ) ) {
17354 unless( foreign_key_exists( 'messages', 'messages_borrowernumber' ) ) {
17356 DELETE m FROM messages m
17357 LEFT JOIN borrowers b ON m.borrowernumber=b.borrowernumber
17358 WHERE b.borrowernumber IS NULL
17361 ALTER TABLE messages
17362 ADD CONSTRAINT messages_borrowernumber
17363 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
17366 SetVersion( $DBversion );
17367 print "Upgrade to $DBversion done (Bug 13515 - Add a FOREIGN KEY constaint on messages.borrowernumber)\n";
17370 $DBversion = '18.12.00.015';
17371 if( CheckVersion( $DBversion ) ) {
17372 $dbh->do( "UPDATE action_logs SET info = REPLACE(info,'cardnumber_replaced','cardnumber'), timestamp = timestamp WHERE module='MEMBERS' AND action='MODIFY'" );
17373 $dbh->do( "UPDATE action_logs SET info = REPLACE(info,'previous_cardnumber','before'), timestamp = timestamp WHERE module='MEMBERS' AND action='MODIFY'" );
17374 $dbh->do( "UPDATE action_logs SET info = REPLACE(info,'new_cardnumber','after'), timestamp = timestamp WHERE module='MEMBERS' AND action='MODIFY'" );
17376 SetVersion( $DBversion );
17377 print "Upgrade to $DBversion done (Bug 3820 - Update patron modification logs)\n";
17380 $DBversion = '18.12.00.016';
17381 if( CheckVersion( $DBversion ) ) {
17383 if ( !column_exists( 'illrequests', 'status_alias' ) ) {
17384 # Fresh upgrade, just add the column and constraint
17385 $dbh->do( "ALTER TABLE illrequests ADD COLUMN status_alias varchar(80) DEFAULT NULL AFTER status" );
17387 # Migrate all existing foreign keys from referencing authorised_values.id
17388 # to referencing authorised_values.authorised_value
17389 # First remove the foreign key constraint and index
17390 if ( foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
17391 $dbh->do( "ALTER TABLE illrequests DROP FOREIGN KEY illrequests_safk");
17393 if ( index_exists( 'illrequests', 'illrequests_safk' ) ) {
17394 $dbh->do( "DROP INDEX illrequests_safk ON illrequests" );
17396 # Now change the illrequests.status_alias column definition from int to varchar
17397 $dbh->do( "ALTER TABLE illrequests MODIFY COLUMN status_alias varchar(80)" );
17398 # Now replace all references to authorised_values.id with their
17399 # corresponding authorised_values.authorised_value
17400 my $sth = $dbh->prepare( "SELECT illrequest_id, status_alias FROM illrequests WHERE status_alias IS NOT NULL" );
17402 while (my @row = $sth->fetchrow_array()) {
17403 my $r_id = $row[0];
17404 my $av_id = $row[1];
17405 # Get the authorised value's authorised_value value
17406 my ($av_val) = $dbh->selectrow_array( "SELECT authorised_value FROM authorised_values WHERE id = ?", {}, $av_id );
17407 # Now update illrequests.status_alias
17409 $dbh->do( "UPDATE illrequests SET status_alias = ? WHERE illrequest_id = ?", {}, ($av_val, $r_id) );
17413 if ( !foreign_key_exists( 'illrequests', 'illrequests_safk' ) ) {
17414 $dbh->do( "ALTER TABLE illrequests ADD CONSTRAINT illrequests_safk FOREIGN KEY (status_alias) REFERENCES authorised_values(authorised_value) ON UPDATE CASCADE ON DELETE SET NULL" );
17416 $dbh->do( "INSERT IGNORE INTO authorised_value_categories SET category_name = 'ILLSTATUS'");
17418 SetVersion( $DBversion );
17419 print "Upgrade to $DBversion done (Bug 20581 - Allow manual selection of custom ILL request statuses)\n";
17422 $DBversion = '18.12.00.017';
17423 if( CheckVersion( $DBversion ) ) {
17425 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'fine_increase' ), ( 'fine_decrease' );
17428 UPDATE account_offsets SET type = 'fine_increase' WHERE type = 'Fine Update' AND amount > 0;
17431 UPDATE account_offsets SET type = 'fine_decrease' WHERE type = 'Fine Update' AND amount < 0;
17435 DELETE FROM account_offset_types WHERE type = 'Fine Update';
17437 SetVersion( $DBversion );
17438 print "Upgrade to $DBversion done (Bug 21747 - Update account_offset_types to include 'fine_increase' and 'fine_decrease')\n";
17441 $DBversion = '18.12.00.018';
17442 if( CheckVersion( $DBversion ) ) {
17443 $dbh->do( "UPDATE `search_field` SET `name` = 'date-of-publication', `label` = 'date-of-publication' WHERE `name` = 'pubdate'" );
17444 $dbh->do( "UPDATE `search_field` SET `name` = 'title-series', `label` = 'title-series' WHERE `name` = 'se'" );
17445 $dbh->do( "UPDATE `search_field` SET `name` = 'identifier-standard', `label` = 'identifier-standard' WHERE `name` = 'identifier-standard'" );
17446 $dbh->do( "UPDATE `search_field` SET `name` = 'author', `label` = 'author' WHERE `name` = 'author'" );
17447 $dbh->do( "UPDATE `search_field` SET `name` = 'control-number', `label` = 'control-number' WHERE `name` = 'control-number'" );
17448 $dbh->do( "UPDATE `search_field` SET `name` = 'place-of-publication', `label` = 'place-of-publication' WHERE `name` = 'place'" );
17449 $dbh->do( "UPDATE `search_field` SET `name` = 'date-of-acquisition', `label` = 'date-of-acquisition' WHERE `name` = 'acqdate'" );
17450 $dbh->do( "UPDATE `search_field` SET `name` = 'isbn', `label` = 'isbn' WHERE `name` = 'isbn'" );
17451 $dbh->do( "UPDATE `search_field` SET `name` = 'koha-auth-number', `label` = 'koha-auth-number' WHERE `name` = 'an'" );
17452 $dbh->do( "UPDATE `search_field` SET `name` = 'subject', `label` = 'subject' WHERE `name` = 'subject'" );
17453 $dbh->do( "UPDATE `search_field` SET `name` = 'publisher', `label` = 'publisher' WHERE `name` = 'publisher'" );
17454 $dbh->do( "UPDATE `search_field` SET `name` = 'record-source', `label` = 'record-source' WHERE `name` = 'record-source'" );
17455 $dbh->do( "UPDATE `search_field` SET `name` = 'title', `label` = 'title' WHERE `name` = 'title'" );
17456 $dbh->do( "UPDATE `search_field` SET `name` = 'local-classification', `label` = 'local-classification' WHERE `name` = 'local-classification'" );
17457 $dbh->do( "UPDATE `search_field` SET `name` = 'bib-level', `label` = 'bib-level' WHERE `name` = 'bib-level'" );
17458 $dbh->do( "UPDATE `search_field` SET `name` = 'microform-generation', `label` = 'microform-generation' WHERE `name` = 'microform-generation'" );
17459 $dbh->do( "UPDATE `search_field` SET `name` = 'material-type', `label` = 'material-type' WHERE `name` = 'material-type'" );
17460 $dbh->do( "UPDATE `search_field` SET `name` = 'bgf-number', `label` = 'bgf-number' WHERE `name` = 'bgf-number'" );
17461 $dbh->do( "UPDATE `search_field` SET `name` = 'number-db', `label` = 'number-db' WHERE `name` = 'number-db'" );
17462 $dbh->do( "UPDATE `search_field` SET `name` = 'number-natl-biblio', `label` = 'number-natl-biblio' WHERE `name` = 'number-natl-biblio'" );
17463 $dbh->do( "UPDATE `search_field` SET `name` = 'number-legal-deposit', `label` = 'number-legal-deposit' WHERE `name` = 'number-legal-deposit'" );
17464 $dbh->do( "UPDATE `search_field` SET `name` = 'issn', `label` = 'issn' WHERE `name` = 'issn'" );
17465 $dbh->do( "UPDATE `search_field` SET `name` = 'local-number', `label` = 'local-number' WHERE `name` = 'local-number'" );
17466 $dbh->do( "UPDATE `search_field` SET `name` = 'suppress', `label` = 'supress' WHERE `name` = 'suppress'" );
17467 $dbh->do( "UPDATE `search_field` SET `name` = 'bnb-card-number', `label` = 'bnb-card-number' WHERE `name` = 'bnb-card-number'" );
17468 $dbh->do( "UPDATE `search_field` SET `name` = 'date/time-last-modified', `label` = 'date/time-last-modified' WHERE `name` = 'date-time-last-modified'" );
17469 $dbh->do( "DELETE FROM `search_field` WHERE `name` = 'lc-cardnumber'" );
17470 $dbh->do( "DELETE FROM `search_marc_map` WHERE `id` NOT IN(SELECT `search_marc_map_id` FROM `search_marc_to_field`)" );
17471 SetVersion( $DBversion );
17472 print "Upgrade to $DBversion done (Bug 19575 - Use canonical field names and resolve aliased fields)\n";
17475 $DBversion = '18.12.00.019';
17476 if( CheckVersion( $DBversion ) ) {
17478 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Reserve Fee' );
17481 SetVersion( $DBversion );
17482 print "Upgrade to $DBversion done (Bug 21728 - Add 'Reserve Fee' to the account_offset_types table if missing)\n";
17485 $DBversion = '18.12.00.020';
17486 if( CheckVersion( $DBversion ) ) {
17487 if ( TableExists( 'branch_borrower_circ_rules' ) ) {
17488 if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) {
17490 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17491 SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
17492 FROM branch_borrower_circ_rules
17495 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17496 SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
17497 FROM branch_borrower_circ_rules
17499 $dbh->do("DROP TABLE branch_borrower_circ_rules");
17503 if ( TableExists( 'default_borrower_circ_rules' ) ) {
17504 if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) {
17506 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17507 SELECT categorycode, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
17508 FROM default_borrower_circ_rules
17511 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17512 SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
17513 FROM default_borrower_circ_rules
17515 $dbh->do("DROP TABLE default_borrower_circ_rules");
17519 if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) {
17521 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17522 SELECT NULL, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
17523 FROM default_circ_rules
17526 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17527 SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
17528 FROM default_circ_rules
17530 $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
17533 if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) {
17535 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17536 SELECT NULL, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' )
17537 FROM default_branch_circ_rules
17540 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17541 SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' )
17542 FROM default_branch_circ_rules
17544 $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
17547 if ( column_exists( 'issuingrules', 'maxissueqty' ) ) {
17548 # Cleaning invalid rules before, to avoid FK contraints to fail
17550 DELETE FROM issuingrules WHERE categorycode != '*' AND categorycode NOT IN (SELECT categorycode FROM categories);
17553 DELETE FROM issuingrules WHERE branchcode != '*' AND branchcode NOT IN (SELECT branchcode FROM branches);
17556 DELETE FROM issuingrules WHERE itemtype != '*' AND itemtype NOT IN (SELECT itemtype FROM itemtypes);
17560 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17561 SELECT IF(categorycode='*', NULL, categorycode),
17562 IF(branchcode='*', NULL, branchcode),
17563 IF(itemtype='*', NULL, itemtype),
17565 COALESCE( maxissueqty, '' )
17569 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
17570 SELECT IF(categorycode='*', NULL, categorycode),
17571 IF(branchcode='*', NULL, branchcode),
17572 IF(itemtype='*', NULL, itemtype),
17573 'maxonsiteissueqty',
17574 COALESCE( maxonsiteissueqty, '' )
17577 $dbh->do("ALTER TABLE issuingrules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty");
17580 SetVersion( $DBversion );
17581 print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n";
17584 $DBversion = '18.12.00.021';
17585 if ( CheckVersion($DBversion) ) {
17587 if ( !column_exists( 'itemtypes', 'rentalcharge_daily' ) ) {
17588 $dbh->do("ALTER TABLE `itemtypes` ADD COLUMN `rentalcharge_daily` decimal(28,6) default NULL AFTER `rentalcharge`");
17591 if ( !column_exists( 'itemtypes', 'rentalcharge_hourly' ) ) {
17592 $dbh->do("ALTER TABLE `itemtypes` ADD COLUMN `rentalcharge_hourly` decimal(28,6) default NULL AFTER `rentalcharge_daily`");
17595 if ( column_exists( 'itemtypes', 'rental_charge_daily' ) ) {
17596 $dbh->do("UPDATE `itemtypes` SET `rentalcharge_daily` = `rental_charge_daily`");
17597 $dbh->do("ALTER TABLE `itemtypes` DROP COLUMN `rental_charge_daily`");
17600 SetVersion($DBversion);
17601 print "Upgrade to $DBversion done (Bug 20912 - Support granular rental charges)\n";
17604 $DBversion = '18.12.00.022';
17605 if( CheckVersion( $DBversion ) ) {
17607 INSERT IGNORE INTO permissions (module_bit,code,description)
17609 (3,'manage_additional_fields','Add, edit, or delete additional custom fields for baskets or subscriptions (also requires order_manage or edit_subscription permissions)')
17612 INSERT INTO user_permissions (borrowernumber, module_bit, code)
17613 SELECT borrowernumber, 3, 'manage_additional_fields' FROM borrowers WHERE borrowernumber IN (SELECT DISTINCT borrowernumber FROM user_permissions WHERE code = 'order_manage' OR code = 'edit_subscription');
17616 INSERT INTO user_permissions (borrowernumber, module_bit, code)
17617 SELECT borrowernumber, 3, 'manage_additional_fields' FROM borrowers WHERE borrowernumber IN (SELECT borrowernumber FROM borrowers WHERE MOD(flags DIV POWER(2,11),2)=1 OR MOD(flags DIV POWER(2,15),2) =1);
17619 SetVersion( $DBversion );
17620 print "Upgrade to $DBversion done (Bug 15774 - Add permission for managing additional fields)\n";
17623 $DBversion = '18.12.00.023';
17624 if( CheckVersion( $DBversion ) ) {
17626 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
17627 VALUES ('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple');
17630 # Always end with this (adjust the bug info)
17631 SetVersion( $DBversion );
17632 print "Upgrade to $DBversion done (Bug 20639 - Add ILLOpacbackends syspref)\n";
17635 $DBversion = '18.12.00.024';
17636 if ( CheckVersion($DBversion) ) {
17638 # Fixup any pre-existing bad suggestedby, manageddate, accepteddate dates
17640 local $dbh->{PrintError} = 0;
17642 "UPDATE suggestions SET suggesteddate = '1970-01-01' WHERE suggesteddate = '0000-00-00';"
17645 "UPDATE suggestions SET manageddate = '1970-01-01' WHERE manageddate = '0000-00-00';"
17648 "UPDATE suggestions SET accepteddate = '1970-01-01' WHERE accepteddate = '0000-00-00';"
17652 # Add constraint for suggestedby
17653 unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_suggestedby' ) )
17656 "ALTER TABLE suggestions CHANGE COLUMN suggestedby suggestedby INT(11) NULL DEFAULT NULL;"
17659 "UPDATE suggestions LEFT JOIN borrowers ON (suggestions.suggestedby = borrowers.borrowernumber) SET suggestedby = null WHERE borrowernumber IS null"
17662 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_suggestedby` FOREIGN KEY (`suggestedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
17666 # Add constraint for managedby
17667 unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_managedby' ) )
17670 "UPDATE suggestions LEFT JOIN borrowers ON (suggestions.managedby = borrowers.borrowernumber) SET managedby = null WHERE borrowernumber IS NULL"
17673 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
17677 # Add constraint for acceptedby
17679 foreign_key_exists( 'suggestions', 'suggestions_ibfk_acceptedby' ) )
17682 "UPDATE suggestions LEFT JOIN borrowers ON (suggestions.acceptedby = borrowers.borrowernumber) SET acceptedby = null WHERE borrowernumber IS NULL"
17685 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
17689 # Add constraint for rejectedby
17691 foreign_key_exists( 'suggestions', 'suggestions_ibfk_rejectedby' ) )
17694 "UPDATE suggestions LEFT JOIN borrowers ON (suggestions.rejectedby = borrowers.borrowernumber) SET rejectedby = null WHERE borrowernumber IS null"
17697 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
17701 # Add constraint for biblionumber
17703 foreign_key_exists( 'suggestions', 'suggestions_ibfk_biblionumber' ) )
17706 "UPDATE suggestions s LEFT JOIN biblio b ON (s.biblionumber = b.biblionumber) SET s.biblionumber = null WHERE b.biblionumber IS null"
17709 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE"
17713 # Add constraint for branchcode
17715 foreign_key_exists( 'suggestions', 'suggestions_ibfk_branchcode' ) )
17718 "UPDATE suggestions s LEFT JOIN branches b ON (s.branchcode = b.branchcode) SET s.branchcode = null WHERE b.branchcode IS null"
17721 "ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE"
17725 SetVersion($DBversion);
17727 "Upgrade to $DBversion done (Bug 22368 - Add missing constraints to suggestions)\n";
17730 $DBversion = '18.12.00.025';
17731 if( CheckVersion( $DBversion ) ) {
17733 $dbh->do('SET FOREIGN_KEY_CHECKS=0');
17735 # Change columns accordingly
17737 ALTER TABLE tags_index
17738 MODIFY COLUMN term VARCHAR(191) COLLATE utf8mb4_bin NOT NULL;
17742 ALTER TABLE tags_approval
17743 MODIFY COLUMN term VARCHAR(191) COLLATE utf8mb4_bin NOT NULL;
17747 ALTER TABLE tags_all
17748 MODIFY COLUMN term VARCHAR(191) COLLATE utf8mb4_bin NOT NULL;
17751 $dbh->do('SET FOREIGN_KEY_CHECKS=1');
17753 SetVersion( $DBversion );
17754 print "Upgrade to $DBversion done (Bug 21846 - Using emoji as tags has broken weights)\n";
17755 my $maintenance_script = C4::Context->config("intranetdir") . "/misc/maintenance/fix_tags_weight.pl";
17756 print "WARNING: (Bug 21846) You need to manually run $maintenance_script to fix possible issues with tags.\n";
17759 $DBversion = '18.12.00.026';
17760 if( CheckVersion( $DBversion ) ) {
17761 $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, explanation, type) VALUES ('IllLog', 0, 'If ON, log information about ILL requests', 'YesNo')" );
17763 SetVersion( $DBversion );
17764 print "Upgrade to $DBversion done (Bug 20750 - Allow timestamped auditing of ILL request events)\n";
17767 $DBversion = '18.12.00.027';
17768 if( CheckVersion( $DBversion ) ) {
17770 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
17771 ('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo');
17773 SetVersion( $DBversion );
17774 print "Upgrade to $DBversion done (Bug 18837: Add ILLModuleUnmediated Syspref)\n";
17777 $DBversion = '18.12.00.028';
17778 if( CheckVersion( $DBversion ) ) {
17780 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Account Fee' );
17784 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Hold Expired' );
17787 SetVersion( $DBversion );
17788 print "Upgrade to $DBversion done (Bug 21756 - Add 'Account Fee' and 'Hold Expired' to the account_offset_types table if missing)\n";
17791 $DBversion = '18.12.00.029';
17792 if( CheckVersion( $DBversion ) ) {
17793 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPriceRounding',NULL,'Local preference for rounding orders before calculations to ensure correct calculations','|nearest_cent','Choice')" );
17795 SetVersion( $DBversion );
17796 print "Upgrade to $DBversion done (Bug 18736 - Add syspref to control order rounding)\n";
17799 $DBversion = '18.12.00.030';
17800 if( CheckVersion( $DBversion ) ) {
17801 if( column_exists( 'accountlines', 'accountno' ) ) {
17802 $dbh->do( "ALTER TABLE accountlines DROP COLUMN accountno" );
17804 if( column_exists( 'statistics', 'proccode' ) ) {
17805 $dbh->do( "ALTER TABLE statistics DROP COLUMN proccode" );
17807 SetVersion( $DBversion );
17808 print "Upgrade to $DBversion done (Bug 21683 - Remove accountlines.accountno and statistics.proccode fields)\n";
17811 $DBversion = '18.12.00.031';
17812 if( CheckVersion( $DBversion ) ) {
17814 # Add constraint for manager_id
17815 unless( foreign_key_exists( 'accountlines', 'accountlines_ibfk_borrowers_2' ) ) {
17816 $dbh->do("ALTER TABLE accountlines CHANGE COLUMN manager_id manager_id INT(11) NULL DEFAULT NULL");
17817 $dbh->do("UPDATE accountlines a LEFT JOIN borrowers b ON ( a.manager_id = b.borrowernumber) SET a.manager_id = NULL WHERE b.borrowernumber IS NULL");
17818 $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE");
17821 # Rename accountlines_ibfk_2 to accountlines_ibfk_items
17822 if ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_2' ) ) {
17823 $dbh->do("ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_2");
17825 unless ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_items' ) ) {
17826 $dbh->do("ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE");
17829 SetVersion( $DBversion );
17830 print "Upgrade to $DBversion done (Bug 22008 - Add missing constraints for accountlines.manager_id)\n";
17833 $DBversion = '18.12.00.032';
17834 if( CheckVersion( $DBversion ) ) {
17835 if( !column_exists( 'search_field', 'facet_order' ) ) {
17836 $dbh->do("ALTER TABLE search_field ADD COLUMN facet_order TINYINT(4) DEFAULT NULL AFTER weight");
17838 $dbh->do("UPDATE search_field SET facet_order=1 WHERE name='author'");
17839 $dbh->do("UPDATE search_field SET facet_order=2 WHERE name='itype'");
17840 $dbh->do("UPDATE search_field SET facet_order=3 WHERE name='location'");
17841 $dbh->do("UPDATE search_field SET facet_order=4 WHERE name='su-geo'");
17842 $dbh->do("UPDATE search_field SET facet_order=5 WHERE name='title-series'");
17843 $dbh->do("UPDATE search_field SET facet_order=6 WHERE name='subject'");
17844 $dbh->do("UPDATE search_field SET facet_order=7 WHERE name='ccode'");
17845 $dbh->do("UPDATE search_field SET facet_order=8 WHERE name='holdingbranch'");
17846 $dbh->do("UPDATE search_field SET facet_order=9 WHERE name='homebranch'");
17847 SetVersion( $DBversion );
17848 print "Upgrade to $DBversion done (Bug 18235 - Elastic search - make facets configurable)\n";
17851 $DBversion = '18.12.00.033';
17852 if( CheckVersion( $DBversion ) ) {
17853 $dbh->do( "UPDATE search_field SET facet_order=10 WHERE name='ln'" );
17854 SetVersion( $DBversion );
17855 print "Upgrade to $DBversion done (Bug 18213 - Add language facets to Elasticsearch)\n";
17858 $DBversion = '18.12.00.034';
17859 if( CheckVersion( $DBversion ) ) {
17861 if ( column_exists( 'accountlines', 'lastincrement' ) ) {
17862 $dbh->do("ALTER TABLE `accountlines` DROP COLUMN `lastincrement`");
17865 SetVersion( $DBversion );
17866 print "Upgrade to $DBversion done (Bug 22516 - Drop deprecated accountlines.lastincrement field)\n";
17869 $DBversion = '18.12.00.035';
17870 if( CheckVersion( $DBversion ) ) {
17871 $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
17872 VALUES ('MaxItemsToDisplayForBatchMod','1000',NULL,'Display up to a given number of items in a single item modification batch.','Integer')"
17874 SetVersion( $DBversion );
17875 print "Upgrade to $DBversion done (Bug 19722 - Add a MaxItemsToDisplayForBatchMod preference)\n";
17878 $DBversion = '18.12.00.036';
17879 if ( CheckVersion($DBversion) ) {
17881 my $rows = $dbh->do(
17883 UPDATE `accountlines`
17885 `accounttype` = 'FU'
17887 `accounttype` = 'O'
17891 SetVersion($DBversion);
17892 printf "Upgrade to $DBversion done (Bug 22518 - Fix accounttype 'O' to 'FU' - %d updated)\n", $rows;
17895 $DBversion = '18.12.00.037';
17896 if( CheckVersion( $DBversion ) ) {
17898 $dbh->do( "UPDATE issues SET renewals = 0 WHERE renewals IS NULL" );
17899 $dbh->do( "UPDATE old_issues SET renewals = 0 WHERE renewals IS NULL" );
17901 $dbh->do( "ALTER TABLE issues MODIFY COLUMN renewals tinyint(4) NOT NULL default 0");
17902 $dbh->do( "ALTER TABLE old_issues MODIFY COLUMN renewals tinyint(4) NOT NULL default 0");
17904 # Always end with this (adjust the bug info)
17905 SetVersion( $DBversion );
17906 print "Upgrade to $DBversion done (Bug 22607 - Set default value of issues.renewals to 0)\n";
17909 $DBversion = '18.12.00.038';
17910 if ( CheckVersion($DBversion) ) {
17912 if ( !column_exists( 'accountlines', 'status' ) ) {
17915 ALTER TABLE `accountlines`
17917 `status` varchar(16) DEFAULT NULL
17924 SetVersion($DBversion);
17925 print "Upgrade to $DBversion done (Bug 22512 - Add status to accountlines)\n";
17928 $DBversion = '18.12.00.039';
17929 if ( CheckVersion($DBversion) ) {
17931 if ( !column_exists( 'accountlines', 'interface' ) ) {
17934 ALTER TABLE `accountlines`
17936 `interface` varchar(16)
17949 borrowernumber = manager_id;
17960 branchcode IS NULL;
17967 interface = 'intranet'
17973 ALTER TABLE `accountlines`
17974 MODIFY COLUMN `interface` varchar(16) NOT NULL;
17977 SetVersion($DBversion);
17978 print "Upgrade to $DBversion done (Bug 22600 - Add interface to accountlines)\n";
17981 $DBversion = '18.12.00.040';
17982 if( CheckVersion( $DBversion ) ) {
17983 $dbh->do("UPDATE accountlines SET description = REPLACE(description, 'Reserve Charge - ', '') WHERE description LIKE 'Reserve Charge - %'");
17984 SetVersion( $DBversion );
17985 print "Upgrade to $DBversion done (Bug 12166 - Remove 'Reserve Charge' text from accountlines description)\n";
17988 $DBversion = '18.12.00.041';
17989 if( CheckVersion( $DBversion ) ) {
17990 my $table_sth = $dbh->prepare('SHOW CREATE TABLE `search_marc_map`');
17991 $table_sth->execute();
17992 my @table = $table_sth->fetchrow_array();
17993 unless ( $table[1] =~ /`marc_field`.*COLLATE utf8mb4_bin/ ) { #catches utf8mb4 collated tables
17994 $dbh->do("ALTER TABLE `search_marc_map` MODIFY `marc_field` VARCHAR(255) NOT NULL COLLATE utf8mb4_bin COMMENT 'the MARC specifier for this field'");
17997 # Always end with this (adjust the bug info)
17998 SetVersion( $DBversion );
17999 print "Upgrade to $DBversion done (Bug 19670 - Change collation of marc_field to allow mixed case search field mappings)\n";
18002 $DBversion = '18.12.00.042';
18003 if( CheckVersion( $DBversion ) ) {
18004 $dbh->do( "UPDATE systempreferences SET value = 'default' WHERE variable = 'XSLTDetailsDisplay' AND value = ''" );
18005 SetVersion( $DBversion );
18006 print "Upgrade to $DBversion done (Bug 29891 - Remove non-XSLT detail view in the staff client)\n";
18009 $DBversion = '18.12.00.043';
18010 if ( CheckVersion($DBversion) ) {
18011 $dbh->do("UPDATE accountlines SET description = REPLACE(description, 'Lost Item ', '') WHERE description LIKE 'Lost Item %'");
18012 SetVersion($DBversion);
18013 print "Upgrade to $DBversion done (Bug 21953 - Remove 'Lost Item' text from accountlines description)\n";
18016 $DBversion = '18.12.00.044';
18017 if( CheckVersion( $DBversion ) ) {
18019 if ( !column_exists( 'categories', 'reset_password' ) ) {
18021 ALTER TABLE categories
18022 ADD COLUMN reset_password TINYINT(1) NULL DEFAULT NULL
18023 AFTER checkprevcheckout
18027 SetVersion( $DBversion );
18028 print "Upgrade to $DBversion done (Bug 21890 - Patron password reset by category)\n";
18031 $DBversion = '18.12.00.045';
18032 if( CheckVersion( $DBversion ) ) {
18034 if ( !column_exists( 'categories', 'change_password' ) ) {
18036 ALTER TABLE categories
18037 ADD COLUMN change_password TINYINT(1) NULL DEFAULT NULL
18038 AFTER reset_password
18042 SetVersion( $DBversion );
18043 print "Upgrade to $DBversion done (Bug 10796 - Patron password change by category)\n";
18046 $DBversion = '18.12.00.046';
18047 if( CheckVersion( $DBversion ) ) {
18048 $dbh->do( "UPDATE systempreferences SET value = 'default' WHERE variable = 'XSLTResultsDisplay' AND value = ''" );
18049 SetVersion( $DBversion );
18050 print "Upgrade to $DBversion done (Bug 22695 - Remove non-XSLT search results view from the staff client)\n";
18053 $DBversion = '18.12.00.047';
18054 if( CheckVersion( $DBversion ) ) {
18056 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('LibrisKey', '', 'This key must be obtained at http://api.libris.kb.se/. It is unique for the IP of the server.', NULL, 'Free');
18059 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('LibrisURL', 'http://api.libris.kb.se/bibspell/', 'This is the base URL for the Libris spellchecking API.',NULL,'Free');
18061 SetVersion( $DBversion );
18062 print "Upgrade to $DBversion done (Bug 14557: Add Libris spellchecking system preferences)\n";
18065 $DBversion = '18.12.00.048';
18066 if( CheckVersion( $DBversion ) ) {
18068 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
18069 VALUES ('NoRenewalBeforePrecision', 'exact_time', 'Calculate "No renewal before" based on date or exact time. Only relevant for loans calculated in days, hourly loans are not affected.', 'date|exact_time', 'Choice');
18071 $dbh->do("UPDATE systempreferences SET value='exact_time' WHERE variable='NoRenewalBeforePrecision' AND value IS NULL;" );
18072 SetVersion( $DBversion );
18073 print "Upgrade to $DBversion done (Bug 22044 - Set a default value for NoRenewalBeforePrecision)\n";
18076 $DBversion = '18.12.00.049';
18077 if( CheckVersion( $DBversion ) ) {
18080 ALTER TABLE borrowers
18081 ADD COLUMN flgAnonymized tinyint DEFAULT 0
18082 AFTER overdrive_auth_token
18083 }) if !column_exists('borrowers', 'flgAnonymized');
18086 ALTER TABLE deletedborrowers
18087 ADD COLUMN flgAnonymized tinyint DEFAULT 0
18088 AFTER overdrive_auth_token
18089 }) if !column_exists('deletedborrowers', 'flgAnonymized');
18091 SetVersion( $DBversion );
18092 print "Upgrade to $DBversion done (Bug 21336 - Add field flgAnonymized)\n";
18095 $DBversion = '18.12.00.050';
18096 if( CheckVersion( $DBversion ) ) {
18098 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
18100 ('UnsubscribeReflectionDelay','',NULL,'Delay for locking unsubscribers', 'Integer'),
18101 ('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
18102 ('PatronRemovalDelay','',NULL,'Delay for removing anonymized patrons', 'Integer')
18104 SetVersion( $DBversion );
18105 print "Upgrade to $DBversion done (Bug 21336 - Add preferences)\n";
18108 $DBversion = '18.12.00.051';
18109 if( CheckVersion( $DBversion ) ) {
18110 my $failed_attempts = C4::Context->preference('FailedLoginAttempts');
18111 $dbh->do( "UPDATE borrowers SET login_attempts = ? WHERE login_attempts > ?", undef, $failed_attempts, $failed_attempts ) if $failed_attempts && $failed_attempts > 0;
18112 SetVersion( $DBversion );
18113 print "Upgrade to $DBversion done (Bug 21336 - Reset login_attempts)\n";
18116 $DBversion = '18.12.00.052';
18117 if( CheckVersion( $DBversion ) ) {
18119 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
18120 ('OpacMoreSearches', '', NULL, 'Add additional elements to the OPAC more searches bar', 'Textarea')
18123 SetVersion( $DBversion );
18124 print "Upgrade to $DBversion done (Bug 22311 - Add a SysPref to allow adding content to the #moresearches div in the opac)\n";
18127 $DBversion = '18.12.00.053';
18128 if( CheckVersion( $DBversion ) ) {
18130 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES
18131 ('AutoReturnCheckedOutItems', '0', '', 'If disabled, librarian must confirm return of checked out item when checking out to another.', 'YesNo');
18134 SetVersion( $DBversion );
18135 print "Upgrade to $DBversion done (Bug 17171 - Add a syspref to allow currently issued items to be issued to a new patron without staff confirmation)\n";
18138 $DBversion = '18.12.00.054';
18139 if( CheckVersion( $DBversion ) ) {
18141 INSERT IGNORE permissions (module_bit, code, description)
18143 (9,'advanced_editor','Use the advanced cataloging editor')
18145 if( C4::Context->preference('EnableAdvancedCatalogingEditor') ){
18147 INSERT INTO user_permissions (borrowernumber, module_bit, code)
18148 SELECT borrowernumber, 9, 'advanced_editor' FROM borrowers WHERE borrowernumber IN (SELECT DISTINCT borrowernumber FROM user_permissions WHERE code = 'edit_catalogue');
18151 SetVersion( $DBversion );
18152 print "Upgrade to $DBversion done (Bug 20128: Add permission for Advanced Cataloging Editor)\n";
18155 $DBversion = '18.12.00.055';
18156 if ( CheckVersion($DBversion) ) {
18160 `account_offset_types`
18169 `account_offset_types`
18171 type = 'OVERDUE_INCREASE'
18173 type = 'fine_increase';
18178 `account_offset_types`
18180 type = 'OVERDUE_DECREASE'
18182 type = 'fine_decrease';
18185 if ( column_exists( 'accountlines', 'accounttype' ) ) {
18188 ALTER TABLE `accountlines`
18189 CHANGE COLUMN `accounttype`
18190 `accounttype` varchar(16) DEFAULT NULL;
18199 accounttype = 'OVERDUE',
18200 status = 'UNRETURNED'
18202 accounttype = 'FU';
18209 accounttype = 'OVERDUE',
18210 status = 'FORGIVEN'
18212 accounttype = 'FFOR';
18219 accounttype = 'OVERDUE',
18220 status = 'RETURNED'
18224 SetVersion($DBversion);
18225 print "Upgrade to $DBversion done (Bug 22521 - Update accountlines.accounttype to varchar(16), and map new statuses)\n";
18228 $DBversion = '18.12.00.056';
18229 if( CheckVersion( $DBversion ) ) {
18230 $dbh->do( "UPDATE systempreferences SET explanation = 'This syspref allows to define custom rules for hiding specific items at the OPAC. See http://wiki.koha-community.org/wiki/OpacHiddenItems for more information.' WHERE variable = 'OpacHiddenItems'");
18231 SetVersion( $DBversion );
18232 print "Upgrade to $DBversion done (Bug 8701 - Update OpacHiddenItems system preference description)\n";
18235 $DBversion = '18.12.00.057';
18236 if( CheckVersion( $DBversion ) ) {
18237 if( column_exists('statistics', 'associatedborrower') ) {
18238 $dbh->do(q{ ALTER TABLE statistics DROP COLUMN associatedborrower });
18240 if( column_exists('statistics', 'usercode') ) {
18241 $dbh->do(q{ ALTER TABLE statistics DROP COLUMN usercode });
18244 SetVersion($DBversion);
18245 print "Upgrade to $DBversion done (Bug 13795 - Delete unused fields from statistics table)\n";
18248 $DBversion = '18.12.00.058';
18249 if( CheckVersion( $DBversion ) ) {
18250 my $opaclang = C4::Context->preference("opaclanguages");
18252 push @langs, split ( '\,', $opaclang );
18253 # Get any existing value from the OpacNavRight system preference
18254 my ($OpacNavRight) = $dbh->selectrow_array( q|
18255 SELECT value FROM systempreferences WHERE variable='OpacNavRight';
18257 if( $OpacNavRight ){
18258 # If there is a value in the OpacNavRight preference, insert it into opac_news
18259 $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacNavRight_$langs[0]", $OpacNavRight);
18261 # Remove the OpacNavRight system preference
18262 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacNavRight'");
18263 SetVersion ($DBversion);
18264 print "Upgrade to $DBversion done (Bug 22318: Move contents of OpacNavRight preference to Koha news system)\n";
18267 $DBversion = '18.12.00.059';
18268 if( CheckVersion( $DBversion ) ) {
18269 if( column_exists( 'import_records', 'z3950random' ) ) {
18270 $dbh->do( "ALTER TABLE import_records DROP COLUMN z3950random" );
18273 # Always end with this (adjust the bug info)
18274 SetVersion( $DBversion );
18275 print "Upgrade to $DBversion done (Bug 22532 - Remove import_records z3950random column)\n";
18278 $DBversion = '18.12.00.060';
18279 if ( CheckVersion($DBversion) ) {
18281 my $rows = $dbh->do(
18283 UPDATE `accountlines`
18285 `accounttype` = 'L',
18286 `status` = 'REPLACED'
18288 `accounttype` = 'Rep'
18292 SetVersion($DBversion);
18293 printf "Upgrade to $DBversion done (Bug 22564 - Fix accounttype 'Rep' - %d updated)\n", $rows;
18296 $DBversion = '18.12.00.061';
18297 if( CheckVersion( $DBversion ) ) {
18299 if ( column_exists( 'borrowers', 'flgAnonymized' ) ) {
18301 UPDATE borrowers SET flgAnonymized = 0 WHERE flgAnonymized IS NULL
18304 ALTER TABLE borrowers
18305 CHANGE `flgAnonymized` `anonymized` TINYINT(1) NOT NULL DEFAULT 0
18309 if ( column_exists( 'deletedborrowers', 'flgAnonymized' ) ) {
18311 UPDATE deletedborrowers SET flgAnonymized = 0 WHERE flgAnonymized IS NULL
18314 ALTER TABLE deletedborrowers
18315 CHANGE `flgAnonymized` `anonymized` TINYINT(1) NOT NULL DEFAULT 0
18319 SetVersion( $DBversion );
18320 print "Upgrade to $DBversion done (Bug 21336 - (follow-up) Rename flgAnonymized column)\n";
18323 $DBversion = '18.12.00.062';
18324 if( CheckVersion( $DBversion ) ) {
18326 UPDATE search_marc_map SET marc_field='007_/0'
18327 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='007_/1' AND id IN
18328 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18329 (SELECT id FROM search_field WHERE label='ff7-00')
18334 UPDATE search_marc_map SET marc_field='007_/1'
18335 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='007_/2' AND id IN
18336 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18337 (SELECT id FROM search_field WHERE label='ff7-01')
18342 UPDATE search_marc_map SET marc_field='007_/2'
18343 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='007_/3' AND id IN
18344 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18345 (SELECT id FROM search_field WHERE label='ff7-02')
18349 # N.B. ff7-01-02 really is 00-01!
18351 UPDATE search_marc_map SET marc_field='007_/0-1'
18352 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='007_/1-2' AND id IN
18353 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18354 (SELECT id FROM search_field WHERE label='ff7-01-02')
18359 UPDATE search_marc_map SET marc_field='008_/0-5'
18360 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='008_/1-5' AND id IN
18361 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18362 (SELECT id FROM search_field WHERE label='date-entered-on-file')
18367 UPDATE search_marc_map SET marc_field='leader_/0-4'
18368 WHERE marc_type IN ('marc21', 'normarc') AND marc_field='leader_/1-5' AND id IN
18369 (SELECT search_marc_map_id FROM search_marc_to_field WHERE search_field_id IN
18370 (SELECT id FROM search_field WHERE label='llength')
18374 # Always end with this (adjust the bug info)
18375 SetVersion( $DBversion );
18376 print "Upgrade to $DBversion done (Bug 22339 - Fix search field mappings of MARC fixed fields)\n";
18379 $DBversion = '18.12.00.063';
18380 if ( CheckVersion($DBversion) ) {
18384 'Payment' => 'Pay',
18385 'Lost Item' => 'CR',
18386 'Manual Credit' => 'C',
18387 'Forgiven' => 'FOR'
18390 my $sth = $dbh->prepare( "SELECT accountlines_id FROM accountlines WHERE accounttype = 'VOID'" );
18391 my $sth2 = $dbh->prepare( "SELECT type FROM account_offsets WHERE credit_id = ? ORDER BY created_on LIMIT 1" );
18392 my $sth3 = $dbh->prepare( "UPDATE accountlines SET accounttype = ?, status = 'VOID' WHERE accountlines_id = ?" );
18394 while (my $row = $sth->fetchrow_hashref) {
18395 $sth2->execute($row->{accountlines_id});
18396 my $result = $sth2->fetchrow_hashref;
18397 my $type = $types_map->{$result->{'type'}} // 'Pay';
18398 $sth3->execute($type,$row->{accountlines_id});
18401 SetVersion($DBversion);
18402 print "Upgrade to $DBversion done (Bug 22511 - Update existing VOID accountlines)\n";
18405 $DBversion = '18.12.00.064';
18406 if( CheckVersion( $DBversion ) ) {
18408 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('UpdateItemLocationOnCheckin', 'PROC: _PERM_\n', 'NULL', 'This is a list of value pairs.\n Examples:\n PROC: FIC - causes an item in the Processing Center location to be updated into the Fiction location on check in.\n FIC: GEN - causes an item in the Fiction location to be updated into the General stacks location on check in.\n _BLANK_:FIC - causes an item that has no location to be updated into the Fiction location on check in.\nFIC: _BLANK_ - causes an item in location FIC to be updated to a blank location on check in.\n_ALL_:FIC - causes all items to be updated into the Fiction location on check in.\nPROC: _PERM_ - causes an item that is in the Processing Center to be updated to it''s permanent location.\nGeneral rule: if the location value on the left matches the item''s current location, it will be updated to match the location value on the right.\nNote: PROC and CART are special values, for these locations only can location and permanent_location differ, in all other cases an update will affect both. Items in the CART location will be returned to their permanent location on checkout.\nThe special term _BLANK_ may be used on either side of a value pair to update or remove the location from items with no location assigned. The special term _ALL_ is used on the left side of the colon (:) to affect all items.\nThe special term _PERM_ is used on the right side of the colon (:) to return items to their permanent location.', 'Free');
18411 UPDATE systempreferences s1, (SELECT IF(value,'PROC: CART\n','') AS p2c FROM systempreferences WHERE variable='InProcessingToShelvingCart') s2 SET s1.value= CONCAT(s2.p2c, REPLACE(s1.value,'PROC: _PERM_\n','') ) WHERE s1.variable='UpdateItemLocationOnCheckin' AND s1.value NOT LIKE '%PROC: CART%';
18414 DELETE FROM systempreferences WHERE variable='InProcessingToShelvingCart';
18417 UPDATE systempreferences s1, (SELECT IF(value,'_ALL_: CART\n','') AS rtc FROM systempreferences WHERE variable='ReturnToShelvingCart') s2 SET s1.value= CONCAT(s2.rtc,s1.value) WHERE s1.variable='UpdateItemLocationOnCheckin' AND s1.value NOT LIKE '%_ALL_: CART%';
18420 DELETE FROM systempreferences WHERE variable='ReturnToShelvingCart';
18422 SetVersion( $DBversion );
18423 print "Upgrade to $DBversion done (Bug 14576: Add UpdateItemLocationOnCheckin syspref)\n";
18426 $DBversion = '18.12.00.065';
18427 if( CheckVersion( $DBversion ) ) {
18429 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
18430 SELECT 'IndependentBranchesTransfers', value, NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'
18431 FROM systempreferences WHERE variable = 'IndependentBranches'
18433 SetVersion( $DBversion );
18434 print "Upgrade to $DBversion done (Bug 10300 - Allow transferring of items to be have separate IndependentBranches syspref)\n";
18437 $DBversion = '18.12.00.066';
18438 if ( CheckVersion($DBversion) ) {
18440 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `explanation`, `options`, `type`) VALUES
18441 ('OpenURLResolverURL', '', 'URL of OpenURL Resolver', NULL, 'Free'),
18442 ('OpenURLText', '', 'Text of OpenURL links (or image title if OpenURLImageLocation is defined)', NULL, 'Free'),
18443 ('OpenURLImageLocation', '', 'Location of image for OpenURL links', NULL, 'Free'),
18444 ('OPACShowOpenURL', '', 'Enable display of OpenURL links in OPAC search results and detail page', NULL, 'YesNo'),
18445 ('OPACOpenURLItemTypes', '', 'Show the OpenURL link only for these item types', NULL, 'Free');
18448 SetVersion($DBversion);
18450 "Upgrade to $DBversion done (Bug 8995 - Add new preferences for OpenURLResolvers)\n";
18453 $DBversion = '18.12.00.067';
18454 if ( CheckVersion($DBversion) ) {
18456 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
18457 VALUES ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free');
18459 SetVersion($DBversion);
18461 "Upgrade to $DBversion done (Bug 8000 - Add new preferences for SendAllEmailsTo)\n";
18464 $DBversion = '18.12.00.068';
18465 if ( CheckVersion($DBversion) ) {
18467 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
18468 ('AllowRenewalOnHoldOverride','0','','If on, allow items on hold to be renewed with a specified due date','YesNo');
18470 SetVersion($DBversion);
18471 print "Upgrade to $DBversion done (Bug 7088: Cannot renew items on hold even with override)\n";
18474 $DBversion = '18.12.00.069';
18475 if( CheckVersion( $DBversion ) ) {
18478 INSERT INTO plugin_data
18479 (plugin_class, plugin_key, plugin_value)
18485 WHERE plugin_key='__INSTALLED_VERSION__'
18488 # Always end with this (adjust the bug info)
18489 SetVersion( $DBversion );
18490 print "Upgrade to $DBversion done (Bug 22053 - enable all plugins)\n";
18493 $DBversion = '18.12.00.070';
18494 if ( CheckVersion($DBversion) ) {
18496 INSERT IGNORE INTO systempreferences
18497 ( `variable`, `value`, `options`, `explanation`, `type` )
18499 ('SelfCheckAllowByIPRanges','',NULL,'(Leave blank if not used. Use ranges or simple ip addresses separated by spaces, like <code>192.168.1.1 192.168.0.0/24</code>.)','Short');
18501 SetVersion($DBversion);
18502 print "Upgrade to $DBversion done (Bug 14407 - Limit web-based self-checkout to specific IP addresses)\n";
18505 $DBversion = '18.12.00.071';
18506 if( CheckVersion( $DBversion ) ) {
18508 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
18509 ('circulation', 'ACCOUNT_CREDIT', '', 'Account payment', 0, 'Account payment', '<table>
18510 [% IF ( LibraryName ) %]
18512 <th colspan="4" class="centerednames">
18513 <h3>[% LibraryName | html %]</h3>
18518 <th colspan="4" class="centerednames">
18519 <h2><u>Fee receipt</u></h2>
18523 <th colspan="4" class="centerednames">
18524 <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
18529 Received with thanks from [% patron.firstname | html %] [% patron.surname | html %] <br />
18530 Card number: [% patron.cardnumber | html %]<br />
18535 <th>Description of charges</th>
18540 [% FOREACH account IN accounts %]
18541 <tr class="highlight">
18542 <td>[% account.date | $KohaDates %]</td>
18544 [% PROCESS account_type_description account=account %]
18545 [%- IF account.description %], [% account.description | html %][% END %]
18547 <td>[% account.note | html %]</td>
18548 [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
18554 <td colspan="3">Total outstanding dues as on date: </td>
18555 [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
18558 </table>', 'print', 'default');
18560 SetVersion( $DBversion );
18561 print "Upgrade to $DBversion done (Bug 22809 - Move 'ACCOUNT_CREDIT' from template to a slip)\n";
18564 $DBversion = '18.12.00.072';
18565 if( CheckVersion( $DBversion ) ) {
18567 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
18568 ('circulation', 'ACCOUNT_DEBIT', '', 'Account fee', 0, 'Account fee', '<table>
18569 [% IF ( LibraryName ) %]
18571 <th colspan="5" class="centerednames">
18572 <h3>[% LibraryName | html %]</h3>
18578 <th colspan="5" class="centerednames">
18579 <h2><u>INVOICE</u></h2>
18583 <th colspan="5" class="centerednames">
18584 <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
18589 Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
18590 Card number: [% patron.cardnumber | html %]<br />
18595 <th>Description of charges</th>
18597 <th style="text-align:right;">Amount</th>
18598 <th style="text-align:right;">Amount outstanding</th>
18601 [% FOREACH account IN accounts %]
18602 <tr class="highlight">
18603 <td>[% account.date | $KohaDates%]</td>
18605 [% PROCESS account_type_description account=account %]
18606 [%- IF account.description %], [% account.description | html %][% END %]
18608 <td>[% account.note | html %]</td>
18609 [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
18610 [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
18616 <td colspan="4">Total outstanding dues as on date: </td>
18617 [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
18620 </table>', 'print', 'default');
18622 SetVersion( $DBversion );
18623 print "Upgrade to $DBversion done (Bug 22809 - Move 'INVOICE' from template to a slip)\n";
18626 $DBversion = '18.12.00.073';
18627 if( CheckVersion( $DBversion ) ) {
18629 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
18630 ('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that will be sent new purchase suggestions','Choice'),
18631 ('EmailAddressForSuggestions','','','If you choose EmailAddressForSuggestions you should enter a valid email address','free')
18635 INSERT IGNORE INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES
18636 ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Suggestion pending approval</h3>
18637 <p><h4>Suggested by</h4>
18639 <li><<borrowers.firstname>> <<borrowers.surname>></li>
18640 <li><<borrowers.cardnumber>></li>
18641 <li><<borrowers.phone>></li>
18642 <li><<borrowers.email>></li>
18645 <p><h4>Title suggested</h4>
18647 <li><b>Library:</b> <<branches.branchname>></li>
18648 <li><b>Title:</b> <<suggestions.title>></li>
18649 <li><b>Author:</b> <<suggestions.author>></li>
18650 <li><b>Copyright date:</b> <<suggestions.copyrightdate>></li>
18651 <li><b>Standard number (ISBN, ISSN or other):</b> <<suggestions.isbn>></li>
18652 <li><b>Publisher:</b> <<suggestions.publishercode>></li>
18653 <li><b>Collection title:</b> <<suggestions.collectiontitle>></li>
18654 <li><b>Publication place:</b> <<suggestions.place>></li>
18655 <li><b>Quantity:</b> <<suggestions.quantity>></li>
18656 <li><b>Item type:</b> <<suggestions.itemtype>></li>
18657 <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
18658 <li><b>Notes:</b> <<suggestions.note>></li>
18663 SetVersion( $DBversion );
18664 print "Upgrade to $DBversion done (Bug 5770 - Email librarian when purchase suggestion made)\n";
18667 $DBversion = '18.12.00.074';
18668 if( CheckVersion( $DBversion ) ) {
18669 unless ( TableExists( 'keyboard_shortcuts' ) ) {
18671 CREATE TABLE keyboard_shortcuts (
18672 shortcut_name varchar(80) NOT NULL,
18673 shortcut_keys varchar(80) NOT NULL,
18674 PRIMARY KEY (shortcut_name)
18675 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
18679 INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
18680 ("insert_copyright","Alt-C"),
18681 ("insert_copyright_sound","Alt-P"),
18682 ("insert_delimiter","Ctrl-D"),
18683 ("subfield_help","Ctrl-H"),
18684 ("link_authorities","Shift-Ctrl-L"),
18685 ("delete_field","Ctrl-X"),
18686 ("delete_subfield","Shift-Ctrl-X"),
18687 ("new_line","Enter"),
18688 ("line_break","Shift-Enter"),
18689 ("next_position","Tab"),
18690 ("prev_position","Shift-Tab")
18694 INSERT IGNORE permissions (module_bit, code, description)
18696 (3,'manage_keyboard_shortcuts','Manage keyboard shortcuts for advanced cataloging editor')
18699 SetVersion( $DBversion );
18700 print "Upgrade to $DBversion done (Bug 21411 - Add keyboard_shortcuts table)\n";
18703 $DBversion = '18.12.00.075';
18704 if( CheckVersion( $DBversion ) ) {
18705 # you can use $dbh here like:
18706 unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) {
18708 DELETE t FROM tmp_holdsqueue t
18709 LEFT JOIN items i ON t.itemnumber=i.itemnumber
18710 WHERE i.itemnumber IS NULL
18713 ALTER TABLE tmp_holdsqueue
18714 ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)
18715 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
18718 SetVersion( $DBversion );
18719 print "Upgrade to $DBversion done (Bug 22899 - Add items constraint to tmp_holdsqueue)\n";
18722 $DBversion = '19.05.00.000';
18723 if( CheckVersion( $DBversion ) ) {
18724 SetVersion( $DBversion );
18725 print "Upgrade to $DBversion done (19.05.00 release)\n";
18728 $DBversion = '19.06.00.000';
18729 if( CheckVersion( $DBversion ) ) {
18730 SetVersion( $DBversion );
18731 print "Upgrade to $DBversion done (Wingardium Leviosa!)\n";
18734 $DBversion = '19.06.00.001';
18735 if( CheckVersion( $DBversion ) ) {
18737 UPDATE systempreferences
18738 SET explanation = 'This is a list of value pairs.\n Examples:\n PROC: FIC - causes an item in the Processing Center location to be updated into the Fiction location on check in.\n FIC: GEN - causes an item in the Fiction location to be updated into the General stacks location on check in.\n _BLANK_:FIC - causes an item that has no location to be updated into the Fiction location on check in.\nFIC: _BLANK_ - causes an item in location FIC to be updated to a blank location on check in.\n_ALL_:FIC - causes all items to be updated into the Fiction location on check in.\nPROC: _PERM_ - causes an item that is in the Processing Center to be updated to it''s permanent location.\nGeneral rule: if the location value on the left matches the item''s current location, it will be updated to match the location value on the right.\nNote: PROC and CART are special values, for these locations only can location and permanent_location differ, in all other cases an update will affect both. Items in the CART location will be returned to their permanent location on checkout.\nThe special term _BLANK_ may be used on either side of a value pair to update or remove the location from items with no location assigned. The special term _ALL_ is used on the left side of the colon (:) to affect all items.\nThe special term _PERM_ is used on the right side of the colon (:) to return items to their permanent location.'
18739 WHERE variable = 'UpdateItemLocationOnCheckin'
18741 SetVersion( $DBversion );
18742 print "Upgrade to $DBversion done (Bug 22960: Fix typo in syspref description)\n";
18745 $DBversion = '19.06.00.002';
18746 if ( CheckVersion($DBversion) ) {
18748 $dbh->do(q{ALTER TABLE subscriptionhistory CHANGE opacnote opacnote LONGTEXT NULL});
18749 $dbh->do(q{ALTER TABLE subscriptionhistory CHANGE librariannote librariannote LONGTEXT NULL});
18751 $dbh->do(q{UPDATE subscriptionhistory SET opacnote = NULL WHERE opacnote = ''});
18752 $dbh->do(q{UPDATE subscriptionhistory SET librariannote = NULL WHERE librariannote = ''});
18754 SetVersion ($DBversion);
18755 print "Upgrade to $DBversion done (Bug 10215: Increase the size of opacnote and librariannote for table subscriptionhistory)\n";
18758 $DBversion = '19.06.00.003';
18759 if( CheckVersion( $DBversion ) ) {
18760 $dbh->do(q{UPDATE systempreferences SET value = REPLACE( value, ' ', '|' ) WHERE variable = 'UniqueItemFields'; });
18762 SetVersion( $DBversion );
18763 print "Upgrade to $DBversion done (Bug 22867: UniqueItemFields preference value should be pipe-delimited)\n";
18766 $DBversion = '19.06.00.004';
18767 if( CheckVersion( $DBversion ) ) {
18768 $dbh->do( 'UPDATE language_descriptions SET description = "Griechisch (Modern 1453-)"
18769 WHERE subtag = "el" and type = "language" and lang ="de"' );
18770 SetVersion( $DBversion );
18771 print "Upgrade to $DBversion done (Bug 22770: Fix typo in language description for el in German)\n";
18774 $DBversion = '19.06.00.005';
18775 if( CheckVersion( $DBversion ) ) {
18776 unless ( column_exists( 'reserves', 'item_level_hold' ) ) {
18777 $dbh->do( "ALTER TABLE reserves ADD COLUMN item_level_hold BOOLEAN NOT NULL DEFAULT 0 AFTER itemtype" );
18779 unless ( column_exists( 'old_reserves', 'item_level_hold' ) ) {
18780 $dbh->do( "ALTER TABLE old_reserves ADD COLUMN item_level_hold BOOLEAN NOT NULL DEFAULT 0 AFTER itemtype" );
18783 SetVersion( $DBversion );
18784 print "Upgrade to $DBversion done (Bug 9834: Add the reserves.item_level_hold column)\n";
18787 $DBversion = '19.06.00.006';
18788 if( CheckVersion( $DBversion ) ) {
18790 unless ( TableExists('plugin_methods') ) {
18792 CREATE TABLE plugin_methods (
18793 plugin_class varchar(255) NOT NULL,
18794 plugin_method varchar(255) NOT NULL,
18795 PRIMARY KEY ( `plugin_class` (191), `plugin_method` (191) )
18796 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18800 require Koha::Plugins;
18801 Koha::Plugins->new({ enable_plugins => 1 })->InstallPlugins;
18803 SetVersion( $DBversion );
18804 print "Upgrade to $DBversion done (Bug 21073: Improve plugin performance)\n";
18807 $DBversion = '19.06.00.007';
18808 if( CheckVersion( $DBversion ) ) {
18809 $dbh->do( "DELETE FROM systempreferences WHERE variable = 'RotationPreventTransfers'" );
18810 SetVersion( $DBversion );
18811 print "Upgrade to $DBversion done (Bug 22653: Remove unimplemented RotationPreventTransfers system preference)\n";
18814 $DBversion = '19.06.00.008';
18815 if( CheckVersion( $DBversion ) ) {
18816 $dbh->do( "UPDATE userflags SET flagdesc = 'Allow staff members to modify permissions and passwords for other staff members' WHERE flag = 'staffaccess'" );
18817 SetVersion( $DBversion );
18818 print "Upgrade to $DBversion done (Bug 23109: Improve description of staffaccess permission)\n";
18821 $DBversion = '19.06.00.009';
18822 if( CheckVersion( $DBversion ) ) {
18824 INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys)
18825 VALUES ("toggle_keyboard", "Shift-Ctrl-K")
18828 SetVersion( $DBversion );
18829 print "Upgrade to $DBversion done (Bug 17178: add shortcut to keyboard_shortcuts)\n";
18832 $DBversion = '19.06.00.010';
18833 if( CheckVersion( $DBversion ) ) {
18835 if ( TableExists('default_circ_rules') ) {
18836 if ( column_exists( 'default_circ_rules', 'holdallowed' ) ) {
18838 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18839 SELECT NULL, NULL, NULL, 'holdallowed', holdallowed
18840 FROM default_circ_rules
18843 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18844 SELECT NULL, NULL, NULL, 'hold_fulfillment_policy', hold_fulfillment_policy
18845 FROM default_circ_rules
18848 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18849 SELECT NULL, NULL, NULL, 'returnbranch', returnbranch
18850 FROM default_circ_rules
18852 $dbh->do("DROP TABLE default_circ_rules");
18856 if ( TableExists('default_branch_circ_rules') ) {
18857 if ( column_exists( 'default_branch_circ_rules', 'holdallowed' ) ) {
18859 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18860 SELECT NULL, branchcode, NULL, 'holdallowed', holdallowed
18861 FROM default_branch_circ_rules
18864 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18865 SELECT NULL, branchcode, NULL, 'hold_fulfillment_policy', hold_fulfillment_policy
18866 FROM default_branch_circ_rules
18869 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18870 SELECT NULL, branchcode, NULL, 'returnbranch', returnbranch
18871 FROM default_branch_circ_rules
18873 $dbh->do("DROP TABLE default_branch_circ_rules");
18877 if ( TableExists('branch_item_rules') ) {
18878 if ( column_exists( 'branch_item_rules', 'holdallowed' ) ) {
18880 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18881 SELECT NULL, branchcode, itemtype, 'holdallowed', holdallowed
18882 FROM branch_item_rules
18885 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18886 SELECT NULL, branchcode, itemtype, 'hold_fulfillment_policy', hold_fulfillment_policy
18887 FROM branch_item_rules
18890 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18891 SELECT NULL, branchcode, itemtype, 'returnbranch', returnbranch
18892 FROM branch_item_rules
18894 $dbh->do("DROP TABLE branch_item_rules");
18898 if ( TableExists('default_branch_item_rules') ) {
18899 if ( column_exists( 'default_branch_item_rules', 'holdallowed' ) ) {
18901 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18902 SELECT NULL, NULL, itemtype, 'holdallowed', holdallowed
18903 FROM default_branch_item_rules
18906 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18907 SELECT NULL, NULL, itemtype, 'hold_fulfillment_policy', hold_fulfillment_policy
18908 FROM default_branch_item_rules
18911 INSERT IGNORE INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18912 SELECT NULL, NULL, itemtype, 'returnbranch', returnbranch
18913 FROM default_branch_item_rules
18915 $dbh->do("DROP TABLE default_branch_item_rules");
18919 SetVersion( $DBversion );
18920 print "Upgrade to $DBversion done (Bug 18928: Move holdallowed, hold_fulfillment_policy, returnbranch to circulation_rules)\n";
18923 $DBversion = '19.06.00.011';
18924 if( CheckVersion( $DBversion ) ) {
18926 if ( TableExists('refund_lost_item_fee_rules') ) {
18927 if ( column_exists( 'refund_lost_item_fee_rules', 'refund' ) ) {
18929 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
18930 SELECT NULL, IF(branchcode='*', NULL, branchcode), NULL, 'refund', refund
18931 FROM refund_lost_item_fee_rules
18933 $dbh->do("DROP TABLE refund_lost_item_fee_rules");
18937 SetVersion( $DBversion );
18938 print "Upgrade to $DBversion done (Bug 18930: Move lost item refund rules to circulation_rules table)\n";
18941 $DBversion = '19.06.00.012';
18942 if ( CheckVersion($DBversion) ) {
18944 # Find and correct pathological cases of LR becoming a credit
18945 my $sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'LR' AND amount < 0" );
18947 while ( my $row = $sth->fetchrow_hashref ) {
18949 "INSERT INTO accountlines (accounttype, issue_id, borrowernumber, itemnumber, amount, manager_id, interface) VALUES ( ?, ?, ?, ?, ?, ?, ? );",
18952 'CR', $row->{issue_id},
18953 $row->{borrowernumber}, $row->{itemnumber},
18954 $row->{amount}, $row->{manager_id},
18958 my $credit_id = $dbh->last_insert_id(undef, undef, 'accountlines', undef);
18959 my $amount = $row->{amount} * -1;
18960 $dbh->do("INSERT INTO account_offsets (credit_id, debit_id, type, amount) VALUES (?,?,?,?);",{},($credit_id, $row->{accountlines_id}, 'Lost Item', $amount));
18961 $dbh->do("UPDATE accountlines SET amount = '$amount' WHERE accountlines_id = '$row->{accountlines_id}';");
18968 accounttype = 'LOST',
18969 status = 'RETURNED'
18971 accounttype = 'LR';
18974 # Find and correct pathalogical cases of L having been converted to W
18975 $sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'W' AND itemnumber IS NOT NULL" );
18977 while ( my $row = $sth->fetchrow_hashref ) {
18978 my $amount = $row->{amount} * -1;
18980 "INSERT INTO accountlines (accounttype, issue_id, borrowernumber, itemnumber, amount, manager_id, interface) VALUES ( ?, ?, ?, ?, ?, ?, ? );",
18983 'LOST', $row->{issue_id}, $row->{borrowernumber},
18984 $row->{itemnumber}, $amount, $row->{manager_id},
18988 my $debit_id = $dbh->last_insert_id(undef, undef, 'accountlines', undef);
18990 "INSERT INTO account_offsets (credit_id, debit_id, type, amount) VALUES (?,?,?,?);",
18993 $row->{accountlines_id}, $debit_id,
18994 'Lost Item', $amount
19003 accounttype = 'LOST'
19012 accounttype = 'LOST_RETURN'
19014 accounttype = 'CR';
19017 SetVersion($DBversion);
19018 print "Upgrade to $DBversion done (Bug 22563: Fix accounttypes for 'L', 'LR' and 'CR')\n";
19021 $DBversion = '19.06.00.013';
19022 if ( CheckVersion( $DBversion ) ) {
19023 unless ( column_exists( 'borrower_modifications', 'changed_fields' ) ) {
19024 $dbh->do("ALTER TABLE borrower_modifications ADD changed_fields MEDIUMTEXT AFTER verification_token;");
19026 SetVersion( $DBversion );
19027 print "Upgrade to $DBversion done (Bug 23151: Add borrower_modifications.changed_fields column)\n";
19030 $DBversion = '19.06.00.014';
19031 if ( CheckVersion($DBversion) ) {
19037 accounttype = 'RENT_DAILY_RENEW'
19039 accounttype = 'Rent'
19041 description LIKE 'Renewal of Daily Rental Item%';
19048 accounttype = 'RENT_DAILY'
19050 accounttype = 'Rent'
19052 description LIKE 'Daily rental';
19060 accounttype = 'RENT_RENEW'
19062 accounttype = 'Rent'
19064 description LIKE 'Renewal of Rental Item%';
19071 accounttype = 'RENT'
19073 accounttype = 'Rent';
19076 SetVersion($DBversion);
19077 print "Upgrade to $DBversion done (Bug 11573: Fix accounttypes for 'Rent')\n";
19080 $DBversion = '19.06.00.015';
19081 if( CheckVersion( $DBversion ) ) {
19082 $dbh->do( "UPDATE `search_field` SET `name` = 'date-time-last-modified', `label` = 'date-time-last-modified' WHERE `name` = 'date/time-last-modified'" );
19084 SetVersion( $DBversion );
19085 print "Upgrade to $DBversion done (Bug 22524: Fix date/time-last-modified search with Elasticsearch)\n";
19088 $DBversion = '19.06.00.016';
19089 if( CheckVersion( $DBversion ) ) {
19092 INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
19093 ("insert_copyright","Alt-C"),
19094 ("insert_copyright_sound","Alt-P"),
19095 ("insert_delimiter","Ctrl-D"),
19096 ("subfield_help","Ctrl-H"),
19097 ("link_authorities","Shift-Ctrl-L"),
19098 ("delete_field","Ctrl-X"),
19099 ("delete_subfield","Shift-Ctrl-X"),
19100 ("new_line","Enter"),
19101 ("line_break","Shift-Enter"),
19102 ("next_position","Tab"),
19103 ("prev_position","Shift-Tab"),
19104 ("toggle_keyboard", "Shift-Ctrl-K")
19107 SetVersion( $DBversion );
19108 print "Upgrade to $DBversion done (Bug 23396: Fix missing keyboard_shortcuts table)\n";
19111 $DBversion = '19.06.00.017';
19112 if ( CheckVersion($DBversion) ) {
19116 authorised_values (category,authorised_value,lib)
19118 ('PAYMENT_TYPE','SIP00','Cash via SIP2'),
19119 ('PAYMENT_TYPE','SIP01','VISA via SIP2'),
19120 ('PAYMENT_TYPE','SIP02','Creditcard via SIP2')
19127 accounttype = 'Pay',
19128 payment_type = 'SIP00'
19130 accounttype = 'Pay00';
19137 accounttype = 'Pay',
19138 payment_type = 'SIP01'
19140 accounttype = 'Pay01';
19147 accounttype = 'Pay',
19148 payment_type = 'SIP02'
19150 accounttype = 'Pay02';
19153 my $sth = $dbh->prepare( q{SELECT * FROM accountlines WHERE accounttype REGEXP '^Pay[[:digit:]]{2}$' } );
19156 while (my $row = $sth->fetchrow_hashref) {
19157 my $type = $row->{accounttype};
19158 my $sipcode = $type;
19159 $sipcode =~ s/Pay/SIP/g;
19160 unless ($seen->{$sipcode}) {
19163 authorised_values (category,authorised_value,lib)
19165 ('PAYMENT_TYPE',"$sipcode",'Unrecognised SIP2 payment type')
19172 accounttype = 'Pay',
19173 payment_type = "$sipcode"
19175 accounttype = "$type";
19178 $seen->{$sipcode} = 1;
19182 SetVersion($DBversion);
19183 print "Upgrade to $DBversion done (Bug 22610: Fix accounttypes for SIP2 payments)\n";
19186 $DBversion = '19.06.00.018';
19187 if( CheckVersion( $DBversion ) ) {
19188 if( !column_exists( 'biblio', 'subtitle' ) ) {
19189 $dbh->do( "ALTER TABLE biblio ADD COLUMN medium LONGTEXT AFTER title" );
19190 $dbh->do( "ALTER TABLE biblio ADD COLUMN subtitle LONGTEXT AFTER medium" );
19191 $dbh->do( "ALTER TABLE biblio ADD COLUMN part_number LONGTEXT AFTER subtitle" );
19192 $dbh->do( "ALTER TABLE biblio ADD COLUMN part_name LONGTEXT AFTER part_number" );
19194 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN medium LONGTEXT AFTER title" );
19195 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN subtitle LONGTEXT AFTER medium" );
19196 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_number LONGTEXT AFTER subtitle" );
19197 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_name LONGTEXT AFTER part_number" );
19200 $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' WHERE kohafield='bibliosubtitle.subtitle'" );
19202 my $marcflavour = C4::Context->preference('marcflavour');
19204 if ( $marcflavour eq 'UNIMARC' ) {
19206 UPDATE marc_subfield_structure SET kohafield='biblio.medium'
19207 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='b'
19210 UPDATE marc_subfield_structure SET kohafield='biblio.subtitle'
19211 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='e'
19214 UPDATE marc_subfield_structure SET kohafield='biblio.part_number'
19215 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='h'
19218 UPDATE marc_subfield_structure SET kohafield='biblio.part_name'
19219 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='i'
19223 UPDATE marc_subfield_structure SET kohafield='biblio.medium'
19224 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='h'
19227 UPDATE marc_subfield_structure SET kohafield='biblio.subtitle'
19228 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='b'
19231 UPDATE marc_subfield_structure SET kohafield='biblio.part_number'
19232 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='n'
19235 UPDATE marc_subfield_structure SET kohafield='biblio.part_name'
19236 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='p'
19240 $sth = $dbh->prepare("SELECT * FROM fieldmapping");
19243 if ( $sth->rows ) {
19244 while ( my $value = $sth->fetchrow_hashref() ) {
19246 $value->{frameworkcode} eq ""
19248 : $value->{frameworkcode};
19251 field => $value->{field},
19252 fieldcode => $value->{fieldcode},
19253 subfieldcode => $value->{subfieldcode},
19254 framework => $framework
19259 $dbh->do( "DROP TABLE IF EXISTS fieldmapping" );
19261 $dbh->do( "DELETE FROM user_permissions WHERE code='manage_keywords2koha_mappings'" );
19263 $dbh->do( "DELETE FROM permissions WHERE code='manage_keywords2koha_mappings'" );
19265 # Always end with this (adjust the bug info)
19266 SetVersion( $DBversion );
19267 print "Upgrade to $DBversion done (Bug 11529: Add medium, subtitle and part information to biblio table)\n";
19268 if ( @fails_11529 ) {
19269 print "WARNING: Keyword to MARC Mappings:\n";
19270 for my $fail_11529 ( @fails_11529 ) {
19272 . $fail_11529->{field}
19274 . $fail_11529->{fieldcode} . "\$"
19275 . $fail_11529->{subfieldcode} . " for "
19276 . $fail_11529->{framework}
19279 print "The keyword to marc mapping feature is no longer supported. Above find the\n";
19280 print "mappings that had been defined in your system. You will need to remap any\n";
19281 print "desired MARC fields to the Koha field you desire in the Koha to MARC mappings\n";
19282 print "page under Administration\n";
19284 print "NOTE: misc/batchRebuildBiblioTables.pl should be run to populate the fields introduced in bug 11529. It may take some time for larger databases.\n\n"
19287 $DBversion = '19.06.00.019';
19288 if ( CheckVersion($DBversion) ) {
19290 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
19293 'FinePaymentAutoPopup',
19296 'If enabled, automatically display a print dialog for a payment receipt when making a payment.',
19301 SetVersion($DBversion);
19303 "Upgrade to $DBversion done (Bug 23228: Add option to automatically display payment receipt for printing after making a payment)\n";
19306 $DBversion = '19.06.00.020';
19307 if( CheckVersion( $DBversion ) ) {
19309 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
19310 ('PreserveSerialNotes','1','','When a new "Expected" issue is generated, should it be prefilled with last created issue notes?','YesNo');
19313 SetVersion( $DBversion );
19314 print "Upgrade to $DBversion done (Bug 23416: Add PreserveSerialNotes syspref)\n";
19317 $DBversion = '19.06.00.021';
19318 if( CheckVersion( $DBversion ) ) {
19321 ALTER TABLE marc_subfield_structure CHANGE COLUMN hidden hidden TINYINT(1) DEFAULT 8 NOT NULL;
19323 # Always end with this (adjust the bug info)
19324 SetVersion( $DBversion );
19325 print "Upgrade to $DBversion done (Bug 23309: Can't add new subfields to bibliographic frameworks in strict mode)\n";
19328 $DBversion = '19.06.00.022';
19329 if ( CheckVersion($DBversion) ) {
19331 unless ( TableExists('borrower_relationships') ) {
19333 CREATE TABLE `borrower_relationships` (
19334 id INT(11) NOT NULL AUTO_INCREMENT,
19335 guarantor_id INT(11) NOT NULL,
19336 guarantee_id INT(11) NOT NULL,
19337 relationship VARCHAR(100) NOT NULL,
19339 UNIQUE KEY `guarantor_guarantee_idx` ( `guarantor_id`, `guarantee_id` ),
19340 CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE,
19341 CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
19342 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
19347 LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber )
19348 SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL;
19351 # Bad data handling: guarantorid IS NOT NULL AND relationship IS NULL
19354 SET relationship = '_bad_data'
19355 WHERE guarantorid IS NOT NULL AND
19356 relationship IS NULL
19360 INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship )
19361 SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL;
19364 # Clean migrated guarantor data
19367 SET contactname=NULL,
19368 contactfirstname=NULL,
19370 WHERE guarantorid IS NOT NULL
19374 if ( column_exists( 'borrowers', 'guarantorid' ) ) {
19376 ALTER TABLE borrowers DROP guarantorid;
19380 if ( column_exists( 'deletedborrowers', 'guarantorid' ) ) {
19382 ALTER TABLE deletedborrowers DROP guarantorid;
19386 if ( column_exists( 'borrower_modifications', 'guarantorid' ) ) {
19388 ALTER TABLE borrower_modifications DROP guarantorid;
19392 SetVersion($DBversion);
19393 print "Upgrade to $DBversion done (Bug 14570: Make it possible to add multiple guarantors to a record)\n";
19396 $DBversion = '19.06.00.023';
19397 if( CheckVersion( $DBversion ) ) {
19399 INSERT IGNORE INTO `systempreferences` (`variable`,`value`,`explanation`,`options`,`type`) VALUES
19400 ('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice')
19403 SetVersion( $DBversion );
19404 print "Upgrade to $DBversion done (Bug 22258: Add ElasticsearchMARCFormat preference)\n";
19407 $DBversion = '19.06.00.024';
19408 if( CheckVersion( $DBversion ) ) {
19409 $dbh->do(q{ALTER TABLE accountlines CHANGE COLUMN accounttype accounttype varchar(80) default NULL});
19411 SetVersion( $DBversion );
19412 print "Upgrade to $DBversion done (Bug 23539: accountlines.accounttype should match authorised_values.authorised_value in size)\n";
19415 $DBversion = '19.06.00.025';
19416 if( CheckVersion( $DBversion ) ) {
19417 $dbh->do( q/INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES (?, ?, ?, ?, ?)/, undef, 'BarcodeSeparators','\s\r\n','','Splitting characters for barcodes','Free' );
19418 SetVersion( $DBversion );
19419 print "Upgrade to $DBversion done (Bug 22996: Add pref BarcodeSeparators)\n";
19422 $DBversion = '19.06.00.026';
19423 if( CheckVersion( $DBversion ) ) {
19425 unless ( column_exists( 'borrowers', 'privacy_guarantor_fines' ) ) {
19427 ALTER TABLE borrowers
19428 ADD privacy_guarantor_fines TINYINT(1) NOT NULL DEFAULT '0' AFTER privacy;
19432 unless ( column_exists( 'deletedborrowers', 'privacy_guarantor_fines' ) ) {
19434 ALTER TABLE deletedborrowers
19435 ADD privacy_guarantor_fines TINYINT(1) NOT NULL DEFAULT '0' AFTER privacy;
19440 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type )
19442 'AllowStaffToSetFinesVisibilityForGuarantor', '0', NULL,
19443 'If enabled, library staff can set a patron''s fines to be visible to linked patrons from the opac.', 'YesNo'
19445 'AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL,
19446 'If enabled, the patron can set fines to be visible to his or her guarantor', 'YesNo'
19450 SetVersion( $DBversion );
19451 print "Upgrade to $DBversion done (Bug 20691: Add ability for guarantors to view guarantee's fines in OPAC)\n";
19454 $DBversion = '19.06.00.027';
19455 if( CheckVersion( $DBversion ) ) {
19457 if( !TableExists( 'itemtypes_branches' ) ) {
19459 CREATE TABLE itemtypes_branches( -- association table between authorised_values and branches
19460 itemtype VARCHAR(10) NOT NULL,
19461 branchcode VARCHAR(10) NOT NULL,
19462 FOREIGN KEY (itemtype) REFERENCES itemtypes(itemtype) ON DELETE CASCADE,
19463 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
19464 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
19468 SetVersion( $DBversion );
19469 print "Upgrade to $DBversion done (Bug 15497: Add itemtypes_branches table)\n";
19472 $DBversion = '19.06.00.028';
19473 if ( CheckVersion($DBversion) ) {
19479 accounttype = 'ACCOUNT'
19484 SetVersion($DBversion);
19485 print "Upgrade to $DBversion done (Bug 11573: Fix accounttypes for 'A')\n";
19488 $DBversion = '19.06.00.029';
19489 if ( CheckVersion($DBversion) ) {
19491 unless ( TableExists( 'cash_registers' ) ) {
19493 CREATE TABLE `cash_registers` (
19494 `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
19495 `name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
19496 `description` longtext NOT NULL, -- the user friendly description for each account register
19497 `branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
19498 `branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
19499 `starting_float` decimal(28, 6), -- the starting float this account register should be assigned
19500 `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
19501 PRIMARY KEY (`id`),
19502 UNIQUE KEY `name` (`name`,`branch`),
19503 CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
19504 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
19508 unless ( column_exists( 'accountlines', 'register_id' ) ) {
19509 $dbh->do(qq{ALTER TABLE `accountlines` ADD `register_id` int(11) NULL DEFAULT NULL AFTER `manager_id`});
19511 ALTER TABLE `accountlines`
19512 ADD CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`)
19513 REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
19518 INSERT IGNORE INTO `userflags` (`bit`, `flag`, `flagdesc`, `defaulton`)
19519 VALUES (25, 'cash_management', 'Cash management', 0)
19523 INSERT IGNORE permissions (module_bit, code, description)
19525 (25, 'manage_cash_registers', 'Add and remove cash registers')
19529 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
19530 ('UseCashRegisters','0','','Use cash registers with the accounting system and assign patron transactions to them.','YesNo')
19533 SetVersion($DBversion);
19534 print "Upgrade to $DBversion done (Bug 23321: Add cash_registers table, permissions and preferences)\n";
19537 $DBversion = '19.06.00.030';
19538 if( CheckVersion( $DBversion ) ) {
19540 if ( !TableExists('club_holds') ) {
19542 CREATE TABLE club_holds (
19543 id INT(11) NOT NULL AUTO_INCREMENT,
19544 club_id INT(11) NOT NULL, -- id for the club the hold was generated for
19545 biblio_id INT(11) NOT NULL, -- id for the bibliographic record the hold has been placed against
19546 item_id INT(11) NULL DEFAULT NULL, -- If item-level, the id for the item the hold has been placed agains
19547 date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Timestamp for the placed hold
19549 -- KEY club_id (club_id),
19550 CONSTRAINT clubs_holds_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
19551 CONSTRAINT clubs_holds_ibfk_2 FOREIGN KEY (biblio_id) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE,
19552 CONSTRAINT clubs_holds_ibfk_3 FOREIGN KEY (item_id) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE
19553 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
19557 if ( !TableExists('club_holds_to_patron_holds') ) {
19559 CREATE TABLE club_holds_to_patron_holds (
19560 id INT(11) NOT NULL AUTO_INCREMENT,
19561 club_hold_id INT(11) NOT NULL,
19562 patron_id INT(11) NOT NULL,
19564 error_code ENUM ( 'damaged', 'ageRestricted', 'itemAlreadyOnHold',
19565 'tooManyHoldsForThisRecord', 'tooManyReservesToday',
19566 'tooManyReserves', 'notReservable', 'cannotReserveFromOtherBranches',
19567 'libraryNotFound', 'libraryNotPickupLocation', 'cannotBeTransferred'
19568 ) NULL DEFAULT NULL,
19569 error_message varchar(100) NULL DEFAULT NULL,
19571 -- KEY club_hold_id (club_hold_id),
19572 CONSTRAINT clubs_holds_paton_holds_ibfk_1 FOREIGN KEY (club_hold_id) REFERENCES club_holds (id) ON DELETE CASCADE ON UPDATE CASCADE,
19573 CONSTRAINT clubs_holds_paton_holds_ibfk_2 FOREIGN KEY (patron_id) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
19574 CONSTRAINT clubs_holds_paton_holds_ibfk_3 FOREIGN KEY (hold_id) REFERENCES reserves (reserve_id) ON DELETE CASCADE ON UPDATE CASCADE
19575 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
19579 # Always end with this (adjust the bug info)
19580 SetVersion( $DBversion );
19581 print "Upgrade to $DBversion done (Bug 19618: add club_holds tables)\n";
19584 $DBversion = '19.06.00.031';
19585 if( CheckVersion( $DBversion ) ) {
19587 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
19588 ('OPACDetailQRCode','0','','Enable the display of a QR Code on the OPAC detail page','YesNo');
19591 SetVersion( $DBversion );
19592 print "Upgrade to $DBversion done (Bug 23566: Add OPACDetailQRCode system preference)\n";
19595 $DBversion = '19.06.00.032';
19596 if ( CheckVersion($DBversion) ) {
19597 if ( !column_exists( 'search_marc_to_field', 'search' ) ) {
19599 ALTER TABLE `search_marc_to_field` ADD COLUMN `search` tinyint(1) NOT NULL DEFAULT 1
19602 if ( !column_exists( 'search_field', 'staff_client' ) ) {
19604 ALTER TABLE `search_field` ADD COLUMN `staff_client` tinyint(1) NOT NULL DEFAULT 1
19607 if ( !column_exists( 'search_field', 'opac' ) ) {
19609 ALTER TABLE `search_field` ADD COLUMN `opac` tinyint(1) NOT NULL DEFAULT 1
19613 SetVersion($DBversion);
19615 "Upgrade to $DBversion done (Bug 20589: Add field boosting and use elastic query fields parameter instead of depricated _all)\n";
19618 $DBversion = '19.06.00.033';
19619 if( CheckVersion( $DBversion ) ) {
19622 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
19623 ('OnSiteCheckoutAutoCheck','0','','Enable/Do not enable onsite checkout by default if last checkout was an onsite checkout','YesNo')
19625 SetVersion( $DBversion );
19626 print "Upgrade to $DBversion done (Bug 23686: Add OnSiteCheckoutAutoCheck system preference)\n";
19629 $DBversion = '19.06.00.034';
19630 if( CheckVersion( $DBversion ) ) {
19632 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
19633 ('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo')
19635 SetVersion( $DBversion );
19636 print "Upgrade to $DBversion done (Bug 23007: Make transfer modals optionally block circ)\n";
19639 $DBversion = '19.06.00.035';
19640 if( CheckVersion( $DBversion ) ) {
19643 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
19644 ( 'IntranetCoce','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff client', 'YesNo')
19648 UPDATE systempreferences SET
19649 variable = 'OpacCoce',
19650 explanation = 'If on, enables cover retrieval from the configured Coce server in the OPAC'
19655 SetVersion( $DBversion );
19656 print "Upgrade to $DBversion done (Bug 18421: Add Coce image cache to the Intranet)\n";
19659 $DBversion = '19.06.00.036';
19660 if( CheckVersion( $DBversion ) ) {
19663 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES
19664 ('QueryRegexEscapeOptions', 'escape', 'dont_escape|escape|unescape_escaped', 'Escape option for regexps delimiters in Elasicsearch queries.', 'Choice')
19667 SetVersion( $DBversion );
19668 print "Upgrade to $DBversion done (Bug 20334: Add elasticsearch escape options preference)\n";
19671 $DBversion = '19.06.00.037';
19672 if( CheckVersion( $DBversion ) ) {
19674 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
19675 VALUES ('PayPalReturnURL','BaseURL','BaseURL|OPACAlias','Specify whether PayPal will return to the url specified in the OPACBaseURL option or to the OPAC\'s alias url.','Choice')
19678 SetVersion( $DBversion );
19679 print "Upgrade to $DBversion done (Bug 21701: PayPal return URL option)\n";
19682 $DBversion = '19.06.00.038';
19683 if( CheckVersion( $DBversion ) ) {
19684 $dbh->do( "UPDATE systempreferences SET variable='PatronAutoComplete' WHERE variable='CircAutocompl' LIMIT 1" );
19685 SetVersion( $DBversion );
19686 print "Upgrade to $DBversion done (Bug 23697: Rename CircAutocompl system preference to PatronAutoComplete)\n";
19689 $DBversion = '19.06.00.039';
19690 if( CheckVersion( $DBversion ) ) {
19692 INSERT IGNORE INTO keyboard_shortcuts (shortcut_name, shortcut_keys) VALUES
19693 ("copy_line","Ctrl-C"),
19694 ("copy_subfield","Shift-Ctrl-C"),
19695 ("paste_line","Ctrl-P"),
19696 ("insert_line","Ctrl-I")
19699 SetVersion( $DBversion );
19700 print "Upgrade to $DBversion done (Bug 17179: Add additional keyboard_shortcuts)\n";
19703 $DBversion = '19.06.00.040';
19704 if( CheckVersion( $DBversion ) ) {
19706 INSERT IGNORE INTO systempreferences
19707 (variable,value,explanation,options,type)
19709 ('RoundFinesAtPayment','0','If enabled any fines with fractions of a cent will be rounded to the nearest cent when payments are collected. e.g. 1.004 will be paid off by a 1.00 payment','0','YesNo')
19712 SetVersion( $DBversion );
19713 print "Upgrade to $DBversion done (Bug 17140: Add pref to allow rounding fines at payment)\n";
19716 $DBversion = '19.06.00.041';
19717 if( CheckVersion( $DBversion ) ) {
19718 my ($socialnetworks) = $dbh->selectrow_array( q|
19719 SELECT value FROM systempreferences WHERE variable='socialnetworks';
19721 if( $socialnetworks ){
19722 # If the socialnetworks preference is enabled, enable all social networks
19723 $dbh->do("UPDATE systempreferences SET value = 'email,facebook,linkedin,twitter', explanation = 'email|facebook|linkedin|twitter', type = 'multiple' WHERE variable = 'SocialNetworks'");
19725 $dbh->do("UPDATE systempreferences SET value = '', explanation = 'email|facebook|linkedin|twitter', type = 'multiple' WHERE variable = 'SocialNetworks'");
19727 SetVersion ($DBversion);
19728 print "Upgrade to $DBversion done (Bug 22880: Allow granular control of socialnetworks preference)\n";
19731 $DBversion = '19.06.00.042';
19732 if( CheckVersion( $DBversion ) ) {
19734 INSERT IGNORE INTO systempreferences
19735 ( variable, value, options, explanation, type )
19737 ('CustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed in the staff client. CustomCoverImagesURL must be defined.','YesNo'),
19738 ('OPACCustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed at the OPAC. CustomCoverImagesURL must be defined.','YesNo'),
19739 ('CustomCoverImagesURL','',NULL,'Define an URL serving book cover images, using the following patterns: {issn}, {isbn}, {normalized_isbn}, {field$subfield} (use it with CustomCoverImages and/or OPACCustomCoverImages)','free')
19742 SetVersion( $DBversion );
19743 print "Upgrade to $DBversion done (Bug 22445: Add new pref *CustomCoverImages*)\n";
19746 $DBversion = '19.06.00.043';
19747 if ( CheckVersion($DBversion) ) {
19749 # Adding account_debit_types
19750 if ( !TableExists('account_debit_types') ) {
19753 CREATE TABLE account_debit_types (
19754 code varchar(80) NOT NULL,
19755 description varchar(200) NULL,
19756 can_be_added_manually tinyint(4) NOT NULL DEFAULT 1,
19757 default_amount decimal(28, 6) NULL,
19758 is_system tinyint(1) NOT NULL DEFAULT 0,
19759 archived tinyint(1) NOT NULL DEFAULT 0,
19761 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
19766 # Adding account_debit_types_branches
19767 if ( !TableExists('account_debit_types_branches') ) {
19770 CREATE TABLE account_debit_types_branches (
19771 debit_type_code VARCHAR(80),
19772 branchcode VARCHAR(10),
19773 FOREIGN KEY (debit_type_code) REFERENCES account_debit_types(code) ON DELETE CASCADE,
19774 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
19775 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
19780 # Populating account_debit_types
19783 INSERT IGNORE INTO account_debit_types (
19786 can_be_added_manually,
19791 ('ACCOUNT', 'Account creation fee', 0, NULL, 1),
19792 ('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
19793 ('RESERVE_EXPIRED', 'Hold waiting too long', 0, NULL, 1),
19794 ('LOST', 'Lost item', 1, NULL, 1),
19795 ('MANUAL', 'Manual fee', 1, NULL, 0),
19796 ('NEW_CARD', 'New card fee', 1, NULL, 1),
19797 ('OVERDUE', 'Overdue fine', 0, NULL, 1),
19798 ('PROCESSING', 'Lost item processing fee', 0, NULL, 1),
19799 ('RENT', 'Rental fee', 0, NULL, 1),
19800 ('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
19801 ('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
19802 ('RENT_DAILY_RENEW', 'Renewal of daily rental item', 0, NULL, 1),
19803 ('RESERVE', 'Hold fee', 0, NULL, 1)
19807 # Update accountype 'Res' to 'RESERVE'
19810 UPDATE accountlines SET accounttype = 'RESERVE' WHERE accounttype = 'Res'
19814 # Update accountype 'PF' to 'PROCESSING'
19817 UPDATE accountlines SET accounttype = 'PROCESSING' WHERE accounttype = 'PF'
19821 # Update accountype 'HE' to 'RESERVE_EXPIRED'
19824 UPDATE accountlines SET accounttype = 'RESERVE_EXPIRED' WHERE accounttype = 'HE'
19828 # Update accountype 'N' to 'NEW_CARD'
19831 UPDATE accountlines SET accounttype = 'NEW_CARD' WHERE accounttype = 'N'
19835 # Update accountype 'M' to 'MANUAL'
19838 UPDATE accountlines SET accounttype = 'MANUAL' WHERE accounttype = 'M'
19842 # Catch 'F' cases introduced since bug 22521
19847 accounttype = 'OVERDUE',
19848 status = 'RETURNED'
19853 # Moving MANUAL_INV to account_debit_types
19856 INSERT IGNORE INTO account_debit_types (
19860 can_be_added_manually,
19872 category = 'MANUAL_INV'
19876 # Update uncaught partial accounttypes left behind after bugs 23539 and 22521
19877 my $sth = $dbh->prepare( "SELECT code, SUBSTR(code, 1,5) AS subcode FROM account_debit_types" );
19879 while ( my $row = $sth->fetchrow_hashref ) {
19882 UPDATE accountlines SET accounttype = ? WHERE accounttype = ?
19892 # Add any unexpected accounttype codes to debit_types as appropriate
19895 INSERT IGNORE INTO account_debit_types (
19898 can_be_added_manually,
19903 DISTINCT(accounttype),
19904 "Unexpected type found during upgrade",
19915 # Adding debit_type_code to accountlines
19916 unless ( column_exists('accountlines', 'debit_type_code') ) {
19919 ALTER TABLE accountlines
19921 debit_type_code varchar(80) DEFAULT NULL
19928 # Linking debit_type_code in accountlines to code in account_debit_types
19929 unless ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_debit_type' ) ) {
19932 ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON DELETE RESTRICT ON UPDATE CASCADE
19937 # Populating debit_type_code
19940 UPDATE accountlines SET debit_type_code = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_debit_types) AND amount >= 0
19944 # Remove MANUAL_INV
19947 DELETE FROM authorised_values WHERE category = 'MANUAL_INV'
19952 DELETE FROM authorised_value_categories WHERE category_name = 'MANUAL_INV'
19956 # Add new permission
19959 INSERT IGNORE INTO permissions (module_bit, code, description)
19964 'Manage Account Debit and Credit Types'
19969 SetVersion($DBversion);
19970 print "Upgrade to $DBversion done (Bug 23049: Add account debit_types)\n";
19973 $DBversion = '19.06.00.044';
19974 if ( CheckVersion($DBversion) ) {
19976 # Adding account_credit_types
19977 if ( !TableExists('account_credit_types') ) {
19980 CREATE TABLE account_credit_types (
19981 code varchar(80) NOT NULL,
19982 description varchar(200) NULL,
19983 can_be_added_manually tinyint(4) NOT NULL DEFAULT 1,
19984 is_system tinyint(1) NOT NULL DEFAULT 0,
19986 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
19991 # Adding account_credit_types_branches
19992 if ( !TableExists('account_credit_types_branches') ) {
19995 CREATE TABLE account_credit_types_branches (
19996 credit_type_code VARCHAR(80),
19997 branchcode VARCHAR(10),
19998 FOREIGN KEY (credit_type_code) REFERENCES account_credit_types(code) ON DELETE CASCADE,
19999 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
20000 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
20005 # Populating account_credit_types
20008 INSERT IGNORE INTO account_credit_types (
20011 can_be_added_manually,
20015 ('PAYMENT', 'Payment', 0, 1),
20016 ('WRITEOFF', 'Writeoff', 0, 1),
20017 ('FORGIVEN', 'Forgiven', 1, 1),
20018 ('CREDIT', 'Credit', 1, 1),
20019 ('LOST_RETURN', 'Lost item fee refund', 0, 1)
20023 # Adding credit_type_code to accountlines
20024 unless ( column_exists('accountlines', 'credit_type_code') ) {
20027 ALTER TABLE accountlines
20029 credit_type_code varchar(80) DEFAULT NULL
20036 # Catch LOST_RETURNED cases from original bug 22563 update
20039 UPDATE accountlines
20040 SET accounttype = 'LOST_RETURN'
20041 WHERE accounttype = 'LOST_RETURNED'
20044 # Linking credit_type_code in accountlines to code in account_credit_types
20045 unless ( foreign_key_exists( 'accountlines', 'accountlines_ibfk_credit_type' ) ) {
20048 ALTER TABLE accountlines
20050 `accountlines_ibfk_credit_type`
20051 FOREIGN KEY (`credit_type_code`) REFERENCES `account_credit_types` (`code`)
20058 # Update accountype 'C' to 'CREDIT'
20061 UPDATE accountlines SET accounttype = 'CREDIT' WHERE accounttype = 'C' OR accounttype = 'CR'
20065 # Update accountype 'FOR' to 'FORGIVEN'
20068 UPDATE accountlines SET accounttype = 'FORGIVEN' WHERE accounttype = 'FOR' OR accounttype = 'FORW'
20072 # Update accountype 'Pay' to 'PAYMENT'
20075 UPDATE accountlines SET accounttype = 'PAYMENT' WHERE accounttype = 'Pay' OR accounttype = 'PAY'
20079 # Update accountype 'W' to 'WRITEOFF'
20082 UPDATE accountlines SET accounttype = 'WRITEOFF' WHERE accounttype = 'W' OR accounttype = 'WO'
20086 # Add any unexpected accounttype codes to credit_types as appropriate
20089 INSERT IGNORE INTO account_credit_types (
20092 can_be_added_manually,
20096 DISTINCT(accounttype),
20097 "Unexpected type found during upgrade",
20107 # Populating credit_type_code
20113 credit_type_code = accounttype, accounttype = NULL
20114 WHERE accounttype IN (SELECT code from account_credit_types)
20118 # Drop accounttype field
20121 ALTER TABLE accountlines
20122 DROP COLUMN `accounttype`
20126 SetVersion($DBversion);
20127 print "Upgrade to $DBversion done (Bug 23805: Add account credit_types)\n";
20130 $DBversion = '19.06.00.045';
20131 if( CheckVersion( $DBversion ) ) {
20132 $dbh->do( "UPDATE systempreferences SET value = '2' WHERE value = '0' AND variable = 'UsageStats'" );
20134 SetVersion( $DBversion );
20135 print "Upgrade to $DBversion done (Bug 23866: Set HEA syspref to prompt for review)\n";
20138 $DBversion = '19.06.00.046';
20139 if( CheckVersion( $DBversion ) ) {
20141 UPDATE systempreferences
20143 options = "Calendar|Days|Datedue|Dayweek",
20144 explanation = "Choose the method for calculating due date: select Calendar, Datedue or Dayweek to use the holidays module, and Days to ignore the holidays module"
20146 variable = "useDaysMode"
20149 # Always end with this (adjust the bug info)
20150 SetVersion( $DBversion );
20151 print "Upgrade to $DBversion done (Bug 15260: Option for extended loan with useDaysMode)\n";
20154 $DBversion = '19.06.00.047';
20155 if ( CheckVersion($DBversion) ) {
20156 if ( !TableExists('return_claims') ) {
20159 CREATE TABLE return_claims (
20160 id int(11) auto_increment, -- Unique ID of the return claim
20161 itemnumber int(11) NOT NULL, -- ID of the item
20162 issue_id int(11) NULL DEFAULT NULL, -- ID of the checkout that triggered the claim
20163 borrowernumber int(11) NOT NULL, -- ID of the patron
20164 notes MEDIUMTEXT DEFAULT NULL, -- Notes about the claim
20165 created_on TIMESTAMP NULL, -- Time and date the claim was created
20166 created_by int(11) NULL DEFAULT NULL, -- ID of the staff member that registered the claim
20167 updated_on TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, -- Time and date of the latest change on the claim (notes)
20168 updated_by int(11) NULL DEFAULT NULL, -- ID of the staff member that updated the claim
20169 resolution varchar(80) NULL DEFAULT NULL, -- Resolution code (RETURN_CLAIM_RESOLUTION AVs)
20170 resolved_on TIMESTAMP NULL DEFAULT NULL, -- Time and date the claim was resolved
20171 resolved_by int(11) NULL DEFAULT NULL, -- ID of the staff member that resolved the claim
20172 PRIMARY KEY (`id`),
20173 KEY `itemnumber` (`itemnumber`),
20174 CONSTRAINT UNIQUE `issue_id` ( issue_id ),
20175 CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE,
20176 CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
20177 CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
20178 CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
20179 CONSTRAINT `rc_updated_by_ibfk` FOREIGN KEY (`updated_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
20180 CONSTRAINT `rc_resolved_by_ibfk` FOREIGN KEY (`resolved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
20181 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20188 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
20189 ('ClaimReturnedChargeFee', 'ask', 'ask|charge|no_charge', 'Controls whether or not a lost item fee is charged for return claims', 'Choice'),
20190 ('ClaimReturnedLostValue', '', '', 'Sets the LOST AV value that represents "Claims returned" as a lost value', 'Free'),
20191 ('ClaimReturnedWarningThreshold', '', '', 'Sets the number of return claims past which the librarian will be warned the patron has many return claims', 'Integer');
20197 INSERT IGNORE INTO authorised_value_categories ( category_name ) VALUES
20198 ('RETURN_CLAIM_RESOLUTION');
20204 INSERT IGNORE INTO `authorised_values` ( category, authorised_value, lib )
20206 ('RETURN_CLAIM_RESOLUTION', 'RET_BY_PATRON', 'Returned by patron'),
20207 ('RETURN_CLAIM_RESOLUTION', 'FOUND_IN_LIB', 'Found in library');
20211 SetVersion($DBversion);
20213 "Upgrade to $DBversion done (Bug 14697: Extend and enhance 'Claims returned' lost status)\n";
20216 $DBversion = '19.06.00.048';
20217 if( CheckVersion( $DBversion ) ) {
20218 # you can use $dbh here like:
20220 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
20221 VALUES ('OPACShowMusicalInscripts','0','','Display musical inscripts on the OPAC record details page when available.','YesNo'),
20222 ('OPACPlayMusicalInscripts','0','','If displayed musical inscripts, play midi conversion on the OPAC record details page.','YesNo')
20225 SetVersion( $DBversion );
20226 print "Upgrade to $DBversion done (Bug 22581: add new OPACShowMusicalInscripts and OPACPlayMusicalInscripts system preferences)\n";
20229 $DBversion = '19.06.00.049';
20230 if( CheckVersion( $DBversion ) ) {
20233 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
20235 'SuspensionsCalendar',
20236 IF( value='noFinesWhenClosed', 'noSuspensionsWhenClosed', 'ignoreCalendar'),
20237 'ignoreCalendar|noSuspensionsWhenClosed',
20238 'Specify whether to use the Calendar in calculating suspensions',
20240 FROM systempreferences
20241 WHERE variable='finesCalendar';
20244 SetVersion( $DBversion );
20245 print "Upgrade to $DBversion done (Bug 13958: Add a SuspensionsCalendar syspref)\n";
20248 $DBversion = '19.06.00.050';
20249 if( CheckVersion( $DBversion ) ) {
20251 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
20252 VALUES ('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in OPACFineNoRenewals should include any unapplied account credits in the calculation','YesNo')
20255 SetVersion( $DBversion );
20256 print "Upgrade to $DBversion done (Bug 23293: Add 'OPACFineNoRenewalsIncludeCredits' system preference)\n";
20259 $DBversion = '19.11.00.000';
20260 if( CheckVersion( $DBversion ) ) {
20261 NewVersion( $DBversion, undef, '19.11.00 release' );
20264 $DBversion = '19.12.00.000';
20265 if( CheckVersion( $DBversion ) ) {
20266 NewVersion( $DBversion, undef, 'Dobbie is a free elf...' );
20269 $DBversion = '19.12.00.001';
20270 if( CheckVersion( $DBversion ) ) {
20271 $dbh->do( "UPDATE marc_subfield_structure SET kohafield = NULL WHERE kohafield = 'bibliosubject.subject';" );
20272 NewVersion( $DBversion, 17831, 'Remove non-existing bibliosubject.subject from frameworks' );
20275 $DBversion = '19.12.00.002';
20276 if( CheckVersion( $DBversion ) ) {
20278 UPDATE systempreferences SET
20279 variable = 'AllowItemsOnHoldCheckoutSIP',
20280 explanation = 'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else via SIP. This allows self checkouts for those items.'
20281 WHERE variable = 'AllowItemsOnHoldCheckout'
20284 NewVersion( $DBversion, 23233, 'Rename AllowItemsOnHoldCheckout syspref' );
20287 $DBversion = '19.12.00.003';
20288 if( CheckVersion( $DBversion ) ) {
20290 if( !column_exists( 'library_groups', 'ft_local_hold_group' ) ) {
20291 $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" );
20294 NewVersion( $DBversion, 22284, 'Add ft_local_hold_group column to library_groups' );
20297 $DBversion = '19.12.00.004';
20298 if ( CheckVersion($DBversion) ) {
20302 INSERT IGNORE INTO account_debit_types (
20305 can_be_added_manually,
20310 ('PAYOUT', 'Payment from library to patron', 0, NULL, 1)
20315 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('PAYOUT');
20319 INSERT IGNORE permissions (module_bit, code, description)
20321 (10, 'payout', 'Perform account payout action')
20324 NewVersion( $DBversion, 24080, ['Add PAYOUT account_debit_type', 'Add PAYOUT account_offset_type', 'Add accounts payout permission'] );
20327 $DBversion = '19.12.00.005';
20328 if( CheckVersion( $DBversion ) ) {
20329 $dbh->do( "ALTER TABLE action_logs MODIFY COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP" );
20331 NewVersion( $DBversion, 24329, 'Do not update action_log.timestamp' );
20334 $DBversion = '19.12.00.006';
20335 if( CheckVersion( $DBversion ) ) {
20337 UPDATE borrowers SET relationship = NULL
20338 WHERE relationship = ""
20341 NewVersion( $DBversion, 24263, 'Replace relationship with NULL when empty string' );
20344 $DBversion = '19.12.00.007';
20345 if ( CheckVersion($DBversion) ) {
20349 INSERT IGNORE INTO account_credit_types (code, description, can_be_added_manually, is_system)
20351 ('REFUND', 'A refund applied to a patrons fine', 0, 1)
20356 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('REFUND');
20360 INSERT IGNORE permissions (module_bit, code, description)
20362 (10, 'refund', 'Perform account refund action')
20365 NewVersion( $DBversion, 23442, ['Add REFUND to account_credit_types', 'Add REFUND to account_offset_types', 'Add accounts refund permission'] );
20368 $DBversion = '19.12.00.008';
20369 if( CheckVersion( $DBversion ) ) {
20370 $dbh->do( 'UPDATE systempreferences SET value = REPLACE(value, "http://worldcat.org", "https://worldcat.org") WHERE variable = "OPACSearchForTitleIn"' );
20371 $dbh->do( 'UPDATE systempreferences SET value = REPLACE(value, "http://www.bookfinder.com", "https://www.bookfinder.com") WHERE variable = "OPACSearchForTitleIn"' );
20372 $dbh->do( 'UPDATE systempreferences SET value = REPLACE(value, "https://openlibrary.org/search/?", "https://openlibrary.org/search?") WHERE variable = "OPACSearchForTitleIn"' );
20374 NewVersion( $DBversion, 24206, 'Update OpacSearchForTitleIn system preference' );
20377 $DBversion = '19.12.00.009';
20378 if( CheckVersion( $DBversion ) ) {
20381 INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' );
20385 INSERT IGNORE INTO account_credit_types ( code, description, can_be_added_manually, is_system )
20386 VALUES ('PURCHASE', 'Purchase', 0, 1);
20389 my $sth = $dbh->prepare(q{
20390 SELECT COUNT(*) FROM authorised_values WHERE category = 'PAYMENT_TYPE' AND authorised_value = 'CASH'
20393 my $already_exists = $sth->fetchrow;
20394 if ( not $already_exists ) {
20396 INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('PAYMENT_TYPE','CASH','Cash')
20400 # Updating field in account_debit_types
20401 unless ( column_exists('account_debit_types', 'can_be_invoiced') ) {
20404 ALTER TABLE account_debit_types
20406 can_be_added_manually can_be_invoiced tinyint(1) NOT NULL DEFAULT 1
20410 unless ( column_exists('account_debit_types', 'can_be_sold') ) {
20413 ALTER TABLE account_debit_types
20415 can_be_sold tinyint(1) DEFAULT 0
20423 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
20424 ('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '[% PROCESS "accounts.inc" %]
20426 [% IF ( LibraryName ) %]
20428 <th colspan="2" class="centerednames">
20429 <h3>[% LibraryName | html %]</h3>
20434 <th colspan="2" class="centerednames">
20435 <h2>[% Branches.GetName( payment.branchcode ) | html %]</h2>
20439 <th colspan="2" class="centerednames">
20440 <h3>[% payment.date | $KohaDates %]</h3>
20443 <td>Transaction ID: </td>
20444 <td>[% payment.accountlines_id %]</td>
20447 <td>Operator ID: </td>
20448 <td>[% payment.manager_id %]</td>
20451 <td>Payment type: </td>
20452 <td>[% payment.payment_type %]</td>
20456 <th colspan="2" class="centerednames">
20457 <h2><u>Fee receipt</u></h2>
20462 <th>Description of charges</th>
20466 [% FOREACH offset IN offsets %]
20468 <td>[% PROCESS account_type_description account=offset.debit %]</td>
20469 <td>[% offset.amount * -1 | $Price %]</td>
20474 <tr class="highlight">
20476 <td>[% payment.amount * -1| $Price %]</td>
20479 <td>Tendered: </td>
20480 <td>[% collected | $Price %]</td>
20484 <td>[% change | $Price %]</td>
20487 </table>', 'print', 'default');
20491 INSERT IGNORE permissions (module_bit, code, description)
20493 (25, 'takepayment', 'Access the point of sale page and take payments')
20496 NewVersion( $DBversion, 23354, [q|Add 'Purchase' account offset type|, q|Add 'RECEIPT' notice for Point of Sale|, q|Add point of sale permissions|] );
20499 $DBversion = '19.12.00.010';
20500 if( CheckVersion( $DBversion ) ) {
20501 if( !column_exists( 'oai_sets_mappings', 'rule_order' ) ) {
20502 $dbh->do( "ALTER TABLE oai_sets_mappings ADD COLUMN rule_order INT AFTER set_id, ADD COLUMN rule_operator VARCHAR(3) AFTER rule_order" );
20503 $dbh->do( "UPDATE oai_sets_mappings SET rule_operator='or'" );
20504 my $sets = $dbh->selectall_arrayref("SELECT * from oai_sets_mappings ORDER BY set_id", { Slice => {} });
20506 my $previous_set_id;
20507 for my $set ( @{$sets}) {
20508 my $set_id = $set->{set_id};
20510 if ($previous_set_id && $previous_set_id != $set_id) {
20515 $dbh->do("UPDATE oai_sets_mappings SET rule_operator=NULL WHERE set_id=? LIMIT 1", {}, $set_id);
20518 $dbh->do("UPDATE oai_sets_mappings SET rule_order=? WHERE set_id=? AND rule_order IS NULL LIMIT 1", {}, $i, $set_id);
20521 $previous_set_id = $set_id;
20525 NewVersion( $DBversion, 21520, 'Add rule_order and rule_operator fields to oai_sets_mappings table' );
20528 $DBversion = '19.12.00.011';
20529 if( CheckVersion( $DBversion ) ) {
20530 if( !foreign_key_exists( 'repeatable_holidays', 'repeatable_holidays_ibfk_1' ) ) {
20533 FROM repeatable_holidays h
20534 LEFT JOIN branches b ON h.branchcode=b.branchcode
20535 WHERE b.branchcode IS NULL;
20538 ALTER TABLE repeatable_holidays
20539 ADD FOREIGN KEY repeatable_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
20543 if( !foreign_key_exists( 'special_holidays', 'special_holidays_ibfk_1' ) ) {
20546 FROM special_holidays h
20547 LEFT JOIN branches b ON h.branchcode=b.branchcode
20548 WHERE b.branchcode IS NULL;
20551 ALTER TABLE special_holidays
20552 ADD FOREIGN KEY special_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
20556 NewVersion( $DBversion, 24289, 'Adding foreign keys on *_holidays.branchcode tables' );
20559 $DBversion = '19.12.00.012';
20560 if( CheckVersion( $DBversion ) ) {
20568 `code` = 'manage_cash_registers'
20571 NewVersion( $DBversion, 24481, 'Move permission to correct module_bit' );
20574 $DBversion = '19.12.00.013';
20575 if( CheckVersion( $DBversion ) ) {
20578 systempreferences (variable,value,options,explanation,type)
20580 ('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo')
20583 NewVersion( $DBversion, 24478, 'Add `EnablePointOfSale` system preference to allow disabling the point of sale feature)' );
20586 $DBversion = '19.12.00.014';
20587 if( CheckVersion( $DBversion ) ) {
20588 unless ( column_exists('branchtransfers', 'reason') ) {
20591 ALTER TABLE branchtransfers
20593 `reason` enum('Manual')
20600 NewVersion( $DBversion, 24287, q|Add 'reason' field to transfers table| );
20603 $DBversion = '19.12.00.015';
20604 if( CheckVersion( $DBversion ) ) {
20606 # Add stockrotation states to reason enum
20614 'StockrotationAdvance',
20615 'StockrotationRepatriation'
20621 # Move stockrotation states to reason field
20627 `reason` = 'StockrotationAdvance',
20630 `comments` = 'StockrotationAdvance'
20638 `reason` = 'StockrotationRepatriation',
20641 `comments` = 'StockrotationRepatriation'
20645 NewVersion( $DBversion, 24296, q|Update stockrotation to use 'reason' field in transfers table| );
20648 $DBversion = '19.12.00.016';
20649 if( CheckVersion( $DBversion ) ) {
20651 INSERT IGNORE INTO `userflags` (`bit`, `flag`, `flagdesc`, `defaulton`)
20652 VALUES (12, 'suggestions', 'Suggestion management', 0)
20656 UPDATE permissions SET module_bit=12
20657 WHERE code="suggestions_manage"
20661 UPDATE borrowers SET flags = flags | (1<<12) WHERE flags & (1 << 11)
20664 NewVersion( $DBversion, 22868, 'Move suggestions_manage subpermission out of acquisition permission' );
20667 $DBversion = '19.12.00.017';
20668 if( CheckVersion( $DBversion ) ) {
20669 if( !index_exists( 'library_groups', 'library_groups_uniq_2' ) ) {
20671 DELETE FROM library_groups
20674 FROM ( SELECT * FROM library_groups ) AS lg
20675 GROUP BY parent_id, branchcode
20677 AND NOT(parent_id IS NULL OR branchcode IS NULL);
20680 ALTER TABLE library_groups
20681 ADD UNIQUE KEY library_groups_uniq_2 (parent_id, branchcode)
20685 NewVersion( $DBversion, 21674, 'Add unique key (parent_id, branchcode) to library_group' );
20688 $DBversion = '19.12.00.018';
20689 if( CheckVersion( $DBversion ) ) {
20696 suspension_chargeperiod
20699 chargeperiod_charge_at
20709 no_auto_renewal_after
20710 no_auto_renewal_after_hard_limit
20717 cap_fine_to_replacement_price
20723 DELETE i FROM issuingrules i
20724 LEFT JOIN itemtypes it ON i.itemtype=it.itemtype
20725 WHERE it.itemtype IS NULL AND i.itemtype!='*'
20728 DELETE i FROM issuingrules i
20729 LEFT JOIN branches b ON i.branchcode=b.branchcode
20730 WHERE b.branchcode IS NULL AND i.branchcode!='*'
20733 DELETE i FROM issuingrules i
20734 LEFT JOIN categories c ON i.categorycode=c.categorycode
20735 WHERE c.categorycode IS NULL AND i.categorycode!='*'
20737 if ( column_exists( 'issuingrules', 'categorycode' ) ) {
20738 foreach my $column ( @columns ) {
20740 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
20741 SELECT IF(categorycode='*', NULL, categorycode), IF(branchcode='*', NULL, branchcode), IF(itemtype='*', NULL, itemtype), \'$column\', COALESCE( $column, '' )
20746 DELETE FROM circulation_rules WHERE rule_name='holdallowed' AND rule_value='';
20748 $dbh->do("DROP TABLE issuingrules");
20751 NewVersion( $DBversion, 18936, 'Convert issuingrules fields to circulation_rules' );
20754 $DBversion = '19.12.00.019';
20755 if( CheckVersion( $DBversion ) ) {
20757 $dbh->do("ALTER TABLE message_queue MODIFY time_queued timestamp NULL");
20759 if( !column_exists( 'message_queue', 'updated_on' ) ) {
20760 $dbh->do("ALTER TABLE message_queue ADD COLUMN updated_on timestamp NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER time_queued");
20761 $dbh->do("UPDATE message_queue SET updated_on=time_queued");
20764 NewVersion( $DBversion, 23673, 'modify time_queued and add updated_on to message_queue' );
20767 $DBversion = '19.12.00.020';
20768 if ( CheckVersion($DBversion) ) {
20769 if ( !column_exists( 'marc_subfield_structure', 'important') ){
20770 $dbh->do("ALTER TABLE marc_subfield_structure ADD COLUMN important TINYINT(4) NOT NULL DEFAULT 0 AFTER mandatory");
20772 if ( !column_exists( 'marc_tag_structure', 'important') ){
20773 $dbh->do("ALTER TABLE marc_tag_structure ADD COLUMN important TINYINT(4) NOT NULL DEFAULT 0 AFTER mandatory");
20776 NewVersion( $DBversion, 8643, 'Add important constraint to marc subfields' );
20779 $DBversion = '19.12.00.021';
20780 if( CheckVersion( $DBversion ) ) {
20782 # Add LOST_FOUND debit type
20785 account_credit_types ( code, description, can_be_added_manually, is_system )
20787 ('LOST_FOUND', 'Lost item fee refund', 0, 1)
20790 # Migrate LOST_RETURN to LOST_FOUND
20795 credit_type_code = 'LOST_FOUND'
20797 credit_type_code = 'LOST_RETURN'
20799 credit_type_code = 'LOST_RETURNED'
20802 # Migrate LOST + RETURNED to LOST + FOUND
20809 debit_type_code = 'LOST'
20811 status = 'RETURNED'
20814 # Drop LOST_RETURNED credit type
20816 DELETE FROM account_credit_types WHERE code = 'LOST_RETURNED'
20819 # Drop LOST_RETURN credit type
20821 DELETE FROM account_credit_types WHERE code = 'LOST_RETURN'
20824 # Add Lost Item Found offset type
20827 account_offset_types ( type )
20829 ( 'Lost Item Found' )
20832 NewVersion( $DBversion, 24592, 'Update LOST_RETURN to LOST_FOUND');
20835 $DBversion = '19.12.00.022';
20836 if( CheckVersion( $DBversion ) ) {
20837 $dbh->do( "ALTER TABLE items MODIFY COLUMN uri MEDIUMTEXT" );
20838 $dbh->do( "ALTER TABLE deleteditems MODIFY COLUMN uri MEDIUMTEXT" );
20840 NewVersion( $DBversion, 20882, 'items.uri to MEDIUMTEXT');
20843 $DBversion = '19.12.00.023';
20844 if( CheckVersion( $DBversion ) ) {
20845 $dbh->do( "ALTER TABLE quotes MODIFY timestamp datetime NULL" );
20847 NewVersion( $DBversion, 24640, 'Allow quotes.timestamp to be NULL');
20850 $DBversion = '19.12.00.024';
20851 if( CheckVersion( $DBversion ) ) {
20853 UPDATE systempreferences SET value = 'off'
20854 WHERE variable = 'finesMode' AND (value <> 'production' OR value IS NULL)
20857 UPDATE systempreferences SET options = 'off|production',
20858 explanation = "Choose the fines mode, 'off' (do not accrue fines) or 'production' (accrue overdue fines). Requires accruefines cronjob or CalculateFinesOnReturn system preference."
20859 WHERE variable = 'finesMode'
20862 NewVersion( $DBversion, 21633, 'Remove finesMode "test"');
20865 $DBversion = '19.12.00.025';
20866 if( CheckVersion( $DBversion ) ) {
20868 INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type)
20869 VALUES ('DumpSearchQueryTemplate',0,'','Add the search query being passed to the search engine into the template for debugging','YesNo')
20872 NewVersion( $DBversion, 24103, 'add DumpSearchQueryTemplate syspref');
20875 $DBversion = '19.12.00.026';
20876 if( CheckVersion( $DBversion ) ) {
20877 if( !column_exists( 'z3950servers', 'attributes' ) ) {
20878 $dbh->do( "ALTER TABLE z3950servers ADD COLUMN attributes VARCHAR(255) after add_xslt" );
20881 NewVersion( $DBversion, 11297, 'Add support for custom PQF attributes for Z39.50 server searches');
20884 $DBversion = '19.12.00.027';
20885 if( CheckVersion( $DBversion ) ) {
20887 # Add any pathalogical incorrect debit_types as credit_types as appropriate
20890 INSERT IGNORE INTO account_credit_types (
20893 can_be_added_manually,
20897 DISTINCT(debit_type_code),
20898 "Unexpected type found during upgrade",
20906 debit_type_code IS NOT NULL
20910 # Correct any pathalogical cases
20915 credit_type_code = debit_type_code,
20916 debit_type_code = NULL
20920 debit_type_code IS NOT NULL
20923 NewVersion( $DBversion, 24532, 'Fix pathological cases of negative debits');
20926 $DBversion = '19.12.00.028';
20927 if( CheckVersion( $DBversion ) ) {
20929 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
20931 ('OpacBrowseSearch', '0',NULL, "Elasticsearch only: add a page allowing users to 'browse' all items in the collection",'YesNo')
20934 NewVersion( $DBversion, 14567, 'Add OpacBrowseSearch syspref');
20937 $DBversion = '19.12.00.029';
20938 if( CheckVersion( $DBversion ) ) {
20939 if (!column_exists('account_credit_types', 'archived')) {
20940 $dbh->do('ALTER TABLE account_credit_types ADD COLUMN archived tinyint(1) NOT NULL DEFAULT 0 AFTER is_system');
20943 NewVersion( $DBversion, 17702, 'Add column account_credit_types.archived');
20946 $DBversion = '19.12.00.030';
20947 if( CheckVersion( $DBversion ) ) {
20949 # get list of installed translations
20950 require C4::Languages;
20952 my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
20954 foreach my $language ( @$tlangs ) {
20955 foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
20956 push @langs, $sublanguage->{'rfc4646_subtag'};
20960 # Get any existing value from the opacheader system preference
20961 my ($opacheader) = $dbh->selectrow_array( q|
20962 SELECT value FROM systempreferences WHERE variable='opacheader';
20967 foreach my $lang ( @langs ) {
20968 # If there is a value in the opacheader preference, insert it into opac_news
20969 $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "opacheader_$lang", $opacheader);
20970 push @detail, "Inserted opacheader contents into $lang news item...";
20973 # Remove the opacheader system preference
20974 $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'");
20976 unshift @detail, 'Move contents of opacheader preference to Koha news system';
20977 NewVersion( $DBversion, 22880, \@detail);
20980 $DBversion = '19.12.00.031';
20981 if( CheckVersion( $DBversion ) ) {
20983 ALTER TABLE article_requests MODIFY COLUMN created_on timestamp NULL, MODIFY COLUMN updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
20986 NewVersion( $DBversion, 22273, "Column article_requests.created_on should not be updated" );
20989 $DBversion = '19.12.00.032';
20990 if( CheckVersion( $DBversion ) ) {
20992 DELETE FROM systempreferences WHERE variable="UseQueryParser"
20995 NewVersion( $DBversion, 24735, "Remove UseQueryParser system preference" );
20998 $DBversion = '19.12.00.033';
20999 if ( CheckVersion($DBversion) ) {
21001 # Add cash_register_actions table
21002 if ( !TableExists('cash_register_actions') ) {
21004 CREATE TABLE `cash_register_actions` (
21005 `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register action
21006 `code` varchar(24) NOT NULL, -- action code denoting the type of action recorded (enum),
21007 `register_id` int(11) NOT NULL, -- id of cash_register this action belongs to,
21008 `manager_id` int(11) NOT NULL, -- staff member performing the action
21009 `amount` decimal(28,6) DEFAULT NULL, -- amount recorded in action (signed)
21010 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
21011 PRIMARY KEY (`id`),
21012 CONSTRAINT `cash_register_actions_manager` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
21013 CONSTRAINT `cash_register_actions_register` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
21014 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
21018 # Add cashup permission
21020 INSERT IGNORE permissions (module_bit, code, description)
21022 (25, 'cashup', 'Perform cash register cashup action')
21025 NewVersion( $DBversion, 23355, [ "Add cash_register_actions table", "Add cash register cashup permissions" ] );
21028 $DBversion = '19.12.00.034';
21029 if ( CheckVersion($DBversion) ) {
21033 INSERT IGNORE INTO account_credit_types (code, description, can_be_added_manually, is_system)
21035 ('DISCOUNT', 'A discount applied to a patrons fine', 0, 1)
21041 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('DISCOUNT');
21047 INSERT IGNORE permissions (module_bit, code, description)
21049 (10, 'discount', 'Perform account discount action')
21053 NewVersion( $DBversion, 24081, "Add DISCOUNT to account_credit_types and account_offset_types, Add accounts discount permission");
21056 $DBversion = '19.12.00.035';
21057 if ( CheckVersion($DBversion) ) {
21060 INSERT IGNORE permissions (module_bit, code, description)
21062 (25, 'anonymous_refund', 'Perform refund actions from cash registers')
21065 NewVersion( $DBversion, 23442, "Add a refund option to the point of sale system" );
21068 $DBversion = '19.12.00.036';
21069 if( CheckVersion( $DBversion ) ) {
21071 INSERT IGNORE INTO `systempreferences`
21072 (`variable`, `value`, `options`, `explanation`, `type`)
21074 ('AccessControlAllowOrigin', '', NULL, 'Set the Access-Control-Allow-Origin header to the specified value', 'Free');
21077 NewVersion( $DBversion, 24369, "Add CORS support to Koha");
21080 $DBversion = '19.12.00.037';
21081 if( CheckVersion( $DBversion ) ) {
21083 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemInOpac', '0', 'If enabled, when the fines on an item accruing is paid off in the OPAC via a payment plugin, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue', '', 'YesNo'); | );
21085 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemWhenPaid', '0', 'If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue', '', 'YesNo'); | );
21087 NewVersion( $DBversion, 23051, [ "Add RenewAccruingItemInOpac syspref", "Add RenewAccruingItemWhenPaid syspref" ]);
21090 $DBversion = '19.12.00.038';
21091 if( CheckVersion( $DBversion ) ) {
21092 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CirculateILL', '0', 'If enabled, it is possible to circulate ILL requested items from within ILL', '', 'YesNo'); | );
21094 NewVersion( $DBversion, 23112, "Add CirculateILL syspref");
21097 $DBversion = '19.12.00.039';
21098 if( CheckVersion( $DBversion ) ) {
21099 $dbh->do( "DROP TABLE IF EXISTS printers" );
21101 if( column_exists( 'branches', 'branchprinter' ) ) {
21102 $dbh->do( "ALTER TABLE branches DROP COLUMN branchprinter" );
21105 $dbh->do(qq{ DELETE FROM systempreferences WHERE variable = "printcirculationslips"} );
21107 NewVersion( $DBversion, 17845, "Drop unused table printers and branchprinter column");
21110 $DBversion = '19.12.00.040';
21111 if( CheckVersion( $DBversion ) ) {
21112 $dbh->do( "UPDATE systempreferences SET explanation = 'Comma separated list defining the default fields to be used during a patron search using the \"standard\" option. If empty Koha will default to \"surname,firstname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.' WHERE variable='DefaultPatronSearchFields' " );
21114 NewVersion( $DBversion, 17374, "Update description of DefaultPatronSearchFields");
21117 $DBversion = '19.12.00.041';
21118 if( CheckVersion( $DBversion ) ) {
21120 # Update existing NULL priorities
21122 UPDATE reserves SET priority = 1 WHERE priority IS NULL
21126 ALTER TABLE reserves MODIFY priority SMALLINT(6) NOT NULL DEFAULT 1
21130 UPDATE old_reserves SET priority = 1 WHERE priority IS NULL
21134 ALTER TABLE old_reserves MODIFY priority SMALLINT(6) NOT NULL DEFAULT 1
21137 NewVersion( $DBversion, 24722, "Enforce NOT NULL constraint for reserves.priority");
21140 $DBversion = '19.12.00.042';
21141 if( CheckVersion( $DBversion ) ) {
21142 if (!column_exists('message_queue', 'reply_address')) {
21143 $dbh->do('ALTER TABLE message_queue ADD COLUMN reply_address LONGTEXT AFTER from_address');
21146 NewVersion( $DBversion, 22821, "Add reply_address to message_queue");
21149 $DBversion = '19.12.00.043';
21150 if( CheckVersion( $DBversion ) ) {
21152 # Add return reasons to enum
21160 'StockrotationAdvance',
21161 'StockrotationRepatriation',
21169 NewVersion( $DBversion, 24296, "Add 'return' reasons to branchtransfers enum");
21172 $DBversion = '19.12.00.044';
21173 if( CheckVersion( $DBversion ) ) {
21175 INSERT IGNORE permissions (module_bit, code, description)
21177 (13, 'batch_extend_due_dates', 'Perform batch extend due dates')
21180 NewVersion( $DBversion, 24846, "Add a new permission for new tool batch extend due dates");
21183 $DBversion = '19.12.00.045';
21184 if( CheckVersion( $DBversion ) ) {
21186 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
21188 ('CollapseFieldsPatronAddForm','',NULL,'Collapse these fields by default when adding a new patron. These fields can still be expanded.','Multiple')
21191 NewVersion( $DBversion, 4461, "Add CollapseFieldsPatronAddForm system preference");
21194 $DBversion = '19.12.00.046';
21195 if( CheckVersion( $DBversion ) ) {
21197 $dbh->do( "ALTER TABLE accountlines MODIFY COLUMN date TIMESTAMP NULL" );
21199 NewVersion( $DBversion, 24818, "Update 'accountlines.date' from DATE to TIMESTAMP");
21202 $DBversion = '19.12.00.047';
21203 if( CheckVersion( $DBversion ) ) {
21205 ALTER TABLE biblioimages
21206 ADD `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
21210 NewVersion( $DBversion, 22987, "Add biblioimages.timestamp");
21213 $DBversion = '19.12.00.048';
21214 if( CheckVersion( $DBversion ) ) {
21216 # Add rotating collection states to reason enum
21224 'StockrotationAdvance',
21225 'StockrotationRepatriation',
21228 'RotatingCollection'
21234 NewVersion( $DBversion, 24299, "Add 'collection' reasons to branchtransfers enum");
21237 $DBversion = '19.12.00.049';
21238 if( CheckVersion( $DBversion ) ) {
21240 # Add reserve reasons enum
21248 'StockrotationAdvance',
21249 'StockrotationRepatriation',
21252 'RotatingCollection',
21261 NewVersion( $DBversion, 24299, "Add 'reserve' reasons to branchtransfers enum");
21264 $DBversion = '19.12.00.050';
21265 if( CheckVersion( $DBversion ) ) {
21266 $dbh->do( "DELETE FROM systempreferences WHERE variable in ('IDreamBooksReadometer','IDreamBooksResults','IDreamBooksReviews')" );
21268 NewVersion( $DBversion, 24854, "Remove IDreamBooks* system preferences");
21271 $DBversion = '19.12.00.051';
21272 if( CheckVersion( $DBversion ) ) {
21274 UPDATE systempreferences SET options = 'itemhomebranch|patronhomebranch|checkoutbranch|none' WHERE variable='OpacRenewalBranch'
21277 UPDATE systempreferences SET value = "none" WHERE variable='OpacRenewalBranch'
21281 UPDATE systempreferences SET value = 'opacrenew' WHERE variable='OpacRenewalBranch'
21282 AND value NOT IN ('checkoutbranch','itemhomebranch','opacrenew','patronhomebranch','none')
21285 NewVersion( $DBversion, 24759, "Cleanup OpacRenewalBranch");
21288 $DBversion = '19.12.00.052';
21289 if( CheckVersion( $DBversion ) ) {
21290 my $finesCalendar = C4::Context->preference('finesCalendar');
21291 my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0;
21293 if( !column_exists( 'itemtypes', 'rentalcharge_daily_calendar' ) ) {
21295 ALTER TABLE itemtypes ADD COLUMN
21296 rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1
21297 AFTER rentalcharge_daily;
21300 $dbh->do("UPDATE itemtypes SET rentalcharge_daily_calendar = $value");
21303 if( !column_exists( 'itemtypes', 'rentalcharge_hourly_calendar' ) ) {
21305 ALTER TABLE itemtypes ADD COLUMN
21306 rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1
21307 AFTER rentalcharge_hourly;
21310 $dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value");
21313 NewVersion( $DBversion, 21443, "Add ability to exclude holidays when calculating rentals fees by time period");
21316 $DBversion = '19.12.00.053';
21317 if( CheckVersion( $DBversion ) ) {
21318 unless( column_exists('borrowers','autorenew_checkouts') ){
21319 $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
21321 unless( column_exists('deletedborrowers','autorenew_checkouts') ){
21322 $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
21325 INSERT IGNORE INTO systempreferences
21326 ( `variable`, `value`, `options`, `explanation`, `type` )
21328 ('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account to choose whether their checkouts are auto renewed or not','YesNo')
21331 NewVersion( $DBversion, 24476, "Allow patrons to opt-out of autorenewal");
21334 $DBversion = '19.12.00.054';
21335 if( CheckVersion( $DBversion ) ) {
21337 if ( !TableExists('desks') ) {
21339 CREATE TABLE `desks` ( -- desks available in a library
21340 `desk_id` int(11) NOT NULL auto_increment, -- unique identifier added by Koha
21341 `desk_name` varchar(100) NOT NULL default '', -- name of the desk
21342 `branchcode` varchar(10) NOT NULL, -- library the desk is located at
21343 PRIMARY KEY (`desk_id`),
21344 KEY `fk_desks_branchcode` (`branchcode`),
21345 CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
21346 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21350 NewVersion( $DBversion, 13881, "Add desk management");
21353 $DBversion = '19.12.00.055';
21354 if( CheckVersion( $DBversion ) ) {
21355 if( !column_exists( 'suggestions', 'lastmodificationby' ) ) {
21357 ALTER TABLE suggestions ADD COLUMN lastmodificationby INT(11) DEFAULT NULL AFTER rejecteddate
21361 ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_lastmodificationby` FOREIGN KEY (`lastmodificationby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
21365 if( !column_exists( 'suggestions', 'lastmodificationdate' ) ) {
21367 ALTER TABLE suggestions ADD COLUMN lastmodificationdate DATE DEFAULT NULL AFTER lastmodificationby
21370 my $suggestions = $dbh->selectall_arrayref(q|
21371 SELECT suggestionid, managedby, manageddate, acceptedby, accepteddate, rejectedby, rejecteddate
21373 |, { Slice => {} });
21374 for my $suggestion ( @$suggestions ) {
21375 my ( $max_date ) = sort ( $suggestion->{manageddate} || (), $suggestion->{accepteddate} || (), $suggestion->{rejecteddate} || () );
21376 next unless $max_date;
21377 my $last_modif_by = ( defined $suggestion->{manageddate} and $max_date eq $suggestion->{manageddate} )
21378 ? $suggestion->{managedby}
21379 : ( defined $suggestion->{accepteddate} and $max_date eq $suggestion->{accepteddate} )
21380 ? $suggestion->{acceptedby}
21381 : ( defined $suggestion->{rejecteddate} and $max_date eq $suggestion->{rejecteddate} )
21382 ? $suggestion->{rejectedby}
21384 next unless $last_modif_by;
21387 SET lastmodificationdate = ?, lastmodificationby = ?
21388 WHERE suggestionid = ?
21389 |, undef, $max_date, $last_modif_by, $suggestion->{suggestionid});
21395 INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('suggestions', 'NOTIFY_MANAGER', '', 'Notify manager of a suggestion', 0, "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email', 'default');
21398 NewVersion( $DBversion, 23590, "Add lastmodificationby and lastmodificationdate to the suggestions table");
21401 $DBversion = '19.12.00.056';
21402 if( CheckVersion( $DBversion ) ) {
21404 $dbh->do( "DELETE FROM systempreferences WHERE variable='UseKohaPlugins'" );
21406 NewVersion( $DBversion, 20415, "Remove UseKohaPlugins preference");
21409 $DBversion = '19.12.00.057';
21410 if( CheckVersion( $DBversion ) ) {
21412 $dbh->do( "DELETE FROM systempreferences WHERE variable='INTRAdidyoumean'" );
21414 NewVersion( $DBversion, 20399, "Remove INTRAdidyoumean preference");
21417 $DBversion = '19.12.00.058';
21418 if( CheckVersion( $DBversion ) ) {
21420 INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES
21421 ('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'),
21422 ('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff client search results','YesNo')
21425 NewVersion( $DBversion, 14715, "Add sysprefs numSearchResultsDropdown and OPACnumSearchResultsDropdown");
21428 $DBversion = '19.12.00.059';
21429 if( CheckVersion( $DBversion ) ) {
21431 for my $column ( qw(othersupplier booksellerfax booksellerurl bookselleremail currency) ) {
21432 if( column_exists( 'aqbooksellers', $column ) ) {
21433 my ($count) = $dbh->selectrow_array(qq|
21436 WHERE $column IS NOT NULL AND $column <> ""
21439 warn "Warning - Cannot remove column aqbooksellers.$column. At least one value exists";
21442 ALTER TABLE aqbooksellers
21443 DROP COLUMN $column
21449 NewVersion( $DBversion, 18177, "Remove some unused columns from aqbooksellers");
21452 $DBversion = '19.12.00.060';
21453 if( CheckVersion( $DBversion ) ) {
21455 ALTER TABLE search_marc_map CHANGE marc_type `marc_type` enum('marc21','normarc','unimarc') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'what MARC type this map is for';
21457 NewVersion( $DBversion, 23204, "Change enum order for marc_type in search_marc_map to fix sorting");
21460 $DBversion = '19.12.00.061';
21461 if ( CheckVersion($DBversion) ) {
21466 options = "batchmod|moredetail|cronjob|additem|pendingreserves|onpayment"
21468 variable = "MarkLostItemsAsReturned"
21471 my $lost_item_returned = C4::Context->preference("MarkLostItemsAsReturned");
21472 my @set = split( ",", $lost_item_returned );
21473 push @set, 'onpayment';
21474 $lost_item_returned = join( ",", @set );
21480 value = "$lost_item_returned"
21482 variable = "MarkLostItemsAsReturned"
21485 NewVersion( $DBversion, 24474, "Add `onpayment` option to MarkLostItemsAsReturned");
21488 $DBversion = '19.12.00.062';
21489 if( CheckVersion( $DBversion ) ) {
21490 $dbh->do( "UPDATE account_debit_types SET description = REPLACE(description,'Rewewal','Renewal') WHERE description like '%Rewewal%'" );
21492 NewVersion( $DBversion, 25010, "Fix typo in account_debit_type description");
21495 $DBversion = '19.12.00.063';
21496 if( CheckVersion( $DBversion ) ) {
21497 $dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('PrefillGuaranteeField', 'phone,email,streetnumber,address,city,state,zipcode,country', NULL, 'Prefill these fields in guarantee member entry form from guarantor patron record', 'Multiple') });
21499 NewVersion( $DBversion, 22534, "Add PreFillGuaranteeField syspref");
21502 $DBversion = '19.12.00.064';
21503 if( CheckVersion( $DBversion ) ) {
21506 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
21507 SELECT 'OpacNoItemTypeImages', value, NULL, 'If ON, disables itemtype images in the OPAC','YesNo'
21508 FROM (SELECT value FROM systempreferences WHERE variable="NoItemTypeImages") tmp
21510 $dbh->do( "UPDATE systempreferences SET explanation = 'If ON, disables itemtype images in the staff interface'
21511 WHERE variable = 'noItemTypeImages' ");
21513 NewVersion( $DBversion, 4944, "Add new system preference OpacNoItemTypeImages");
21516 $DBversion = '19.12.00.065';
21517 if( CheckVersion( $DBversion ) ) {
21520 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
21521 VALUES ('ILLCheckAvailability', '0', 'If enabled, during the ILL request process third party sources will be checked for current availability', '', 'YesNo')
21524 NewVersion( $DBversion, 23173, "Add ILLCheckAvailability syspref");
21527 $DBversion = '19.12.00.066';
21528 if ( CheckVersion($DBversion) ) {
21530 q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACReportProblem', 0, NULL, 'Allow patrons to submit problem reports for OPAC pages to the library or Koha Administrator', 'YesNo') }
21533 q{INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('members', 'PROBLEM_REPORT','OPAC Problem Report','OPAC Problem Report','Username: <<problem_reports.username>>\n\nProblem page: <<problem_reports.problempage>>\n\nTitle: <<problem_reports.title>>\n\nMessage: <<problem_reports.content>>','email') }
21535 if ( !TableExists('problem_reports') ) {
21537 q{ CREATE TABLE problem_reports (
21538 reportid int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
21539 title varchar(40) NOT NULL default '', -- report subject line
21540 content varchar(255) NOT NULL default '', -- report message content
21541 borrowernumber int(11) NOT NULL default 0, -- the user who created the problem report
21542 branchcode varchar(10) NOT NULL default '', -- borrower's branch
21543 username varchar(75) default NULL, -- OPAC username
21544 problempage TEXT default NULL, -- page the user triggered the problem report form from
21545 recipient enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
21546 created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of report submission
21547 status varchar(6) NOT NULL default 'New', -- status of the report. New, Viewed, Closed
21548 PRIMARY KEY (reportid),
21549 CONSTRAINT problem_reports_ibfk1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
21550 CONSTRAINT problem_reports_ibfk2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
21551 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci }
21555 q{INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (26, 'problem_reports', 'Manage problem reports', 0) }
21558 q{INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (26, 'manage_problem_reports', 'Manage OPAC problem reports') }
21565 "Add OPACReportProblem system preference",
21566 "Adding PROBLEM_REPORT notice",
21567 "Add problem reports table",
21568 "Add user permissions for managing OPAC problem reports"
21573 $DBversion = '19.12.00.067';
21574 if( CheckVersion( $DBversion ) ) {
21575 # From: https://stackoverflow.com/questions/3311903/remove-duplicate-rows-in-mysql
21578 FROM virtualshelfshares as a, virtualshelfshares as b
21582 a.borrowernumber IS NOT NULL
21584 a.borrowernumber=b.borrowernumber
21586 a.shelfnumber=b.shelfnumber
21589 NewVersion( $DBversion, 20754, "Remove double accepted list shares" );
21592 $DBversion = '19.12.00.068';
21593 if( CheckVersion( $DBversion ) ) {
21595 INSERT IGNORE INTO systempreferences
21596 (variable,value,explanation,options,type)
21598 ('AuthFailureLog','','If enabled, log authentication failures',NULL,'YesNo'),
21599 ('AuthSuccessLog','','If enabled, log successful authentications',NULL,'YesNo')
21602 NewVersion( $DBversion, 21190, "Add prefs AuthFailureLog and AuthSuccessLog");
21605 $DBversion = '19.12.00.069';
21606 if( CheckVersion( $DBversion ) ) {
21607 if( !column_exists( 'suggestions', 'archived' ) ) {
21609 ALTER TABLE suggestions ADD COLUMN archived TINYINT(1) NOT NULL DEFAULT 0 AFTER `STATUS`;
21613 NewVersion( $DBversion, 22784, "Add a new suggestions.archived column");
21616 $DBversion = '19.12.00.070';
21617 if( CheckVersion( $DBversion ) ) {
21620 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
21621 ('MaxTotalSuggestions','','Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'),
21622 ('NumberOfSuggestionDays','','Number of days that will be used to determine the MaxTotalSuggestions limit','Free')
21625 NewVersion( $DBversion, 22774, "Limit purchase suggestion in a specified time period");
21628 $DBversion = '19.12.00.071';
21629 if( CheckVersion( $DBversion ) ) {
21630 my @description = ("Add unique constraint to authorised_values");
21631 unless ( index_exists('authorised_values', 'av_uniq') ) {
21633 DELETE FROM authorised_values
21634 WHERE category="COUNTRY" AND authorised_value="CC" AND lib="Keeling"
21636 my $duplicates = $dbh->selectall_arrayref(q|
21637 SELECT category, authorised_value, COUNT(concat(category, ':', authorised_value)) AS c
21638 FROM authorised_values
21639 GROUP BY category, authorised_value
21640 HAVING COUNT(concat(category, ':', authorised_value)) > 1
21641 |, { Slice => {} });
21642 if ( @$duplicates ) {
21643 push @description, "WARNING - Cannot create unique constraint on authorised_value(category, authorised_value)";
21644 push @description, "The following entries are duplicated: " . join(
21647 sprintf "%s:%s (%s)", $_->{category},
21648 $_->{authorised_value}, $_->{c}
21651 for my $warning (@description) {
21655 $dbh->do( q{ALTER TABLE `authorised_values` ADD CONSTRAINT `av_uniq` UNIQUE (category, authorised_value)} );
21659 NewVersion( $DBversion, 22887, \@description );
21662 $DBversion = '19.12.00.072';
21663 if( CheckVersion( $DBversion ) ) {
21665 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
21666 SELECT 'CalculateFinesOnBackdate',value,'','Switch to control if overdue fines are calculated on return when backdating','YesNo'
21667 FROM ( SELECT value FROM systempreferences WHERE variable = 'CalculateFinesOnReturn' ) tmp
21670 NewVersion( $DBversion, 24380, "Add syspref CalculateFinesOnBackdate");
21673 $DBversion = '19.12.00.073';
21674 if( CheckVersion( $DBversion ) ) {
21675 $dbh->do( "ALTER TABLE subscription MODIFY COLUMN closed tinyint(1) not null default 0" );
21677 NewVersion( $DBversion, 25152, "Update subscription.closed to tinyint(1) as per guidelines");
21680 $DBversion = '19.12.00.074';
21681 if( CheckVersion( $DBversion ) ) {
21682 $dbh->do( "UPDATE systempreferences SET variable = 'SCOAllowCheckin' WHERE variable = 'AllowSelfCheckReturns'" );
21684 # Always end with this (adjust the bug info)
21685 NewVersion( $DBversion, 25147, "Rename AllowSelfCheckReturns to SCOAllowCheckin for consistency");
21688 $DBversion = '19.12.00.075';
21689 if( CheckVersion( $DBversion ) ) {
21691 $dbh->do( "ALTER TABLE borrower_modifications MODIFY changed_fields MEDIUMTEXT DEFAULT NULL" );
21693 NewVersion( $DBversion, 25086, "Set changed_fields column of borrower_modifications as nullable");
21696 $DBversion = '19.12.00.076';
21697 if( CheckVersion( $DBversion ) ) {
21701 local $dbh->{PrintError} = 0;
21704 SET planneddate = NULL
21705 WHERE planneddate = '0000-00-00'
21710 SET publisheddate = NULL
21711 WHERE publisheddate = '0000-00-00'
21716 SET claimdate = NULL
21717 WHERE claimdate = '0000-00-00'
21723 MODIFY COLUMN biblionumber INT(11) NOT NULL
21726 unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) {
21727 my $serials = $dbh->selectall_arrayref(q|
21728 SELECT serialid FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
21729 |, { Slice => {} });
21731 push @warnings, q|WARNING - The following serials are deleted, they were not attached to an existing bibliographic record (serialid): | . join ", ", map { $_->{serialid} } @$serials;
21733 DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
21738 ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
21744 MODIFY COLUMN subscriptionid INT(11) NOT NULL
21747 unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) {
21748 my $serials = $dbh->selectall_arrayref(q|
21749 SELECT serialid FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
21750 |, { Slice => {} });
21752 push @warnings, q|WARNING - The following serials are deleted, they were not attached to an existing subscription (serialid): | . join ", ", map { $_->{serialid} } @$serials;
21754 DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
21759 ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
21764 ALTER TABLE subscriptionhistory
21765 MODIFY COLUMN biblionumber int(11) NOT NULL,
21766 MODIFY COLUMN subscriptionid int(11) NOT NULL
21769 unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_1' ) ) {
21771 DELETE FROM subscriptionhistory WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
21774 ALTER TABLE subscriptionhistory
21775 ADD CONSTRAINT subscription_history_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
21779 unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_2' ) ) {
21781 DELETE FROM subscriptionhistory WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription)
21784 ALTER TABLE subscriptionhistory
21785 ADD CONSTRAINT subscription_history_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE
21790 ALTER TABLE subscription
21791 MODIFY COLUMN biblionumber int(11) NOT NULL
21794 unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) {
21795 my $subscriptions = $dbh->selectall_arrayref(q|
21796 SELECT subscriptionid FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
21797 |, { Slice => {} });
21798 if ( @$subscriptions ) {
21799 push @warnings, q|WARNING - The following subscriptions are deleted, they were not attached to an existing bibliographic record (subscriptionid): | . join ", ", map { $_->{subscriptionid} } @$subscriptions;
21802 DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio)
21806 ALTER TABLE subscription
21807 ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
21811 for my $warning (@warnings) {
21815 my $description = [ "Add foreign key constraints on serial", @warnings ];
21816 NewVersion( $DBversion, 21901, $description);
21819 $DBversion = '19.12.00.077';
21820 if( CheckVersion( $DBversion ) ) {
21821 if ( !column_exists( 'course_items', 'itype_enabled' ) ) {
21823 ALTER TABLE course_items
21824 ADD COLUMN itype_enabled tinyint(1) NOT NULL DEFAULT 0 AFTER itype,
21825 ADD COLUMN ccode_enabled tinyint(1) NOT NULL DEFAULT 0 AFTER ccode,
21826 ADD COLUMN holdingbranch_enabled tinyint(1) NOT NULL DEFAULT 0 AFTER holdingbranch,
21827 ADD COLUMN location_enabled tinyint(1) NOT NULL DEFAULT 0 AFTER location,
21828 ADD COLUMN itype_storage varchar(10) DEFAULT NULL AFTER itype_enabled,
21829 ADD COLUMN ccode_storage varchar(80) DEFAULT NULL AFTER ccode_enabled,
21830 ADD COLUMN holdingbranch_storage varchar(10) DEFAULT NULL AFTER ccode_enabled,
21831 ADD COLUMN location_storage varchar(80) DEFAULT NULL AFTER location_enabled
21834 my $item_level_items = C4::Context->preference('item-level_itypes');
21835 my $itype_field = $item_level_items ? 'i.itype' : 'bi.itemtype';
21837 UPDATE course_items ci
21838 LEFT JOIN items i USING ( itemnumber )
21839 LEFT JOIN biblioitems bi USING ( biblioitemnumber )
21842 -- Assume the column is enabled if the course item is active and i.itype/bi.itemtype is set,
21843 -- or if the course item is not enabled and ci.itype is set
21844 ci.itype_enabled = IF( ci.enabled = 'yes', IF( $itype_field IS NULL, 0, 1 ), IF( ci.itype IS NULL, 0, 1 ) ),
21845 ci.ccode_enabled = IF( ci.enabled = 'yes', IF( i.ccode IS NULL, 0, 1 ), IF( ci.ccode IS NULL, 0, 1 ) ),
21846 ci.holdingbranch_enabled = IF( ci.enabled = 'yes', IF( i.holdingbranch IS NULL, 0, 1 ), IF( ci.holdingbranch IS NULL, 0, 1 ) ),
21847 ci.location_enabled = IF( ci.enabled = 'yes', IF( i.location IS NULL, 0, 1 ), IF( ci.location IS NULL, 0, 1 ) ),
21849 -- If the course item is enabled, copy the value from the item.
21850 -- If the course item is not enabled, keep the existing value
21851 ci.itype = IF( ci.enabled = 'yes', $itype_field, ci.itype ),
21852 ci.ccode = IF( ci.enabled = 'yes', i.ccode, ci.ccode ),
21853 ci.holdingbranch = IF( ci.enabled = 'yes', i.holdingbranch, ci.holdingbranch ),
21854 ci.location = IF( ci.enabled = 'yes', i.location, ci.location ),
21856 -- If the course is enabled, copy the value from the item to storage.
21857 -- If it is not enabled, copy the value from the course item to storage
21858 ci.itype_storage = IF( ci.enabled = 'no', $itype_field, ci.itype ),
21859 ci.ccode_storage = IF( ci.enabled = 'no', i.ccode, ci.ccode ),
21860 ci.holdingbranch_storage = IF( ci.enabled = 'no', i.holdingbranch, ci.holdingbranch ),
21861 ci.location_storage = IF( ci.enabled = 'no', i.location, ci.location );
21864 # Clean up the storage columns
21866 UPDATE course_items SET
21867 itype_storage = NULL,
21868 ccode_storage = NULL,
21869 holdingbranch_storage = NULL,
21870 location_storage = NULL
21871 WHERE enabled = 'no';
21874 # Clean up the course enabled value columns
21876 UPDATE course_items SET
21877 itype = IF( itype_enabled = 'no', NULL, itype ),
21878 ccode = IF( ccode_enabled = 'no', NULL, ccode ),
21879 holdingbranch = IF( holdingbranch_enabled = 'no', NULL, holdingbranch ),
21880 location = IF( location_enabled = 'no', NULL, location )
21881 WHERE enabled = 'no';
21885 NewVersion( $DBversion, 23727, "Editing course reserve items is broken");
21888 $DBversion = '19.12.00.078';
21889 if( CheckVersion( $DBversion ) ) {
21890 $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo') });
21892 NewVersion( $DBversion, 24913, "Add PatronSelfRegistrationConfirmEmail syspref");
21895 $DBversion = '19.12.00.079';
21896 if( CheckVersion( $DBversion ) ) {
21898 # Default to the homologous OpacPublic syspref
21899 my $opac_public = C4::Context->preference('OpacPublic') ? 1 : 0;
21902 INSERT IGNORE INTO `systempreferences`
21903 (`variable`,`value`,`explanation`,`options`,`type`)
21905 ('RESTPublicAnonymousRequests', $opac_public, NULL,'If enabled, the API will allow anonymous access to public routes that do not require authenticated access.','YesNo');
21908 NewVersion( $DBversion, 25045, "Add a way to restrict anonymous access to public routes (OpacPublic behaviour)");
21911 $DBversion = '19.12.00.080';
21912 if( CheckVersion( $DBversion ) ) {
21913 $dbh->do( "UPDATE items set issues=0 where issues is null" );
21914 $dbh->do( "UPDATE deleteditems set issues=0 where issues is null" );
21915 $dbh->do( "ALTER TABLE items ALTER issues set default 0" );
21916 $dbh->do( "ALTER TABLE deleteditems ALTER issues set default 0" );
21918 NewVersion( $DBversion, 23081, "Set default to 0 for items.issues");
21921 $DBversion = '19.12.00.081';
21922 if (CheckVersion($DBversion)) {
21923 if (!column_exists('course_items', 'homebranch')) {
21925 ALTER TABLE course_items
21926 ADD COLUMN homebranch VARCHAR(10) NULL DEFAULT NULL AFTER ccode_storage
21930 if (!foreign_key_exists('course_items', 'fk_course_items_homebranch')) {
21932 ALTER TABLE course_items
21933 ADD CONSTRAINT fk_course_items_homebranch
21934 FOREIGN KEY (homebranch) REFERENCES branches (branchcode)
21935 ON DELETE CASCADE ON UPDATE CASCADE
21939 if (!column_exists('course_items', 'homebranch_enabled')) {
21941 ALTER TABLE course_items
21942 ADD COLUMN homebranch_enabled tinyint(1) NOT NULL DEFAULT 0 AFTER homebranch
21946 if (!column_exists('course_items', 'homebranch_storage')) {
21948 ALTER TABLE course_items
21949 ADD COLUMN homebranch_storage VARCHAR(10) NULL DEFAULT NULL AFTER homebranch_enabled
21953 if (!foreign_key_exists('course_items', 'fk_course_items_homebranch_storage')) {
21955 ALTER TABLE course_items
21956 ADD CONSTRAINT fk_course_items_homebranch_storage
21957 FOREIGN KEY (homebranch_storage) REFERENCES branches (branchcode)
21958 ON DELETE CASCADE ON UPDATE CASCADE
21962 NewVersion( $DBversion, 22630, "Add course_items.homebranch");
21965 $DBversion = '19.12.00.082';
21966 if( CheckVersion( $DBversion ) ) {
21968 # get list of installed translations
21969 require C4::Languages;
21971 my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
21973 foreach my $language ( @$tlangs ) {
21974 foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
21975 push @langs, $sublanguage->{'rfc4646_subtag'};
21979 # Get any existing value from the OpacMainUserBlock system preference
21980 my ($opacmainuserblock) = $dbh->selectrow_array( q|
21981 SELECT value FROM systempreferences WHERE variable='OpacMainUserBlock';
21985 if( $opacmainuserblock ){
21986 foreach my $lang ( @langs ) {
21987 # If there is a value in the OpacMainUserBlock preference, insert it into opac_news
21988 $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacMainUserBlock_$lang", $opacmainuserblock);
21989 push @detail, "Inserting OpacMainUserBlock contents into $lang news item...";
21992 # Remove the OpacMainUserBlock system preference
21993 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlock'");
21995 unshift @detail, "Move contents of OpacMainUserBlock preference to Koha news system";
21996 NewVersion( $DBversion, 23794, \@detail);
21999 $DBversion = '19.12.00.083';
22000 if( CheckVersion( $DBversion ) ) {
22002 unless ( column_exists( 'authorised_value_categories', 'is_system' ) ) {
22004 ALTER TABLE authorised_value_categories
22005 ADD COLUMN is_system TINYINT(1) DEFAULT 0 AFTER category_name
22010 UPDATE authorised_value_categories
22012 WHERE category_name IN ('LOC', 'LOST', 'WITHDRAWN', 'Bsort1', 'Bsort2', 'Asort1', 'Asort2', 'SUGGEST', 'DAMAGED', 'LOST', 'BOR_NOTES', 'CCODE', 'NOT_LOAN')
22016 UPDATE authorised_value_categories
22018 WHERE category_name IN ('branches', 'itemtypes', 'cn_source')
22021 NewVersion( $DBversion, 17355, "Add is_system to authorised_value_categories table");
22024 $DBversion = '19.12.00.084';
22025 if( CheckVersion( $DBversion ) ) {
22026 unless ( TableExists('advanced_editor_macros') ) {
22028 CREATE TABLE advanced_editor_macros (
22029 id INT(11) NOT NULL AUTO_INCREMENT,
22030 name varchar(80) NOT NULL,
22031 macro longtext NULL,
22032 borrowernumber INT(11) default NULL,
22033 shared TINYINT(1) default 0,
22035 CONSTRAINT borrower_macro_fk FOREIGN KEY ( borrowernumber ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE
22036 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;|
22040 INSERT IGNORE INTO permissions (module_bit, code, description)
22041 VALUES (9, 'create_shared_macros', 'Create public macros')
22044 INSERT IGNORE INTO permissions (module_bit, code, description)
22045 VALUES (9, 'delete_shared_macros', 'Delete public macros')
22048 NewVersion( $DBversion, 17682, "Add macros db table and permissions");
22051 $DBversion = '19.12.00.085';
22052 if( CheckVersion( $DBversion ) ) {
22053 unless ( TableExists( 'aqorders_claims' ) ) {
22055 CREATE TABLE aqorders_claims (
22056 id int(11) AUTO_INCREMENT,
22057 ordernumber INT(11) NOT NULL,
22058 claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
22060 CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
22061 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
22064 my $orders = $dbh->selectall_arrayref(q|
22065 SELECT ordernumber, claims_count, claimed_date
22067 WHERE claims_count > 0
22068 |, { Slice => {} });
22069 my $insert_claim_sth = $dbh->prepare(q|
22070 INSERT INTO aqorders_claims (ordernumber, claimed_on)
22074 for my $order ( @$orders ) {
22075 for my $claim (1..$order->{claims_count}) {
22076 $insert_claim_sth->execute($order->{ordernumber}, $order->{claimed_on});
22080 $dbh->do(q|ALTER TABLE aqorders DROP COLUMN claims_count, DROP COLUMN claimed_date|);
22083 NewVersion( $DBversion, 24161, "Add new join table aqorders_claims to keep track of claims");
22086 $DBversion = '19.12.00.086';
22087 if( CheckVersion( $DBversion ) ) {
22089 INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type, used_for ) VALUES
22090 ("Late orders (CSV profile)", "Default CSV export for late orders", 'Title[% separator %]Author[% separator %]Publication year[% separator %]ISBN[% separator %]Quantity[% separator %]Number of claims
22091 [% FOR order IN orders ~%]
22092 [%~ SET biblio = order.biblio ~%]
22093 "[% biblio.title %]"[% separator ~%]
22094 "[% biblio.author %]"[% separator ~%]
22095 "[% bibio.biblioitem.publicationyear %]"[% separator ~%]
22096 "[% biblio.biblioitem.isbn %]"[% separator ~%]
22097 "[% order.quantity%]"[% separator ~%]
22098 "[% order.claims.count%][% IF order.claims.count %]([% FOR c IN order.claims %][% c.claimed_on | $KohaDates %][% UNLESS loop.last %], [% END %][% END %])[% END %]"
22099 [% END %]', ",", "sql", "late_orders")
22102 NewVersion( $DBversion, 24163, "Define a default CSV profile for late orders");
22105 $DBversion = '19.12.00.087';
22106 if( CheckVersion( $DBversion ) ) {
22108 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
22109 ('TrapHoldsOnOrder','1',NULL,'If enabled, Koha will trap holds for on order items ( notforloan < 0 )','YesNo')
22112 NewVersion( $DBversion, 25184, "Items with a negative notforloan status should not be captured for holds");
22115 $DBversion = '19.12.00.088';
22116 if( CheckVersion( $DBversion ) ) {
22120 name = REPLACE(name, "notification on auto renewing", "Notification of automatic renewal"),
22121 title = REPLACE(title, "Auto renewals", "Automatic renewal notice"),
22122 content = REPLACE(content, "You have reach the maximum of checkouts possible.", "You have reached the maximum number of checkouts possible.")
22123 WHERE code = 'AUTO_RENEWALS';
22127 content = REPLACE(content, "You have overdues.", "You have overdue items.")
22128 WHERE code = 'AUTO_RENEWALS';
22132 content = REPLACE(content, "It's too late to renew this checkout.", "It's too late to renew this item.")
22133 WHERE code = 'AUTO_RENEWALS';
22137 content = REPLACE(content, "You have too much unpaid fines.", "Your total unpaid fines are too high.")
22138 WHERE code = 'AUTO_RENEWALS';
22142 content = REPLACE(content, "The following item [% biblio.title %] has correctly been renewed and is now due [% checkout.date_due %]", "The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due as_due_date => 1 %]
22144 WHERE code = 'AUTO_RENEWALS';
22147 NewVersion( $DBversion, 24378, "Fix some grammatical errors in default auto renewal notice");
22150 $DBversion = '19.12.00.089';
22151 if( CheckVersion( $DBversion ) ) {
22153 # Migrate LOST_RETURNED to LOST_FOUND
22158 credit_type_code = 'LOST_FOUND'
22160 credit_type_code = 'LOST_RETURNED'
22163 # Drop LOST_RETURNED credit type
22165 DELETE FROM account_credit_types WHERE code = 'LOST_RETURNED'
22168 NewVersion( $DBversion, 25389, "Catch errant cases of LOST_RETURNED");
22171 $DBversion = '19.12.00.090';
22172 if ( CheckVersion($DBversion) ) {
22176 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
22177 ('UseIssueDesks','0','','Use issue desks with circulation.','YesNo')
22181 NewVersion( $DBversion, 13881, "Add issue desks system preference");
22184 $DBversion = '19.12.00.091';
22185 if ( CheckVersion($DBversion) ) {
22188 UPDATE systempreferences SET variable = 'UseCirculationDesks' WHERE variable = 'UseIssueDesks'
22191 NewVersion( $DBversion, 13881, "Correction to preference terminology");
22194 $DBversion = '20.05.00.000';
22195 if( CheckVersion( $DBversion ) ) {
22196 NewVersion( $DBversion, undef, '20.05.00 alpha release' );
22199 $DBversion = '20.06.00.000';
22200 if( CheckVersion( $DBversion ) ) {
22201 NewVersion( $DBversion, undef, 'All our codebase are belong to everybody' );
22204 $DBversion = '20.06.00.001';
22205 if( CheckVersion( $DBversion ) ) {
22206 for my $f (qw( streetnumber streettype zipcode mobile B_streetnumber B_streettype B_zipcode ) ) {
22208 ALTER TABLE borrowers MODIFY $f TINYTEXT DEFAULT NULL
22211 ALTER TABLE deletedborrowers MODIFY $f TINYTEXT DEFAULT NULL
22214 for my $f ( qw( B_address altcontactfirstname altcontactsurname altcontactaddress1 altcontactaddress2 altcontactaddress3 altcontactzipcode altcontactphone ) ) {
22216 ALTER TABLE borrowers MODIFY $f MEDIUMTEXT DEFAULT NULL
22219 ALTER TABLE deletedborrowers MODIFY $f MEDIUMTEXT DEFAULT NULL
22223 NewVersion( $DBversion, 24986, "Switch borrowers address related fields to TINYTEXT or MEDIUMTEXT");
22226 $DBversion = '20.06.00.002';
22227 if( CheckVersion( $DBversion ) ) {
22229 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
22230 ('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer')
22233 NewVersion( $DBversion, 25184, "Items with a negative notforloan status should not be captured for holds");
22236 $DBversion = '20.06.00.003';
22237 if( CheckVersion( $DBversion ) ) {
22238 unless ( TableExists( 'tables_settings' ) ) {
22240 CREATE TABLE tables_settings (
22241 module varchar(255) NOT NULL,
22242 page varchar(255) NOT NULL,
22243 tablename varchar(255) NOT NULL,
22244 default_display_length smallint(6) NOT NULL DEFAULT 20,
22245 default_sort_order varchar(255),
22246 PRIMARY KEY(module (191), page (191), tablename (191) )
22247 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22251 NewVersion( $DBversion, 24156, "Add new table tables_settings" );
22254 $DBversion = '20.06.00.004';
22255 if( CheckVersion( $DBversion ) ) {
22257 DELETE FROM circulation_rules WHERE rule_name='holdallowed' AND rule_value='';
22259 NewVersion( $DBversion, 25851, "Remove holdallowed rule if value is an empty string");
22262 $DBversion = '20.06.00.005';
22263 if( CheckVersion( $DBversion ) ) {
22264 $dbh->do( "UPDATE borrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
22265 $dbh->do( "ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
22266 $dbh->do( "UPDATE deletedborrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
22267 $dbh->do( "ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
22268 NewVersion( $DBversion, 24379, "Set login_attempts NOT NULL" );
22271 $DBversion = '20.06.00.006';
22272 if( CheckVersion( $DBversion ) ) {
22273 unless( TableExists( 'pseudonymized_transactions' ) ) {
22275 CREATE TABLE `pseudonymized_transactions` (
22276 `id` INT(11) NOT NULL AUTO_INCREMENT,
22277 `hashed_borrowernumber` VARCHAR(60) NOT NULL,
22278 `has_cardnumber` TINYINT(1) NOT NULL DEFAULT 0,
22281 `state` MEDIUMTEXT default NULL,
22282 `zipcode` varchar(25) default NULL,
22283 `country` MEDIUMTEXT,
22284 `branchcode` varchar(10) NOT NULL default '',
22285 `categorycode` varchar(10) NOT NULL default '',
22286 `dateenrolled` date default NULL,
22287 `sex` varchar(1) default NULL,
22288 `sort1` varchar(80) default NULL,
22289 `sort2` varchar(80) default NULL,
22290 `datetime` datetime default NULL,
22291 `transaction_branchcode` varchar(10) default NULL,
22292 `transaction_type` varchar(16) default NULL,
22293 `itemnumber` int(11) default NULL,
22294 `itemtype` varchar(10) default NULL,
22295 `holdingbranch` varchar(10) default null,
22296 `homebranch` varchar(10) default null,
22297 `location` varchar(80) default NULL,
22298 `itemcallnumber` varchar(255) default NULL,
22299 `ccode` varchar(80) default NULL,
22300 PRIMARY KEY (`id`),
22301 CONSTRAINT `pseudonymized_transactions_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`),
22302 CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`),
22303 CONSTRAINT `pseudonymized_transactions_borrowers_ibfk_3` FOREIGN KEY (`transaction_branchcode`) REFERENCES `branches` (`branchcode`)
22304 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22309 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
22310 VALUES ('Pseudonymization','0',NULL,'If enabled patrons and transactions will be copied in a separate table for statistics purpose','YesNo')
22313 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
22314 VALUES ('PseudonymizationPatronFields','','title,city,state,zipcode,country,branchcode,categorycode,dateenrolled,sex,sort1,sort2','Patron fields to copy to the pseudonymized_transactions table','multiple')
22317 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
22318 VALUES ('PseudonymizationTransactionFields','','datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,homebranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple')
22321 unless( TableExists( 'pseudonymized_borrower_attributes' ) ) {
22323 CREATE TABLE pseudonymized_borrower_attributes (
22324 `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, -- Row id field
22325 `transaction_id` int(11) NOT NULL,
22326 `code` varchar(10) NOT NULL,
22327 `attribute` varchar(255) default NULL,
22328 CONSTRAINT `pseudonymized_borrower_attributes_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `pseudonymized_transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
22329 CONSTRAINT `anonymized_borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
22330 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22334 unless( column_exists('borrower_attribute_types', 'keep_for_pseudonymization') ) {
22336 ALTER TABLE borrower_attribute_types ADD COLUMN `keep_for_pseudonymization` TINYINT(1) NOT NULL DEFAULT 0 AFTER `class`
22340 NewVersion( $DBversion, 24151, "Add pseudonymized_transactions tables and sysprefs for Pseudonymization" );
22343 $DBversion = '20.06.00.007';
22344 if( CheckVersion( $DBversion ) ) {
22345 if( !column_exists( 'borrower_attribute_types', 'mandatory' ) ) {
22347 ALTER TABLE borrower_attribute_types
22348 ADD COLUMN mandatory TINYINT(1) NOT NULL DEFAULT 0
22349 AFTER keep_for_pseudonymization
22353 NewVersion( $DBversion, 22844, "Add borrower_attribute_types.mandatory" );
22356 $DBversion = '20.06.00.008';
22357 if( CheckVersion( $DBversion ) ) {
22358 $dbh->do( "UPDATE itemtypes SET imageurl = REPLACE (imageurl, '.gif', '.png') WHERE imageurl LIKE 'bridge/%'" );
22360 NewVersion( $DBversion, 23148, "Replace Bridge icons with transparent PNG files" );
22363 $DBversion = '20.06.00.009';
22364 if( CheckVersion( $DBversion ) ) {
22366 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
22367 VALUES ('ILLHiddenRequestStatuses',NULL,NULL,'ILL statuses that are considered finished and should not be displayed in the ILL module','multiple')
22370 NewVersion( $DBversion, 23391, "Hide finished ILL requests" );
22373 $DBversion = '20.06.00.010';
22374 if( CheckVersion( $DBversion ) ) {
22376 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
22377 ('NoRefundOnLostReturnedItemsAge','','','Do not refund lost item fees if item is lost for more than this number of days','Integer')
22380 NewVersion( $DBversion, 20815, "Add NoRefundOnLostReturnedItemsAge system preference" );
22383 $DBversion = '20.06.00.011';
22384 if( CheckVersion( $DBversion ) ) {
22385 unless( column_exists( 'export_format', 'staff_only' ) ) {
22387 ALTER TABLE export_format
22388 ADD staff_only TINYINT(1) NOT NULL DEFAULT 0 AFTER used_for,
22389 ADD KEY `staff_only_idx` (`staff_only`);
22393 unless ( index_exists( 'export_format', 'used_for_idx' ) ) {
22395 ALTER TABLE export_format
22396 ADD KEY `used_for_idx` (`used_for` (191));
22400 NewVersion( $DBversion, 5087, "Add export_format.staff_only" );
22403 $DBversion = '20.06.00.012';
22404 if( CheckVersion( $DBversion ) ) {
22406 # get list of installed translations
22407 require C4::Languages;
22409 my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
22411 foreach my $language ( @$tlangs ) {
22412 foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
22413 push @langs, $sublanguage->{'rfc4646_subtag'};
22417 # Get any existing value from the opaccredits system preference
22418 my ($opaccredits) = $dbh->selectrow_array( q|
22419 SELECT value FROM systempreferences WHERE variable='opaccredits';
22421 if( $opaccredits ){
22422 foreach my $lang ( @langs ) {
22423 # If there is a value in the opaccredits preference, insert it into opac_news
22424 $dbh->do("INSERT IGNORE INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "opaccredits_$lang", $opaccredits);
22427 # Remove the opaccredits system preference
22428 $dbh->do("DELETE FROM systempreferences WHERE variable='opaccredits'");
22430 NewVersion( $DBversion, 23795, "Convert OpacCredits system preference to news block" );
22433 $DBversion = '20.06.00.013';
22434 if( CheckVersion( $DBversion ) ) {
22436 # get list of installed translations
22437 require C4::Languages;
22439 my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
22441 foreach my $language ( @$tlangs ) {
22442 foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
22443 push @langs, $sublanguage->{'rfc4646_subtag'};
22447 # Get any existing value from the OpacCustomSearch system preference
22448 my ($OpacCustomSearch) = $dbh->selectrow_array( q|
22449 SELECT value FROM systempreferences WHERE variable='OpacCustomSearch';
22451 if( $OpacCustomSearch ){
22452 foreach my $lang ( @langs ) {
22453 # If there is a value in the OpacCustomSearch preference, insert it into opac_news
22454 $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacCustomSearch_$lang", $OpacCustomSearch);
22457 # Remove the OpacCustomSearch system preference
22458 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacCustomSearch'");
22460 NewVersion( $DBversion, 23795, "Convert OpacCustomSearch system preference to news block" );
22463 $DBversion = '20.06.00.014';
22464 if( CheckVersion( $DBversion ) ) {
22466 $dbh->do( "ALTER TABLE opac_news CHANGE lang lang VARCHAR(50) NOT NULL DEFAULT ''" );
22468 NewVersion( $DBversion, 23797, "Extend the opac_news lang column to accommodate longer values" );
22471 $DBversion = '20.06.00.015';
22472 if( CheckVersion( $DBversion ) ) {
22474 # get list of installed translations
22475 require C4::Languages;
22477 my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
22479 foreach my $language ( @$tlangs ) {
22480 foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
22481 push @langs, $sublanguage->{'rfc4646_subtag'};
22485 # Get any existing value from the OpacLoginInstructions system preference
22486 my ($opaclogininstructions) = $dbh->selectrow_array( q|
22487 SELECT value FROM systempreferences WHERE variable='OpacLoginInstructions';
22489 if( $opaclogininstructions ){
22490 foreach my $lang ( @langs ) {
22491 # If there is a value in the OpacLoginInstructions preference, insert it into opac_news
22492 $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacLoginInstructions_$lang", $opaclogininstructions);
22495 # Remove the OpacLoginInstructions system preference
22496 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacLoginInstructions'");
22498 NewVersion( $DBversion, 23797, "Convert OpacLoginInstructions system preference to news block" );
22501 $DBversion = '20.06.00.016';
22502 if( CheckVersion( $DBversion ) ) {
22504 unless ( column_exists('branchtransfers', 'daterequested') ) {
22507 ALTER TABLE branchtransfers
22509 `daterequested` timestamp NOT NULL default CURRENT_TIMESTAMP
22516 NewVersion( $DBversion, 23092, "Add 'daterequested' field to transfers table" );
22519 $DBversion = '20.06.00.017';
22520 if( CheckVersion( $DBversion ) ) {
22521 $dbh->do( "UPDATE systempreferences SET variable='NotesToHide' WHERE variable = 'NotesBlacklist'" );
22522 NewVersion( $DBversion, 25709, "Rename systempreference to NotesToHide");
22525 $DBversion = '20.06.00.018';
22526 if( CheckVersion( $DBversion ) ) {
22528 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
22529 (11, 'reopen_closed_invoices', 'Reopen closed invoices')
22533 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
22534 (11, 'edit_invoices', 'Edit invoices')
22538 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
22539 (11, 'delete_baskets', 'Delete baskets')
22543 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
22544 (11, 'delete_invoices', 'Delete invoices')
22548 INSERT IGNORE INTO permissions (module_bit, code, description) VALUES
22549 (11, 'merge_invoices', 'Merge invoices')
22552 NewVersion( $DBversion, 24157, "Add new permissions reopen_closed_invoices, edit_invoices, delete_invoices, merge_invoices, delete_basket");
22555 $DBversion = '20.06.00.019';
22556 if( CheckVersion( $DBversion ) ) {
22557 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('NewsToolEditor','tinymce', 'Choose tool for editing News','tinymce|codemirror','Choice')" );
22559 NewVersion( $DBversion, 22660, "Adds NewsToolEditor system preference");
22562 $DBversion = '20.06.00.020';
22563 if( CheckVersion( $DBversion ) ) {
22564 # Remove from the systempreferences table
22565 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GoogleIndicTransliteration'");
22567 NewVersion( $DBversion, 26070, "Remove references to deprecated Google Transliterate API");
22570 $DBversion = '20.06.00.021';
22571 if( CheckVersion( $DBversion ) ) {
22573 UPDATE systempreferences SET options = "callnum|ccode|location|library"
22574 WHERE variable = "OpacItemLocation"
22576 NewVersion( $DBversion, 25871, "Add library option to OpacItemLocation");
22579 $DBversion = '20.06.00.022';
22580 if( CheckVersion( $DBversion ) ) {
22581 unless ( column_exists('itemtypes', 'parent_type') ) {
22583 ALTER TABLE itemtypes
22584 ADD COLUMN parent_type VARCHAR(10) NULL DEFAULT NULL
22589 unless ( foreign_key_exists( 'itemtypes', 'itemtypes_ibfk_1') ){
22591 ALTER TABLE itemtypes
22592 ADD CONSTRAINT itemtypes_ibfk_1
22593 FOREIGN KEY (parent_type) REFERENCES itemtypes (itemtype)
22597 NewVersion( $DBversion, 21946, "Add parent type to itemtypes" );
22600 $DBversion = '20.06.00.023';
22601 if( CheckVersion( $DBversion ) ) {
22603 my ( $QuoteOfTheDay ) = $dbh->selectrow_array(q|
22604 SELECT value FROM systempreferences WHERE variable='QuoteOfTheDay'
22606 my $options = $QuoteOfTheDay ? 'opac' : '';
22608 UPDATE systempreferences
22610 options = 'intranet,opac',
22611 explanation = 'Enable or disable display of Quote of the Day on the OPAC and staff interface home page',
22613 WHERE variable = 'QuoteOfTheDay'
22614 |, undef, $options );
22616 NewVersion( $DBversion, 16371, "Quote of the Day (QOTD) for the staff interface " );
22619 $DBversion = '20.06.00.024';
22620 if( CheckVersion( $DBversion ) ) {
22622 $dbh->do( "UPDATE marc_subfield_structure SET liblibrarian = 'Home library' WHERE liblibrarian = 'Permanent location'
22623 AND tagfield = 952 and tagsubfield = 'a'" );
22624 $dbh->do( "UPDATE marc_subfield_structure SET libopac = 'Home library' WHERE libopac = 'Permanent location'
22625 AND tagfield = 952 and tagsubfield = 'a'" );
22626 $dbh->do( "UPDATE marc_subfield_structure SET liblibrarian = 'Current library' WHERE liblibrarian = 'Current location'
22627 AND tagfield = 952 and tagsubfield = 'b'" );
22628 $dbh->do( "UPDATE marc_subfield_structure SET libopac = 'Current library' WHERE libopac = 'Current location'
22629 AND tagfield = 952 and tagsubfield = 'b'" );
22631 NewVersion( $DBversion, 25867, "Update subfield descriptions for 952\$a and 952\$b");
22634 $DBversion = '20.06.00.025';
22635 if( CheckVersion( $DBversion ) ) {
22638 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
22639 ('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free')
22642 NewVersion( $DBversion, 6725, "Adds PatronDuplicateMatchingAddFields system preference");
22645 $DBversion = '20.06.00.026';
22646 if (CheckVersion($DBversion)) {
22647 unless (column_exists('accountlines', 'credit_number')) {
22648 $dbh->do('ALTER TABLE accountlines ADD COLUMN credit_number VARCHAR(20) NULL DEFAULT NULL COMMENT "autogenerated number for credits" AFTER debit_type_code');
22651 unless (column_exists('account_credit_types', 'credit_number_enabled')) {
22653 ALTER TABLE account_credit_types
22654 ADD COLUMN credit_number_enabled TINYINT(1) NOT NULL DEFAULT 0
22655 COMMENT "Is autogeneration of credit number enabled for this credit type"
22656 AFTER can_be_added_manually
22660 $dbh->do('INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES(?, ?, ?, ?, ?)', undef, 'AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice');
22662 NewVersion( $DBversion, 19036, "Add accountlines.credit_number, account_credit_types.credit_number_enabled and syspref AutoCreditNumber" );
22665 $DBversion = '20.06.00.027';
22666 if( CheckVersion( $DBversion ) ) {
22667 $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('BiblioItemtypeInfo', '0','Control whether biblio level itemtype image displays','0','YesNo')" );
22669 NewVersion( $DBversion, 8732, 'Add new BiblioItemtypeInfo to system preferences' );
22672 $DBversion = '20.06.00.028';
22673 if( CheckVersion( $DBversion ) ) {
22675 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
22676 ('DefaultLongOverdueSkipLostStatuses', '', NULL, 'Skip these lost statuses by default in longoverdue.pl', 'Free')
22679 NewVersion( $DBversion, 25958, "Allow LongOverdue cron to exclude specified lost values");
22682 $DBversion = '20.06.00.029';
22683 if ( CheckVersion( $DBversion ) ) {
22685 INSERT IGNORE INTO authorised_value_categories( category_name, is_system ) VALUES ('HOLD_CANCELLATION', 0);
22688 if ( !column_exists( 'reserves', 'cancellation_reason' ) ) {
22690 ALTER TABLE reserves ADD COLUMN `cancellation_reason` varchar(80) default NULL AFTER cancellationdate;
22694 if ( !column_exists( 'old_reserves', 'cancellation_reason' ) ) {
22696 ALTER TABLE old_reserves ADD COLUMN `cancellation_reason` varchar(80) default NULL AFTER cancellationdate;
22700 NewVersion( $DBversion, 25534, "Add ability to send an email specifying a reason when canceling a hold");
22703 $DBversion = '20.06.00.030';
22704 if ( CheckVersion( $DBversion ) ) {
22707 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES
22708 ('AutoApprovePatronProfileSettings', '0', '', 'Automatically approve patron profile changes from the OPAC.', 'YesNo');
22711 NewVersion( $DBversion, 20057, "Add new system preference 'AutoApprovePatronProfileSettings'");
22714 $DBversion = '20.06.00.031';
22715 if( CheckVersion( $DBversion ) ) {
22717 if( !column_exists( 'reserves', 'non_priority' ) ) {
22718 $dbh->do("ALTER TABLE reserves ADD COLUMN `non_priority` tinyint(1) NOT NULL DEFAULT 0 AFTER `item_level_hold`");
22721 if( !column_exists( 'old_reserves', 'non_priority' ) ) {
22722 $dbh->do("ALTER TABLE old_reserves ADD COLUMN `non_priority` tinyint(1) NOT NULL DEFAULT 0 AFTER `item_level_hold`");
22725 NewVersion( $DBversion, 22789, "Add non_priority column on reserves and old_reserves tables");
22728 $DBversion = '20.06.00.032';
22729 if( CheckVersion( $DBversion ) ) {
22730 if( !column_exists( 'items', 'exclude_from_local_holds_priority' ) ) {
22732 ALTER TABLE `items` ADD COLUMN `exclude_from_local_holds_priority` tinyint(1) default NULL AFTER `new_status`
22736 if( !column_exists( 'deleteditems', 'exclude_from_local_holds_priority' ) ) {
22738 ALTER TABLE `deleteditems` ADD COLUMN `exclude_from_local_holds_priority` tinyint(1) default NULL AFTER `new_status`
22742 if( !column_exists( 'categories', 'exclude_from_local_holds_priority' ) ) {
22744 ALTER TABLE `categories` ADD COLUMN `exclude_from_local_holds_priority` tinyint(1) default NULL AFTER `change_password`
22747 NewVersion( $DBversion, 19889, "Add exclude_from_local_holds_priority column to items, deleteditems and categories tables");
22750 $DBversion = '20.06.00.033';
22751 if( CheckVersion( $DBversion ) ) {
22752 if( column_exists( 'opac_news', 'timestamp' ) ) {
22754 ALTER TABLE opac_news
22755 CHANGE COLUMN timestamp published_on date DEFAULT NULL
22758 if( !column_exists( 'opac_news', 'updated_on' ) ) {
22760 ALTER TABLE opac_news
22761 ADD COLUMN updated_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER published_on
22767 SET content = REPLACE(content,?,?)
22768 WHERE content LIKE ?
22769 |, undef, 'opac_news.timestamp', 'opac_news.published_on', '%opac_news.timestamp%' );
22771 NewVersion( $DBversion, 21066, ["Rename column opac_news.timestamp with published_on", "Add new column opac_news.updated_on", "Replace timestamp references in letters table"] );
22774 $DBversion = '20.06.00.034';
22775 if( CheckVersion( $DBversion ) ) {
22777 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
22778 VALUES ('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free')
22781 NewVersion( $DBversion, 24197, "Add new system preference 'AddressForFailedOverdueNotices'" );
22784 $DBversion = '20.06.00.035';
22785 if ( CheckVersion( $DBversion ) ) {
22787 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
22788 ('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice')
22791 NewVersion( $DBversion, 23682, "Add new system preference 'EdifactInvoiceImport'" );
22794 $DBversion = '20.06.00.036';
22795 if( CheckVersion( $DBversion ) ) {
22796 # Fix the markup in the OPACSearchForTitleIn system preference
22797 $dbh->do("UPDATE systempreferences SET VALUE = replace( value, '</li>', ''), value = REPLACE( value, '<li>', '') WHERE VARIABLE = 'OPACSearchForTitleIn';");
22799 NewVersion( $DBversion, 20168, "Update OPACSearchForTitleIn to work with Bootstrap 4");
22802 $DBversion = '20.06.00.037';
22803 if( CheckVersion( $DBversion ) ) {
22804 if( !column_exists( 'categories', 'min_password_length' ) ) {
22805 $dbh->do("ALTER TABLE categories ADD COLUMN `min_password_length` smallint(6) NULL DEFAULT NULL AFTER `change_password` -- set minimum password length for patrons in this category");
22807 if( !column_exists( 'categories', 'require_strong_password' ) ) {
22808 $dbh->do("ALTER TABLE categories ADD COLUMN `require_strong_password` TINYINT(1) NULL DEFAULT NULL AFTER `min_password_length` -- set required password strength for patrons in this category");
22811 NewVersion( $DBversion, 23816, "Add min_password_length and require_strong_password columns in categories table");
22814 $DBversion = '20.06.00.038';
22815 if( CheckVersion( $DBversion ) ) {
22816 $dbh->do( "ALTER TABLE `search_field` MODIFY COLUMN `type` enum('','string','date','number','boolean','sum','isbn','stdno','year') NOT NULL" );
22817 $dbh->do( "UPDATE `search_field` SET type = 'year' WHERE name = 'date-of-publication'" );
22819 NewVersion( $DBversion, 24807, "Add 'year' type to improve sorting behaviour" );
22822 $DBversion = '20.06.00.039';
22823 if( CheckVersion( $DBversion ) ) {
22825 if( !column_exists( 'hold_fill_targets', 'reserve_id' ) ) {
22826 $dbh->do( "ALTER TABLE hold_fill_targets ADD COLUMN reserve_id int(11) DEFAULT NULL AFTER item_level_request" );
22829 NewVersion( $DBversion, 18958, "Add reserve_id to hold_fill_targets");
22832 $DBversion = '20.06.00.040';
22833 if( CheckVersion( $DBversion ) ) {
22834 $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OpacMetaDescription','','','This description will show in search engine results (160 characters).','Textarea');" );
22836 NewVersion( $DBversion, 26454, "Add system preference to set meta description for the OPAC");
22839 $DBversion = '20.06.00.041';
22840 if ( CheckVersion($DBversion) ) {
22842 if ( column_exists( 'items', 'paidfor' ) ) {
22843 my ($count) = $dbh->selectrow_array(
22847 WHERE paidfor IS NOT NULL AND paidfor <> ""
22851 warn "Warning - Cannot remove column items.paidfor. At least one value exists";
22854 $dbh->do(q|ALTER TABLE items DROP COLUMN paidfor|);
22855 $dbh->do(q|UPDATE marc_subfield_structure SET kohafield = '' WHERE kohafield = 'items.paidfor'|);
22859 if ( column_exists( 'deleteditems', 'paidfor' ) ) {
22860 my ($count) = $dbh->selectrow_array(
22864 WHERE paidfor IS NOT NULL AND paidfor <> ""
22868 warn "Warning - Cannot remove column deleteditems.paidfor. At least one value exists";
22871 $dbh->do(q|ALTER TABLE deleteditems DROP COLUMN paidfor|);
22875 NewVersion( $DBversion, 26268, "Remove items.paidfor field" );
22878 $DBversion = '20.06.00.042';
22879 if( CheckVersion( $DBversion ) ) {
22880 unless ( column_exists('letter', 'updated_on') ) {
22882 ALTER TABLE letter ADD COLUMN updated_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER lang
22886 NewVersion( $DBversion, 25776, "Add letter.updated_on");
22889 $DBversion = '20.06.00.043';
22890 if( CheckVersion( $DBversion ) ) {
22892 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('CircConfirmItemParts', '0', NULL, 'Require staff to confirm that all parts of an item are present at checkin/checkout.', 'YesNo')
22895 NewVersion( $DBversion, 25261, "Add CircConfirmItemParts syspref");
22898 $DBversion = '20.06.00.044';
22899 if( CheckVersion( $DBversion ) ) {
22901 unless (TableExists('smtp_servers')) {
22905 CREATE TABLE `smtp_servers` (
22906 `id` INT(11) NOT NULL AUTO_INCREMENT,
22907 `name` VARCHAR(80) NOT NULL,
22908 `host` VARCHAR(80) NOT NULL DEFAULT 'localhost',
22909 `port` INT(11) NOT NULL DEFAULT 25,
22910 `timeout` INT(11) NOT NULL DEFAULT 120,
22911 `ssl_mode` ENUM('disabled', 'ssl', 'starttls') NOT NULL,
22912 `user_name` VARCHAR(80) NULL DEFAULT NULL,
22913 `password` VARCHAR(80) NULL DEFAULT NULL,
22914 `debug` TINYINT(1) NOT NULL DEFAULT 0,
22915 PRIMARY KEY (`id`),
22916 KEY `host_idx` (`host`)
22917 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22921 unless (TableExists('library_smtp_servers')) {
22923 CREATE TABLE `library_smtp_servers` (
22924 `id` INT(11) NOT NULL AUTO_INCREMENT,
22925 `library_id` VARCHAR(10) NOT NULL,
22926 `smtp_server_id` INT(11) NOT NULL,
22927 PRIMARY KEY (`id`),
22928 UNIQUE KEY `library_id_idx` (`library_id`),
22929 KEY `smtp_server_id_idx` (`smtp_server_id`),
22930 CONSTRAINT `library_smtp_servers_library_fk` FOREIGN KEY (`library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
22931 CONSTRAINT `library_smtp_servers_smtp_servers_fk` FOREIGN KEY (`smtp_server_id`) REFERENCES `smtp_servers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
22932 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22937 INSERT IGNORE INTO permissions
22938 (module_bit, code, description)
22939 VALUES ( 3, 'manage_smtp_servers', 'Manage SMTP servers configuration');
22942 NewVersion( $DBversion, 22343, "Add SMTP configuration options");
22945 $DBversion = '20.06.00.045';
22946 if( CheckVersion( $DBversion ) ) {
22948 unless ( TableExists('background_jobs') ) {
22950 CREATE TABLE background_jobs (
22951 id INT(11) NOT NULL AUTO_INCREMENT,
22952 status VARCHAR(32),
22955 borrowernumber INT(11),
22958 enqueued_on DATETIME DEFAULT NULL,
22959 started_on DATETIME DEFAULT NULL,
22960 ended_on DATETIME DEFAULT NULL,
22962 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22967 INSERT IGNORE permissions (module_bit, code, description)
22969 (3, 'manage_background_jobs', 'Manage background jobs')
22972 NewVersion( $DBversion, 22417, "Add new table background_jobs");
22975 $DBversion = '20.06.00.046';
22976 if( CheckVersion( $DBversion ) ) {
22977 unless ( foreign_key_exists( 'alert', 'alert_ibfk_1' ) ) {
22979 DELETE a FROM alert a
22980 LEFT JOIN borrowers b ON a.borrowernumber=b.borrowernumber
22981 WHERE b.borrowernumber IS NULL
22985 ADD CONSTRAINT alert_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON UPDATE CASCADE ON DELETE CASCADE
22988 NewVersion( $DBversion, 13535, "Add FK constraint on borrowernumber to alert table" );
22991 $DBversion = '20.06.00.047';
22992 if ( CheckVersion($DBversion) ) {
22994 #Get value from AllowPurchaseSuggestionBranchChoice system preference
22995 my ($allowpurchasesuggestionbranchchoice) =
22996 C4::Context->preference('AllowPurchaseSuggestionBranchChoice');
22997 if ($allowpurchasesuggestionbranchchoice) {
22999 INSERT IGNORE INTO systempreferences
23000 (`variable`, `value`, `options`, `explanation`, `type`)
23002 ('OPACSuggestionUnwantedFields','branch', NULL,'Define the hidden fields for a patron purchase suggestions made via OPAC.','multiple');
23007 INSERT IGNORE INTO systempreferences
23008 (`variable`, `value`, `options`, `explanation`, `type`)
23010 ('OPACSuggestionUnwantedFields','', NULL,'Define the hidden fields for a patron purchase suggestions made via OPAC.','multiple');
23014 #Remove the AllowPurchaseSuggestionBranchChoice system preference
23016 "DELETE FROM systempreferences WHERE variable='AllowPurchaseSuggestionBranchChoice'"
23018 NewVersion( $DBversion, 23420, "Allow configuration of hidden fields on the suggestion form in OPAC" );
23021 $DBversion = '20.06.00.048';
23022 if( CheckVersion( $DBversion ) ) {
23024 DELETE FROM circulation_rules WHERE
23025 rule_name IN ('holdallowed','hold_fulfillment_policy','returnbranch') AND
23028 NewVersion( $DBversion, 26529, "Remove blank default branch rules");
23031 $DBversion = '20.06.00.049';
23032 if( CheckVersion( $DBversion ) ) {
23034 if( TableExists('biblioimages') && !column_exists( 'biblioimages', 'itemnumber' ) ) {
23036 ALTER TABLE biblioimages
23037 ADD COLUMN itemnumber INT(11) DEFAULT NULL
23038 AFTER biblionumber;
23041 ALTER TABLE biblioimages
23042 ADD FOREIGN KEY bibliocoverimage_fk2 (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
23045 ALTER TABLE biblioimages MODIFY biblionumber INT(11) DEFAULT NULL
23049 if( !TableExists('cover_images') ) {
23051 ALTER TABLE biblioimages RENAME cover_images
23055 NewVersion( $DBversion, '26145', ["Add the biblioimages.itemnumber column", "Rename table biblioimages with cover_images"] );
23058 $DBversion = '20.06.00.050';
23059 if ( CheckVersion($DBversion) ) {
23061 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
23062 ('NoIssuesChargeGuarantorsWithGuarantees','','','Define maximum amount withstanding before checkouts are blocked including guarantors and their other guarantees','Integer');
23065 NewVersion( $DBversion, 19382, "Add ability to block guarantees based on fees owed by guarantor and other guarantee - new system preference 'NoIssuesChargeGuarantorsWithGuarantees'");
23068 $DBversion = '20.06.00.051';
23069 if( CheckVersion( $DBversion ) ) {
23071 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
23072 ('HoldsNeedProcessingSIP', '0', NULL, 'Require staff to check-in before hold is set to waiting state', 'YesNo' )
23075 NewVersion( $DBversion, 12556, "Add new syspref HoldsNeedProcessingSIP");
23078 $DBversion = '20.06.00.052';
23079 if ( CheckVersion($DBversion) ) {
23081 INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OAI-PMH:AutoUpdateSetEmbedItemData', '0', '', 'Embed item information when automatically updating OAI sets. Requires OAI-PMH:AutoUpdateSets syspref to be enabled', 'YesNo')
23085 UPDATE systempreferences SET explanation = 'Automatically update OAI sets when a bibliographic or item record is created or updated' WHERE variable = 'OAI-PMH:AutoUpdateSets'
23088 NewVersion( $DBversion, 25460, "Update OAI set when adding/editing/deleting item records" );
23091 $DBversion = '20.06.00.053';
23092 if( CheckVersion( $DBversion ) ) {
23093 $dbh->do( "UPDATE systempreferences SET explanation='Define which baskets a user is allowed to view: their own only, any within their branch, or all' WHERE variable='AcqViewBaskets'" );
23094 $dbh->do( "UPDATE systempreferences SET explanation='If enabled, the patron can set checkouts to be visible to their guarantor' WHERE variable='AllowPatronToSetCheckoutsVisibilityForGuarantor'" );
23095 $dbh->do( "UPDATE systempreferences SET explanation='If enabled, the patron can set fines to be visible to their guarantor' WHERE variable='AllowPatronToSetFinesVisibilityForGuarantor'" );
23096 $dbh->do( "UPDATE systempreferences SET explanation='If on, and a patron is logged into the OPAC, items from their home library will be emphasized and shown first in search results and item details.' WHERE variable='HighlightOwnItemsOnOPAC'" );
23097 $dbh->do( "UPDATE systempreferences SET explanation='If ON, the next user will automatically get the last searches in their history' WHERE variable='LoadSearchHistoryToTheFirstLoggedUser'" );
23098 $dbh->do( "UPDATE systempreferences SET explanation='If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate their account.' WHERE variable='PatronSelfRegistrationVerifyByEmail'" );
23100 NewVersion( $DBversion, 26569, "Use gender neutral pronouns in system preference explanations" );
23103 $DBversion = '20.06.00.054';
23104 if ( CheckVersion($DBversion) ) {
23108 INSERT IGNORE INTO account_credit_types (code, description, can_be_added_manually, is_system)
23110 ('OVERPAYMENT', 'Overpayment refund', 0, 1)
23116 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('Overpayment');
23122 UPDATE accountlines SET credit_type_code = 'OVERPAYMENT' WHERE credit_type_code = 'CREDIT' AND description = 'Overpayment refund'
23126 NewVersion( $DBversion, 25596, "Add OVERPAYMENT credit type" );
23129 $DBversion = '20.06.00.055';
23130 if( CheckVersion( $DBversion ) ) {
23131 my $count_missing_budget = $dbh->selectrow_arrayref(q|
23132 SELECT COUNT(*) FROM aqbudgets ab WHERE NOT EXISTS
23133 (SELECT * FROM aqbudgetperiods abp WHERE abp.budget_period_id = ab.budget_period_id)
23134 AND budget_period_id IS NOT NULL;
23139 if($count_missing_budget->[0] > 0) {
23141 CREATE TABLE _bug_18050_aqbudgets AS
23142 SELECT * FROM aqbudgets ab WHERE NOT EXISTS
23143 (SELECT * FROM aqbudgetperiods abp WHERE abp.budget_period_id = ab.budget_period_id)
23147 UPDATE aqbudgets ab SET budget_period_id = NULL
23149 (SELECT * FROM aqbudgetperiods abp WHERE abp.budget_period_id = ab.budget_period_id)
23151 $message = ". There are $count_missing_budget->[0] funds in your database that are not linked
23152 to a valid budget. Setting invalid budget id (budget_period_id) to null. The table _bug_18050_aqbudgets
23153 was created with original data. Please check that table and place valid ids in aqbudget table as soon as possible."
23157 if ( !foreign_key_exists( 'aqbudgets', 'aqbudgetperiods_ibfk_1' ) ) {
23159 ALTER TABLE aqbudgets ADD CONSTRAINT `aqbudgetperiods_ibfk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON UPDATE CASCADE ON DELETE CASCADE
23161 NewVersion( $DBversion, 18050, "Add FK constraint on aqbudgets.budget_period_id$message");
23163 NewVersion( $DBversion, 18050, "FK constraint on aqbudgets.budget already exists");
23168 $DBversion = '20.06.00.056';
23169 if( CheckVersion( $DBversion ) ) {
23171 $dbh->do("DROP INDEX title ON import_biblios");
23172 $dbh->do("DROP INDEX isbn ON import_biblios");
23173 $dbh->do("ALTER TABLE import_biblios MODIFY title LONGTEXT");
23174 $dbh->do("ALTER TABLE import_biblios MODIFY author LONGTEXT");
23175 $dbh->do("ALTER TABLE import_biblios MODIFY isbn LONGTEXT");
23176 $dbh->do("ALTER TABLE import_biblios MODIFY issn LONGTEXT");
23177 $dbh->do("CREATE INDEX title ON import_biblios (title(191));");
23178 $dbh->do("CREATE INDEX isbn ON import_biblios (isbn(191));");
23180 NewVersion( $DBversion, 26853, "Update import_biblios columns and indexes" );
23183 $DBversion = '20.06.00.057';
23184 if( CheckVersion( $DBversion ) ) {
23186 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES
23187 ('ArticleRequestsMandatoryFieldsItemOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''item_only''', 'multiple')
23190 DELETE FROM systempreferences WHERE variable = "ArticleRequestsMandatoryFieldsItemsOnly"
23193 NewVersion( $DBversion, 26638, "Add missing system preference ArticleRequestsMandatoryFieldsItemOnly");
23196 $DBversion = '20.06.00.058';
23197 if( CheckVersion( $DBversion ) ) {
23199 UPDATE message_transport_types SET message_transport_type = "itiva" WHERE message_transport_type = "phone"
23202 NewVersion( $DBversion, 25333, q{Change message transport type for Talking Tech from "phone" to "itiva"});
23205 $DBversion = '20.06.00.059';
23206 if( CheckVersion( $DBversion ) ) {
23208 if( !column_exists( 'search_field', 'mandatory' ) ) {
23209 $dbh->do( "ALTER TABLE search_field ADD COLUMN mandatory tinyint(1) NULL DEFAULT NULL AFTER opac" );
23212 NewVersion( $DBversion, 19482, "Add mandatory column to search_field for ES mapping" );
23215 $DBversion = '20.06.00.060';
23216 if( CheckVersion( $DBversion ) ) {
23218 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
23219 ('PhoneNotification','0',NULL,'If ON, enables generation of phone notifications to be sent by plugins','YesNo')
23223 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('phone')
23227 INSERT IGNORE INTO `message_transports`
23228 (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`)
23230 (1, 'phone', 0, 'circulation', 'DUE'),
23231 (1, 'phone', 1, 'circulation', 'DUEDGST'),
23232 (2, 'phone', 0, 'circulation', 'PREDUE'),
23233 (2, 'phone', 1, 'circulation', 'PREDUEDGST'),
23234 (4, 'phone', 0, 'reserves', 'HOLD'),
23235 (5, 'phone', 0, 'circulation', 'CHECKIN'),
23236 (6, 'phone', 0, 'circulation', 'CHECKOUT');
23239 NewVersion( $DBversion, 25334, "Add generic 'phone' message transport type");
23242 $DBversion = '20.06.00.061';
23243 if( CheckVersion( $DBversion ) ) {
23244 if ( !column_exists( 'reserves', 'desk_id' ) ) {
23246 ALTER TABLE reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode,
23247 ADD KEY desk_id (`desk_id`),
23248 ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`desk_id`) REFERENCES `desks` (`desk_id`) ON DELETE SET NULL ON UPDATE CASCADE ;
23251 ALTER TABLE old_reserves ADD COLUMN desk_id INT(11) DEFAULT NULL AFTER branchcode,
23252 ADD KEY `old_desk_id` (`desk_id`);
23256 NewVersion( $DBversion, 24412, "Attach waiting reserve to desk" );
23259 $DBversion = '20.06.00.062';
23260 if( CheckVersion( $DBversion ) ) {
23261 $dbh->do( "UPDATE circulation_rules SET rule_name = 'lostreturn' WHERE rule_name = 'refund'" );
23262 $dbh->do( "UPDATE circulation_rules SET rule_value = 'refund' WHERE rule_name = 'lostreturn' AND rule_value = 1" );
23264 NewVersion( $DBversion, 23091, "Update refund rules");
23267 $DBversion = '20.06.00.063';
23268 if( CheckVersion( $DBversion ) ) {
23269 $dbh->do(q{INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'decreaseloanholds', NULL) });
23271 NewVersion( $DBversion, 14866, "Add decreaseloanholds circulation rule" );
23274 $DBversion = '20.06.00.064';
23275 if ( CheckVersion($DBversion) ) {
23278 INSERT IGNORE INTO account_credit_types (code, description, can_be_added_manually, is_system)
23279 VALUES ('CANCELLATION', 'Cancelled charge', 0, 1)
23283 INSERT IGNORE INTO account_offset_types ( type ) VALUES ('CANCELLATION');
23286 NewVersion( $DBversion, 24603, "Add CANCELLATION credit_type_code" );
23289 $DBversion = '20.06.00.065';
23290 if( CheckVersion( $DBversion ) ) {
23291 if( !column_exists( 'issues', 'issuer_id' ) ) {
23292 $dbh->do( q| ALTER TABLE issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
23294 if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
23295 $dbh->do( q| ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
23297 if( !column_exists( 'old_issues', 'issuer_id' ) ) {
23298 $dbh->do( q| ALTER TABLE old_issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
23300 if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
23301 $dbh->do( q| ALTER TABLE old_issues ADD CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
23304 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RecordStaffUserOnCheckout', '0', 'If enabled, when an item is checked out, the user who checked out the item is recorded', '', 'YesNo'); | );
23306 NewVersion( $DBversion, 23916, [ "Add new [old_]issues.issuer DB fields", "Add new syspref RecordStaffUserOnCheckout" ] );
23309 $DBversion = '20.06.00.066';
23310 if( CheckVersion( $DBversion ) ) {
23311 if( !column_exists( 'branches', 'branchillemail' ) ) {
23312 $dbh->do( q| ALTER TABLE branches ADD branchillemail LONGTEXT AFTER branchemail | );
23315 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('ILLDefaultStaffEmail', '', 'Fallback email address for staff ILL notices to be sent to in the absence of a branch address', NULL, 'Free'); | );
23316 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('ILLSendStaffNotices', NULL, 'Send these ILL notices to staff', NULL, 'multiple'); | );
23318 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PICKUP_READY', '', 'ILL request ready for pickup', 0, "Interlibrary loan request ready for pickup", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe Interlibrary loans request number [% illrequest.illrequest_id %] you placed for:\n\n- [% ill_bib_title %] - [% ill_bib_author %]\n\nis ready for pick up from [% branch.branchname %].\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'email', 'default'); | );
23319 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_UNAVAIL', '', 'ILL request unavailable', 0, "Interlibrary loan request unavailable", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe Interlibrary loans request number [% illrequest.illrequest_id %] you placed for\n\n- [% ill_bib_title %] - [% ill_bib_author %]\n\nis unfortunately unavailable.\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'email', 'default'); | );
23320 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_CANCEL', '', 'ILL request cancelled', 0, "Interlibrary loan request cancelled", "The patron for interlibrary loans request [% illrequest.illrequest_id %], with the following details, has requested cancellation of this ILL request:\n\n[% ill_full_metadata %]", 'email', 'default'); | );
23321 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_MODIFIED', '', 'ILL request modified', 0, "Interlibrary loan request modified", "The patron for interlibrary loans request [% illrequest.illrequest_id %], with the following details, has modified this ILL request:\n\n[% ill_full_metadata %]", 'email', 'default'); | );
23322 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PARTNER_REQ', '', 'ILL request to partners', 0, "Interlibrary loan request to partners", "Dear Sir/Madam,\n\nWe would like to request an interlibrary loan for a title matching the following description:\n\n[% ill_full_metadata %]\n\nPlease let us know if you are able to supply this to us.\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'email', 'default'); | );
23323 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PICKUP_READY', '', 'ILL request ready for pickup', 0, "Interlibrary loan request ready for pickup", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe Interlibrary loans request number [% illrequest.illrequest_id %] you placed for:\n\n- [% ill_bib_title %] - [% ill_bib_author %]\n\nis ready for pick up from [% branch.branchname %].\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'sms', 'default'); | );
23324 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_UNAVAIL', '', 'ILL request unavailable', 0, "Interlibrary loan request unavailable", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nThe Interlibrary loans request number [% illrequest.illrequest_id %] you placed for\n\n- [% ill_bib_title %] - [% ill_bib_author %]\n\nis unfortunately unavailable.\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'sms', 'default'); | );
23325 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_CANCEL', '', 'ILL request cancelled', 0, "Interlibrary loan request cancelled", "The patron for interlibrary loans request [% illrequest.illrequest_id %], with the following details, has requested cancellation of this ILL request:\n\n[% ill_full_metadata %]", 'sms', 'default'); | );
23326 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_MODIFIED', '', 'ILL request modified', 0, "Interlibrary loan request modified", "The patron for interlibrary loans request [% illrequest.illrequest_id %], with the following details, has modified this ILL request:\n\n[% ill_full_metadata %]", 'sms', 'default'); | );
23327 $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PARTNER_REQ', '', 'ILL request to partners', 0, "Interlibrary loan request to partners", "Dear Sir/Madam,\n\nWe would like to request an interlibrary loan for a title matching the following description:\n\n[% ill_full_metadata %]\n\nPlease let us know if you are able to supply this to us.\n\nKind Regards\n\n[% branch.branchname %]\n[% branch.branchaddress1 %]\n[% branch.branchaddress2 %]\n[% branch.branchaddress3 %]\n[% branch.branchcity %]\n[% branch.branchstate %]\n[% branch.branchzip %]\n[% branch.branchphone %]\n[% branch.branchillemail %]\n[% branch.branchemail %]", 'sms', 'default'); | );
23328 # Add patron messaging preferences
23329 $dbh->do( q| INSERT IGNORE INTO message_attributes (message_name, takes_days) VALUES ('Ill_ready', 0); | );
23330 my $ready_id = $dbh->last_insert_id(undef, undef, 'message_attributes', undef);
23331 if (defined $ready_id) {
23332 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'email', 0, 'ill', 'ILL_PICKUP_READY');) );
23333 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'sms', 0, 'ill', 'ILL_PICKUP_READY');) );
23334 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'phone', 0, 'ill', 'ILL_PICKUP_READY');) );
23336 $dbh->do( q| INSERT IGNORE INTO message_attributes (message_name, takes_days) VALUES ('Ill_unavailable', 0); | );
23337 my $unavail_id = $dbh->last_insert_id(undef, undef, 'message_attributes', undef);
23338 if (defined $unavail_id) {
23339 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'email', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) );
23340 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'sms', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) );
23341 $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'phone', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) );
23344 NewVersion( $DBversion, 22818, "Add ILL notices" );
23347 $DBversion = '20.06.00.067';
23348 if( CheckVersion( $DBversion ) ) {
23350 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
23351 ('OPACHoldsHistory','0','','If ON, enables display of Patron Holds History in OPAC','YesNo')
23354 NewVersion( $DBversion, 20936, "Add new system preference OPACHoldsHistory");
23357 $DBversion = '20.06.00.068';
23358 if( CheckVersion( $DBversion ) ) {
23359 if( !TableExists( 'import_batch_profiles' ) ) {
23361 CREATE TABLE `import_batch_profiles` ( -- profile for batches of marc records to be imported
23362 `id` int(11) NOT NULL auto_increment, -- unique identifier and primary key
23363 `name` varchar(100) NOT NULL, -- name of this profile
23364 `matcher_id` int(11) default NULL, -- the id of the match rule used (matchpoints.matcher_id)
23365 `template_id` int(11) default NULL, -- the id of the marc modification template
23366 `overlay_action` varchar(50) default NULL, -- how to handle duplicate records
23367 `nomatch_action` varchar(50) default NULL, -- how to handle records where no match is found
23368 `item_action` varchar(50) default NULL, -- what to do with item records
23369 `parse_items` tinyint(1) default NULL, -- should items be parsed
23370 `record_type` varchar(50) default NULL, -- type of record in the batch
23371 `encoding` varchar(50) default NULL, -- file encoding
23372 `format` varchar(50) default NULL, -- marc format
23373 `comments` LONGTEXT, -- any comments added when the file was uploaded
23374 PRIMARY KEY (`id`),
23375 UNIQUE KEY `u_import_batch_profiles__name` (`name`)
23376 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
23380 if(!column_exists('import_batches', 'profile_id')) {
23382 ALTER TABLE import_batches ADD COLUMN `profile_id` int(11) default NULL AFTER comments
23386 ALTER TABLE import_batches ADD CONSTRAINT `import_batches_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `import_batch_profiles` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
23390 NewVersion( $DBversion, 23019, "Add import_batch_profiles table and profile_id column in import_batches" );
23393 $DBversion = '20.06.00.069';
23394 if( CheckVersion( $DBversion ) ) {
23395 my ($count) = $dbh->selectrow_array(
23398 FROM circulation_rules
23399 WHERE rule_name = 'unseen_renewals_allowed'
23404 INSERT INTO circulation_rules (rule_name, rule_value)
23405 VALUES ('unseen_renewals_allowed', '')
23409 if( !column_exists( 'issues', 'unseen_renewals' ) ) {
23410 $dbh->do( q| ALTER TABLE issues ADD unseen_renewals TINYINT(4) DEFAULT 0 NOT NULL AFTER renewals | );
23412 if( !column_exists( 'old_issues', 'unseen_renewals' ) ) {
23413 $dbh->do( q| ALTER TABLE old_issues ADD unseen_renewals TINYINT(4) DEFAULT 0 NOT NULL AFTER renewals | );
23416 $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('UnseenRenewals', '0', 'If enabled, a renewal can be recorded as "unseen" by the library and count against the borrowers unseen renewals limit', '', 'YesNo'); | );
23418 NewVersion( $DBversion, 24083, ["Add circulation_rules 'unseen_renewals_allowed'", "Add issues.unseen_renewals & old_issues.unseen_renewals)", "Add new system preference UnseenRenewals"] );
23421 $DBversion = '20.11.00.000';
23422 if( CheckVersion( $DBversion ) ) {
23423 NewVersion( $DBversion, "", "Koha 20.11.00 release" );
23426 $DBversion = '20.12.00.000';
23427 if( CheckVersion( $DBversion ) ) {
23428 NewVersion( $DBversion, "", "Sorry, this is my first life, I am still learning!" );
23431 $DBversion = '20.12.00.001';
23432 if( CheckVersion( $DBversion ) ) {
23434 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
23435 ('ElasticsearchCrossFields', '1', '', 'Enable "cross_fields" option for searches using Elastic search.', 'YesNo')
23437 NewVersion( $DBversion, 27252, "Add ElasticsearchCrossFields system preference");
23440 $DBversion = '20.12.00.002';
23441 if( CheckVersion( $DBversion ) ) {
23442 $dbh->do(q{UPDATE systempreferences SET `type` = 'Choice' WHERE `variable` = 'UsageStatsCountry'});
23443 NewVersion( $DBversion, 27351, "Set type for UsageStatsCountry to Choice");
23446 $DBversion = '20.12.00.003';
23447 if( CheckVersion( $DBversion ) ) {
23448 $dbh->do(q{UPDATE systempreferences SET `type` = 'Choice' WHERE `variable` = 'Mana'});
23449 NewVersion( $DBversion, 27349, "Update type for Mana system preference to Choice");
23452 $DBversion = '20.12.00.004';
23453 if( CheckVersion( $DBversion ) ) {
23454 $dbh->do(q{UPDATE systempreferences set variable="TaxRates" WHERE variable="gist"});
23455 NewVersion( $DBversion, 27485, "Rename system preference 'gist' to 'TaxRates'");
23458 $DBversion = '20.12.00.005';
23459 if( CheckVersion( $DBversion ) ) {
23460 $dbh->do(q{UPDATE systempreferences set variable="OPACLanguages" WHERE variable="opaclanguages"});
23461 NewVersion( $DBversion, 27491, "Rename system preference 'opaclanguages' to 'OPACLanguages'");
23464 $DBversion = '20.12.00.006';
23465 if( CheckVersion( $DBversion ) ) {
23466 $dbh->do(q{UPDATE systempreferences SET variable="OPACComments" WHERE variable="reviewson" });
23467 NewVersion( $DBversion, 27487, "Rename system preference 'reviewson' to 'OPACComments");
23470 $DBversion = '20.12.00.007';
23471 if( CheckVersion( $DBversion ) ) {
23472 $dbh->do(q{UPDATE systempreferences set variable="CSVDelimiter" WHERE variable="delimiter"});
23473 NewVersion( $DBversion, 27486, "Renaming system preference 'delimiter' to 'CSVDelimiter'");
23476 $DBversion = '20.12.00.008';
23477 if( CheckVersion( $DBversion ) ) {
23479 UPDATE systempreferences
23480 SET options = "claim_returned|batchmod|moredetail|cronjob|additem|pendingreserves|onpayment"
23481 WHERE variable = "MarkLostItemsAsReturned";
23483 NewVersion( $DBversion, 25552, "Add missing Claims Returned option to MarkLostItemsAsReturned");
23486 $DBversion = '20.12.00.009';
23487 if( CheckVersion( $DBversion ) ) {
23488 $dbh->do( "UPDATE systempreferences SET variable = 'UseICUStyleQUotes' WHERE variable = 'UseICU'" );
23489 NewVersion( $DBversion, 27581, "Rename system preference 'UseICU' to 'UseICUStyleQuotes'");
23492 $DBversion = '20.12.00.010';
23493 if( CheckVersion( $DBversion ) ) {
23495 DELETE FROM systempreferences WHERE variable="OpacGroupResults"
23498 NewVersion( $DBversion, 20410, "Remove OpacGroupResults");
23501 $DBversion = '20.12.00.011';
23502 if ( CheckVersion($DBversion) ) {
23504 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
23506 ('OPACShibOnly','0','If ON enables shibboleth only authentication for the opac','','YesNo'),
23507 ('staffShibOnly','0','If ON enables shibboleth only authentication for the staff client','','YesNo')
23509 NewVersion( $DBversion, 18506, "Add OPACShibOnly and staffShibOnly system preferences" );
23512 $DBversion = '20.12.00.012';
23513 if( CheckVersion( $DBversion ) ) {
23514 my $category_exists = $dbh->selectrow_array("SELECT count(category_name) FROM authorised_value_categories WHERE category_name='UPLOAD'");
23516 if( $category_exists ){
23517 $description = "The UPLOAD authorized value category exists. Update the 'is_system' value to 1.";
23518 $dbh->do( "UPDATE authorised_value_categories SET is_system = 1 WHERE category_name = 'UPLOAD'" );
23520 $description = "The UPLOAD authorized value category does not exist. Create it.";
23521 $dbh->do( "INSERT IGNORE INTO authorised_value_categories (category_name, is_system) VALUES ('UPLOAD', 1)" );
23524 NewVersion( $DBversion, 27598, ["Add UPLOAD as a built-in system authorized value category", $description] );
23527 $DBversion = '20.12.00.013';
23528 if( CheckVersion( $DBversion ) ) {
23530 INSERT IGNORE INTO systempreferences
23531 (variable, value, explanation, options, type) VALUES
23532 ('DefaultSaveRecordFileID', 'biblionumber', 'Defines whether the advanced cataloging editor will use the bibliographic record number or control number field to populate the name of the save file.', 'biblionumber|controlnumber', 'Choice')
23534 NewVersion( $DBversion, 24108, "Add system preference DefaultSaveRecordFileID");
23538 # if there is anything in the atomicupdate, read and execute it.
23539 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
23540 opendir( my $dirh, $update_dir );
23541 foreach my $file ( sort readdir $dirh ) {
23542 next if $file !~ /\.(sql|perl)$/; #skip other files
23543 next if $file eq 'skeleton.perl'; # skip the skeleton file
23544 print "DEV atomic update: $file\n";
23545 if ( $file =~ /\.sql$/ ) {
23546 my $installer = C4::Installer->new();
23547 my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
23548 } elsif ( $file =~ /\.perl$/ ) {
23549 my $code = read_file( $update_dir . $file );
23550 eval $code; ## no critic (StringyEval)
23551 say "Atomic update generated errors: $@" if $@;
23557 =head2 DropAllForeignKeys($table)
23559 Drop all foreign keys of the table $table
23563 sub DropAllForeignKeys {
23565 # get the table description
23566 my $sth = $dbh->prepare("SHOW CREATE TABLE $table");
23568 my $vsc_structure = $sth->fetchrow;
23569 # split on CONSTRAINT keyword
23570 my @fks = split /CONSTRAINT /,$vsc_structure;
23573 # isolate what is before FOREIGN KEY, if there is something, it's a foreign key to drop
23574 $_ = /(.*) FOREIGN KEY.*/;
23577 # we have found 1 foreign, drop it
23578 $dbh->do("ALTER TABLE $table DROP FOREIGN KEY $id");
23585 =head2 TransformToNum
23587 Transform the Koha version from a 4 parts string
23588 to a number, with just 1 .
23592 sub TransformToNum {
23593 my $version = shift;
23594 # remove the 3 last . to have a Perl number
23595 $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
23596 # three X's at the end indicate that you are testing patch with dbrev
23597 # change it into 999
23598 # prevents error on a < comparison between strings (should be: lt)
23599 $version =~ s/XXX$/999/;
23605 set the DBversion in the systempreferences
23610 return if $_[0]=~ /XXX$/;
23611 #you are testing a patch with a db revision; do not change version
23612 my $kohaversion = TransformToNum($_[0]);
23613 if (C4::Context->preference('Version')) {
23614 my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
23615 $finish->execute($kohaversion);
23617 my $finish=$dbh->prepare("INSERT into systempreferences (variable,value,explanation) values ('Version',?,'The Koha database version. WARNING: Do not change this value manually, it is maintained by the webinstaller')");
23618 $finish->execute($kohaversion);
23620 C4::Context::clear_syspref_cache(); # invalidate cached preferences
23624 my ( $DBversion, $bug_number, $descriptions ) = @_;
23626 SetVersion($DBversion);
23628 unless ( ref($descriptions) ) {
23629 $descriptions = [ $descriptions ];
23632 my $time = POSIX::strftime("%H:%M:%S",localtime);
23633 for my $description ( @$descriptions ) {
23634 if ( @$descriptions > 1 ) {
23636 unless ( $bug_number ) {
23637 say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description;
23639 say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description;
23642 say sprintf "\t\t\t\t\t\t - %s", $description;
23645 unless ( $bug_number ) {
23646 say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description;
23648 say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description;
23655 =head2 CheckVersion
23657 Check whether a given update should be run when passed the proposed version
23658 number. The update will always be run if the proposed version is greater
23659 than the current database version and less than or equal to the version in
23660 kohaversion.pl. The update is also run if the version contains XXX, though
23661 this behavior will be changed following the adoption of non-linear updates
23662 as implemented in bug 7167.
23667 my ($proposed_version) = @_;
23668 my $version_number = TransformToNum($proposed_version);
23670 # The following line should be deleted when bug 7167 is pushed
23671 return 1 if ( $proposed_version =~ m/XXX/ );
23673 if ( C4::Context->preference("Version") < $version_number
23674 && $version_number <= TransformToNum( $Koha::VERSION ) )