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 under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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!
43 use MARC::File::XML ( BinaryEncoding => 'utf8' );
45 # FIXME - The user might be installing a new database, so can't rely
46 # on /etc/koha.conf anyway.
53 %existingtables, # tables already in database
57 $type, $null, $key, $default, $extra,
58 $prefitem, # preference item in systempreferences table
65 my $dbh = C4::Context->dbh;
66 $|=1; # flushes output
68 local $dbh->{RaiseError} = 0;
70 # Record the version we are coming from
72 my $original_version = C4::Context->preference("Version");
74 # Deal with virtualshelves
75 my $DBversion = "3.00.00.001";
76 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
77 # update virtualshelves table to
79 $dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
80 $dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
81 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
82 $dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
83 # drop all foreign keys : otherwise, we can't drop itemnumber field.
84 DropAllForeignKeys('virtualshelfcontents');
85 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
86 # create the new foreign keys (on biblionumber)
87 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
88 # re-create the foreign key on virtualshelf
89 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
90 $dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
91 print "Upgrade to $DBversion done (virtualshelves)\n";
92 SetVersion ($DBversion);
96 $DBversion = "3.00.00.002";
97 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
98 $dbh->do("DROP TABLE sessions");
99 $dbh->do("CREATE TABLE `sessions` (
100 `id` varchar(32) NOT NULL,
101 `a_session` text NOT NULL,
102 UNIQUE KEY `id` (`id`)
103 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
104 print "Upgrade to $DBversion done (sessions uses CGI::session, new table structure for sessions)\n";
105 SetVersion ($DBversion);
109 $DBversion = "3.00.00.003";
110 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
111 if (C4::Context->preference("opaclanguages") eq "fr") {
112 $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')");
114 $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')");
116 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
117 SetVersion ($DBversion);
121 $DBversion = "3.00.00.004";
122 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
123 $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')");
124 print "Upgrade to $DBversion done (adding DebugLevel systempref, in 'Admin' tab)\n";
125 SetVersion ($DBversion);
128 $DBversion = "3.00.00.005";
129 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
130 $dbh->do("CREATE TABLE `tags` (
131 `entry` varchar(255) NOT NULL default '',
132 `weight` bigint(20) NOT NULL default 0,
133 PRIMARY KEY (`entry`)
134 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
136 $dbh->do("CREATE TABLE `nozebra` (
137 `server` varchar(20) NOT NULL,
138 `indexname` varchar(40) NOT NULL,
139 `value` varchar(250) NOT NULL,
140 `biblionumbers` longtext NOT NULL,
141 KEY `indexname` (`server`,`indexname`),
142 KEY `value` (`server`,`value`))
143 ENGINE=InnoDB DEFAULT CHARSET=utf8;
145 print "Upgrade to $DBversion done (adding tags and nozebra tables )\n";
146 SetVersion ($DBversion);
149 $DBversion = "3.00.00.006";
150 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
151 $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate='0000-00-00'");
152 print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n";
153 SetVersion ($DBversion);
156 $DBversion = "3.00.00.007";
157 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
158 $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')");
159 print "Upgrade to $DBversion done (set SessionStorage variable)\n";
160 SetVersion ($DBversion);
163 $DBversion = "3.00.00.008";
164 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
165 $dbh->do("ALTER TABLE `biblio` ADD `datecreated` DATE NOT NULL AFTER `timestamp` ;");
166 $dbh->do("UPDATE biblio SET datecreated=timestamp");
167 print "Upgrade to $DBversion done (biblio creation date)\n";
168 SetVersion ($DBversion);
171 $DBversion = "3.00.00.009";
172 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
174 # Create backups of call number columns
175 # in case default migration needs to be customized
177 # UPGRADE NOTE: temp_upg_biblioitems_call_num should be dropped
178 # after call numbers have been transformed to the new structure
180 # Not bothering to do the same with deletedbiblioitems -- assume
181 # default is good enough.
182 $dbh->do("CREATE TABLE `temp_upg_biblioitems_call_num` AS
183 SELECT `biblioitemnumber`, `biblionumber`,
184 `classification`, `dewey`, `subclass`,
186 FROM `biblioitems`");
188 # biblioitems changes
189 $dbh->do("ALTER TABLE `biblioitems` CHANGE COLUMN `volumeddesc` `volumedesc` TEXT,
190 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
191 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
192 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
193 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
194 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
195 ADD `totalissues` INT(10) AFTER `cn_sort`");
197 # default mapping of call number columns:
198 # cn_class = concatentation of classification + dewey,
199 # trimmed to fit -- assumes that most users do not
200 # populate both classification and dewey in a single record
202 # cn_source = left null
205 # After upgrade, cn_sort will have to be set based on whatever
206 # default call number scheme user sets as a preference. Misc
207 # script will be added at some point to do that.
209 $dbh->do("UPDATE `biblioitems`
210 SET cn_class = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
215 # Now drop the old call number columns
216 $dbh->do("ALTER TABLE `biblioitems` DROP COLUMN `classification`,
218 DROP COLUMN `subclass`,
219 DROP COLUMN `lcsort`,
220 DROP COLUMN `ccode`");
222 # deletedbiblio changes
223 $dbh->do("ALTER TABLE `deletedbiblio` ALTER COLUMN `frameworkcode` SET DEFAULT '',
225 ADD `datecreated` DATE NOT NULL AFTER `timestamp`");
226 $dbh->do("UPDATE deletedbiblio SET datecreated = timestamp");
228 # deletedbiblioitems changes
229 $dbh->do("ALTER TABLE `deletedbiblioitems`
230 MODIFY `publicationyear` TEXT,
231 CHANGE `volumeddesc` `volumedesc` TEXT,
232 MODIFY `collectiontitle` MEDIUMTEXT DEFAULT NULL AFTER `volumedesc`,
233 MODIFY `collectionissn` TEXT DEFAULT NULL AFTER `collectiontitle`,
234 MODIFY `collectionvolume` MEDIUMTEXT DEFAULT NULL AFTER `collectionissn`,
235 MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
236 MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
237 MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
238 MODIFY `marc` LONGBLOB,
239 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
240 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
241 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
242 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
243 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
244 ADD `totalissues` INT(10) AFTER `cn_sort`,
245 ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
246 ADD KEY `isbn` (`isbn`),
247 ADD KEY `publishercode` (`publishercode`)
250 $dbh->do("UPDATE `deletedbiblioitems`
251 SET `cn_class` = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
252 `cn_item` = `subclass`,
255 $dbh->do("ALTER TABLE `deletedbiblioitems`
256 DROP COLUMN `classification`,
258 DROP COLUMN `subclass`,
259 DROP COLUMN `lcsort`,
263 # deleteditems changes
264 $dbh->do("ALTER TABLE `deleteditems`
265 MODIFY `barcode` VARCHAR(20) DEFAULT NULL,
266 MODIFY `price` DECIMAL(8,2) DEFAULT NULL,
267 MODIFY `replacementprice` DECIMAL(8,2) DEFAULT NULL,
269 MODIFY `itemcallnumber` VARCHAR(30) DEFAULT NULL AFTER `wthdrawn`,
270 MODIFY `holdingbranch` VARCHAR(10) DEFAULT NULL,
272 MODIFY `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER `paidfor`,
274 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
275 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
276 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
277 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
278 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`,
279 MODIFY `marc` LONGBLOB AFTER `uri`,
281 DROP KEY `itembarcodeidx`,
282 DROP KEY `itembinoidx`,
283 DROP KEY `itembibnoidx`,
284 ADD UNIQUE KEY `delitembarcodeidx` (`barcode`),
285 ADD KEY `delitembinoidx` (`biblioitemnumber`),
286 ADD KEY `delitembibnoidx` (`biblionumber`),
287 ADD KEY `delhomebranch` (`homebranch`),
288 ADD KEY `delholdingbranch` (`holdingbranch`)");
289 $dbh->do("UPDATE deleteditems SET `ccode` = `itype`");
290 $dbh->do("ALTER TABLE deleteditems DROP `itype`");
291 $dbh->do("UPDATE `deleteditems` SET `cn_sort` = `itemcallnumber`");
294 $dbh->do("ALTER TABLE `items` ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
295 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
296 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
297 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
298 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`
300 $dbh->do("ALTER TABLE `items`
301 DROP KEY `itembarcodeidx`,
302 ADD UNIQUE KEY `itembarcodeidx` (`barcode`)");
304 # map items.itype to items.ccode and
305 # set cn_sort to itemcallnumber -- as with biblioitems.cn_sort,
306 # will have to be subsequently updated per user's default
307 # classification scheme
308 $dbh->do("UPDATE `items` SET `cn_sort` = `itemcallnumber`,
311 $dbh->do("ALTER TABLE `items` DROP `cutterextra`,
314 print "Upgrade to $DBversion done (major changes to biblio, biblioitems, items, and deleted* versions of same\n";
315 SetVersion ($DBversion);
318 $DBversion = "3.00.00.010";
319 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
320 $dbh->do("CREATE INDEX `userid` ON borrowers (`userid`) ");
321 print "Upgrade to $DBversion done (userid index added)\n";
322 SetVersion ($DBversion);
325 $DBversion = "3.00.00.011";
326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
327 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
328 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
329 $dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
330 $dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
331 $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
332 print "Upgrade to $DBversion done (added branchcategory type)\n";
333 SetVersion ($DBversion);
336 $DBversion = "3.00.00.012";
337 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
338 $dbh->do("CREATE TABLE `class_sort_rules` (
339 `class_sort_rule` varchar(10) NOT NULL default '',
340 `description` mediumtext,
341 `sort_routine` varchar(30) NOT NULL default '',
342 PRIMARY KEY (`class_sort_rule`),
343 UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
344 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
345 $dbh->do("CREATE TABLE `class_sources` (
346 `cn_source` varchar(10) NOT NULL default '',
347 `description` mediumtext,
348 `used` tinyint(4) NOT NULL default 0,
349 `class_sort_rule` varchar(10) NOT NULL default '',
350 PRIMARY KEY (`cn_source`),
351 UNIQUE KEY `cn_source_idx` (`cn_source`),
352 KEY `used_idx` (`used`),
353 CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`)
354 REFERENCES `class_sort_rules` (`class_sort_rule`)
355 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
356 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type)
357 VALUES('DefaultClassificationSource','ddc',
358 'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'free')");
359 $dbh->do("INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
360 ('dewey', 'Default filing rules for DDC', 'Dewey'),
361 ('lcc', 'Default filing rules for LCC', 'LCC'),
362 ('generic', 'Generic call number filing rules', 'Generic')");
363 $dbh->do("INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
364 ('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
365 ('lcc', 'Library of Congress Classification', 1, 'lcc'),
366 ('udc', 'Universal Decimal Classification', 0, 'generic'),
367 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
368 ('z', 'Other/Generic Classification Scheme', 0, 'generic')");
369 print "Upgrade to $DBversion done (classification sources added)\n";
370 SetVersion ($DBversion);
373 $DBversion = "3.00.00.013";
374 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
375 $dbh->do("CREATE TABLE `import_batches` (
376 `import_batch_id` int(11) NOT NULL auto_increment,
377 `template_id` int(11) default NULL,
378 `branchcode` varchar(10) default NULL,
379 `num_biblios` int(11) NOT NULL default 0,
380 `num_items` int(11) NOT NULL default 0,
381 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
382 `overlay_action` enum('replace', 'create_new', 'use_template') NOT NULL default 'create_new',
383 `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
384 `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
385 `file_name` varchar(100),
386 `comments` mediumtext,
387 PRIMARY KEY (`import_batch_id`),
388 KEY `branchcode` (`branchcode`)
389 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
390 $dbh->do("CREATE TABLE `import_records` (
391 `import_record_id` int(11) NOT NULL auto_increment,
392 `import_batch_id` int(11) NOT NULL,
393 `branchcode` varchar(10) default NULL,
394 `record_sequence` int(11) NOT NULL default 0,
395 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
396 `import_date` DATE default NULL,
397 `marc` longblob NOT NULL,
398 `marcxml` longtext NOT NULL,
399 `marcxml_old` longtext NOT NULL,
400 `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
401 `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
402 `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted') NOT NULL default 'staged',
403 `import_error` mediumtext,
404 `encoding` varchar(40) NOT NULL default '',
405 `z3950random` varchar(40) default NULL,
406 PRIMARY KEY (`import_record_id`),
407 CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
408 REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
409 KEY `branchcode` (`branchcode`),
410 KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
411 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
412 $dbh->do("CREATE TABLE `import_record_matches` (
413 `import_record_id` int(11) NOT NULL,
414 `candidate_match_id` int(11) NOT NULL,
415 `score` int(11) NOT NULL default 0,
416 CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
417 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
418 KEY `record_score` (`import_record_id`, `score`)
419 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
420 $dbh->do("CREATE TABLE `import_biblios` (
421 `import_record_id` int(11) NOT NULL,
422 `matched_biblionumber` int(11) default NULL,
423 `control_number` varchar(25) default NULL,
424 `original_source` varchar(25) default NULL,
425 `title` varchar(128) default NULL,
426 `author` varchar(80) default NULL,
427 `isbn` varchar(14) default NULL,
428 `issn` varchar(9) default NULL,
429 `has_items` tinyint(1) NOT NULL default 0,
430 CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
431 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
432 KEY `matched_biblionumber` (`matched_biblionumber`),
433 KEY `title` (`title`),
435 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
436 $dbh->do("CREATE TABLE `import_items` (
437 `import_items_id` int(11) NOT NULL auto_increment,
438 `import_record_id` int(11) NOT NULL,
439 `itemnumber` int(11) default NULL,
440 `branchcode` varchar(10) default NULL,
441 `status` enum('error', 'staged', 'imported', 'reverted') NOT NULL default 'staged',
442 `marcxml` longtext NOT NULL,
443 `import_error` mediumtext,
444 PRIMARY KEY (`import_items_id`),
445 CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
446 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
447 KEY `itemnumber` (`itemnumber`),
448 KEY `branchcode` (`branchcode`)
449 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
451 $dbh->do("INSERT INTO `import_batches`
452 (`overlay_action`, `import_status`, `batch_type`, `file_name`)
453 SELECT distinct 'create_new', 'staged', 'z3950', `file`
454 FROM `marc_breeding`");
456 $dbh->do("INSERT INTO `import_records`
457 (`import_batch_id`, `import_record_id`, `record_sequence`, `marc`, `record_type`, `status`,
458 `encoding`, `z3950random`, `marcxml`, `marcxml_old`)
459 SELECT `import_batch_id`, `id`, 1, `marc`, 'biblio', 'staged', `encoding`, `z3950random`, '', ''
461 JOIN `import_batches` ON (`file_name` = `file`)");
463 $dbh->do("INSERT INTO `import_biblios`
464 (`import_record_id`, `title`, `author`, `isbn`)
465 SELECT `import_record_id`, `title`, `author`, `isbn`
467 JOIN `import_records` ON (`import_record_id` = `id`)");
469 $dbh->do("UPDATE `import_batches`
470 SET `num_biblios` = (
472 FROM `import_records`
473 WHERE `import_batch_id` = `import_batches`.`import_batch_id`
476 $dbh->do("DROP TABLE `marc_breeding`");
478 print "Upgrade to $DBversion done (import_batches et al. added)\n";
479 SetVersion ($DBversion);
482 $DBversion = "3.00.00.014";
483 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
484 $dbh->do("ALTER TABLE subscription ADD lastbranch VARCHAR(4)");
485 print "Upgrade to $DBversion done (userid index added)\n";
486 SetVersion ($DBversion);
489 $DBversion = "3.00.00.015";
490 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
491 $dbh->do("CREATE TABLE `saved_sql` (
492 `id` int(11) NOT NULL auto_increment,
493 `borrowernumber` int(11) default NULL,
494 `date_created` datetime default NULL,
495 `last_modified` datetime default NULL,
497 `last_run` datetime default NULL,
498 `report_name` varchar(255) default NULL,
499 `type` varchar(255) default NULL,
502 KEY boridx (`borrowernumber`)
503 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
504 $dbh->do("CREATE TABLE `saved_reports` (
505 `id` int(11) NOT NULL auto_increment,
506 `report_id` int(11) default NULL,
508 `date_run` datetime default NULL,
510 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
511 print "Upgrade to $DBversion done (saved_sql and saved_reports added)\n";
512 SetVersion ($DBversion);
515 $DBversion = "3.00.00.016";
516 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
517 $dbh->do(" CREATE TABLE reports_dictionary (
518 id int(11) NOT NULL auto_increment,
519 name varchar(255) default NULL,
521 date_created datetime default NULL,
522 date_modified datetime default NULL,
524 area int(11) default NULL,
526 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
527 print "Upgrade to $DBversion done (reports_dictionary) added)\n";
528 SetVersion ($DBversion);
531 $DBversion = "3.00.00.017";
532 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
533 $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
534 $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)");
535 $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
536 $dbh->do("UPDATE action_logs SET action_id = if (\@a, \@a:=\@a+1, \@a:=1)");
537 $dbh->do("ALTER TABLE action_logs MODIFY action_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY");
538 print "Upgrade to $DBversion done (added column to action_logs)\n";
539 SetVersion ($DBversion);
542 $DBversion = "3.00.00.018";
543 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
544 $dbh->do("ALTER TABLE `zebraqueue`
545 ADD `done` INT NOT NULL DEFAULT '0',
546 ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
548 print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
549 SetVersion ($DBversion);
552 $DBversion = "3.00.00.019";
553 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
554 $dbh->do("ALTER TABLE biblio MODIFY biblionumber INT(11) NOT NULL AUTO_INCREMENT");
555 $dbh->do("ALTER TABLE biblioitems MODIFY biblioitemnumber INT(11) NOT NULL AUTO_INCREMENT");
556 $dbh->do("ALTER TABLE items MODIFY itemnumber INT(11) NOT NULL AUTO_INCREMENT");
557 print "Upgrade to $DBversion done (made bib/item PKs auto_increment)\n";
558 SetVersion ($DBversion);
561 $DBversion = "3.00.00.020";
562 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
563 $dbh->do("ALTER TABLE deleteditems
564 DROP KEY `delitembarcodeidx`,
565 ADD KEY `delitembarcodeidx` (`barcode`)");
566 print "Upgrade to $DBversion done (dropped uniqueness of key on deleteditems.barcode)\n";
567 SetVersion ($DBversion);
570 $DBversion = "3.00.00.021";
571 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
572 $dbh->do("ALTER TABLE items CHANGE homebranch homebranch VARCHAR(10)");
573 $dbh->do("ALTER TABLE deleteditems CHANGE homebranch homebranch VARCHAR(10)");
574 $dbh->do("ALTER TABLE statistics CHANGE branch branch VARCHAR(10)");
575 $dbh->do("ALTER TABLE subscription CHANGE lastbranch lastbranch VARCHAR(10)");
576 print "Upgrade to $DBversion done (extended missed branchcode columns to 10 chars)\n";
577 SetVersion ($DBversion);
580 $DBversion = "3.00.00.022";
581 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
582 $dbh->do("ALTER TABLE items
583 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
584 $dbh->do("ALTER TABLE deleteditems
585 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
586 print "Upgrade to $DBversion done (adding damaged column to items table)\n";
587 SetVersion ($DBversion);
590 $DBversion = "3.00.00.023";
591 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
592 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
593 VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
594 print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
595 SetVersion ($DBversion);
597 $DBversion = "3.00.00.024";
598 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
599 $dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
600 print "Upgrade to $DBversion done (changing itemtype to (10))\n";
601 SetVersion ($DBversion);
604 $DBversion = "3.00.00.025";
605 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
606 $dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
607 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
608 if(C4::Context->preference('item-level_itypes')){
609 $dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
611 print "Upgrade to $DBversion done (reintroduce items.itype - fill from itemtype)\n ";
612 SetVersion ($DBversion);
615 $DBversion = "3.00.00.026";
616 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
617 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
618 VALUES ('HomeOrHoldingBranch','homebranch','homebranch|holdingbranch','With independent branches turned on this decides whether to check the items holdingbranch or homebranch at circulatilon','choice')");
619 print "Upgrade to $DBversion done (adding new system preference for choosing whether homebranch or holdingbranch is checked in circulation)\n";
620 SetVersion ($DBversion);
623 $DBversion = "3.00.00.027";
624 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
625 $dbh->do("CREATE TABLE `marc_matchers` (
626 `matcher_id` int(11) NOT NULL auto_increment,
627 `code` varchar(10) NOT NULL default '',
628 `description` varchar(255) NOT NULL default '',
629 `record_type` varchar(10) NOT NULL default 'biblio',
630 `threshold` int(11) NOT NULL default 0,
631 PRIMARY KEY (`matcher_id`),
633 KEY `record_type` (`record_type`)
634 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
635 $dbh->do("CREATE TABLE `matchpoints` (
636 `matcher_id` int(11) NOT NULL,
637 `matchpoint_id` int(11) NOT NULL auto_increment,
638 `search_index` varchar(30) NOT NULL default '',
639 `score` int(11) NOT NULL default 0,
640 PRIMARY KEY (`matchpoint_id`),
641 CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
642 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
643 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
644 $dbh->do("CREATE TABLE `matchpoint_components` (
645 `matchpoint_id` int(11) NOT NULL,
646 `matchpoint_component_id` int(11) NOT NULL auto_increment,
647 sequence int(11) NOT NULL default 0,
648 tag varchar(3) NOT NULL default '',
649 subfields varchar(40) NOT NULL default '',
650 offset int(4) NOT NULL default 0,
651 length int(4) NOT NULL default 0,
652 PRIMARY KEY (`matchpoint_component_id`),
653 KEY `by_sequence` (`matchpoint_id`, `sequence`),
654 CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
655 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
656 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
657 $dbh->do("CREATE TABLE `matchpoint_component_norms` (
658 `matchpoint_component_id` int(11) NOT NULL,
659 `sequence` int(11) NOT NULL default 0,
660 `norm_routine` varchar(50) NOT NULL default '',
661 KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
662 CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
663 REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
664 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
665 $dbh->do("CREATE TABLE `matcher_matchpoints` (
666 `matcher_id` int(11) NOT NULL,
667 `matchpoint_id` int(11) NOT NULL,
668 CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
669 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
670 CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
671 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
672 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
673 $dbh->do("CREATE TABLE `matchchecks` (
674 `matcher_id` int(11) NOT NULL,
675 `matchcheck_id` int(11) NOT NULL auto_increment,
676 `source_matchpoint_id` int(11) NOT NULL,
677 `target_matchpoint_id` int(11) NOT NULL,
678 PRIMARY KEY (`matchcheck_id`),
679 CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
680 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
681 CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
682 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
683 CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
684 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
685 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
686 print "Upgrade to $DBversion done (added C4::Matcher serialization tables)\n ";
687 SetVersion ($DBversion);
690 $DBversion = "3.00.00.028";
691 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
692 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
693 VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
694 print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
695 SetVersion ($DBversion);
699 $DBversion = "3.00.00.029";
700 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
701 $dbh->do("ALTER TABLE `import_batches` ADD `matcher_id` int(11) NULL AFTER `import_batch_id`");
702 print "Upgrade to $DBversion done (adding matcher_id to import_batches)\n";
703 SetVersion ($DBversion);
706 $DBversion = "3.00.00.030";
707 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
709 CREATE TABLE services_throttle (
710 service_type varchar(10) NOT NULL default '',
711 service_count varchar(45) default NULL,
712 PRIMARY KEY (service_type)
713 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
715 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
716 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')");
717 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
718 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')");
719 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
720 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')");
721 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
722 VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free')");
723 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
724 VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo')");
725 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
726 VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo')");
727 print "Upgrade to $DBversion done (adding services throttle table and sysprefs for xISBN)\n";
728 SetVersion ($DBversion);
731 $DBversion = "3.00.00.031";
732 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
734 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryStemming',1,'If ON, enables query stemming',NULL,'YesNo')");
735 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryFuzzy',1,'If ON, enables fuzzy option for searches',NULL,'YesNo')");
736 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryWeightFields',1,'If ON, enables field weighting',NULL,'YesNo')");
737 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo')");
738 $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')");
739 $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')");
740 $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')");
741 $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')");
742 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice')");
743 $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')");
744 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortOrder',NULL,'Specify the default sort order','asc|dsc|za|az','Choice')");
745 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
746 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
747 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
748 $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')");
749 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
750 $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')");
751 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice')");
752 $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')");
753 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
754 $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')");
755 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
756 $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')");
757 $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')");
758 $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')");
759 $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')");
760 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
762 print "Upgrade to $DBversion done (adding additional system preference)\n";
763 SetVersion ($DBversion);
766 $DBversion = "3.00.00.032";
767 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
768 $dbh->do("UPDATE `marc_subfield_structure` SET `kohafield` = 'items.wthdrawn' WHERE `kohafield` = 'items.withdrawn'");
769 print "Upgrade to $DBversion done (fixed MARC framework references to items.withdrawn)\n";
770 SetVersion ($DBversion);
773 $DBversion = "3.00.00.033";
774 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
775 $dbh->do("INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0)");
776 print "Upgrade to $DBversion done (Adding permissions flag for staff member access modification. )\n";
777 SetVersion ($DBversion);
780 $DBversion = "3.00.00.034";
781 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
782 $dbh->do("ALTER TABLE `virtualshelves` ADD COLUMN `sortfield` VARCHAR(16) ");
783 print "Upgrade to $DBversion done (Adding sortfield for Virtual Shelves. )\n";
784 SetVersion ($DBversion);
787 $DBversion = "3.00.00.035";
788 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
789 $dbh->do("UPDATE marc_subfield_structure
790 SET authorised_value = 'cn_source'
791 WHERE kohafield IN ('items.cn_source', 'biblioitems.cn_source')
792 AND (authorised_value is NULL OR authorised_value = '')");
793 print "Upgrade to $DBversion done (MARC frameworks: make classification source a drop-down)\n";
794 SetVersion ($DBversion);
797 $DBversion = "3.00.00.036";
798 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
799 $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');");
800 print "Upgrade to $DBversion done (OPACItemsResultsDisplay systempreference added)\n";
801 SetVersion ($DBversion);
804 $DBversion = "3.00.00.037";
805 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
806 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactfirstname` varchar(255)");
807 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactsurname` varchar(255)");
808 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress1` varchar(255)");
809 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress2` varchar(255)");
810 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress3` varchar(255)");
811 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactzipcode` varchar(50)");
812 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactphone` varchar(50)");
813 print "Upgrade to $DBversion done (Adding Alternative Contact Person information to borrowers table)\n";
814 SetVersion ($DBversion);
817 $DBversion = "3.00.00.038";
818 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
819 $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'");
820 $dbh->do("DELETE FROM `systempreferences` WHERE variable='hideBiblioNumber'");
821 print "Upgrade to $DBversion done ('alter finesMode systempreference, remove superfluous syspref.')\n";
822 SetVersion ($DBversion);
825 $DBversion = "3.00.00.039";
826 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
827 $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')");
828 $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')");
829 $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')");
830 # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
831 print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
832 SetVersion ($DBversion);
835 $DBversion = "3.00.00.040";
836 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
837 $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')");
838 $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')");
839 print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
840 SetVersion ($DBversion);
844 $DBversion = "3.00.00.041";
845 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
846 # Strictly speaking it is not necessary to explicitly change
847 # NULL values to 0, because the ALTER TABLE statement will do that.
848 # However, setting them first avoids a warning.
849 $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL");
850 $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL");
851 $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL");
852 $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL");
853 $dbh->do("ALTER TABLE items
854 MODIFY notforloan tinyint(1) NOT NULL default 0,
855 MODIFY damaged tinyint(1) NOT NULL default 0,
856 MODIFY itemlost tinyint(1) NOT NULL default 0,
857 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
858 $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
859 $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
860 $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
861 $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
862 $dbh->do("ALTER TABLE deleteditems
863 MODIFY notforloan tinyint(1) NOT NULL default 0,
864 MODIFY damaged tinyint(1) NOT NULL default 0,
865 MODIFY itemlost tinyint(1) NOT NULL default 0,
866 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
867 print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
868 SetVersion ($DBversion);
871 $DBversion = "3.00.00.04";
872 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
873 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
874 print "Upgrade to $DBversion done (disallow NULL in aqbooksellers.name; part of fix for bug 1251)\n";
875 SetVersion ($DBversion);
878 $DBversion = "3.00.00.043";
879 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
880 $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");
881 print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
882 SetVersion ($DBversion);
885 $DBversion = "3.00.00.044";
886 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
887 $dbh->do("ALTER TABLE deletedborrowers
888 ADD `altcontactfirstname` varchar(255) default NULL,
889 ADD `altcontactsurname` varchar(255) default NULL,
890 ADD `altcontactaddress1` varchar(255) default NULL,
891 ADD `altcontactaddress2` varchar(255) default NULL,
892 ADD `altcontactaddress3` varchar(255) default NULL,
893 ADD `altcontactzipcode` varchar(50) default NULL,
894 ADD `altcontactphone` varchar(50) default NULL
896 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
897 ('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
898 ('language','en','Set the default language in the staff client.',NULL,'Languages'),
899 ('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
900 ('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
902 print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
903 SetVersion ($DBversion);
906 #-- http://www.w3.org/International/articles/language-tags/
909 $DBversion = "3.00.00.045";
910 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
912 CREATE TABLE language_subtag_registry (
914 type varchar(25), -- language-script-region-variant-extension-privateuse
915 description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
917 KEY `subtag` (`subtag`)
918 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
920 #-- TODO: add suppress_scripts
921 #-- this maps three letter codes defined in iso639.2 back to their
922 #-- two letter equivilents in rfc4646 (LOC maintains iso639+)
923 $dbh->do("CREATE TABLE language_rfc4646_to_iso639 (
924 rfc4646_subtag varchar(25),
925 iso639_2_code varchar(25),
926 KEY `rfc4646_subtag` (`rfc4646_subtag`)
927 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
929 $dbh->do("CREATE TABLE language_descriptions (
933 description varchar(255),
935 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
937 #-- bi-directional support, keyed by script subcode
938 $dbh->do("CREATE TABLE language_script_bidi (
939 rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
940 bidi varchar(3), -- rtl ltr
941 KEY `rfc4646_subtag` (`rfc4646_subtag`)
942 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
944 #-- BIDI Stuff, Arabic and Hebrew
945 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
946 VALUES( 'Arab', 'rtl')");
947 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
948 VALUES( 'Hebr', 'rtl')");
950 #-- TODO: need to map language subtags to script subtags for detection
951 #-- of bidi when script is not specified (like ar, he)
952 $dbh->do("CREATE TABLE language_script_mapping (
953 language_subtag varchar(25),
954 script_subtag varchar(25),
955 KEY `language_subtag` (`language_subtag`)
956 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
958 #-- Default mappings between script and language subcodes
959 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
960 VALUES( 'ar', 'Arab')");
961 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
962 VALUES( 'he', 'Hebr')");
964 print "Upgrade to $DBversion done (adding language subtag registry and basic BiDi support NOTE: You should import the subtag registry SQL)\n";
965 SetVersion ($DBversion);
968 $DBversion = "3.00.00.046";
969 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
970 $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
971 CHANGE `weeklength` `weeklength` int(11) default '0'");
972 $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
973 $dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
974 print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
975 SetVersion ($DBversion);
978 $DBversion = "3.00.00.047";
979 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
980 $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');");
981 print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
982 SetVersion ($DBversion);
985 $DBversion = "3.00.00.048";
986 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
987 $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
988 print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
989 SetVersion ($DBversion);
992 $DBversion = "3.00.00.049";
993 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
994 $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
995 print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
996 SetVersion ($DBversion);
999 $DBversion = "3.00.00.050";
1000 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1001 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
1002 print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
1003 SetVersion ($DBversion);
1006 $DBversion = "3.00.00.051";
1007 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1008 $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
1009 print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
1010 SetVersion ($DBversion);
1013 $DBversion = "3.00.00.052";
1014 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1015 $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
1016 print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
1017 SetVersion ($DBversion);
1020 $DBversion = "3.00.00.053";
1021 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1022 $dbh->do("CREATE TABLE `printers_profile` (
1023 `prof_id` int(4) NOT NULL auto_increment,
1024 `printername` varchar(40) NOT NULL,
1025 `tmpl_id` int(4) NOT NULL,
1026 `paper_bin` varchar(20) NOT NULL,
1027 `offset_horz` float default NULL,
1028 `offset_vert` float default NULL,
1029 `creep_horz` float default NULL,
1030 `creep_vert` float default NULL,
1031 `unit` char(20) NOT NULL default 'POINT',
1032 PRIMARY KEY (`prof_id`),
1033 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1034 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1035 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1036 $dbh->do("CREATE TABLE `labels_profile` (
1037 `tmpl_id` int(4) NOT NULL,
1038 `prof_id` int(4) NOT NULL,
1039 UNIQUE KEY `tmpl_id` (`tmpl_id`),
1040 UNIQUE KEY `prof_id` (`prof_id`)
1041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1042 print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
1043 SetVersion ($DBversion);
1046 $DBversion = "3.00.00.054";
1047 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1048 $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';");
1049 print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
1050 SetVersion ($DBversion);
1053 $DBversion = "3.00.00.055";
1054 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1055 $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
1056 print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
1057 SetVersion ($DBversion);
1059 $DBversion = "3.00.00.056";
1060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1061 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
1062 $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) ");
1064 $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) ");
1066 $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
1067 print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
1068 SetVersion ($DBversion);
1071 $DBversion = "3.00.00.057";
1072 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1073 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
1074 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
1075 $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');");
1076 $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');");
1077 $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');");
1078 SetVersion ($DBversion);
1081 $DBversion = "3.00.00.058";
1082 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1083 $dbh->do("ALTER TABLE `opac_news`
1084 CHANGE `lang` `lang` VARCHAR( 25 )
1086 COLLATE utf8_general_ci
1087 NOT NULL default ''");
1088 print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
1089 SetVersion ($DBversion);
1092 $DBversion = "3.00.00.059";
1093 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1095 $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
1096 `tmpl_id` int(4) NOT NULL auto_increment,
1097 `tmpl_code` char(100) default '',
1098 `tmpl_desc` char(100) default '',
1099 `page_width` float default '0',
1100 `page_height` float default '0',
1101 `label_width` float default '0',
1102 `label_height` float default '0',
1103 `topmargin` float default '0',
1104 `leftmargin` float default '0',
1105 `cols` int(2) default '0',
1106 `rows` int(2) default '0',
1107 `colgap` float default '0',
1108 `rowgap` float default '0',
1109 `active` int(1) default NULL,
1110 `units` char(20) default 'PX',
1111 `fontsize` int(4) NOT NULL default '3',
1112 PRIMARY KEY (`tmpl_id`)
1113 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1114 $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
1115 `prof_id` int(4) NOT NULL auto_increment,
1116 `printername` varchar(40) NOT NULL,
1117 `tmpl_id` int(4) NOT NULL,
1118 `paper_bin` varchar(20) NOT NULL,
1119 `offset_horz` float default NULL,
1120 `offset_vert` float default NULL,
1121 `creep_horz` float default NULL,
1122 `creep_vert` float default NULL,
1123 `unit` char(20) NOT NULL default 'POINT',
1124 PRIMARY KEY (`prof_id`),
1125 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1126 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1127 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1128 print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
1129 SetVersion ($DBversion);
1132 $DBversion = "3.00.00.060";
1133 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1134 $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
1135 `cardnumber` varchar(16) NOT NULL,
1136 `mimetype` varchar(15) NOT NULL,
1137 `imagefile` mediumblob NOT NULL,
1138 PRIMARY KEY (`cardnumber`),
1139 CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1140 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1141 print "Upgrade to $DBversion done ( Added patronimage table. )\n";
1142 SetVersion ($DBversion);
1145 $DBversion = "3.00.00.061";
1146 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1147 $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
1148 print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
1149 SetVersion ($DBversion);
1152 $DBversion = "3.00.00.062";
1153 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1154 $dbh->do("CREATE TABLE `old_issues` (
1155 `borrowernumber` int(11) default NULL,
1156 `itemnumber` int(11) default NULL,
1157 `date_due` date default NULL,
1158 `branchcode` varchar(10) default NULL,
1159 `issuingbranch` varchar(18) default NULL,
1160 `returndate` date default NULL,
1161 `lastreneweddate` date default NULL,
1162 `return` varchar(4) default NULL,
1163 `renewals` tinyint(4) default NULL,
1164 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1165 `issuedate` date default NULL,
1166 KEY `old_issuesborridx` (`borrowernumber`),
1167 KEY `old_issuesitemidx` (`itemnumber`),
1168 KEY `old_bordate` (`borrowernumber`,`timestamp`),
1169 CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1170 ON DELETE SET NULL ON UPDATE SET NULL,
1171 CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1172 ON DELETE SET NULL ON UPDATE SET NULL
1173 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1174 $dbh->do("CREATE TABLE `old_reserves` (
1175 `borrowernumber` int(11) default NULL,
1176 `reservedate` date default NULL,
1177 `biblionumber` int(11) default NULL,
1178 `constrainttype` varchar(1) default NULL,
1179 `branchcode` varchar(10) default NULL,
1180 `notificationdate` date default NULL,
1181 `reminderdate` date default NULL,
1182 `cancellationdate` date default NULL,
1183 `reservenotes` mediumtext,
1184 `priority` smallint(6) default NULL,
1185 `found` varchar(1) default NULL,
1186 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1187 `itemnumber` int(11) default NULL,
1188 `waitingdate` date default NULL,
1189 KEY `old_reserves_borrowernumber` (`borrowernumber`),
1190 KEY `old_reserves_biblionumber` (`biblionumber`),
1191 KEY `old_reserves_itemnumber` (`itemnumber`),
1192 KEY `old_reserves_branchcode` (`branchcode`),
1193 CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1194 ON DELETE SET NULL ON UPDATE SET NULL,
1195 CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1196 ON DELETE SET NULL ON UPDATE SET NULL,
1197 CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1198 ON DELETE SET NULL ON UPDATE SET NULL
1199 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1201 # move closed transactions to old_* tables
1202 $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
1203 $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
1204 $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1205 $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1207 print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
1208 SetVersion ($DBversion);
1211 $DBversion = "3.00.00.063";
1212 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1213 $dbh->do("ALTER TABLE deleteditems
1214 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
1215 ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
1216 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1217 $dbh->do("ALTER TABLE items
1218 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
1219 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1220 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";
1221 SetVersion ($DBversion);
1224 $DBversion = "3.00.00.064";
1225 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1226 $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');");
1227 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
1228 $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
1229 $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
1230 $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
1231 print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
1232 SetVersion ($DBversion);
1235 $DBversion = "3.00.00.065";
1236 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1237 $dbh->do("CREATE TABLE `patroncards` (
1238 `cardid` int(11) NOT NULL auto_increment,
1239 `batch_id` varchar(10) NOT NULL default '1',
1240 `borrowernumber` int(11) NOT NULL,
1241 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1242 PRIMARY KEY (`cardid`),
1243 KEY `patroncards_ibfk_1` (`borrowernumber`),
1244 CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1245 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1246 print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
1247 SetVersion ($DBversion);
1250 $DBversion = "3.00.00.066";
1251 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1252 $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
1253 DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
1255 print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
1256 SetVersion ($DBversion);
1259 $DBversion = "3.00.00.067";
1260 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1261 $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
1262 print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
1263 SetVersion ($DBversion);
1266 $DBversion = "3.00.00.068";
1267 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1268 $dbh->do("CREATE TABLE `permissions` (
1269 `module_bit` int(11) NOT NULL DEFAULT 0,
1270 `code` varchar(30) DEFAULT NULL,
1271 `description` varchar(255) DEFAULT NULL,
1272 PRIMARY KEY (`module_bit`, `code`),
1273 CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
1274 ON DELETE CASCADE ON UPDATE CASCADE
1275 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1276 $dbh->do("CREATE TABLE `user_permissions` (
1277 `borrowernumber` int(11) NOT NULL DEFAULT 0,
1278 `module_bit` int(11) NOT NULL DEFAULT 0,
1279 `code` varchar(30) DEFAULT NULL,
1280 CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1281 ON DELETE CASCADE ON UPDATE CASCADE,
1282 CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
1283 REFERENCES `permissions` (`module_bit`, `code`)
1284 ON DELETE CASCADE ON UPDATE CASCADE
1285 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1287 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
1288 (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
1289 (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
1290 (13, 'edit_calendar', 'Define days when the library is closed'),
1291 (13, 'moderate_comments', 'Moderate patron comments'),
1292 (13, 'edit_notices', 'Define notices'),
1293 (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
1294 (13, 'view_system_logs', 'Browse the system logs'),
1295 (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
1296 (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
1297 (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
1298 (13, 'export_catalog', 'Export bibliographic and holdings data'),
1299 (13, 'import_patrons', 'Import patron data'),
1300 (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
1301 (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
1302 (13, 'schedule_tasks', 'Schedule tasks to run')");
1304 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
1306 print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
1307 SetVersion ($DBversion);
1309 $DBversion = "3.00.00.069";
1310 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1311 $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
1312 print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
1313 SetVersion ($DBversion);
1316 $DBversion = "3.00.00.070";
1317 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1318 $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
1320 my ($value) = $sth->fetchrow;
1321 $value =~ s/2.3.1/2.5.1/;
1322 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
1323 print "Update yuipath syspref to 2.5.1 if necessary\n";
1324 SetVersion ($DBversion);
1327 $DBversion = "3.00.00.071";
1328 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1329 $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
1330 # fill the new field with the previous systempreference value, then drop the syspref
1331 my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
1333 my ($serialsadditems) = $sth->fetchrow();
1334 $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
1335 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1336 print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
1337 SetVersion ($DBversion);
1340 $DBversion = "3.00.00.072";
1341 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1342 $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring mediumtext DEFAULT NULL AFTER printingtype");
1343 print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
1344 SetVersion ($DBversion);
1347 $DBversion = "3.00.00.073";
1348 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1349 $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
1351 CREATE TABLE `tags_all` (
1352 `tag_id` int(11) NOT NULL auto_increment,
1353 `borrowernumber` int(11) NOT NULL,
1354 `biblionumber` int(11) NOT NULL,
1355 `term` varchar(255) NOT NULL,
1356 `language` int(4) default NULL,
1357 `date_created` datetime NOT NULL,
1358 PRIMARY KEY (`tag_id`),
1359 KEY `tags_borrowers_fk_1` (`borrowernumber`),
1360 KEY `tags_biblionumber_fk_1` (`biblionumber`),
1361 CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
1362 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1363 CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1364 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1365 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1367 $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
1369 CREATE TABLE `tags_approval` (
1370 `term` varchar(255) NOT NULL,
1371 `approved` int(1) NOT NULL default '0',
1372 `date_approved` datetime default NULL,
1373 `approved_by` int(11) default NULL,
1374 `weight_total` int(9) NOT NULL default '1',
1375 PRIMARY KEY (`term`),
1376 KEY `tags_approval_borrowers_fk_1` (`approved_by`),
1377 CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
1378 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1379 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1381 $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
1383 CREATE TABLE `tags_index` (
1384 `term` varchar(255) NOT NULL,
1385 `biblionumber` int(11) NOT NULL,
1386 `weight` int(9) NOT NULL default '1',
1387 PRIMARY KEY (`term`,`biblionumber`),
1388 KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
1389 CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
1390 REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
1391 CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1392 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1393 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1396 INSERT INTO `systempreferences` VALUES
1397 ('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=',''),
1398 ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
1399 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
1400 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
1401 ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
1402 ('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.',''),
1403 ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
1404 ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
1405 ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
1406 ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
1407 ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
1409 print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
1410 SetVersion ($DBversion);
1413 $DBversion = "3.00.00.074";
1414 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1415 $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
1416 where imageurl not like 'http%'
1417 and imageurl is not NULL
1418 and imageurl != '') );
1419 print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
1420 SetVersion ($DBversion);
1423 $DBversion = "3.00.00.075";
1424 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1425 $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
1426 print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
1427 SetVersion ($DBversion);
1430 $DBversion = "3.00.00.076";
1431 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1432 $dbh->do("ALTER TABLE import_batches
1433 ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
1434 $dbh->do("ALTER TABLE import_batches
1435 ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
1436 NOT NULL default 'always_add' AFTER nomatch_action");
1437 $dbh->do("ALTER TABLE import_batches
1438 MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
1439 NOT NULL default 'create_new'");
1440 $dbh->do("ALTER TABLE import_records
1441 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
1442 'ignored') NOT NULL default 'staged'");
1443 $dbh->do("ALTER TABLE import_items
1444 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
1446 print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
1447 SetVersion ($DBversion);
1450 $DBversion = "3.00.00.077";
1451 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1452 # drop these tables only if they exist and none of them are empty
1453 # these tables are not defined in the packaged 2.2.9, but since it is believed
1454 # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
1455 # some care is taken.
1456 my ($print_error) = $dbh->{PrintError};
1457 $dbh->{PrintError} = 0;
1458 my ($raise_error) = $dbh->{RaiseError};
1459 $dbh->{RaiseError} = 1;
1463 eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
1467 eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
1471 eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
1477 $dbh->do("DROP TABLE IF EXISTS `categorytable`");
1478 $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
1479 $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
1482 $dbh->{PrintError} = $print_error;
1483 $dbh->{RaiseError} = $raise_error;
1484 print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
1485 SetVersion ($DBversion);
1488 $DBversion = "3.00.00.078";
1489 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1490 my ($print_error) = $dbh->{PrintError};
1491 $dbh->{PrintError} = 0;
1493 unless ($dbh->do("SELECT 1 FROM browser")) {
1494 $dbh->{PrintError} = $print_error;
1495 $dbh->do("CREATE TABLE `browser` (
1496 `level` int(11) NOT NULL,
1497 `classification` varchar(20) NOT NULL,
1498 `description` varchar(255) NOT NULL,
1499 `number` bigint(20) NOT NULL,
1500 `endnode` tinyint(4) NOT NULL
1501 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1503 $dbh->{PrintError} = $print_error;
1504 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1505 SetVersion ($DBversion);
1508 $DBversion = "3.00.00.079";
1509 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1510 my ($print_error) = $dbh->{PrintError};
1511 $dbh->{PrintError} = 0;
1513 $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
1514 ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
1515 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1516 SetVersion ($DBversion);
1519 $DBversion = "3.00.00.080";
1520 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1521 $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
1522 $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
1523 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
1524 print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
1525 SetVersion ($DBversion);
1528 $DBversion = "3.00.00.081";
1529 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1530 $dbh->do("CREATE TABLE `borrower_attribute_types` (
1531 `code` varchar(10) NOT NULL,
1532 `description` varchar(255) NOT NULL,
1533 `repeatable` tinyint(1) NOT NULL default 0,
1534 `unique_id` tinyint(1) NOT NULL default 0,
1535 `opac_display` tinyint(1) NOT NULL default 0,
1536 `password_allowed` tinyint(1) NOT NULL default 0,
1537 `staff_searchable` tinyint(1) NOT NULL default 0,
1538 `authorised_value_category` varchar(10) default NULL,
1539 PRIMARY KEY (`code`)
1540 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1541 $dbh->do("CREATE TABLE `borrower_attributes` (
1542 `borrowernumber` int(11) NOT NULL,
1543 `code` varchar(10) NOT NULL,
1544 `attribute` varchar(30) default NULL,
1545 `password` varchar(30) default NULL,
1546 KEY `borrowernumber` (`borrowernumber`),
1547 KEY `code_attribute` (`code`, `attribute`),
1548 CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1549 ON DELETE CASCADE ON UPDATE CASCADE,
1550 CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1551 ON DELETE CASCADE ON UPDATE CASCADE
1552 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1553 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
1554 print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
1555 SetVersion ($DBversion);
1558 $DBversion = "3.00.00.082";
1559 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1560 $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
1561 print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
1562 SetVersion ($DBversion);
1565 $DBversion = "3.00.00.083";
1566 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1567 $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
1568 print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
1569 SetVersion ($DBversion);
1571 $DBversion = "3.00.00.084";
1572 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1573 $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')");
1574 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
1575 print "Upgrade to $DBversion done (add new sysprefs)\n";
1576 SetVersion ($DBversion);
1579 $DBversion = "3.00.00.085";
1580 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1581 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1582 $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
1583 $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
1584 $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
1585 $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
1586 $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
1587 $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
1589 print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
1590 SetVersion ($DBversion);
1593 $DBversion = "3.00.00.086";
1594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1596 "CREATE TABLE `tmp_holdsqueue` (
1597 `biblionumber` int(11) default NULL,
1598 `itemnumber` int(11) default NULL,
1599 `barcode` varchar(20) default NULL,
1600 `surname` mediumtext NOT NULL,
1603 `borrowernumber` int(11) NOT NULL,
1604 `cardnumber` varchar(16) default NULL,
1605 `reservedate` date default NULL,
1607 `itemcallnumber` varchar(30) default NULL,
1608 `holdingbranch` varchar(10) default NULL,
1609 `pickbranch` varchar(10) default NULL,
1611 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1613 $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')");
1614 $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')");
1616 print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
1617 SetVersion ($DBversion);
1620 $DBversion = "3.00.00.087";
1621 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1622 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
1623 $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')");
1624 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1625 SetVersion ($DBversion);
1628 $DBversion = "3.00.00.088";
1629 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1630 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
1631 $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')");
1632 $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')");
1633 $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')");
1634 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1635 SetVersion ($DBversion);
1638 $DBversion = "3.00.00.089";
1639 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1640 $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')");
1641 print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
1642 SetVersion ($DBversion);
1645 $DBversion = "3.00.00.090";
1646 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1648 CREATE TABLE `branch_borrower_circ_rules` (
1649 `branchcode` VARCHAR(10) NOT NULL,
1650 `categorycode` VARCHAR(10) NOT NULL,
1651 `maxissueqty` int(4) default NULL,
1652 PRIMARY KEY (`categorycode`, `branchcode`),
1653 CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1654 ON DELETE CASCADE ON UPDATE CASCADE,
1655 CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1656 ON DELETE CASCADE ON UPDATE CASCADE
1657 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1660 CREATE TABLE `default_borrower_circ_rules` (
1661 `categorycode` VARCHAR(10) NOT NULL,
1662 `maxissueqty` int(4) default NULL,
1663 PRIMARY KEY (`categorycode`),
1664 CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1665 ON DELETE CASCADE ON UPDATE CASCADE
1666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1669 CREATE TABLE `default_branch_circ_rules` (
1670 `branchcode` VARCHAR(10) NOT NULL,
1671 `maxissueqty` int(4) default NULL,
1672 PRIMARY KEY (`branchcode`),
1673 CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1674 ON DELETE CASCADE ON UPDATE CASCADE
1675 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1678 CREATE TABLE `default_circ_rules` (
1679 `singleton` enum('singleton') NOT NULL default 'singleton',
1680 `maxissueqty` int(4) default NULL,
1681 PRIMARY KEY (`singleton`)
1682 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1684 print "Upgrade to $DBversion done (added several circ rules tables)\n";
1685 SetVersion ($DBversion);
1689 $DBversion = "3.00.00.091";
1690 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1691 $dbh->do(<<'END_SQL');
1692 ALTER TABLE borrowers
1693 ADD `smsalertnumber` varchar(50) default NULL
1696 $dbh->do(<<'END_SQL');
1697 CREATE TABLE `message_attributes` (
1698 `message_attribute_id` int(11) NOT NULL auto_increment,
1699 `message_name` varchar(20) NOT NULL default '',
1700 `takes_days` tinyint(1) NOT NULL default '0',
1701 PRIMARY KEY (`message_attribute_id`),
1702 UNIQUE KEY `message_name` (`message_name`)
1703 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1706 $dbh->do(<<'END_SQL');
1707 CREATE TABLE `message_transport_types` (
1708 `message_transport_type` varchar(20) NOT NULL,
1709 PRIMARY KEY (`message_transport_type`)
1710 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1713 $dbh->do(<<'END_SQL');
1714 CREATE TABLE `message_transports` (
1715 `message_attribute_id` int(11) NOT NULL,
1716 `message_transport_type` varchar(20) NOT NULL,
1717 `is_digest` tinyint(1) NOT NULL default '0',
1718 `letter_module` varchar(20) NOT NULL default '',
1719 `letter_code` varchar(20) NOT NULL default '',
1720 PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
1721 KEY `message_transport_type` (`message_transport_type`),
1722 KEY `letter_module` (`letter_module`,`letter_code`),
1723 CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1724 CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
1725 CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
1726 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1729 $dbh->do(<<'END_SQL');
1730 CREATE TABLE `borrower_message_preferences` (
1731 `borrower_message_preference_id` int(11) NOT NULL auto_increment,
1732 `borrowernumber` int(11) NOT NULL default '0',
1733 `message_attribute_id` int(11) default '0',
1734 `days_in_advance` int(11) default '0',
1735 `wants_digets` tinyint(1) NOT NULL default '0',
1736 PRIMARY KEY (`borrower_message_preference_id`),
1737 KEY `borrowernumber` (`borrowernumber`),
1738 KEY `message_attribute_id` (`message_attribute_id`),
1739 CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1740 CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
1741 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1744 $dbh->do(<<'END_SQL');
1745 CREATE TABLE `borrower_message_transport_preferences` (
1746 `borrower_message_preference_id` int(11) NOT NULL default '0',
1747 `message_transport_type` varchar(20) NOT NULL default '0',
1748 PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1749 KEY `message_transport_type` (`message_transport_type`),
1750 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,
1751 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
1752 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1755 $dbh->do(<<'END_SQL');
1756 CREATE TABLE `message_queue` (
1757 `message_id` int(11) NOT NULL auto_increment,
1758 `borrowernumber` int(11) NOT NULL,
1761 `message_transport_type` varchar(20) NOT NULL,
1762 `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
1763 `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1764 KEY `message_id` (`message_id`),
1765 KEY `borrowernumber` (`borrowernumber`),
1766 KEY `message_transport_type` (`message_transport_type`),
1767 CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1768 CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
1769 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1772 $dbh->do(<<'END_SQL');
1773 INSERT INTO `systempreferences`
1774 (variable,value,explanation,options,type)
1776 ('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
1779 $dbh->do( <<'END_SQL');
1780 INSERT INTO `letter`
1781 (module, code, name, title, content)
1783 ('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>>'),
1784 ('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
1785 ('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>>'),
1786 ('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
1787 ('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.');
1791 'installer/data/mysql/en/mandatory/message_transport_types.sql',
1792 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
1793 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
1796 my $installer = C4::Installer->new();
1797 foreach my $script ( @sql_scripts ) {
1798 my $full_path = $installer->get_file_path_from_name($script);
1799 my $error = $installer->load_sql($full_path);
1800 warn $error if $error;
1803 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";
1804 SetVersion ($DBversion);
1807 $DBversion = "3.00.00.092";
1808 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1809 $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')");
1810 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
1811 print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
1812 SetVersion ($DBversion);
1815 $DBversion = "3.00.00.093";
1816 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1817 $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1818 $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1819 print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
1820 SetVersion ($DBversion);
1823 $DBversion = "3.00.00.094";
1824 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1825 $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
1826 print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
1827 SetVersion ($DBversion);
1830 $DBversion = "3.00.00.095";
1831 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1832 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1833 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
1834 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
1836 print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
1837 SetVersion ($DBversion);
1840 $DBversion = "3.00.00.096";
1841 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1842 $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
1844 if (my $row = $sth->fetchrow_hashref) {
1845 $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
1847 print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
1848 SetVersion ($DBversion);
1851 $DBversion = '3.00.00.097';
1852 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1854 $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
1855 $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
1856 $dbh->do('ALTER TABLE message_queue ADD content_type text');
1857 $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
1859 print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
1860 SetVersion($DBversion);
1863 $DBversion = '3.00.00.098';
1864 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1866 $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
1867 $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
1869 print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
1870 SetVersion($DBversion);
1873 $DBversion = '3.00.00.099';
1874 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1875 $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')");
1876 print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
1877 SetVersion($DBversion);
1880 $DBversion = '3.00.00.100';
1881 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1882 $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
1883 print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
1884 SetVersion($DBversion);
1887 $DBversion = '3.00.00.101';
1888 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1889 $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1890 $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1891 print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
1892 SetVersion($DBversion);
1895 $DBversion = '3.00.00.102';
1896 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1897 $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
1898 $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
1899 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
1900 # before setting constraint, delete any unvalid data
1901 $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
1902 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
1903 print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
1904 SetVersion($DBversion);
1907 $DBversion = "3.00.00.103";
1908 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1909 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1910 print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
1911 SetVersion ($DBversion);
1914 $DBversion = "3.00.00.104";
1915 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1916 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1917 print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
1918 SetVersion ($DBversion);
1921 $DBversion = '3.00.00.105';
1922 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
1924 # it is possible that this syspref is already defined since the feature was added some time ago.
1925 unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
1926 $dbh->do(<<'END_SQL');
1927 INSERT INTO `systempreferences`
1928 (variable,value,explanation,options,type)
1930 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
1933 print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
1934 SetVersion($DBversion);
1937 $DBversion = "3.00.00.106";
1938 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1939 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1941 # db revision 105 didn't apply correctly, so we're rolling this into 106
1942 $dbh->do("INSERT INTO `systempreferences`
1943 (variable,value,explanation,options,type)
1945 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
1947 print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
1948 $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
1949 $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
1950 SetVersion ($DBversion);
1953 $DBversion = '3.00.00.107';
1954 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1955 $dbh->do(<<'END_SQL');
1956 UPDATE systempreferences
1957 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
1958 WHERE variable = 'OPACShelfBrowser'
1959 AND explanation NOT LIKE '%WARNING%'
1961 $dbh->do(<<'END_SQL');
1962 UPDATE systempreferences
1963 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
1964 WHERE variable = 'CataloguingLog'
1965 AND explanation NOT LIKE '%WARNING%'
1967 $dbh->do(<<'END_SQL');
1968 UPDATE systempreferences
1969 SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
1970 WHERE variable = 'NoZebra'
1971 AND explanation NOT LIKE '%WARNING%'
1973 print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
1974 SetVersion ($DBversion);
1977 $DBversion = '3.01.00.000';
1978 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1979 print "Upgrade to $DBversion done (start of 3.1)\n";
1980 SetVersion ($DBversion);
1983 $DBversion = '3.01.00.001';
1984 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1986 CREATE TABLE hold_fill_targets (
1987 `borrowernumber` int(11) NOT NULL,
1988 `biblionumber` int(11) NOT NULL,
1989 `itemnumber` int(11) NOT NULL,
1990 `source_branchcode` varchar(10) default NULL,
1991 `item_level_request` tinyint(4) NOT NULL default 0,
1992 PRIMARY KEY `itemnumber` (`itemnumber`),
1993 KEY `bib_branch` (`biblionumber`, `source_branchcode`),
1994 CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
1995 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1996 CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
1997 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1998 CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
1999 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2000 CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
2001 REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2002 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2005 ALTER TABLE tmp_holdsqueue
2006 ADD item_level_request tinyint(4) NOT NULL default 0
2009 print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
2010 SetVersion($DBversion);
2013 $DBversion = '3.01.00.002';
2014 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2015 # use statistics where available
2017 ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
2022 SELECT max(datetime)
2024 WHERE type = 'issue'
2025 AND itemnumber = iss.itemnumber
2026 AND borrowernumber = iss.borrowernumber
2028 WHERE issuedate IS NULL;
2030 $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
2032 # default to last renewal date
2035 SET issuedate = lastreneweddate
2036 WHERE issuedate IS NULL
2037 and lastreneweddate IS NOT NULL
2040 my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
2041 if ($num_bad_issuedates > 0) {
2042 print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
2043 "Please check the issues table in your database.";
2045 print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
2046 SetVersion($DBversion);
2049 $DBversion = "3.01.00.003";
2050 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2051 $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')");
2052 print "Upgrade to $DBversion done (add new syspref)\n";
2053 SetVersion ($DBversion);
2056 $DBversion = '3.01.00.004';
2057 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2058 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACDisplayRequestPriority','0','Show patrons the priority level on holds in the OPAC','','YesNo')");
2059 print "Upgrade to $DBversion done (added OPACDisplayRequestPriority system preference)\n";
2060 SetVersion ($DBversion);
2063 $DBversion = '3.01.00.005';
2064 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2066 INSERT INTO `letter` (module, code, name, title, content)
2067 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>>')
2069 $dbh->do("INSERT INTO `message_attributes` (message_attribute_id, message_name, takes_days) values(4, 'Hold Filled', 0)");
2070 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'sms', 0, 'reserves', 'HOLD')");
2071 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'email', 0, 'reserves', 'HOLD')");
2072 print "Upgrade to $DBversion done (Add letter for holds notifications)\n";
2073 SetVersion ($DBversion);
2076 $DBversion = '3.01.00.006';
2077 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2078 $dbh->do("ALTER TABLE `biblioitems` ADD KEY issn (issn)");
2079 print "Upgrade to $DBversion done (add index on biblioitems.issn)\n";
2080 SetVersion ($DBversion);
2083 $DBversion = "3.01.00.007";
2084 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2085 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetmainUserblock'");
2086 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetuserjs'");
2087 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacheader'");
2088 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacMainUserBlock'");
2089 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacNav'");
2090 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacuserjs'");
2091 $dbh->do("UPDATE `systempreferences` SET options='30|10', type='Textarea' WHERE variable='OAI-PMH:Set'");
2092 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetstylesheet'");
2093 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetcolorstylesheet'");
2094 $dbh->do("UPDATE `systempreferences` SET options='10' WHERE variable='globalDueDate'");
2095 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='numSearchResults'");
2096 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='OPACnumSearchResults'");
2097 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='ReservesMaxPickupDelay'");
2098 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='TransfersMaxDaysWarning'");
2099 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='StaticHoldsQueueWeight'");
2100 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='holdCancelLength'");
2101 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='XISBNDailyLimit'");
2102 $dbh->do("UPDATE `systempreferences` SET type='Float' WHERE variable='gist'");
2103 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorUsername'");
2104 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorPassword'");
2105 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10' WHERE variable='ISBD'");
2106 $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'");
2107 print "Upgrade to $DBversion done (fix display of many sysprefs)\n";
2108 SetVersion ($DBversion);
2111 $DBversion = '3.01.00.008';
2112 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2114 $dbh->do("CREATE TABLE branch_transfer_limits (
2115 limitId int(8) NOT NULL auto_increment,
2116 toBranch varchar(4) NOT NULL,
2117 fromBranch varchar(4) NOT NULL,
2118 itemtype varchar(4) NOT NULL,
2119 PRIMARY KEY (limitId)
2120 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
2123 $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')");
2125 print "Upgrade to $DBversion done (added branch_transfer_limits table and UseBranchTransferLimits system preference)\n";
2126 SetVersion ($DBversion);
2129 $DBversion = "3.01.00.009";
2130 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2131 $dbh->do("ALTER TABLE permissions MODIFY `code` varchar(64) DEFAULT NULL");
2132 $dbh->do("ALTER TABLE user_permissions MODIFY `code` varchar(64) DEFAULT NULL");
2133 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'circulate_remaining_permissions', 'Remaining circulation permissions')");
2134 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'override_renewals', 'Override blocked renewals')");
2135 print "Upgrade to $DBversion done (added subpermissions for circulate permission)\n";
2138 $DBversion = '3.01.00.010';
2139 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2140 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `attribute` VARCHAR(64) DEFAULT NULL");
2141 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `password` VARCHAR(64) DEFAULT NULL");
2142 print "Upgrade to $DBversion done (bug 2687: increase length of borrower attribute fields)\n";
2143 SetVersion ($DBversion);
2146 $DBversion = '3.01.00.011';
2147 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2149 # Yes, the old value was ^M terminated.
2150 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);";
2152 my $intranetuserjs = C4::Context->preference('intranetuserjs');
2153 if ($intranetuserjs and $intranetuserjs eq $bad_value) {
2154 my $sql = <<'END_SQL';
2155 UPDATE systempreferences
2157 WHERE variable = 'intranetuserjs'
2161 print "Upgrade to $DBversion done (removed bogus intranetuserjs syspref)\n";
2162 SetVersion($DBversion);
2165 $DBversion = "3.01.00.012";
2166 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2167 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo')");
2169 CREATE TABLE `branch_item_rules` (
2170 `branchcode` varchar(10) NOT NULL,
2171 `itemtype` varchar(10) NOT NULL,
2172 `holdallowed` tinyint(1) default NULL,
2173 PRIMARY KEY (`itemtype`,`branchcode`),
2174 KEY `branch_item_rules_ibfk_2` (`branchcode`),
2175 CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
2176 CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2177 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2180 CREATE TABLE `default_branch_item_rules` (
2181 `itemtype` varchar(10) NOT NULL,
2182 `holdallowed` tinyint(1) default NULL,
2183 PRIMARY KEY (`itemtype`),
2184 CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
2185 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2188 ALTER TABLE default_branch_circ_rules
2189 ADD COLUMN holdallowed tinyint(1) NULL
2192 ALTER TABLE default_circ_rules
2193 ADD COLUMN holdallowed tinyint(1) NULL
2195 print "Upgrade to $DBversion done (Add tables and system preferences for holds policies)\n";
2196 SetVersion ($DBversion);
2199 $DBversion = '3.01.00.013';
2200 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2202 CREATE TABLE item_circulation_alert_preferences (
2203 id int(11) AUTO_INCREMENT,
2204 branchcode varchar(10) NOT NULL,
2205 categorycode varchar(10) NOT NULL,
2206 item_type varchar(10) NOT NULL,
2207 notification varchar(16) NOT NULL,
2209 KEY (branchcode, categorycode, item_type, notification)
2210 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2213 $dbh->do(q{ ALTER TABLE `message_queue` ADD metadata text DEFAULT NULL AFTER content; });
2214 $dbh->do(q{ ALTER TABLE `message_queue` ADD letter_code varchar(64) DEFAULT NULL AFTER metadata; });
2217 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2218 ('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.');
2221 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2222 ('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>>.');
2225 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (5, 'Item Check-in', 0);});
2226 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (6, 'Item Checkout', 0);});
2228 $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');});
2229 $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');});
2230 $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');});
2231 $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');});
2233 print "Upgrade to $DBversion done (data for Email Checkout Slips project)\n";
2234 SetVersion ($DBversion);
2237 $DBversion = "3.01.00.014";
2238 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2239 $dbh->do("ALTER TABLE `branch_transfer_limits` CHANGE `itemtype` `itemtype` VARCHAR( 4 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL");
2240 $dbh->do("ALTER TABLE `branch_transfer_limits` ADD `ccode` VARCHAR( 10 ) NULL ;");
2241 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2243 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice'
2246 print "Upgrade to $DBversion done ( Updated table for Branch Transfer Limits)\n";
2247 SetVersion ($DBversion);
2250 $DBversion = '3.01.00.015';
2251 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2252 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsClientCode', '0', 'Client Code for using Syndetics Solutions content','','free')");
2254 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEnabled', '0', 'Turn on Syndetics Enhanced Content','','YesNo')");
2256 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImages', '0', 'Display Cover Images from Syndetics','','YesNo')");
2258 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsTOC', '0', 'Display Table of Content information from Syndetics','','YesNo')");
2260 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSummary', '0', 'Display Summary Information from Syndetics','','YesNo')");
2262 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEditions', '0', 'Display Editions from Syndetics','','YesNo')");
2264 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsExcerpt', '0', 'Display Excerpts and first chapters on OPAC from Syndetics','','YesNo')");
2266 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsReviews', '0', 'Display Reviews on OPAC from Syndetics','','YesNo')");
2268 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAuthorNotes', '0', 'Display Notes about the Author on OPAC from Syndetics','','YesNo')");
2270 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAwards', '0', 'Display Awards on OPAC from Syndetics','','YesNo')");
2272 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSeries', '0', 'Display Series information on OPAC from Syndetics','','YesNo')");
2274 $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')");
2276 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from Amazon Web Services','','YesNo')");
2278 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from Amazon Web Services','','YesNo')");
2280 $dbh->do("UPDATE systempreferences SET variable='AmazonEnabled' WHERE variable = 'AmazonContent'");
2282 $dbh->do("UPDATE systempreferences SET variable='OPACAmazonEnabled' WHERE variable = 'OPACAmazonContent'");
2284 print "Upgrade to $DBversion done (added Syndetics Enhanced Content system preferences)\n";
2285 SetVersion ($DBversion);
2288 $DBversion = "3.01.00.016";
2289 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2290 $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')");
2291 print "Upgrade to $DBversion done (Added Babeltheque syspref)\n";
2292 SetVersion ($DBversion);
2295 $DBversion = "3.01.00.017";
2296 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2297 $dbh->do("ALTER TABLE `subscription` ADD `staffdisplaycount` VARCHAR(10) NULL;");
2298 $dbh->do("ALTER TABLE `subscription` ADD `opacdisplaycount` VARCHAR(10) NULL;");
2299 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2301 'StaffSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the Staff client', 'Integer'
2303 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2305 'OPACSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the OPAC', 'Integer'
2308 print "Upgrade to $DBversion done ( Updated table for Serials Display)\n";
2309 SetVersion ($DBversion);
2312 $DBversion = "3.01.00.018";
2313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2314 $dbh->do("ALTER TABLE deletedborrowers ADD `smsalertnumber` varchar(50) default NULL");
2315 print "Upgrade to $DBversion done (added deletedborrowers.smsalertnumber, missed in 3.00.00.091)\n";
2316 SetVersion ($DBversion);
2319 $DBversion = "3.01.00.019";
2320 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2321 $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')");
2322 print "Upgrade to $DBversion done (adding OPACShowCheckoutName systempref)\n";
2323 SetVersion ($DBversion);
2326 $DBversion = "3.01.00.020";
2327 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2328 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesID','','See:http://librarything.com/forlibraries/','','free')");
2329 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesEnabled','0','Enable or Disable Library Thing for Libraries Features','','YesNo')");
2330 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesTabbedView','0','Put LibraryThingForLibraries Content in Tabs.','','YesNo')");
2331 print "Upgrade to $DBversion done (adding LibraryThing for Libraries sysprefs)\n";
2332 SetVersion ($DBversion);
2335 $DBversion = "3.01.00.021";
2336 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2337 my $enable_reviews = C4::Context->preference('OPACAmazonEnabled') ? '1' : '0';
2338 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonReviews', '$enable_reviews', 'Display Amazon readers reviews on OPAC','','YesNo')");
2339 print "Upgrade to $DBversion done (adding OPACAmazonReviews syspref)\n";
2340 SetVersion ($DBversion);
2343 $DBversion = '3.01.00.022';
2344 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2345 $dbh->do("ALTER TABLE `labels_conf` MODIFY COLUMN `formatstring` mediumtext DEFAULT NULL");
2346 print "Upgrade to $DBversion done (bug 2945: increase size of labels_conf.formatstring)\n";
2347 SetVersion ($DBversion);
2350 $DBversion = '3.01.00.023';
2351 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2352 $dbh->do("ALTER TABLE biblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2353 $dbh->do("ALTER TABLE deletedbiblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2354 $dbh->do("ALTER TABLE import_biblios MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2355 $dbh->do("ALTER TABLE suggestions MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2356 print "Upgrade to $DBversion done (bug 2765: increase width of isbn column in several tables)\n";
2357 SetVersion ($DBversion);
2360 $DBversion = "3.01.00.024";
2361 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2362 $dbh->do("ALTER TABLE labels MODIFY COLUMN batch_id int(10) NOT NULL default 1;");
2363 print "Upgrade to $DBversion done (change labels.batch_id from varchar to int)\n";
2364 SetVersion ($DBversion);
2367 $DBversion = '3.01.00.025';
2368 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2369 $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')");
2371 print "Upgrade to $DBversion done (added ceilingDueDate system preference)\n";
2372 SetVersion ($DBversion);
2375 $DBversion = '3.01.00.026';
2376 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2377 $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')");
2379 print "Upgrade to $DBversion done (added numReturnedItemsToShow system preference)\n";
2380 SetVersion ($DBversion);
2383 $DBversion = '3.01.00.027';
2384 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2385 $dbh->do("ALTER TABLE zebraqueue CHANGE `biblio_auth_number` `biblio_auth_number` bigint(20) unsigned NOT NULL default 0");
2386 print "Upgrade to $DBversion done (Increased size of zebraqueue biblio_auth_number to address bug 3148.)\n";
2387 SetVersion ($DBversion);
2390 $DBversion = '3.01.00.028';
2391 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2392 my $enable_reviews = C4::Context->preference('AmazonEnabled') ? '1' : '0';
2393 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonReviews', '$enable_reviews', 'Display Amazon reviews on staff interface','','YesNo')");
2394 print "Upgrade to $DBversion done (added AmazonReviews)\n";
2395 SetVersion ($DBversion);
2398 $DBversion = '3.01.00.029';
2399 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2400 $dbh->do(q( UPDATE language_rfc4646_to_iso639
2401 SET iso639_2_code = 'spa'
2402 WHERE rfc4646_subtag = 'es'
2403 AND iso639_2_code = 'rus' )
2405 print "Upgrade to $DBversion done (fixed bug 2599: using Spanish search limit retrieves Russian results)\n";
2406 SetVersion ($DBversion);
2409 $DBversion = "3.01.00.030";
2410 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2411 $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')");
2412 print "Upgrade to $DBversion done (added AllowNotForLoanOverride system preference)\n";
2413 SetVersion ($DBversion);
2416 $DBversion = "3.01.00.031";
2417 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2418 $dbh->do("ALTER TABLE branch_transfer_limits
2419 MODIFY toBranch varchar(10) NOT NULL,
2420 MODIFY fromBranch varchar(10) NOT NULL,
2421 MODIFY itemtype varchar(10) NULL");
2422 print "Upgrade to $DBversion done (fix column widths in branch_transfer_limits)\n";
2423 SetVersion ($DBversion);
2426 $DBversion = "3.01.00.032";
2427 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2428 $dbh->do(<<ENDOFRENEWAL);
2429 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');
2431 print "Upgrade to $DBversion done (Change the field)\n";
2432 SetVersion ($DBversion);
2435 $DBversion = "3.01.00.033";
2436 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2438 ALTER TABLE borrower_message_preferences
2439 MODIFY borrowernumber int(11) default NULL,
2440 ADD categorycode varchar(10) default NULL AFTER borrowernumber,
2441 ADD KEY `categorycode` (`categorycode`),
2442 ADD CONSTRAINT `borrower_message_preferences_ibfk_3`
2443 FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
2444 ON DELETE CASCADE ON UPDATE CASCADE
2446 print "Upgrade to $DBversion done (DB changes to allow patron category defaults for messaging preferences)\n";
2447 SetVersion ($DBversion);
2450 $DBversion = "3.01.00.034";
2451 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2452 $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
2453 print "Upgrade to $DBversion done (Adding graceperiod column to subscription table)\n";
2454 SetVersion ($DBversion);
2457 $DBversion = '3.01.00.035';
2458 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2459 $dbh->do(q{ ALTER TABLE `subscription` ADD location varchar(80) NULL DEFAULT '' AFTER callnumber; });
2460 print "Upgrade to $DBversion done (Adding location to subscription table)\n";
2461 SetVersion ($DBversion);
2464 $DBversion = '3.01.00.036';
2465 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2466 $dbh->do("UPDATE systempreferences SET explanation = 'Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd'
2467 WHERE variable = 'IntranetBiblioDefaultView'
2468 AND explanation = 'IntranetBiblioDefaultView'");
2469 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = 'normal|marc|isbd|labeled_marc'
2470 WHERE variable = 'IntranetBiblioDefaultView'");
2471 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewISBD','1','Allow display of ISBD view of bibiographic records','','YesNo')");
2472 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo')");
2473 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo')");
2474 print "Upgrade to $DBversion done (new viewISBD, viewLabeledMARC, viewMARC sysprefs and tweak IntranetBiblioDefaultView)\n";
2475 SetVersion ($DBversion);
2478 $DBversion = '3.01.00.037';
2479 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2480 $dbh->do('ALTER TABLE authorised_values ADD KEY `lib` (`lib`)');
2481 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo')");
2482 SetVersion ($DBversion);
2483 print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
2486 $DBversion = "3.01.00.038";
2487 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2488 # update branches table
2490 $dbh->do("ALTER TABLE branches ADD `branchzip` varchar(25) default NULL AFTER `branchaddress3`");
2491 $dbh->do("ALTER TABLE branches ADD `branchcity` mediumtext AFTER `branchzip`");
2492 $dbh->do("ALTER TABLE branches ADD `branchcountry` text AFTER `branchcity`");
2493 $dbh->do("ALTER TABLE branches ADD `branchurl` mediumtext AFTER `branchemail`");
2494 $dbh->do("ALTER TABLE branches ADD `branchnotes` mediumtext AFTER `branchprinter`");
2495 print "Upgrade to $DBversion done (add ZIP, city, country, URL, and notes column to branches)\n";
2496 SetVersion ($DBversion);
2499 $DBversion = '3.01.00.039';
2500 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2501 $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')");
2502 $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')");
2503 SetVersion ($DBversion);
2504 print "Upgrade to $DBversion done (added SpineLabelFormat and SpineLabelAutoPrint sysprefs)\n";
2507 $DBversion = '3.01.00.040';
2508 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2509 $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')");
2510 $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')");
2511 SetVersion ($DBversion);
2512 print "Upgrade to $DBversion done (AllowHoldDateInFuture and OPACAllowHoldDateInFuture sysprefs)\n";
2515 $DBversion = '3.01.00.041';
2516 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2517 $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')");
2518 SetVersion ($DBversion);
2519 print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that if you use enhanced content from Amazon, this should be set right away.)\n";
2522 $DBversion = '3.01.00.042';
2523 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2524 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACFineNoRenewals','99999','Fine Limit above which user canmot renew books via OPAC','','Integer')");
2525 SetVersion ($DBversion);
2526 print "Upgrade to $DBversion done (added OPACFineNoRenewals syspref)\n";
2529 $DBversion = '3.01.00.043';
2530 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2531 $dbh->do('ALTER TABLE items ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2532 $dbh->do('UPDATE items SET permanent_location = location');
2533 $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 )', '')");
2534 $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')");
2535 $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')");
2536 SetVersion ($DBversion);
2537 print "Upgrade to $DBversion done (amended Item added NewItemsDefaultLocation, InProcessingToShelvingCart, ReturnToShelvingCart sysprefs)\n";
2540 $DBversion = '3.01.00.044';
2541 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2542 $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')");
2543 SetVersion ($DBversion);
2544 print "Upgrade to $DBversion done (added DisplayClearScreenButton system preference)\n";
2547 $DBversion = '3.01.00.045';
2548 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2549 $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')");
2550 SetVersion ($DBversion);
2551 print "Upgrade to $DBversion done (added a preference to hide the patrons name in the staff catalog)\n";
2554 $DBversion = "3.01.00.046";
2555 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2556 # update borrowers table
2558 $dbh->do("ALTER TABLE borrowers ADD `country` text AFTER zipcode");
2559 $dbh->do("ALTER TABLE borrowers ADD `B_country` text AFTER B_zipcode");
2560 $dbh->do("ALTER TABLE deletedborrowers ADD `country` text AFTER zipcode");
2561 $dbh->do("ALTER TABLE deletedborrowers ADD `B_country` text AFTER B_zipcode");
2562 print "Upgrade to $DBversion done (add country and B_country to borrowers)\n";
2563 SetVersion ($DBversion);
2566 $DBversion = '3.01.00.047';
2567 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2568 $dbh->do("ALTER TABLE items MODIFY itemcallnumber varchar(255);");
2569 $dbh->do("ALTER TABLE deleteditems MODIFY itemcallnumber varchar(255);");
2570 $dbh->do("ALTER TABLE tmp_holdsqueue MODIFY itemcallnumber varchar(255);");
2571 SetVersion ($DBversion);
2572 print " Upgrade to $DBversion done (bug 2761: change max length of itemcallnumber to 255 from 30)\n";
2575 $DBversion = '3.01.00.048';
2576 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2577 $dbh->do("UPDATE userflags SET flagdesc='View Catalog (Librarian Interface)' WHERE bit=2;");
2578 $dbh->do("UPDATE userflags SET flagdesc='Edit Catalog (Modify bibliographic/holdings data)' WHERE bit=9;");
2579 $dbh->do("UPDATE userflags SET flagdesc='Allow to edit authorities' WHERE bit=14;");
2580 $dbh->do("UPDATE userflags SET flagdesc='Allow to access to the reports module' WHERE bit=16;");
2581 $dbh->do("UPDATE userflags SET flagdesc='Allow to manage serials subscriptions' WHERE bit=15;");
2582 SetVersion ($DBversion);
2583 print " Upgrade to $DBversion done (bug 2611: fix spelling/capitalization in permission flag descriptions)\n";
2586 $DBversion = '3.01.00.049';
2587 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2588 $dbh->do("UPDATE permissions SET description = 'Perform inventory (stocktaking) of your catalog' WHERE code = 'inventory';");
2589 SetVersion ($DBversion);
2590 print "Upgrade to $DBversion done (bug 2611: changed catalogue to catalog per the standard)\n";
2593 $DBversion = '3.01.00.050';
2594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2595 $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');");
2596 SetVersion ($DBversion);
2597 print "Upgrade to $DBversion done (bug 1934: Add OPACSearchForTitleIn syspref)\n";
2600 $DBversion = '3.01.00.051';
2601 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2602 $dbh->do("UPDATE systempreferences SET explanation='Fine limit above which user cannot renew books via OPAC' WHERE variable='OPACFineNoRenewals';");
2603 $dbh->do("UPDATE systempreferences SET explanation='If set to ON, a clear screen button will appear on the circulation page.' WHERE variable='DisplayClearScreenButton';");
2604 SetVersion ($DBversion);
2605 print "Upgrade to $DBversion done (fixed typos in new sysprefs)\n";
2608 $DBversion = '3.01.00.052';
2609 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2610 $dbh->do('ALTER TABLE deleteditems ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2611 SetVersion ($DBversion);
2612 print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
2615 $DBversion = '3.01.00.053';
2616 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2617 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
2618 system("perl $upgrade_script");
2619 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";
2620 SetVersion ($DBversion);
2623 $DBversion = '3.01.00.054';
2624 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2625 $dbh->do("ALTER TABLE borrowers ADD `B_address2` text AFTER B_address");
2626 $dbh->do("ALTER TABLE borrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2627 $dbh->do("ALTER TABLE deletedborrowers ADD `B_address2` text AFTER B_address");
2628 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2629 SetVersion ($DBversion);
2630 print "Upgrade to $DBversion done (bug 1600, bug 3454: add altcontactcountry and B_address2 to borrowers and deletedborrowers)\n";
2633 $DBversion = '3.01.00.055';
2634 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2635 $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'|);
2636 SetVersion ($DBversion);
2637 print "Upgrade to $DBversion done (changed OPACSearchForTitleIn per requests in bug 1934)\n";
2640 $DBversion = '3.01.00.056';
2641 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2642 $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');");
2643 SetVersion ($DBversion);
2644 print "Upgrade to $DBversion done (Bug 1172 : Add OPACPatronDetails syspref)\n";
2647 $DBversion = '3.01.00.057';
2648 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2649 $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');");
2650 SetVersion ($DBversion);
2651 print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
2654 $DBversion = '3.01.00.058';
2655 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2656 $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2657 $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2658 $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2659 SetVersion ($DBversion);
2660 print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
2663 $DBversion = '3.01.00.059';
2664 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2665 $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')");
2666 SetVersion ($DBversion);
2667 print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
2670 $DBversion = '3.01.00.060';
2671 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2672 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
2673 $dbh->do('DROP TABLE IF EXISTS messages');
2674 $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
2675 `borrowernumber` int(11) NOT NULL,
2676 `branchcode` varchar(4) default NULL,
2677 `message_type` varchar(1) NOT NULL,
2678 `message` text NOT NULL,
2679 `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2680 PRIMARY KEY (`message_id`)
2681 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
2683 print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
2684 SetVersion ($DBversion);
2687 $DBversion = '3.01.00.061';
2688 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2689 $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')");
2690 print "Upgrade to $DBversion done ( Added ShowPatronImageInWebBasedSelfCheck system preference )\n";
2691 SetVersion ($DBversion);
2694 $DBversion = "3.01.00.062";
2695 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2696 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'manage_csv_profiles', 'Manage CSV export profiles')");
2698 CREATE TABLE `export_format` (
2699 `export_format_id` int(11) NOT NULL auto_increment,
2700 `profile` varchar(255) NOT NULL,
2701 `description` mediumtext NOT NULL,
2702 `marcfields` mediumtext NOT NULL,
2703 PRIMARY KEY (`export_format_id`)
2704 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
2706 print "Upgrade to $DBversion done (added csv export profiles)\n";
2709 $DBversion = "3.01.00.063";
2710 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2712 CREATE TABLE `fieldmapping` (
2713 `id` int(11) NOT NULL auto_increment,
2714 `field` varchar(255) NOT NULL,
2715 `frameworkcode` char(4) NOT NULL default '',
2716 `fieldcode` char(3) NOT NULL,
2717 `subfieldcode` char(1) NOT NULL,
2719 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2721 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";
2724 $DBversion = '3.01.00.065';
2725 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2726 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
2727 $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
2730 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
2732 while(my $row = $sth->fetchrow_hashref){
2733 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
2736 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
2738 SetVersion ($DBversion);
2739 print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2742 $DBversion = '3.01.00.066';
2743 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2744 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2746 my $maxreserves = C4::Context->preference('maxreserves');
2747 $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2748 $sth->execute($maxreserves);
2750 $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2752 $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2754 SetVersion ($DBversion);
2755 print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2758 $DBversion = "3.01.00.067";
2759 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2760 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
2761 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
2762 print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
2763 SetVersion ($DBversion);
2766 $DBversion = "3.01.00.068";
2767 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2768 $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
2769 print "Upgrade to $DBversion done (Adding finedays in issuingrules table)\n";
2770 SetVersion ($DBversion);
2774 $DBversion = "3.01.00.069";
2775 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2776 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableOpacSearchHistory', '1', '', 'Enable or disable opac search history', 'YesNo')");
2778 my $create = <<SEARCHHIST;
2779 CREATE TABLE IF NOT EXISTS `search_history` (
2780 `userid` int(11) NOT NULL,
2781 `sessionid` varchar(32) NOT NULL,
2782 `query_desc` varchar(255) NOT NULL,
2783 `query_cgi` varchar(255) NOT NULL,
2784 `total` int(11) NOT NULL,
2785 `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2786 KEY `userid` (`userid`),
2787 KEY `sessionid` (`sessionid`)
2788 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
2792 print "Upgrade to $DBversion done (added OPAC search history preference and table)\n";
2795 $DBversion = "3.01.00.070";
2796 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2797 $dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
2798 print "Upgrade to $DBversion done (Added a lib_opac field in authorised_values table)\n";
2801 $DBversion = "3.01.00.071";
2802 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2803 $dbh->do("ALTER TABLE `subscription` ADD `enddate` date default NULL");
2804 $dbh->do("ALTER TABLE subscriptionhistory CHANGE enddate histenddate DATE default NULL");
2805 print "Upgrade to $DBversion done ( Adding enddate to subscription)\n";
2808 # Acquisitions update
2810 $DBversion = "3.01.00.072";
2811 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2812 $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')");
2813 # create a new syspref for the 'Mr anonymous' patron
2814 $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,'')");
2815 # fill AnonymousPatron with AnonymousSuggestion value (copy)
2816 my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='AnonSuggestions'");
2818 my ($value) = $sth->fetchrow() || 0;
2819 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='AnonymousPatron'");
2820 # set AnonymousSuggestion do YesNo
2821 # 1st, set the value (1/True if it had a borrowernumber)
2822 $dbh->do("UPDATE systempreferences SET value=1 WHERE variable='AnonSuggestions' AND value>0");
2823 # 2nd, change the type to Choice
2824 $dbh->do("UPDATE systempreferences SET type='YesNo' WHERE variable='AnonSuggestions'");
2825 # borrower reading record privacy : 0 : forever, 1 : laws, 2 : don't keep at all
2826 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
2827 print "Upgrade to $DBversion done (add new syspref and column in borrowers)\n";
2828 SetVersion ($DBversion);
2831 $DBversion = '3.01.00.073';
2832 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2833 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2834 $dbh->do(<<'END_SQL');
2835 CREATE TABLE IF NOT EXISTS `aqcontract` (
2836 `contractnumber` int(11) NOT NULL auto_increment,
2837 `contractstartdate` date default NULL,
2838 `contractenddate` date default NULL,
2839 `contractname` varchar(50) default NULL,
2840 `contractdescription` mediumtext,
2841 `booksellerid` int(11) not NULL,
2842 PRIMARY KEY (`contractnumber`),
2843 CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2844 REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2845 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2847 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2848 print "Upgrade to $DBversion done (adding aqcontract table)\n";
2849 SetVersion ($DBversion);
2852 $DBversion = '3.01.00.074';
2853 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2854 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `basketname` varchar(50) default NULL AFTER `basketno`");
2855 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `note` mediumtext AFTER `basketname`");
2856 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `booksellernote` mediumtext AFTER `note`");
2857 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `contractnumber` int(11) AFTER `booksellernote`");
2858 $dbh->do("ALTER TABLE `aqbasket` ADD FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`)");
2859 print "Upgrade to $DBversion done (edit aqbasket table done)\n";
2860 SetVersion ($DBversion);
2863 $DBversion = '3.01.00.075';
2864 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2865 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `uncertainprice` tinyint(1)");
2867 print "Upgrade to $DBversion done (adding uncertainprices)\n";
2868 SetVersion ($DBversion);
2871 $DBversion = '3.01.00.076';
2872 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2873 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2874 $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` (
2875 `id` int(11) NOT NULL auto_increment,
2876 `name` varchar(50) default NULL,
2877 `closed` tinyint(1) default NULL,
2878 `booksellerid` int(11) NOT NULL,
2880 KEY `booksellerid` (`booksellerid`),
2881 CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2882 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
2883 $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
2884 $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
2885 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
2886 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2887 print "Upgrade to $DBversion done (adding basketgroups)\n";
2888 SetVersion ($DBversion);
2890 $DBversion = '3.01.00.077';
2891 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2893 $dbh->do("SET FOREIGN_KEY_CHECKS=0 ");
2894 # create a mapping table holding the info we need to match orders to budgets
2895 $dbh->do('DROP TABLE IF EXISTS fundmapping');
2897 q|CREATE TABLE fundmapping AS
2898 SELECT aqorderbreakdown.ordernumber, branchcode, bookfundid, budgetdate, entrydate
2899 FROM aqorderbreakdown JOIN aqorders ON aqorderbreakdown.ordernumber = aqorders.ordernumber|);
2900 # match the new type of the corresponding field
2901 $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)');
2902 # System did not ensure budgetdate was valid historically
2903 $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = '0000-00-00' OR budgetdate IS NULL|);
2904 # We save the map in fundmapping in case you need later processing
2905 $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|);
2906 # these can speed processing up
2907 $dbh->do(q|CREATE INDEX fundmaporder ON fundmapping (ordernumber)|);
2908 $dbh->do(q|CREATE INDEX fundmapid ON fundmapping (bookfundid)|);
2910 $dbh->do("DROP TABLE IF EXISTS `aqbudgetperiods` ");
2913 CREATE TABLE `aqbudgetperiods` (
2914 `budget_period_id` int(11) NOT NULL auto_increment,
2915 `budget_period_startdate` date NOT NULL,
2916 `budget_period_enddate` date NOT NULL,
2917 `budget_period_active` tinyint(1) default '0',
2918 `budget_period_description` mediumtext,
2919 `budget_period_locked` tinyint(1) default NULL,
2920 `sort1_authcat` varchar(10) default NULL,
2921 `sort2_authcat` varchar(10) default NULL,
2922 PRIMARY KEY (`budget_period_id`)
2923 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |);
2925 $dbh->do(<<ADDPERIODS);
2926 INSERT INTO aqbudgetperiods (budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_locked)
2927 SELECT DISTINCT startdate, enddate, NOW() BETWEEN startdate and enddate, concat(startdate," ",enddate),NOT NOW() BETWEEN startdate AND enddate from aqbudget
2929 # SORRY , NO AQBUDGET/AQBOOKFUND -> AQBUDGETS IMPORT JUST YET,
2930 # BUT A NEW CLEAN AQBUDGETS TABLE CREATE FOR NOW..
2931 # DROP TABLE IF EXISTS `aqbudget`;
2932 #CREATE TABLE `aqbudget` (
2933 # `bookfundid` varchar(10) NOT NULL default ',
2934 # `startdate` date NOT NULL default 0,
2935 # `enddate` date default NULL,
2936 # `budgetamount` decimal(13,2) default NULL,
2937 # `aqbudgetid` tinyint(4) NOT NULL auto_increment,
2938 # `branchcode` varchar(10) default NULL,
2939 DropAllForeignKeys('aqbudget');
2940 #$dbh->do("drop table aqbudget;");
2943 my $maxbudgetid = $dbh->selectcol_arrayref(<<IDsBUDGET);
2944 SELECT MAX(aqbudgetid) from aqbudget
2947 $$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
2949 $dbh->do(<<BUDGETAUTOINCREMENT);
2950 ALTER TABLE aqbudget AUTO_INCREMENT=$$maxbudgetid[0]
2953 $dbh->do(<<BUDGETNAME);
2954 ALTER TABLE aqbudget RENAME `aqbudgets`
2957 $dbh->do(<<BUDGETS);
2958 ALTER TABLE `aqbudgets`
2959 CHANGE COLUMN aqbudgetid `budget_id` int(11) NOT NULL AUTO_INCREMENT,
2960 CHANGE COLUMN branchcode `budget_branchcode` varchar(10) default NULL,
2961 CHANGE COLUMN budgetamount `budget_amount` decimal(28,6) NOT NULL default '0.00',
2962 CHANGE COLUMN bookfundid `budget_code` varchar(30) default NULL,
2963 ADD COLUMN `budget_parent_id` int(11) default NULL,
2964 ADD COLUMN `budget_name` varchar(80) default NULL,
2965 ADD COLUMN `budget_encumb` decimal(28,6) default '0.00',
2966 ADD COLUMN `budget_expend` decimal(28,6) default '0.00',
2967 ADD COLUMN `budget_notes` mediumtext,
2968 ADD COLUMN `budget_description` mediumtext,
2969 ADD COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2970 ADD COLUMN `budget_amount_sublevel` decimal(28,6) AFTER `budget_amount`,
2971 ADD COLUMN `budget_period_id` int(11) default NULL,
2972 ADD COLUMN `sort1_authcat` varchar(80) default NULL,
2973 ADD COLUMN `sort2_authcat` varchar(80) default NULL,
2974 ADD COLUMN `budget_owner_id` int(11) default NULL,
2975 ADD COLUMN `budget_permission` int(1) default '0';
2978 $dbh->do(<<BUDGETCONSTRAINTS);
2979 ALTER TABLE `aqbudgets`
2980 ADD CONSTRAINT `aqbudgets_ifbk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
2982 # $dbh->do(<<BUDGETPKDROP);
2983 #ALTER TABLE `aqbudgets`
2986 # $dbh->do(<<BUDGETPKADD);
2987 #ALTER TABLE `aqbudgets`
2988 # ADD PRIMARY KEY budget_id
2992 my $query_period= $dbh->prepare(qq|SELECT budget_period_id from aqbudgetperiods where budget_period_startdate=? and budget_period_enddate=?|);
2993 my $query_bookfund= $dbh->prepare(qq|SELECT * from aqbookfund where bookfundid=?|);
2994 my $selectbudgets=$dbh->prepare(qq|SELECT * from aqbudgets|);
2995 my $updatebudgets=$dbh->prepare(qq|UPDATE aqbudgets SET budget_period_id= ? , budget_name=?, budget_branchcode=? where budget_id=?|);
2996 $selectbudgets->execute;
2997 while (my $databudget=$selectbudgets->fetchrow_hashref){
2998 $query_period->execute ($$databudget{startdate},$$databudget{enddate});
2999 my ($budgetperiodid)=$query_period->fetchrow;
3000 $query_bookfund->execute ($$databudget{budget_code});
3001 my $databf=$query_bookfund->fetchrow_hashref;
3002 my $branchcode=$$databudget{budget_branchcode}||$$databf{branchcode};
3003 $updatebudgets->execute($budgetperiodid,$$databf{bookfundname},$branchcode,$$databudget{budget_id});
3005 $dbh->do(<<BUDGETDROPDATES);
3006 ALTER TABLE `aqbudgets`
3012 $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
3013 $dbh->do("CREATE TABLE `aqbudgets_planning` (
3014 `plan_id` int(11) NOT NULL auto_increment,
3015 `budget_id` int(11) NOT NULL,
3016 `budget_period_id` int(11) NOT NULL,
3017 `estimated_amount` decimal(28,6) default NULL,
3018 `authcat` varchar(30) NOT NULL,
3019 `authvalue` varchar(30) NOT NULL,
3020 `display` tinyint(1) DEFAULT 1,
3021 PRIMARY KEY (`plan_id`),
3022 CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
3023 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
3025 $dbh->do("ALTER TABLE `aqorders`
3026 ADD COLUMN `budget_id` tinyint(4) NOT NULL,
3027 ADD COLUMN `budgetgroup_id` int(11) NOT NULL,
3028 ADD COLUMN `sort1_authcat` varchar(10) default NULL,
3029 ADD COLUMN `sort2_authcat` varchar(10) default NULL" );
3030 # We need to map the orders to the budgets
3031 # For Historic reasons this is more complex than it should be on occasions
3032 my $budg_arr = $dbh->selectall_arrayref(
3033 q|SELECT aqbudgets.budget_id, aqbudgets.budget_code, aqbudgetperiods.budget_period_startdate,
3034 aqbudgetperiods.budget_period_enddate
3035 FROM aqbudgets JOIN aqbudgetperiods ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id
3036 ORDER BY budget_code, budget_period_startdate|, { Slice => {} });
3037 # We arbitarily order on start date, this means if you have overlapping periods the order will be
3038 # linked to the latest matching budget YMMV
3039 my $b_sth = $dbh->prepare(
3040 'UPDATE fundmapping set aqbudgetid = ? where bookfundid =? AND budgetdate >= ? AND budgetdate <= ?');
3041 for my $b ( @{$budg_arr}) {
3042 $b_sth->execute($b->{budget_id}, $b->{budget_code}, $b->{budget_period_startdate}, $b->{budget_period_enddate});
3044 # move the budgetids to aqorders
3045 $dbh->do(q|UPDATE aqorders, fundmapping SET aqorders.budget_id = fundmapping.aqbudgetid
3046 WHERE aqorders.ordernumber = fundmapping.ordernumber AND fundmapping.aqbudgetid IS NOT NULL|);
3047 # NB fundmapping is left as an accontants trail also if you have budgetids that werent set
3048 # you can decide what to do with them
3051 q|UPDATE aqorders, aqbudgets SET aqorders.budgetgroup_id = aqbudgets.budget_period_id
3052 WHERE aqorders.budget_id = aqbudgets.budget_id|);
3053 # cannot do until aqorderbreakdown removed
3054 # $dbh->do("DROP TABLE aqbookfund ");
3055 # $dbh->do("ALTER TABLE aqorders ADD FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON UPDATE CASCADE " ); ????
3056 $dbh->do("SET FOREIGN_KEY_CHECKS=1 ");
3058 print "Upgrade to $DBversion done (Adding new aqbudgetperiods, aqbudgets and aqbudget_planning tables )\n";
3059 SetVersion ($DBversion);
3064 $DBversion = '3.01.00.078';
3065 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3066 $dbh->do("ALTER TABLE aqbudgetperiods ADD COLUMN budget_period_total decimal(28,6)");
3067 print "Upgrade to $DBversion done (adds 'budget_period_total' column to aqbudgetperiods table)\n";
3068 SetVersion($DBversion);
3072 $DBversion = '3.01.00.079';
3073 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3074 $dbh->do("ALTER TABLE currency ADD COLUMN active tinyint(1)");
3076 print "Upgrade to $DBversion done (adds 'active' column to currencies table)\n";
3077 SetVersion($DBversion);
3080 $DBversion = '3.01.00.080';
3081 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3082 $dbh->do(<<BUDG_PERM );
3083 INSERT INTO permissions (module_bit, code, description) VALUES
3084 (11, 'vendors_manage', 'Manage vendors'),
3085 (11, 'contracts_manage', 'Manage contracts'),
3086 (11, 'period_manage', 'Manage periods'),
3087 (11, 'budget_manage', 'Manage budgets'),
3088 (11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
3089 (11, 'planning_manage', 'Manage budget plannings'),
3090 (11, 'order_manage', 'Manage orders & basket'),
3091 (11, 'group_manage', 'Manage orders & basketgroups'),
3092 (11, 'order_receive', 'Manage orders & basket'),
3093 (11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
3096 print "Upgrade to $DBversion done (adds permissions for the acquisitions module)\n";
3097 SetVersion($DBversion);
3101 $DBversion = '3.01.00.081';
3102 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3103 $dbh->do("ALTER TABLE aqbooksellers ADD COLUMN `gstrate` decimal(6,4) default NULL");
3104 if (my $gist=C4::Context->preference("gist")){
3105 my $sql=$dbh->prepare("UPDATE aqbooksellers set `gstrate`=? ");
3106 $sql->execute($gist) ;
3108 print "Upgrade to $DBversion done (added per-supplier gstrate setting)\n";
3109 SetVersion($DBversion);
3112 $DBversion = "3.01.00.082";
3113 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3114 if (C4::Context->preference("opaclanguages") eq "fr") {
3115 $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')#);
3117 $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')");
3119 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
3120 SetVersion ($DBversion);
3123 $DBversion = "3.01.00.083";
3124 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3126 CREATE TABLE `aqorders_items` (
3127 `ordernumber` int(11) NOT NULL,
3128 `itemnumber` int(11) NOT NULL,
3129 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
3130 PRIMARY KEY (`itemnumber`),
3131 KEY `ordernumber` (`ordernumber`)
3132 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
3135 $dbh->do(qq| DROP TABLE aqorderbreakdown |);
3136 $dbh->do('DROP TABLE aqbookfund');
3137 print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
3138 SetVersion ($DBversion);
3141 $DBversion = "3.01.00.084";
3142 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3143 $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') #);
3145 print "Upgrade to $DBversion done (CurrencyFormat syspref added)\n";
3146 SetVersion ($DBversion);
3149 $DBversion = "3.01.00.085";
3150 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3151 $dbh->do("ALTER table aqorders drop column title");
3152 $dbh->do("ALTER TABLE `aqorders` CHANGE `budget_id` `budget_id` INT( 11 ) NOT NULL");
3153 print "Upgrade to $DBversion done update budget_id size that should not be a tinyint\n";
3154 SetVersion ($DBversion);
3157 $DBversion = "3.01.00.086";
3158 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3159 $dbh->do(<<SUGGESTIONS);
3160 ALTER table suggestions
3161 ADD budgetid INT(11),
3162 ADD branchcode VARCHAR(10) default NULL,
3163 ADD acceptedby INT(11) default NULL,
3164 ADD accepteddate date default NULL,
3165 ADD suggesteddate date default NULL,
3166 ADD manageddate date default NULL,
3167 ADD rejectedby INT(11) default NULL,
3168 ADD rejecteddate date default NULL,
3169 ADD collectiontitle text default NULL,
3170 ADD itemtype VARCHAR(30) default NULL
3173 print "Upgrade to $DBversion done (Suggestions)\n";
3174 SetVersion ($DBversion);
3177 $DBversion = "3.01.00.087";
3178 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3179 $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;");
3180 print "Upgrade to $DBversion done (Drop column budget_amount_sublevel from aqbudgets)\n";
3181 SetVersion ($DBversion);
3184 $DBversion = "3.01.00.088";
3185 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3186 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo') #);
3188 print "Upgrade to $DBversion done (intranetbookbag syspref added)\n";
3189 SetVersion ($DBversion);
3192 $DBversion = "3.01.00.090";
3193 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3195 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3196 (16, 'execute_reports', 'Execute SQL reports'),
3197 (16, 'create_reports', 'Create SQL Reports')
3200 print "Upgrade to $DBversion done (granular permissions for guided reports added)\n";
3201 SetVersion ($DBversion);
3204 $DBversion = "3.01.00.091";
3205 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3207 UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions'
3208 WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1
3211 print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
3212 SetVersion ($DBversion);
3215 $DBversion = "3.01.00.092";
3216 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3217 if (C4::Context->preference("opaclanguages") =~ /fr/) {
3219 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');
3223 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');
3226 print "Upgrade to $DBversion done (Added RoutingListAddReserves syspref)\n";
3227 SetVersion ($DBversion);
3230 $DBversion = "3.01.00.093";
3231 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3233 ALTER TABLE biblioitems ADD INDEX issn_idx (issn);
3235 print "Upgrade to $DBversion done (added index to ISSN)\n";
3236 SetVersion ($DBversion);
3239 $DBversion = "3.01.00.094";
3240 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3242 ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10) default NULL, ADD deliverycomment VARCHAR(255) default NULL;
3245 print "Upgrade to $DBversion done (adding deliveryplace deliverycomment to basketgroups)\n";
3246 SetVersion ($DBversion);
3249 $DBversion = "3.01.00.095";
3250 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3252 ALTER TABLE items ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number";
3255 ALTER TABLE items ADD UNIQUE INDEX itemsstocknumberidx (stocknumber);
3258 ALTER TABLE deleteditems ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number of deleted items";
3261 ALTER TABLE deleteditems ADD UNIQUE INDEX deleteditemsstocknumberidx (stocknumber);
3263 if (C4::Context->preference('marcflavour') eq 'UNIMARC'){
3265 INSERT IGNORE INTO marc_subfield_structure (frameworkcode,tagfield, tagsubfield, tab, repeatable, mandatory,kohafield)
3266 SELECT DISTINCT (frameworkcode),995,"j",10,0,0,"items.stocknumber" from biblio_framework ;
3268 #Previously, copynumber was used as stocknumber
3270 UPDATE items set stocknumber=copynumber;
3273 UPDATE items set copynumber=NULL;
3276 print "Upgrade to $DBversion done (stocknumber field added)\n";
3277 SetVersion ($DBversion);
3280 $DBversion = "3.01.00.096";
3281 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3282 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPdfTemplate','','Uploads a PDF template to use for printing baskets','NULL','Upload')");
3283 $dbh->do("UPDATE systempreferences SET variable='OrderPdfFormat' WHERE variable='pdfformat'");
3284 print "Upgrade to $DBversion done (PDF orders system preferences added and updated)\n";
3285 SetVersion ($DBversion);
3288 $DBversion = "3.01.00.097";
3289 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3291 ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10) NOT NULL AFTER deliverycomment;
3294 print "Upgrade to $DBversion done (Adding billingplace to aqbasketgroups)\n";
3295 SetVersion ($DBversion);
3298 $DBversion = "3.01.00.098";
3299 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3301 ALTER TABLE auth_subfield_structure MODIFY frameworkcode VARCHAR(10) NULL;
3304 print "Upgrade to $DBversion done (changing frameworkcode length in auth_subfield_structure)\n";
3305 SetVersion ($DBversion);
3308 $DBversion = "3.01.00.099";
3309 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3311 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3312 (9, 'edit_catalogue', 'Edit catalogue'),
3313 (9, 'fast_cataloging', 'Fast cataloging')
3316 print "Upgrade to $DBversion done (granular permissions for cataloging added)\n";
3317 SetVersion ($DBversion);
3320 $DBversion = "3.01.00.100";
3321 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3322 $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')");
3323 print "Upgrade to $DBversion done (added CAS authentication system preferences)\n";
3324 SetVersion ($DBversion);
3327 $DBversion = "3.01.00.101";
3328 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3330 "INSERT INTO systempreferences
3331 (variable, value, options, explanation, type)
3333 'OverdueNoticeBcc', '', '',
3334 'Email address to Bcc outgoing notices sent by email',
3337 print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
3338 SetVersion ($DBversion);
3340 $DBversion = "3.01.00.102";
3341 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3343 "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
3345 print "Upgrade to $DBversion done (fixed spelling error in edit_catalogue permission)\n";
3346 SetVersion ($DBversion);
3349 $DBversion = "3.01.00.103";
3350 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3351 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
3352 print "Upgrade to $DBversion done (adding patron permissions for tags tool)\n";
3353 SetVersion ($DBversion);
3356 $DBversion = "3.01.00.104";
3357 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3359 my ($maninv_count, $borrnotes_count);
3360 eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
3361 if ($maninv_count == 0) {
3362 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
3364 eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
3365 if ($borrnotes_count == 0) {
3366 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
3369 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
3370 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
3372 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";
3373 SetVersion ($DBversion);
3377 $DBversion = "3.01.00.105";
3378 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3380 CREATE TABLE `collections` (
3381 `colId` int(11) NOT NULL auto_increment,
3382 `colTitle` varchar(100) NOT NULL default '',
3383 `colDesc` text NOT NULL,
3384 `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
3385 PRIMARY KEY (`colId`)
3386 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3390 CREATE TABLE `collections_tracking` (
3391 `ctId` int(11) NOT NULL auto_increment,
3392 `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
3393 `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
3394 PRIMARY KEY (`ctId`)
3395 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3398 INSERT INTO permissions (module_bit, code, description)
3399 VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
3400 print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
3401 SetVersion ($DBversion);
3403 $DBversion = "3.01.00.106";
3404 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3405 $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' )");
3406 print "Upgrade to $DBversion done (added OpacAddMastheadLibraryPulldown system preferences)\n";
3407 SetVersion ($DBversion);
3410 $DBversion = '3.01.00.107';
3411 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3412 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
3413 system("perl $upgrade_script");
3414 print "Upgrade to $DBversion done (Migrated labels and patroncards tables and data to new schema.)\n";
3415 SetVersion ($DBversion);
3418 $DBversion = '3.01.00.108';
3419 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3421 ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
3422 ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
3423 ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator`
3425 print "Upgrade to $DBversion done (added separators for csv export)\n";
3426 SetVersion ($DBversion);
3429 $DBversion = "3.01.00.109";
3430 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3432 ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
3434 print "Upgrade to $DBversion done (added encoding for csv export)\n";
3435 SetVersion ($DBversion);
3438 $DBversion = '3.01.00.110';
3439 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3440 $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
3441 print "Upgrade to $DBversion done (Add enrolment period date support)\n";
3442 SetVersion ($DBversion);
3445 $DBversion = '3.01.00.111';
3446 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3447 print "Upgrade to $DBversion done (mark DBrev for 3.2-alpha release)\n";
3448 SetVersion ($DBversion);
3451 $DBversion = '3.01.00.112';
3452 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3453 $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');");
3454 print "Upgrade to $DBversion done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
3455 SetVersion ($DBversion);
3458 $DBversion = '3.01.00.113';
3459 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3460 my $value = C4::Context->preference("XSLTResultsDisplay");
3462 "INSERT INTO systempreferences (variable,value,type)
3463 VALUES('OPACXSLTResultsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3464 $value = C4::Context->preference("XSLTDetailsDisplay");
3466 "INSERT INTO systempreferences (variable,value,type)
3467 VALUES('OPACXSLTDetailsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3468 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";
3469 SetVersion ($DBversion);
3472 $DBversion = '3.01.00.114';
3473 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3474 $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')");
3475 $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')");
3476 $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')");
3477 print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
3478 SetVersion ($DBversion);
3481 $DBversion = '3.01.00.115';
3482 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3483 $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
3484 $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
3485 print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
3486 SetVersion ($DBversion);
3489 $DBversion = '3.01.00.116';
3490 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3491 if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
3492 $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
3494 print "Upgrade to $DBversion done (corrected default OrderPdfFormat value if still set wrong )\n";
3495 SetVersion ($DBversion);
3498 $DBversion = '3.01.00.117';
3499 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3500 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'por' WHERE rfc4646_subtag='pt' ");
3501 print "Upgrade to $DBversion done (corrected ISO 639-2 language code for Portuguese)\n";
3502 SetVersion ($DBversion);
3505 $DBversion = '3.01.00.118';
3506 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3507 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns
3508 WHERE table_name = 'aqbudgets_planning'
3509 AND column_name = 'display'");
3511 $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1");
3513 print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n";
3514 SetVersion ($DBversion);
3517 $DBversion = '3.01.00.119';
3518 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3519 eval{require Locale::Currency::Format};
3521 print "Upgrade to $DBversion done (Locale::Currency::Format installed.)\n";
3522 SetVersion ($DBversion);
3525 print "Upgrade to $DBversion done.\n";
3526 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";
3527 SetVersion ($DBversion);
3531 $DBversion = '3.01.00.120';
3532 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3534 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');
3536 print "Upgrade to $DBversion done (bug 1080: add soundon system preference for circulation sounds)\n";
3537 SetVersion ($DBversion);
3540 $DBversion = '3.01.00.121';
3541 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3542 $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE DEFAULT NULL");
3543 $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3544 $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE DEFAULT NULL");
3545 $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3546 print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
3547 SetVersion ($DBversion);
3550 $DBversion = '3.01.00.122';
3551 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3553 INSERT INTO systempreferences (variable,value,explanation,options,type)
3554 VALUES ('OAI-PMH:ConfFile', '', 'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','','File');
3556 print "Upgrade to $DBversion done. — Add a new system preference OAI-PMF:ConfFile\n";
3557 SetVersion ($DBversion);
3560 $DBversion = "3.01.00.123";
3561 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3562 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3563 (6, 'place_holds', 'Place holds for patrons')");
3564 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3565 (6, 'modify_holds_priority', 'Modify holds priority')");
3566 $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
3567 print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
3568 SetVersion ($DBversion);
3571 $DBversion = '3.01.00.124';
3572 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3574 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>>).');
3576 print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
3577 SetVersion ($DBversion);
3580 $DBversion = '3.01.00.125';
3581 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3583 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' );
3586 INSERT INTO message_transport_types (message_transport_type) values ('print');
3588 print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
3589 SetVersion ($DBversion);
3592 $DBversion = "3.01.00.126";
3593 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3594 $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')");
3595 $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')");
3597 print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:AuthorizedIPs)\n";
3598 SetVersion ($DBversion);
3601 $DBversion = '3.01.00.127';
3602 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3603 $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
3604 print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
3605 SetVersion ($DBversion);
3608 $DBversion = '3.01.00.128';
3609 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3610 $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
3611 print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
3612 SetVersion ($DBversion);
3615 $DBversion = "3.01.00.129";
3616 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3617 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
3618 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
3619 print "Upgrade to $DBversion done (Change permissions names for item batch modification / deletion)\n";
3621 SetVersion ($DBversion);
3624 $DBversion = "3.01.00.130";
3625 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3626 $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'");
3627 print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n";
3628 SetVersion ($DBversion);
3631 $DBversion = "3.01.00.131";
3632 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3634 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
3636 print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
3637 SetVersion ($DBversion);
3640 $DBversion = "3.01.00.132";
3641 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3643 ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
3645 print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
3646 SetVersion ($DBversion);
3649 $DBversion = '3.01.00.133';
3650 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3651 $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')");
3652 print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
3653 SetVersion ($DBversion);
3656 $DBversion = '3.01.00.134';
3657 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3658 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
3659 print "Upgrade to $DBversion done (adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page)\n";
3660 SetVersion ($DBversion);
3663 $DBversion = '3.01.00.135';
3664 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3666 INSERT INTO `letter` (module, code, name, title, content) VALUES
3667 ('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')
3669 print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)\n";
3670 SetVersion ($DBversion);
3673 $DBversion = '3.01.00.136';
3674 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3676 INSERT INTO permissions (module_bit, code, description) VALUES
3677 ( 9, 'edit_items', 'Edit Items');});
3678 print "Upgrade to $DBversion done (Adding a new permission to edit items)\n";
3679 SetVersion ($DBversion);
3682 $DBversion = "3.01.00.137";
3683 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3685 INSERT INTO permissions (module_bit, code, description) VALUES
3686 (15, 'check_expiration', 'Check the expiration of a serial'),
3687 (15, 'claim_serials', 'Claim missing serials'),
3688 (15, 'create_subscription', 'Create a new subscription'),
3689 (15, 'delete_subscription', 'Delete an existing subscription'),
3690 (15, 'edit_subscription', 'Edit an existing subscription'),
3691 (15, 'receive_serials', 'Serials receiving'),
3692 (15, 'renew_subscription', 'Renew a subscription'),
3693 (15, 'routing', 'Routing');
3695 print "Upgrade to $DBversion done (adding granular permissions for serials)\n";
3696 SetVersion ($DBversion);
3699 $DBversion = "3.01.00.138";
3700 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3701 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
3702 print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)\n";
3703 SetVersion ($DBversion);
3706 $DBversion = '3.01.00.139';
3707 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3708 $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
3709 print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
3710 SetVersion ($DBversion);
3713 $DBversion = '3.01.00.140';
3714 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3715 $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'TagsModeration' AND value is NULL");
3716 print "Upgrade to $DBversion done (bug 4312 TagsModeration changed from NULL to 0)\n";
3717 SetVersion ($DBversion);
3720 $DBversion = '3.01.00.141';
3721 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3722 $dbh->do(qq{DELETE FROM message_attributes WHERE message_attribute_id=3;});
3723 $dbh->do(qq{DELETE FROM letter WHERE code='EVENT' AND title='Upcoming Library Event';});
3724 print "Upgrade to $DBversion done Remove upcoming events messaging option (bug 2434)\n";
3725 SetVersion ($DBversion);
3728 $DBversion = '3.01.00.142';
3729 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3730 $dbh->do(qq{DELETE FROM message_transports WHERE message_attribute_id=3;});
3731 print "Upgrade to $DBversion done (Remove upcoming events messaging option part 2 (bug 2434))\n";
3732 SetVersion ($DBversion);
3735 $DBversion = '3.01.00.143';
3736 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3737 $dbh->do(qq{CREATE INDEX auth_value_idx ON authorised_values (authorised_value)});
3738 $dbh->do(qq{CREATE INDEX auth_val_cat_idx ON borrower_attribute_types (authorised_value_category)});
3739 print "Upgrade to $DBversion done (Create index on authorised_values and borrower_attribute_types (bug 4139))\n";
3740 SetVersion ($DBversion);
3743 $DBversion = '3.01.00.144';
3744 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3745 $dbh->do(qq{UPDATE systempreferences SET value='normal' where value='default' and variable='IntranetBiblioDefaultView'});
3746 print "Upgrade to $DBversion done (Update the 'default' to 'normal' for the IntranetBiblioDefaultView syspref (bug 5007))\n";
3747 SetVersion ($DBversion);
3750 $DBversion = "3.01.00.145";
3751 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3752 $dbh->do("ALTER TABLE borrowers ADD KEY `guarantorid` (guarantorid);");
3753 print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3754 SetVersion ($DBversion);
3757 $DBversion = '3.01.00.999';
3758 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3759 print "Upgrade to $DBversion done (3.2.0 release candidate)\n";
3760 SetVersion ($DBversion);
3763 $DBversion = "3.02.00.000";
3764 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3765 my $value = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'HomeOrHoldingBranch'");
3766 $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');");
3767 print "Upgrade to $DBversion done (Add HomeOrHoldingBranchReturn system preference)\n";
3768 SetVersion ($DBversion);
3771 $DBversion = "3.02.00.001";
3772 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3773 $dbh->do(q{DELETE FROM systempreferences WHERE variable IN (
3778 'OPACSubscriptionDisplay',
3779 'OPACDisplayExtendedSubInfo',
3790 print "Upgrade to $DBversion done (bug 3756: remove disused system preferences)\n";
3791 SetVersion ($DBversion);
3794 $DBversion = "3.02.00.002";
3795 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3796 $dbh->do(q{DELETE FROM systempreferences WHERE variable = 'OpacPrivacy'});
3797 print "Upgrade to $DBversion done (bug 3881: remove unused OpacPrivacy system preference)\n";
3798 SetVersion ($DBversion);
3801 $DBversion = "3.02.00.003";
3802 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3803 $dbh->do(q{UPDATE systempreferences SET variable = 'ILS-DI:AuthorizedIPs' WHERE variable = 'ILS-DI:Authorized_IPs'});
3804 print "Upgrade to $DBversion done (correct ILS-DI:AuthorizedIPs)\n";
3805 SetVersion ($DBversion);
3808 $DBversion = "3.02.00.004";
3809 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3810 print "Upgrade to $DBversion done (3.2.0 general release)\n";
3811 SetVersion ($DBversion);
3814 # This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3815 # apply updates that have already been done
3817 $DBversion = "3.03.00.001";
3818 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.005")) {
3819 $dbh->do("DELETE FROM subscriptionroutinglist WHERE borrowernumber IS NULL;");
3820 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `borrowernumber` int(11) NOT NULL;");
3821 $dbh->do("DELETE FROM subscriptionroutinglist WHERE subscriptionid IS NULL;");
3822 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `subscriptionid` int(11) NOT NULL;");
3823 $dbh->do("CREATE TEMPORARY TABLE del_subscriptionroutinglist
3824 SELECT s1.routingid FROM subscriptionroutinglist s1
3825 WHERE EXISTS (SELECT * FROM subscriptionroutinglist s2
3826 WHERE s2.borrowernumber = s1.borrowernumber
3827 AND s2.subscriptionid = s1.subscriptionid
3828 AND s2.routingid < s1.routingid);");
3829 $dbh->do("DELETE FROM subscriptionroutinglist
3830 WHERE routingid IN (SELECT routingid FROM del_subscriptionroutinglist);");
3831 $dbh->do("ALTER TABLE subscriptionroutinglist ADD UNIQUE (subscriptionid, borrowernumber);");
3832 $dbh->do("ALTER TABLE subscriptionroutinglist
3833 ADD CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`)
3834 REFERENCES `borrowers` (`borrowernumber`)
3835 ON DELETE CASCADE ON UPDATE CASCADE");
3836 $dbh->do("ALTER TABLE subscriptionroutinglist
3837 ADD CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`)
3838 REFERENCES `subscription` (`subscriptionid`)
3839 ON DELETE CASCADE ON UPDATE CASCADE");
3840 print "Upgrade to $DBversion done (Make subscriptionroutinglist more strict)\n";
3841 SetVersion ($DBversion);
3844 $DBversion = '3.03.00.002';
3845 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.006")) {
3846 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='arm' WHERE rfc4646_subtag='hy';");
3847 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='eng' WHERE rfc4646_subtag='en';");
3848 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'fi','fin');");
3849 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='fre' WHERE rfc4646_subtag='fr';");
3850 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'lo','lao');");
3851 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it';");
3852 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'sr','srp');");
3853 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'tet','tet');");
3854 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ur','urd');");
3856 print "Upgrade to $DBversion done (Correct language mappings)\n";
3857 SetVersion ($DBversion);
3860 $DBversion = '3.03.00.003';
3861 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.007")) {
3862 $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');");
3863 print "Upgrade to $DBversion done (Add UseTablesortForCirc syspref)\n";
3864 SetVersion ($DBversion);
3867 $DBversion = '3.03.00.004';
3868 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.001")) {
3869 my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ACCEPTED');
3871 INSERT INTO `letter`
3872 (module, code, name, title, content)
3874 ('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>>')
3875 /) unless $count > 0;
3876 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'AVAILABLE');
3878 INSERT INTO `letter`
3879 (module, code, name, title, content)
3881 ('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>>')
3882 /) unless $count > 0;
3883 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ORDERED');
3885 INSERT INTO `letter`
3886 (module, code, name, title, content)
3888 ('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>>')
3889 /) unless $count > 0;
3890 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'REJECTED');
3892 INSERT INTO `letter`
3893 (module, code, name, title, content)
3895 ('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>>')
3896 /) unless $count > 0;
3897 print "Upgrade to $DBversion done (bug 5127: add default templates for suggestion status change notifications)\n";
3898 SetVersion ($DBversion);
3901 $DBversion = '3.03.00.005';
3902 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3903 $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
3904 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
3907 $DBversion = '3.03.00.006';
3908 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.002")) {
3909 $dbh->do("ALTER TABLE deletedborrowers ADD `privacy` int(11) AFTER smsalertnumber;");
3910 $dbh->do("ALTER TABLE deletedborrowers CHANGE `cardnumber` `cardnumber` varchar(16);");
3911 print "Upgrade to $DBversion done (Fix differences between borrowers and deletedborrowers)\n";
3912 SetVersion ($DBversion);
3915 $DBversion = '3.03.00.007';
3916 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3917 $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL,
3918 ADD currency VARCHAR(3) default NULL,
3919 ADD price DECIMAL(28,6) default NULL,
3920 ADD total DECIMAL(28,6) default NULL;
3922 print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n";
3923 SetVersion ($DBversion);
3926 $DBversion = '3.03.00.008';
3927 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3928 $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')");
3929 print "Upgrade to $DBversion done (adding syspref OPACNoResultsFound to control what displays when no results are found for a search in the OPAC.)\n";
3930 SetVersion ($DBversion);
3933 $DBversion = '3.03.00.009';
3934 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.003")) {
3935 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetUserCSS','','Add CSS to be included in the Intranet',NULL,'free')");
3936 print "Upgrade to $DBversion done (Add IntranetUserCSS syspref)\n";
3937 SetVersion ($DBversion);
3940 $DBversion = "3.03.00.010";
3941 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.02.001")) {
3942 $dbh->do("UPDATE `marc_subfield_structure` SET liblibrarian = 'Distance from earth' WHERE liblibrarian = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3943 $dbh->do("UPDATE `marc_subfield_structure` SET libopac = 'Distance from earth' WHERE libopac = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3944 print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
3945 SetVersion ($DBversion);
3948 $DBversion = "3.03.00.011";
3949 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3950 $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3951 print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
3952 SetVersion ($DBversion);
3955 $DBversion = "3.03.00.012";
3956 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3957 $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')");
3958 print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
3959 SetVersion ($DBversion);
3962 $DBversion = "3.03.00.013";
3963 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3964 $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')");
3965 print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n";
3966 SetVersion ($DBversion);
3969 $DBversion = "3.03.00.014";
3970 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3971 $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')");
3972 $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')");
3973 $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')");
3974 print "Upgrade to $DBversion done (Add flexible shelf browser constraints)\n";
3975 SetVersion ($DBversion);
3978 $DBversion = "3.03.00.015";
3979 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3980 if ( C4::Context->preference("marcflavour") eq "MARC21" ) {
3981 my $sth = $dbh->prepare(
3982 "INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`,
3983 `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`)
3984 VALUES ( ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, '', 6, '', '', '', 0, -5, '', '', '', NULL)"
3986 $sth->execute('648');
3987 $sth->execute('654');
3988 $sth->execute('655');
3989 $sth->execute('656');
3990 $sth->execute('657');
3991 $sth->execute('658');
3992 $sth->execute('662');
3995 "Upgrade to $DBversion done (Bug 5619: Add subfield 9 to marc21 648,654,655,656,657,658,662)\n";
3997 SetVersion($DBversion);
4000 $DBversion = '3.03.00.016';
4001 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4002 # reimplement OpacPrivacy system preference
4003 $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')");
4004 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4005 $dbh->do("ALTER TABLE `deletedborrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4006 print "Upgrade to $DBversion done (OpacPrivacy reimplementation)\n";
4007 SetVersion($DBversion);
4010 $DBversion = '3.03.00.017';
4011 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.001")) {
4012 $dbh->do("ALTER TABLE `currency` CHANGE `rate` `rate` FLOAT( 15, 5 ) NULL DEFAULT NULL;");
4013 print "Upgrade to $DBversion done (Enable currency rates >= 100)\n";
4014 SetVersion ($DBversion);
4017 $DBversion = '3.03.00.018';
4018 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.002")) {
4019 $dbh->do( q|update language_descriptions set description = 'Nederlands' where lang = 'nl' and subtag = 'nl'|);
4020 $dbh->do( q|update language_descriptions set description = 'Dansk' where lang = 'da' and subtag = 'da'|);
4021 print "Upgrade to $DBversion done (Correct language descriptions)\n";
4022 SetVersion ($DBversion);
4025 $DBversion = '3.03.00.019';
4026 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.003")) {
4028 $dbh->do("UPDATE language_subtag_registry SET description = 'Norwegian bokmål' WHERE subtag = 'nb';");
4029 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nb','nob');");
4030 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokmål' WHERE subtag = 'nb' AND lang = 'nb';");
4031 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokmål' WHERE subtag = 'nb' AND lang = 'en';");
4032 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokmål' WHERE subtag = 'nb' AND lang = 'fr';");
4034 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'nn', 'language', 'Norwegian nynorsk','2011-02-14' )");
4035 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nn','nno')");
4036 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nb', 'Norsk nynorsk')");
4037 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nn', 'Norsk nynorsk')");
4038 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'en', 'Norwegian nynorsk')");
4039 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'fr', 'Norvégien nynorsk')");
4040 print "Upgrade to $DBversion done (Correct language descriptions for Norwegian)\n";
4041 SetVersion ($DBversion);
4044 $DBversion = '3.03.00.020';
4045 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4046 $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')");
4047 $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')");
4048 print "Upgrade to $DBversion done (Bug 5811: Add sysprefs controlling overriding fines)\n";
4049 SetVersion($DBversion);
4052 $DBversion = '3.03.00.021';
4053 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.001")) {
4054 $dbh->do("ALTER TABLE items MODIFY enumchron TEXT");
4055 $dbh->do("ALTER TABLE deleteditems MODIFY enumchron TEXT");
4056 print "Upgrade to $DBversion done (bug 5642: longer serial enumeration)\n";
4057 SetVersion ($DBversion);
4060 $DBversion = '3.03.00.022';
4061 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4062 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo');");
4063 print "Upgrade to $DBversion done (Add AuthoritiesLog syspref)\n";
4064 SetVersion ($DBversion);
4067 # due to a mismatch in kohastructure.sql some koha will have missing columns in aqbasketgroup
4068 # this attempts to fix that
4069 $DBversion = '3.03.00.023';
4070 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.002")) {
4071 my $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'billingplace'");
4073 $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4074 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliveryplace'");
4076 $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4077 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliverycomment'");
4079 $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") if ! $sth->fetchrow_hashref;
4080 print "Upgrade to $DBversion done (Reconcile aqbasketgroups)\n";
4081 SetVersion ($DBversion);
4084 $DBversion = '3.03.00.024';
4085 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4086 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo')");
4087 $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')");
4088 print "Upgrade to $DBversion done (Add syspref to force whole-subfield matching on subject tracings)\n";
4089 SetVersion($DBversion);
4092 $DBversion = "3.03.00.025";
4093 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4094 $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')");
4095 print "Upgrade to $DBversion done (Add syspref to control if user can choose pickup branch for holds)\n";
4096 SetVersion ($DBversion);
4099 $DBversion = '3.03.00.026';
4100 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.003")) {
4101 $dbh->do("UPDATE `message_attributes` SET message_name='Item Due' WHERE message_attribute_id=1 AND message_name LIKE 'Item DUE'");
4102 print "Upgrade to $DBversion done ( fix capitalization in message type )\n";
4103 SetVersion ($DBversion);
4106 $DBversion = '3.03.00.027';
4107 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4108 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('displayFacetCount', '0', NULL, NULL, 'YesNo')");
4109 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('maxRecordsForFacets', '20', NULL, NULL, 'Integer')");
4110 print "Upgrade to $DBversion done (Preferences for facet count)\n";
4111 SetVersion ($DBversion);
4114 $DBversion = "3.03.00.028";
4115 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4116 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('FacetLabelTruncationLength', 20, 'Truncate facets length to','','free')");
4117 print "Upgrade to $DBversion done (Add FacetLabelTruncationLength syspref to control facets displayed length)\n";
4118 SetVersion ($DBversion);
4121 $DBversion = "3.03.00.029";
4122 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4123 $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')");
4124 print "Upgrade to $DBversion done (Add syspref to control if user can choose branch when making purchase suggestion)\n";
4125 SetVersion ($DBversion);
4128 $DBversion = "3.03.00.030";
4129 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4130 $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')");
4131 $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')");
4132 print "Upgrade to $DBversion done (Add sysprefs to control custom favicons)\n";
4133 SetVersion ($DBversion);
4136 $DBversion = "3.03.00.031";
4137 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4138 $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');");
4139 print "Upgrade to $DBversion done (Add syspref FineNotifyAtCheckin)\n";
4140 SetVersion ($DBversion);
4143 $DBversion = '3.03.00.032';
4144 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4145 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', 1, 'Create searches on all subdivisions for subject tracings.','1','YesNo')");
4146 print "Upgrade to $DBversion done ( include subdivisions when generating subject tracing searches )\n";
4150 $DBversion = '3.03.00.033';
4151 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4152 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages', '1', '', NULL, 'YesNo')");
4153 print "Upgrade to $DBversion done (System pref StaffAuthorisedValueImages)\n";
4154 SetVersion ($DBversion);
4157 $DBversion = '3.03.00.034';
4158 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4159 $dbh->do("ALTER TABLE `categories` ADD `hidelostitems` tinyint(1) NOT NULL default '0' AFTER `reservefee`");
4160 print "Upgrade to $DBversion done (Add hidelostitems preference to borrower categories)\n";
4161 SetVersion ($DBversion);
4164 $DBversion = '3.03.00.035';
4165 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4166 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedate date default NULL AFTER issuelength");
4167 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedatecompare tinyint NOT NULL default 0 AFTER hardduedate");
4169 if (C4::Context->preference("globalDueDate")) {
4170 $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("globalDueDate"));
4171 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = 0");
4172 } elsif (C4::Context->preference("ceilingDueDate")) {
4173 $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("ceilingDueDate"));
4174 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = -1");
4176 $dbh->do("DELETE FROM `systempreferences` WHERE variable = 'globalDueDate' OR variable = 'ceilingDueDate'");
4177 print "Upgrade to $DBversion done (Move global and ceiling due dates to Circ Rules level)\n";
4178 SetVersion ($DBversion);
4181 $DBversion = '3.03.00.036';
4182 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4183 $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')");
4184 print "Upgrade to $DBversion done ( Make COinS optional in OPAC search results )\n";
4185 SetVersion ($DBversion);
4188 $DBversion = '3.03.00.037';
4189 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4190 $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')");
4191 $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')");
4192 print "Upgrade to $DBversion done (Add 'Display856uAsImage' and 'OPACDisplay856uAsImage' syspref)\n";
4193 SetVersion ($DBversion);
4196 $DBversion = '3.03.00.038';
4197 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4198 $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')");
4199 $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')");
4200 $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')");
4201 print "Upgrade to $DBversion done ( Add Self-checkout by Login system preferences )\n";
4204 $DBversion = "3.03.00.039";
4205 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4206 $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');");
4207 print "Upgrade to $DBversion done (Add syspref ShowReviewer)\n";
4210 $DBversion = "3.03.00.040";
4211 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4212 $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');");
4213 print "Upgrade to $DBversion done (Add syspref UseControlNumber)\n";
4216 $DBversion = "3.03.00.041";
4217 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4218 $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')");
4219 $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')");
4220 print "Upgrade to $DBversion done (Add sysprefs to control alternate holdings information display)\n";
4221 SetVersion ($DBversion);
4224 $DBversion = '3.03.00.042';
4225 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4226 stocknumber_checker();
4227 print "Upgrade to $DBversion done (5860 Index itemstocknumber)\n";
4228 SetVersion ($DBversion);
4231 sub stocknumber_checker { #code reused later on
4233 #drop the obsolete itemSStocknumber idx if it exists
4234 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemsstocknumberidx'");
4235 $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;") if @row;
4237 #check itemstocknumber idx; remove it if it is unique
4238 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx' AND non_unique=0");
4239 $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;") if @row;
4241 #add itemstocknumber index non-unique IF it still not exists
4242 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx'");
4243 $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);") unless @row;
4246 $DBversion = "3.03.00.043";
4247 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4249 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No')");
4250 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes')");
4252 print "Upgrade to $DBversion done ( add generic boolean YES_NO authorised_values pair )\n";
4253 SetVersion ($DBversion);
4256 $DBversion = '3.03.00.044';
4257 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4258 $dbh->do("ALTER TABLE `aqbasketgroups` ADD `freedeliveryplace` TEXT NULL AFTER `deliveryplace`;");
4259 print "Upgrade to $DBversion done (adding freedeliveryplace to basketgroups)\n";
4262 $DBversion = '3.03.00.045';
4263 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4264 #Remove obsolete columns from aqbooksellers if needed
4265 my $a = $dbh->selectall_hashref('SHOW columns from aqbooksellers','Field');
4266 my $sqldrop="ALTER TABLE aqbooksellers DROP COLUMN ";
4267 foreach(qw/deliverydays followupdays followupscancel invoicedisc nocalc specialty/) {
4268 $dbh->do($sqldrop.$_) if exists $a->{$_};
4270 #Remove obsolete column from aqbudgets if needed
4271 #The correct column is budget_notes
4272 $a = $dbh->selectall_hashref('SHOW columns from aqbudgets','Field');
4273 if(exists $a->{budget_description}) {
4274 $dbh->do("ALTER TABLE aqbudgets DROP COLUMN budget_description");
4276 print "Upgrade to $DBversion done (Remove obsolete columns from aqbooksellers and aqbudgets if needed)\n";
4277 SetVersion ($DBversion);
4280 $DBversion = "3.03.00.046";
4281 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4282 $dbh->do("ALTER TABLE overduerules ALTER delay1 SET DEFAULT NULL, ALTER delay2 SET DEFAULT NULL, ALTER delay3 SET DEFAULT NULL");
4283 print "Upgrade to $DBversion done (Setting NULL default value for delayn columns in table overduerules)\n";
4284 SetVersion($DBversion);
4287 $DBversion = '3.03.00.047';
4288 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4289 $dbh->do("ALTER TABLE borrowers ADD `state` mediumtext AFTER city;");
4290 $dbh->do("ALTER TABLE borrowers ADD `B_state` mediumtext AFTER B_city;");
4291 $dbh->do("ALTER TABLE borrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4292 $dbh->do("ALTER TABLE deletedborrowers ADD `state` mediumtext AFTER city;");
4293 $dbh->do("ALTER TABLE deletedborrowers ADD `B_state` mediumtext AFTER B_city;");
4294 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4295 print "Upgrade to $DBversion done (Add state field to patron's addresses)\n";
4298 $DBversion = '3.03.00.048';
4299 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4300 $dbh->do("ALTER TABLE branches ADD `branchstate` mediumtext AFTER `branchcity`;");
4301 print "Upgrade to $DBversion done (Add state to branch address)\n";
4302 SetVersion ($DBversion);
4305 $DBversion = '3.03.00.049';
4306 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4307 $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4308 $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4309 print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n";
4310 SetVersion($DBversion);
4313 $DBversion = "3.03.00.050";
4314 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4316 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');
4318 print "Upgrade to $DBversion done (Adding OpacHiddenItems syspref)\n";
4319 SetVersion($DBversion);
4322 $DBversion = "3.03.00.051";
4323 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4324 print "Upgrade to $DBversion done (Remove spaces and dashes from message_attribute names)\n";
4325 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Due' WHERE message_name='Item Due'");
4326 $dbh->do("UPDATE message_attributes SET message_name = 'Advance_Notice' WHERE message_name='Advance Notice'");
4327 $dbh->do("UPDATE message_attributes SET message_name = 'Hold_Filled' WHERE message_name='Hold Filled'");
4328 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Check_in' WHERE message_name='Item Check-in'");
4329 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Checkout' WHERE message_name='Item Checkout'");
4330 SetVersion ($DBversion);
4333 $DBversion = "3.03.00.052";
4334 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4335 $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');");
4336 print "Upgrade to $DBversion done (Add syspref WaitingNotifyAtCheckin)\n";
4337 SetVersion ($DBversion);
4340 $DBversion = "3.04.00.000";
4341 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4342 print "Upgrade to $DBversion done Koha 3.4.0 release \n";
4343 SetVersion ($DBversion);
4346 $DBversion = "3.05.00.001";
4347 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4349 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');
4351 print "Upgrade to $DBversion done (Adds New System preference numSearchRSSResults)\n";
4352 SetVersion($DBversion);
4355 $DBversion = '3.05.00.002';
4356 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4357 #follow up fix 5860: some installs already past 3.3.0.42
4358 stocknumber_checker();
4359 print "Upgrade to $DBversion done (Fix for stocknumber index)\n";
4360 SetVersion ($DBversion);
4363 $DBversion = "3.05.00.003";
4364 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4366 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');
4368 print "Upgrade to $DBversion done (Adds New System preference OpacRenewalBranch)\n";
4369 SetVersion($DBversion);
4372 $DBversion = "3.05.00.004";
4373 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4374 $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');");
4375 print "Upgrade to $DBversion done (Add syspref ShowReviewerPhoto)\n";
4376 SetVersion($DBversion);
4379 $DBversion = "3.05.00.005";
4380 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4381 $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');");
4382 print "Upgrade to $DBversion done (Adds pref BasketConfirmations)\n";
4383 SetVersion($DBversion);
4386 $DBversion = "3.05.00.006";
4387 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4388 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea')");
4389 print "Upgrade to $DBversion done (Add syspref MARCAuthorityControlField008)\n";
4390 SetVersion ($DBversion);
4393 $DBversion = "3.05.00.007";
4394 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4395 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');");
4396 print "Upgrade to $DBversion done (Add syspref OpenLibraryCovers)\n";
4397 SetVersion($DBversion);
4400 $DBversion = "3.05.00.008";
4401 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4402 $dbh->do("ALTER TABLE `cities` ADD `city_state` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_name`;");
4403 $dbh->do("ALTER TABLE `cities` ADD `city_country` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_zipcode`;");
4404 print "Add state and country to cities table corresponding to new columns in borrowers\n";
4405 SetVersion($DBversion);
4408 $DBversion = "3.05.00.009";
4409 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4410 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4411 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE borrowernumber IS NULL");
4412 $dbh->do("DELETE FROM issues WHERE borrowernumber IS NULL");
4414 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4415 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE itemnumber IS NULL");
4416 $dbh->do("DELETE FROM issues WHERE itemnumber IS NULL");
4418 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4419 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)");
4420 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowernumber = issues.borrowernumber)");
4422 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4423 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)");
4424 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM items WHERE itemnumber = issues.itemnumber)");
4426 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_1`");
4427 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_2`");
4428 $dbh->do("ALTER TABLE issues ALTER COLUMN borrowernumber DROP DEFAULT");
4429 $dbh->do("ALTER TABLE issues ALTER COLUMN itemnumber DROP DEFAULT");
4430 $dbh->do("ALTER TABLE issues MODIFY COLUMN borrowernumber int(11) NOT NULL");
4431 $dbh->do("ALTER TABLE issues MODIFY COLUMN itemnumber int(11) NOT NULL");
4432 $dbh->do("ALTER TABLE issues DROP KEY `issuesitemidx`");
4433 $dbh->do("ALTER TABLE issues ADD PRIMARY KEY (`itemnumber`)");
4434 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4435 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4437 print "Upgrade to $DBversion done (issues referential integrity)\n";
4438 SetVersion ($DBversion);
4441 $DBversion = "3.05.00.010";
4442 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4443 $dbh->do("CREATE INDEX priorityfoundidx ON reserves (priority,found)");
4444 print "Create an index on reserves to speed up holds awaiting pickup report bug 5866\n";
4445 SetVersion($DBversion);
4449 $DBversion = "3.05.00.011";
4450 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4451 $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')");
4452 print "Upgrade to $DBversion done (add OPACResultsSidebar syspref (enh 6165))\n";
4453 SetVersion($DBversion);
4456 $DBversion = "3.05.00.012";
4457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4458 $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')");
4459 print "Upgrade to $DBversion done (add RecordLocalUseOnReturn syspref (enh 6403))\n";
4460 SetVersion($DBversion);
4463 $DBversion = "3.05.00.013";
4464 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4465 $dbh->do(qq|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','0',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL)|);
4466 print "Upgrade to $DBversion done (Add syspref 'OpacKohaUrl')\n";
4467 SetVersion($DBversion);
4470 $DBversion = "3.05.00.014";
4471 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4472 $dbh->do("ALTER TABLE `borrowers` MODIFY `userid` VARCHAR(75)");
4473 print "Modified userid column length into 75 in borrowers\n";
4474 SetVersion($DBversion);
4477 $DBversion = "3.05.00.015";
4478 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4479 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectEnabled',0,'Enable Novelist Select content. Requires Novelist Profile and Password',NULL,'YesNo')");
4480 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectProfile',NULL,'Novelist Select user Password',NULL,'free')");
4481 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectPassword',NULL,'Enable Novelist user Profile',NULL,'free')");
4482 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectView','tab','Where to display Novelist Select content','tab|above|below|right','Choice')");
4483 print "Upgrade to $DBversion done (Add support for EBSCO's NoveList Select (enh 6902))\n";
4484 SetVersion($DBversion);
4487 $DBversion = '3.05.00.016';
4488 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4489 $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');");
4490 print "Upgrade to $DBversion done (Add EasyAnalyticalRecords syspref)\n";
4491 SetVersion ($DBversion);
4494 $DBversion = '3.05.00.017';
4495 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4496 if (C4::Context->preference("marcflavour") eq 'MARC21' ||
4497 C4::Context->preference("marcflavour") eq 'NORMARC'){
4498 $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)");
4499 $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)");
4500 print "Upgrade to $DBversion done (Add 773 subfield 9 and 0 to default framework)\n";
4501 SetVersion ($DBversion);
4502 } elsif (C4::Context->preference("marcflavour") eq 'UNIMARC'){
4503 $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)");
4504 print "Upgrade to $DBversion done (Add 461 subfield 9 to default framework)\n";
4505 SetVersion ($DBversion);
4509 $DBversion = "3.05.00.018";
4510 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4511 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacNavBottom','','Links after OpacNav links','70|10','Textarea')");
4512 print "Upgrade to $DBversion done (add OpacNavBottom syspref (enh 6825): if appropriate, you can split OpacNav into OpacNav and OpacNavBottom)\n";
4513 SetVersion($DBversion);
4516 $DBversion = "3.05.00.019";
4517 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4518 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4519 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4520 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4521 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4522 print "Upgrade to $DBversion done (remove duplicate VOKAL Book icons, bug 6862)\n";
4523 SetVersion($DBversion);
4526 $DBversion = "3.05.00.020";
4527 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4528 $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')");
4529 print "Upgrade to $DBversion done (Add syspref AcqViewBaskets)\n";
4530 SetVersion($DBversion);
4533 $DBversion = "3.05.00.021";
4534 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4535 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN display_checkout TINYINT(1) NOT NULL DEFAULT '0';");
4536 print "Upgrade to $DBversion done (Added a display_checkout field in borrower_attribute_types table)\n";
4537 SetVersion($DBversion);
4540 $DBversion = "3.05.00.022";
4541 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4542 $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");
4543 print "Upgrade to $DBversion done (6094: Fixing ModAuthority problems, add a need_merge_authorities table)\n";
4544 SetVersion($DBversion);
4547 $DBversion = "3.05.00.023";
4548 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4549 $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');");
4550 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";
4551 SetVersion($DBversion);
4554 $DBversion = "3.06.00.000";
4555 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4556 print "Upgrade to $DBversion done Koha 3.6.0 release \n";
4557 SetVersion ($DBversion);
4560 $DBversion = "3.07.00.001";
4561 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4562 my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred =1;", { Columns => [1] } );
4563 $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
4564 $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
4565 $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4566 $dbh->do("ALTER TABLE deletedborrowers MODIFY debarred DATE DEFAULT NULL;");
4567 $dbh->do("ALTER TABLE deletedborrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4568 print "Upgrade done (Change borrowers.debarred into Date )\n";
4569 SetVersion($DBversion);
4572 $DBversion = "3.07.00.002";
4573 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4574 $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';");
4575 print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n";
4576 SetVersion($DBversion);
4579 $DBversion = "3.07.00.003";
4580 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4581 $dbh->do(" UPDATE `message_attributes` SET message_name='Item_Due' WHERE message_name='Item_DUE'");
4582 print "Updating message_name in message_attributes\n";
4583 SetVersion($DBversion);
4586 $DBversion = "3.07.00.004";
4587 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4588 $dbh->do("ALTER TABLE `suggestions` ADD `patronreason` TEXT NULL AFTER `reason`");
4589 print "Upgrade to $DBversion done (Add column to suggestions table to store patrons' reasons for submitting a suggestion. )\n";
4590 SetVersion($DBversion);
4593 $DBversion = "3.07.00.005";
4594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4595 $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')");
4596 print "Upgrade to $DBversion done (BorrowerUnwantedField syspref)\n";
4597 SetVersion ($DBversion);
4600 $DBversion = "3.07.00.006";
4601 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4602 $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');");
4603 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";
4604 SetVersion($DBversion);
4607 $DBversion = "3.07.00.007";
4608 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4609 $dbh->do("ALTER TABLE items MODIFY materials text;");
4610 print "Upgrade to $DBversion done alter items.material from varchar(10) to text \n";
4611 SetVersion($DBversion);
4614 $DBversion = '3.07.00.008';
4615 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4616 if (C4::Context->preference("marcflavour") eq 'MARC21') {
4617 if (C4::Context->preference("opaclanguages") eq "de") {
4618 $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, '');");
4620 $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, '');");
4623 print "Upgrade to $DBversion done (add MARC21 field 545 to framework)\n";
4624 SetVersion ($DBversion);
4627 $DBversion = "3.07.00.009";
4628 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4629 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `claims_count` INT(11) DEFAULT 0, ADD COLUMN `claimed_date` DATE DEFAULT NULL AFTER `claims_count`");
4630 print "Upgrade to $DBversion done (Add claims_count and claimed_date fields in aqorders table)\n";
4631 SetVersion($DBversion);
4634 $DBversion = "3.07.00.010";
4635 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4637 q|CREATE TABLE `biblioimages` (
4638 `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
4639 `biblionumber` int(11) NOT NULL,
4640 `mimetype` varchar(15) NOT NULL,
4641 `imagefile` mediumblob NOT NULL,
4642 `thumbnail` mediumblob NOT NULL,
4643 PRIMARY KEY (`imagenumber`),
4644 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4645 ) ENGINE=InnoDB DEFAULT CHARSET=utf8|
4648 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|
4651 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|
4654 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')|
4657 q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|
4659 print "Upgrade to $DBversion done (Added support for local cover images)\n";
4660 SetVersion($DBversion);
4663 $DBversion = "3.07.00.011";
4664 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4665 $dbh->do(<<ENDOFRENEWAL);
4666 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');
4668 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";
4669 SetVersion($DBversion);
4672 $DBversion = "3.07.00.012";
4673 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4674 $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')");
4675 print "Upgrade to $DBversion add 'AllowItemsOnHoldCheckout' syspref \n";
4676 SetVersion ($DBversion);
4679 $DBversion = "3.07.00.013";
4680 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4681 $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');");
4682 print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n";
4683 SetVersion ($DBversion);
4686 $DBversion = "3.07.00.014";
4687 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4688 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";
4689 SetVersion($DBversion);
4692 $DBversion = "3.07.00.015";
4693 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4694 my $sth = $dbh->prepare(q|
4695 SELECT COUNT(*) FROM marc_subfield_structure where kohafield="biblioitems.editionstatement"
4698 my $already_exists = $sth->fetchrow;
4699 if ( not $already_exists ) {
4700 my $field = C4::Context->preference("marcflavour") eq "UNIMARC" ? "205" : "250";
4702 my $sth = $dbh->prepare( q|
4703 UPDATE marc_subfield_structure SET kohafield = "biblioitems.editionstatement"
4704 WHERE tagfield = ? AND tagsubfield = ?
4706 $sth->execute( $field, $subfield );
4707 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement.)\n";
4709 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement (already exists, nothing to do).)\n";
4711 SetVersion($DBversion);
4714 $DBversion = "3.07.00.016";
4715 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4716 $dbh->do("ALTER TABLE items ADD KEY `itemcallnumber` (itemcallnumber)");
4717 print "Upgrade to $DBversion done (Added index on items.itemcallnumber)\n";
4718 SetVersion($DBversion);
4721 $DBversion = "3.07.00.017";
4722 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4723 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo')");
4724 print "Upgrade to $DBversion done (Add sysprefs to control transfer when cancel all waiting holds)\n";
4725 SetVersion ($DBversion);
4728 $DBversion = "3.07.00.018";
4729 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4730 $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;");
4731 print "Upgrade to $DBversion done ( adding offline operations table )\n";
4732 SetVersion($DBversion);
4735 $DBversion = "3.07.00.019";
4736 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4737 $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");
4738 $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");
4739 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";
4740 SetVersion($DBversion);
4743 $DBversion = "3.07.00.020";
4744 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4745 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo');");
4746 print "Upgrade to $DBversion done (Bug 3516: Add the option to show patron images in the OPAC.)\n";
4747 SetVersion($DBversion);
4750 $DBversion = "3.07.00.021";
4751 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4753 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerModule','Default','Chooses which linker module to use (see documentation).','Default|FirstMatchLastMatch','Choice');"
4756 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free');"
4759 "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');"
4762 "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');"
4765 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AutoCreateAuthorities',0,'Automatically create authorities that do not exist when cataloging records.',NULL,'YesNo');"
4768 "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');"
4770 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";
4771 SetVersion($DBversion);
4774 $DBversion = "3.07.00.022";
4775 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4776 $dbh->do("DELETE FROM reviews WHERE biblionumber NOT IN (SELECT biblionumber from biblio)");
4777 $dbh->do("UPDATE reviews SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers)");
4778 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_2 FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
4779 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber ) ON UPDATE CASCADE ON DELETE SET NULL");
4780 print "Upgrade to $DBversion done (Bug 7493 - Add constraint linking OPAC comment biblionumber to biblio, OPAC comment borrowernumber to borrowers.)\n";
4781 SetVersion($DBversion);
4784 $DBversion = "3.07.00.023";
4785 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4786 $dbh->do("ALTER TABLE `message_transports` DROP FOREIGN KEY `message_transports_ibfk_3`");
4787 $dbh->do("ALTER TABLE `letter` DROP PRIMARY KEY");
4788 $dbh->do("ALTER TABLE `letter` ADD `branchcode` varchar(10) default NULL AFTER `code`");
4789 $dbh->do("ALTER TABLE `letter` ADD PRIMARY KEY (`module`,`code`, `branchcode`)");
4790 $dbh->do("ALTER TABLE `message_transports` ADD `branchcode` varchar(10) NOT NULL default ''");
4791 $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");
4792 $dbh->do("ALTER TABLE `letter` ADD `is_html` tinyint(1) default 0 AFTER `name`");
4794 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4795 VALUES ('circulation','ISSUESLIP','Issue Slip','Issue Slip', '<h3><<branches.branchname>></h3>
4796 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4797 (<<borrowers.cardnumber>>) <br />
4801 <h4>Checked Out</h4>
4804 <<biblio.title>> <br />
4805 Barcode: <<items.barcode>><br />
4806 Date due: <<issues.date_due>><br />
4813 <<biblio.title>> <br />
4814 Barcode: <<items.barcode>><br />
4815 Date due: <<issues.date_due>><br />
4821 <h4 style=\"text-align: center; font-style:italic;\">News</h4>
4823 <div class=\"newsitem\">
4824 <h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>
4825 <p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.new>></p>
4826 <p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<opac_news.timestamp>></p>
4830 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4831 VALUES ('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '<h3><<branches.branchname>></h3>
4832 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4833 (<<borrowers.cardnumber>>) <br />
4837 <h4>Checked Out Today</h4>
4840 <<biblio.title>> <br />
4841 Barcode: <<items.barcode>><br />
4842 Date due: <<issues.date_due>><br />
4844 </checkedout>', 1)");
4845 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4846 VALUES ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '<h5>Date: <<today>></h5>
4848 <h3> Transfer to/Hold in <<branches.branchname>></h3>
4850 <h3><<borrowers.surname>>, <<borrowers.firstname>></h3>
4853 <li><<borrowers.cardnumber>></li>
4854 <li><<borrowers.phone>></li>
4855 <li> <<borrowers.address>><br />
4856 <<borrowers.address2>><br />
4857 <<borrowers.city >> <<borrowers.zipcode>>
4859 <li><<borrowers.email>></li>
4862 <h3>ITEM ON HOLD</h3>
4863 <h4><<biblio.title>></h4>
4864 <h5><<biblio.author>></h5>
4866 <li><<items.barcode>></li>
4867 <li><<items.itemcallnumber>></li>
4868 <li><<reserves.waitingdate>></li>
4871 <pre><<reserves.reservenotes>></pre>
4873 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4874 VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
4875 <h3>Transfer to <<branches.branchname>></h3>
4878 <h4><<biblio.title>></h4>
4879 <h5><<biblio.author>></h5>
4881 <li><<items.barcode>></li>
4882 <li><<items.itemcallnumber>></li>
4885 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free')");
4886 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free')");
4888 $dbh->do("UPDATE `letter` SET content = replace(content, '<<title>>', '<<biblio.title>>') WHERE code = 'HOLDPLACED'");
4890 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";
4891 SetVersion($DBversion);
4894 $DBversion = "3.07.00.024";
4895 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4896 $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')");
4897 $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')");
4898 print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
4901 $DBversion = "3.07.00.025";
4902 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4903 if (TableExists('bibliocoverimage')) {
4904 $dbh->do( q|DROP TABLE bibliocoverimage;| );
4906 q|CREATE TABLE biblioimages (
4907 imagenumber int(11) NOT NULL AUTO_INCREMENT,
4908 biblionumber int(11) NOT NULL,
4909 mimetype varchar(15) NOT NULL,
4910 imagefile mediumblob NOT NULL,
4911 thumbnail mediumblob NOT NULL,
4912 PRIMARY KEY (imagenumber),
4913 CONSTRAINT bibliocoverimage_fk1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
4914 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
4917 print "Upgrade to $DBversion done (Correct table name for local cover images if needed. )\n";
4918 SetVersion($DBversion);
4921 $DBversion = "3.07.00.026";
4922 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4923 $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');");
4924 print "Upgrade to $DBversion done (Add syspref CalendarFirstDayOfWeek used to select the first day of week to use in the calendar. )\n";
4925 SetVersion($DBversion);
4928 $DBversion = "3.07.00.027";
4929 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4930 $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');});
4931 print "Upgrade to $DBversion done (Added system preference RoutingListNote for adding a general note to all routing lists.)\n";
4932 SetVersion($DBversion);
4935 $DBversion = "3.07.00.028";
4936 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4938 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');
4940 print "Upgrade to $DBversion done (Bug 6296 New System preference AllowPKIAuth)\n";
4943 $DBversion = "3.07.00.029";
4944 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4946 DROP TABLE IF EXISTS `oai_sets_descriptions`;
4947 DROP TABLE IF EXISTS `oai_sets_mappings`;
4948 DROP TABLE IF EXISTS `oai_sets_biblios`;
4949 DROP TABLE IF EXISTS `oai_sets`;
4951 CREATE TABLE `oai_sets` (
4952 `id` int(11) NOT NULL auto_increment,
4953 `spec` varchar(80) NOT NULL UNIQUE,
4954 `name` varchar(80) NOT NULL,
4956 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4958 CREATE TABLE `oai_sets_descriptions` (
4959 `set_id` int(11) NOT NULL,
4960 `description` varchar(255) NOT NULL,
4961 CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4962 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4964 CREATE TABLE `oai_sets_mappings` (
4965 `set_id` int(11) NOT NULL,
4966 `marcfield` char(3) NOT NULL,
4967 `marcsubfield` char(1) NOT NULL,
4968 `marcvalue` varchar(80) NOT NULL,
4969 CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4970 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4972 CREATE TABLE `oai_sets_biblios` (
4973 `biblionumber` int(11) NOT NULL,
4974 `set_id` int(11) NOT NULL,
4975 PRIMARY KEY (`biblionumber`, `set_id`),
4976 CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4977 CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4978 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4980 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');
4983 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4984 SetVersion($DBversion);
4987 $DBversion = "3.07.00.030";
4988 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4989 $dbh->do("ALTER TABLE default_circ_rules ADD
4990 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4991 $dbh->do("ALTER TABLE branch_item_rules ADD
4992 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4993 $dbh->do("ALTER TABLE default_branch_circ_rules ADD
4994 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4995 $dbh->do("ALTER TABLE default_branch_item_rules ADD
4996 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4997 # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
4998 my $homeorholdingbranchreturn = C4::Context->prefernce('HomeOrHoldingBranchReturn') || 'homebranch';
4999 $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
5000 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
5001 SetVersion($DBversion);
5004 $DBversion = "3.07.00.031";
5005 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5006 $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')");
5007 print "Upgrade to $DBversion done (Add syspref to tell Koha if ICU indexing is in use for Zebra or not.)\n";
5008 SetVersion ($DBversion);
5011 $DBversion = "3.07.00.032";
5012 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5013 $dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers)
5014 $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
5015 $dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents)
5016 $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");
5017 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1");
5018 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2");
5019 $dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3");
5020 $dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3");
5022 $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");
5023 $dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner");
5025 $dbh->do("CREATE TABLE virtualshelfshares
5026 (id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL,
5027 borrowernumber int, invitekey varchar(10), sharedate datetime,
5028 CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5029 CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5031 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');");
5032 $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');");
5034 print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n";
5035 SetVersion($DBversion);
5038 $DBversion = "3.07.00.033";
5039 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5040 $dbh->do("ALTER TABLE branches ADD opac_info text;");
5041 print "Upgrade to $DBversion done add opac_info to branches \n";
5042 SetVersion($DBversion);
5045 $DBversion = "3.07.00.034";
5046 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5047 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
5048 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255) NOT NULL DEFAULT '' AFTER `category_code`");
5049 $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
5050 print "Upgrade to $DBversion done (New fields category_code and class in borrower_attribute_types table)\n";
5051 SetVersion($DBversion);
5054 $DBversion = "3.07.00.035";
5055 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5056 $dbh->do("ALTER TABLE issues CHANGE date_due date_due datetime");
5057 $dbh->do("UPDATE issues SET date_due = CONCAT(SUBSTR(date_due,1,11),'23:59:00')");
5058 $dbh->do("ALTER TABLE issues CHANGE returndate returndate datetime");
5059 $dbh->do("ALTER TABLE issues CHANGE lastreneweddate lastreneweddate datetime");
5060 $dbh->do("ALTER TABLE issues CHANGE issuedate issuedate datetime");
5061 $dbh->do("ALTER TABLE old_issues CHANGE date_due date_due datetime");
5062 $dbh->do("ALTER TABLE old_issues CHANGE returndate returndate datetime");
5063 $dbh->do("ALTER TABLE old_issues CHANGE lastreneweddate lastreneweddate datetime");
5064 $dbh->do("ALTER TABLE old_issues CHANGE issuedate issuedate datetime");
5065 $dbh->do("UPDATE accountlines SET description = CONCAT(description,' 23:59') WHERE accounttype='F' OR accounttype='FU'"); #BUG-8253
5066 print "Upgrade to $DBversion done (Setting up issues and accountlines tables for hourly loans)\n";
5067 SetVersion($DBversion);
5070 $DBversion = "3.07.00.036";
5071 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5073 ALTER TABLE z3950servers ADD timeout INT( 11 ) NOT NULL DEFAULT '0' AFTER syntax;
5075 print "Upgrade to $DBversion done (New timeout field in z3950servers)\n";
5078 $DBversion = "3.07.00.037";
5079 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5081 ALTER TABLE `marc_subfield_structure` ADD `maxlength` INT( 4 ) NOT NULL DEFAULT '9999';
5084 UPDATE `marc_subfield_structure` SET maxlength=24 WHERE tagfield='000';
5087 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='MARC21','40','9999') WHERE tagfield='008';
5090 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='NORMARC','40','9999') WHERE tagfield='008';
5093 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='UNIMARC','36','9999') WHERE tagfield='100';
5095 print "Upgrade to $DBversion done (Add new field maxlength to marc_subfield_structure)\n";
5096 SetVersion($DBversion);
5099 $DBversion = "3.07.00.038";
5100 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5102 INSERT INTO systempreferences(variable,value,explanation,options,type)
5103 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')
5105 print "Upgrade to $DBversion done (Added system preference 'UniqueItemFields')\n";
5106 SetVersion($DBversion);
5109 $DBversion = "3.07.00.039";
5110 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5111 $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')} );
5112 $dbh->do( qq{CREATE TABLE IF NOT EXISTS social_data
5115 num_critics_pro INT,
5118 score_avg DECIMAL(5,2),
5121 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5123 $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')} );
5124 print "Upgrade to $DBversion done (added syspref and table for babeltheque (Babeltheque_url_js, babeltheque))\n";
5125 SetVersion($DBversion);
5128 $DBversion = "3.07.00.040";
5129 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5130 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('SocialNetworks','0','Enable/Disable social networks links in opac detail','','YesNo')} );
5131 print "Upgrade to $DBversion done (added syspref SocialNetworks, to display facebook/ggl+ and other buttons)\n";
5132 SetVersion($DBversion);
5137 $DBversion = "3.07.00.041";
5138 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5139 $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')");
5140 print "Upgrade to $DBversion done (Add system preference SubscriptionDuplicateDroppedInput)\n";
5141 SetVersion($DBversion);
5144 $DBversion = "3.07.00.042";
5145 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5146 $dbh->do("ALTER TABLE reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5147 $dbh->do("ALTER TABLE old_reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5149 $dbh->do("ALTER TABLE reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5150 $dbh->do("ALTER TABLE old_reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5152 $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')");
5154 print "Upgrade to $DBversion done (Add suspend fields to reserves table, add syspref AutoResumeSuspendedHolds)\n";
5155 SetVersion ($DBversion);
5158 $DBversion = "3.07.00.043";
5159 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5160 my $countXSLTDetailsDisplay = 0;
5161 my $valueXSLTDetailsDisplay = "";
5162 my $valueXSLTResultsDisplay = "";
5163 my $valueOPACXSLTDetailsDisplay = "";
5164 my $valueOPACXSLTResultsDisplay = "";
5165 #the line below test if database comes from a BibLibre's branch
5166 $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
5167 if ($countXSLTDetailsDisplay > 0)
5169 #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
5170 $dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
5171 $dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
5175 $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
5176 $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
5177 $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
5178 $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
5179 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
5180 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
5181 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
5182 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
5184 print "Upgrade to $DBversion done (XSLT systempreference takes a path to file rather than YesNo)\n";
5185 SetVersion($DBversion);
5188 $DBversion = "3.07.00.044";
5189 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5190 $dbh->do("ALTER TABLE aqbooksellers ADD deliverytime INT DEFAULT NULL");
5191 print "Upgrade to $DBversion done (Add deliverytime field in aqbooksellers table)";
5192 SetVersion($DBversion);
5195 $DBversion = "3.07.00.045";
5196 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5197 $dbh->do("ALTER TABLE import_batches MODIFY COLUMN batch_type ENUM('batch','z3950','webservice') NOT NULL default 'batch'");
5198 print "Upgrade to $DBversion done (Add 'webservice' to batch_type enum)\n";
5199 SetVersion ($DBversion);
5202 $DBversion = "3.07.00.046";
5203 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5204 $dbh->do("ALTER TABLE issuingrules ADD COLUMN lengthunit varchar(10) DEFAULT 'days' AFTER issuelength");
5205 print "Upgrade to $DBversion done (Setting up issues tables for hourly loans (lengthunit fix))\n";
5206 SetVersion($DBversion);
5209 $DBversion = "3.07.00.047";
5210 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5211 $dbh->do("CREATE INDEX items_location ON items(location)");
5212 $dbh->do("CREATE INDEX items_ccode ON items(ccode)");
5213 print "Upgrade to $DBversion done (items_location and items_ccode indexes added for ShelfBrowser)\n";
5214 SetVersion($DBversion);
5217 $DBversion = "3.07.00.048";
5218 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5220 q | CREATE TABLE ratings (
5221 borrowernumber int(11) NOT NULL,
5222 biblionumber int(11) NOT NULL,
5223 rating_value tinyint(1) NOT NULL,
5224 timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
5225 PRIMARY KEY (borrowernumber,biblionumber),
5226 CONSTRAINT ratings_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
5227 CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
5228 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
5232 q /INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','disable',NULL,'disable|all|details','Choice') /
5236 "Upgrade to $DBversion done (Add 'ratings' table and 'OpacStarRatings' syspref)\n";
5237 SetVersion($DBversion);
5240 $DBversion = "3.07.00.049";
5241 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5242 $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')");
5243 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5244 SetVersion($DBversion);
5247 $DBversion = "3.08.00.000";
5248 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5249 print "Upgrade to $DBversion done\n";
5250 SetVersion($DBversion);
5253 $DBversion = "3.09.00.001";
5254 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5255 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 1 ) NULL DEFAULT NULL");
5256 print "Upgrade to $DBversion done. (Bug 8002: Update patron attribute types table to allow NULL category_code)\n";
5257 SetVersion($DBversion);
5260 $DBversion = "3.09.00.002";
5261 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5262 $dbh->do("ALTER TABLE saved_sql
5264 cache_expiry INT NOT NULL DEFAULT 300,
5265 public BOOLEAN NOT NULL DEFAULT FALSE
5268 print "Upgrade to $DBversion done (Added cache_expiry and public fields in
5269 saved_reports table.)\n";
5270 SetVersion($DBversion);
5273 $DBversion = "3.09.00.003";
5274 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5275 $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');");
5276 print "Upgrade to $DBversion done (Added SvcMaxReportRows syspref)\n";
5277 SetVersion($DBversion);
5280 $DBversion = "3.09.00.004";
5281 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5282 $dbh->do("INSERT IGNORE INTO permissions (module_bit, code, description) VALUES('13', 'edit_patrons', 'Perform batch modifivation of patrons')");
5283 print "Upgrade to $DBversion done (Adds permissions flag for access to the patron modifications tool)\n";
5284 SetVersion($DBversion);
5287 $DBversion = "3.09.00.005";
5288 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5289 unless (TableExists('quotes')) {
5291 CREATE TABLE `quotes` (
5292 `id` int(11) NOT NULL AUTO_INCREMENT,
5293 `source` text DEFAULT NULL,
5294 `text` mediumtext NOT NULL,
5295 `timestamp` datetime NOT NULL,
5297 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5301 INSERT IGNORE INTO permissions VALUES (13, "edit_quotes","Edit quotes for quote-of-the-day feature");
5304 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');
5306 print "Upgrade to $DBversion done (Adding Quote of the Day Option.)\n";
5307 SetVersion($DBversion);
5310 $DBversion = "3.09.00.006";
5311 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5312 $dbh->do("UPDATE systempreferences SET
5313 variable = 'OPACShowHoldQueueDetails',
5314 value = CASE value WHEN '1' THEN 'priority' ELSE 'none' END,
5315 options = 'none|priority|holds|holds_priority',
5316 explanation = 'Show holds details in OPAC',
5318 WHERE variable = 'OPACDisplayRequestPriority'");
5319 print "Upgrade to $DBversion done (Changed system preference OPACDisplayRequestPriority -> OPACShowHoldQueueDetails)\n";
5320 SetVersion($DBversion);
5323 $DBversion = "3.09.00.007";
5324 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5325 unless(C4::Context->preference('ReservesControlBranch')){
5326 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights.','Choice')");
5328 print "Upgrade to $DBversion done (Insert ReservesControlBranch systempreference into systempreferences table )\n";
5329 SetVersion($DBversion);
5332 $DBversion = "3.09.00.008";
5333 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5334 $dbh->do("ALTER TABLE sessions ADD PRIMARY KEY (id);");
5335 $dbh->do("ALTER TABLE sessions DROP INDEX `id`;");
5336 print "Upgrade to $DBversion done (redefine the field id as PRIMARY KEY of sessions)\n";
5337 SetVersion($DBversion);
5340 $DBversion = "3.09.00.009";
5341 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5342 $dbh->do("ALTER TABLE branches ADD PRIMARY KEY (branchcode);");
5343 $dbh->do("ALTER TABLE branches DROP INDEX branchcode;");
5344 print "Upgrade to $DBversion done (redefine the field branchcode as PRIMARY KEY of branches)\n";
5345 SetVersion ($DBversion);
5348 $DBversion = "3.09.00.010";
5349 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5350 $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')");
5351 print "Upgrade to $DBversion done (Add system preference issuelostitem ))\n";
5352 SetVersion($DBversion);
5355 $DBversion = "3.09.00.011";
5356 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5357 $dbh->do("ALTER TABLE `biblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5358 $dbh->do("CREATE INDEX `ean` ON biblioitems (`ean`) ");
5359 $dbh->do("ALTER TABLE `deletedbiblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5360 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
5361 $dbh->do("UPDATE marc_subfield_structure SET kohafield='biblioitems.ean' WHERE tagfield='073' and tagsubfield='a'");
5363 print "Upgrade to $DBversion done (Adding ean in biblioitems and deletedbiblioitems)\n";
5364 print "If you have records with ean, please run misc/batchRebuildBiblioTables.pl to populate bibliotems.ean\n" if (C4::Context->preference("marcflavour") eq 'UNIMARC');
5365 SetVersion($DBversion);
5368 $DBversion = "3.09.00.012";
5369 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5370 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo')");
5371 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo')");
5372 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5373 SetVersion($DBversion);
5376 $DBversion ="3.09.00.013";
5377 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5378 $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');");
5379 print "Upgrade to $DBversion done (Add system preference DefaultLanguageField008))\n";
5380 SetVersion($DBversion);
5383 $DBversion ="3.09.00.014";
5384 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5385 # add phone message transport type
5386 $dbh->do("INSERT INTO message_transport_types (message_transport_type) VALUES ('phone')");
5388 # adds HOLD_PHONE and PREDUE_PHONE letters (as placeholders)
5389 $dbh->do("INSERT INTO letter (module, code, name, title, content) VALUES
5390 ('reserves', 'HOLD_PHONE', 'Item Available for Pick-up (phone notice)', 'Item Available for Pick-up (phone notice)', 'Your item is available for pickup'),
5391 ('circulation', 'PREDUE_PHONE', 'Advance Notice of Item Due (phone notice)', 'Advance Notice of Item Due (phone notice)', 'Your item is due soon'),
5392 ('circulation', 'OVERDUE_PHONE', 'Overdue Notice (phone notice)', 'Overdue Notice (phone notice)', 'Your item is overdue')
5395 # add phone notifications to patron message preferences options
5396 $dbh->do("INSERT INTO message_transports
5397 (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES
5398 (4, 'phone', 0, 'reserves', 'HOLD_PHONE'),
5399 (2, 'phone', 0, 'circulation', 'PREDUE_PHONE')
5402 # add TalkingTechItivaPhoneNotification syspref
5403 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('TalkingTechItivaPhoneNotification',0,'If ON, enables Talking Tech I-tiva phone notifications',NULL,'YesNo');");
5405 print "Upgrade done (Support for Talking Tech i-tiva phone notification system)\n";
5406 SetVersion($DBversion);
5409 $DBversion = "3.09.00.015";
5410 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5412 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')
5414 print "Upgrade to $DBversion done (Add System preference StatisticsFields)\n";
5415 SetVersion($DBversion);
5418 $DBversion = "3.09.00.016";
5419 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5420 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo')");
5421 print "Upgrade to $DBversion done (Add syspref OPACShowBarcode)\n";
5422 SetVersion ($DBversion);
5425 $DBversion = "3.09.00.017";
5426 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5427 $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');");
5428 print "Upgrade to $DBversion done (Add customizable OpacNavRight region to the OPAC main page)\n";
5429 SetVersion ($DBversion);
5432 $DBversion = "3.09.00.018";
5433 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5434 $dbh->do("DROP TABLE IF EXISTS aqbudgetborrowers");
5436 CREATE TABLE aqbudgetborrowers (
5437 budget_id int(11) NOT NULL,
5438 borrowernumber int(11) NOT NULL,
5439 PRIMARY KEY (budget_id, borrowernumber),
5440 CONSTRAINT aqbudgetborrowers_ibfk_1 FOREIGN KEY (budget_id)
5441 REFERENCES aqbudgets (budget_id)
5442 ON DELETE CASCADE ON UPDATE CASCADE,
5443 CONSTRAINT aqbudgetborrowers_ibfk_2 FOREIGN KEY (borrowernumber)
5444 REFERENCES borrowers (borrowernumber)
5445 ON DELETE CASCADE ON UPDATE CASCADE
5446 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5449 INSERT INTO permissions (module_bit, code, description)
5450 VALUES (11, 'budget_manage_all', 'Manage all budgets')
5452 print "Upgrade to $DBversion done (Add aqbudgetborrowers table)\n";
5453 SetVersion($DBversion);
5456 $DBversion = "3.09.00.019";
5457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5458 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo')");
5459 print "Upgrade to $DBversion done (Add OPACShowUnusedAuthorities system preference)\n";
5460 SetVersion ($DBversion);
5463 $DBversion = "3.09.00.020";
5464 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5465 $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')");
5467 CREATE TABLE IF NOT EXISTS borrower_files (
5468 file_id int(11) NOT NULL AUTO_INCREMENT,
5469 borrowernumber int(11) NOT NULL,
5470 file_name varchar(255) NOT NULL,
5471 file_type varchar(255) NOT NULL,
5472 file_description varchar(255) DEFAULT NULL,
5473 file_content longblob NOT NULL,
5474 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5475 PRIMARY KEY (file_id),
5476 KEY borrowernumber (borrowernumber)
5477 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5479 $dbh->do("ALTER TABLE borrower_files ADD CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE");
5481 print "Upgrade to $DBversion done (Added borrow_files table, EnableBorrowerFiles syspref)\n";
5482 SetVersion($DBversion);
5485 $DBversion = "3.09.00.021";
5486 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5487 $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');");
5488 print "Upgrade to $DBversion done (Add syspref UpdateTotalIssuesOnCirc)\n";
5489 SetVersion($DBversion);
5492 $DBversion = "3.09.00.022";
5493 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5494 $dbh->do("ALTER TABLE search_history MODIFY COLUMN query_cgi text NOT NULL");
5495 print "Upgrade to $DBversion done (Change search_history.query_cgi type to text. bug 5981)\n";
5496 SetVersion($DBversion);
5499 $DBversion = "3.09.00.023";
5500 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5501 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
5502 print "Upgrade to $DBversion done (Add system preference SearchEngine )\n";
5503 SetVersion($DBversion);
5506 $DBversion ="3.09.00.024";
5507 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5508 $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')");
5509 print "Upgrade to $DBversion done (Add system preference IntranetSlipPrinterJS))\n";
5510 SetVersion($DBversion);
5513 $DBversion = "3.09.00.025";
5514 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5515 $dbh->do('START TRANSACTION');
5516 $dbh->do('CREATE TABLE tmp_reserves AS SELECT * FROM old_reserves LIMIT 0');
5517 $dbh->do('ALTER TABLE tmp_reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5519 INSERT INTO tmp_reserves (
5520 borrowernumber, reservedate, biblionumber,
5521 constrainttype, branchcode, notificationdate,
5522 reminderdate, cancellationdate, reservenotes,
5523 priority, found, timestamp, itemnumber,
5524 waitingdate, expirationdate, lowestPriority,
5525 suspend, suspend_until
5527 borrowernumber, reservedate, biblionumber,
5528 constrainttype, branchcode, notificationdate,
5529 reminderdate, cancellationdate, reservenotes,
5530 priority, found, timestamp, itemnumber,
5531 waitingdate, expirationdate, lowestPriority,
5532 suspend, suspend_until
5533 FROM old_reserves ORDER BY reservedate
5535 $dbh->do('SET @ai = ( SELECT MAX( reserve_id ) FROM tmp_reserves )');
5536 $dbh->do('TRUNCATE old_reserves');
5537 $dbh->do('ALTER TABLE old_reserves ADD reserve_id INT( 11 ) NOT NULL PRIMARY KEY FIRST');
5538 $dbh->do('INSERT INTO old_reserves SELECT * FROM tmp_reserves WHERE reserve_id <= @ai');
5540 INSERT INTO tmp_reserves (
5541 borrowernumber, reservedate, biblionumber,
5542 constrainttype, branchcode, notificationdate,
5543 reminderdate, cancellationdate, reservenotes,
5544 priority, found, timestamp, itemnumber,
5545 waitingdate, expirationdate, lowestPriority,
5546 suspend, suspend_until
5548 borrowernumber, reservedate, biblionumber,
5549 constrainttype, branchcode, notificationdate,
5550 reminderdate, cancellationdate, reservenotes,
5551 priority, found, timestamp, itemnumber,
5552 waitingdate, expirationdate, lowestPriority,
5553 suspend, suspend_until
5554 FROM reserves ORDER BY reservedate
5556 $dbh->do('TRUNCATE reserves');
5557 $dbh->do('ALTER TABLE reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5558 $dbh->do('INSERT INTO reserves SELECT * FROM tmp_reserves WHERE reserve_id > COALESCE(@ai, 0)');
5559 $dbh->do('DROP TABLE tmp_reserves');
5562 my $sth = $dbh->prepare("
5563 SELECT COUNT( * ) AS count
5564 FROM information_schema.COLUMNS
5565 WHERE COLUMN_NAME = 'reserve_id'
5567 TABLE_NAME LIKE 'reserves'
5569 TABLE_NAME LIKE 'old_reserves'
5573 my $row = $sth->fetchrow_hashref();
5574 die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} );
5576 print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n";
5577 SetVersion($DBversion);
5580 $DBversion = "3.09.00.026";
5581 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5582 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
5583 ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'),
5584 ( 3, 'manage_circ_rules', 'manage circulation rules')");
5585 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5586 SELECT borrowernumber, 3, 'parameters_remaining_permissions'
5587 FROM borrowers WHERE flags & (1 << 3)");
5588 # Give new subpermissions to all users that have 'parameters' permission flag (bit 3) set
5589 # see userflags table
5590 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5591 SELECT borrowernumber, 3, 'manage_circ_rules'
5592 FROM borrowers WHERE flags & (1 << 3)");
5593 print "Upgrade to $DBversion done (Added parameters subpermissions)\n";
5594 SetVersion($DBversion);
5597 $DBversion = '3.09.00.027';
5598 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5599 $dbh->do("ALTER TABLE issuingrules ADD overduefinescap decimal(28,6) DEFAULT NULL");
5600 my $maxfine = C4::Context->preference('MaxFine');
5601 if ($maxfine && $maxfine < 900) { # an arbitrary value that tells us it's not "some huge value"
5602 $dbh->do("UPDATE issuingrules SET overduefinescap=?",undef,$maxfine);
5603 $dbh->do("UPDATE systempreferences SET value = NULL WHERE variable = 'MaxFine'");
5605 $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'");
5606 print "Upgrade to $DBversion done (Bug 7420 add overduefinescap to circulation matrix)\n";
5607 SetVersion ($DBversion);
5610 $DBversion = "3.09.00.028";
5611 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5612 unless ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
5613 my %referencetypes = ( '00' => 'PERSO_NAME',
5614 '10' => 'CORPO_NAME',
5615 '11' => 'MEETI_NAME',
5616 '30' => 'UNIF_TITLE',
5617 '48' => 'CHRON_TERM',
5618 '50' => 'TOPIC_TERM',
5619 '51' => 'GEOGR_NAME',
5620 '55' => 'GENRE/FORM'
5622 my $query = q{SELECT DISTINCT authtypecode, tagfield
5623 FROM auth_subfield_structure
5624 WHERE (tagfield BETWEEN '400' AND '455' OR
5625 tagfield BETWEEN '500' and '555') AND tagsubfield='a' AND
5626 frameworkcode = '' AND ROW(authtypecode, tagfield) NOT IN
5627 (SELECT authtypecode, tagfield FROM auth_subfield_structure
5628 WHERE tagsubfield ='9' )};
5629 $sth = $dbh->prepare($query);
5631 my $sth2 = $dbh->prepare(q{INSERT INTO auth_subfield_structure
5632 (authtypecode, tagfield, tagsubfield, liblibrarian, libopac,
5633 repeatable, mandatory, tab, authorised_value, value_builder,
5634 seealso, isurl, hidden, linkid, kohafield, frameworkcode)
5635 VALUES (?, ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, ?, NULL, NULL,
5636 NULL, 0, 1, '', '', '')});
5637 my $sth3 = $dbh->prepare(q{UPDATE auth_subfield_structure SET
5638 frameworkcode = ? WHERE authtypecode = ? AND
5639 tagfield = ? AND tagsubfield = 'a'});
5640 while (my $row = $sth->fetchrow_arrayref()) {
5641 my ($authtypecode, $field) = @$row;
5642 $sth2->execute($authtypecode, $field, substr($field, 0, 1));
5643 my $authtypemarker = substr $field, 1, 2;
5644 if ($authtypemarker && $referencetypes{$authtypemarker}) {
5645 $sth3->execute($referencetypes{$authtypemarker}, $authtypecode, $field);
5650 print "Upgrade to $DBversion done (Add thesaurus links for MARC21/NORMARC)\n";
5651 SetVersion($DBversion);
5654 $DBversion = "3.09.00.029"; # FIXME
5655 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5656 $dbh->do("UPDATE systempreferences SET options=concat(options,'|EAN13') WHERE variable='itemBarcodeInputFilter' AND options NOT LIKE '%EAN13%'");
5657 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice EAN13)\n";
5659 $dbh->do("UPDATE systempreferences SET options = concat(options,'|EAN13'), explanation = concat(explanation,'; EAN13 - incremental') WHERE variable = 'autoBarcode' AND options NOT LIKE '%EAN13%'");
5660 print "Upgrade to $DBversion done ( Added EAN13 barcode autogeneration sequence )\n";
5661 SetVersion($DBversion);
5664 $DBversion ="3.09.00.030";
5665 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5666 my $query = "SELECT value FROM systempreferences WHERE variable='opacstylesheet'";
5667 my $remote= $dbh->selectrow_arrayref($query);
5668 $dbh->do("DELETE from systempreferences WHERE variable='opacstylesheet'");
5669 if($remote && $remote->[0]) {
5670 $query="UPDATE systempreferences SET value=? WHERE variable='opaclayoutstylesheet'";
5671 $dbh->do($query,undef,$remote->[0]);
5672 print "NOTE: The URL of your remote opac css file has been moved to preference opaclayoutstylesheet.\n";
5674 print "Upgrade to $DBversion done (BZ 8263: Make OPAC stylesheet preferences more consistent)\n";
5675 SetVersion($DBversion);
5678 $DBversion = "3.09.00.031";
5679 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5680 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonReviews'");
5681 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonSimilarItems'");
5682 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSAccessKeyID'");
5683 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSPrivateKey'");
5684 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonReviews'");
5685 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonSimilarItems'");
5686 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonEnabled'");
5687 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonEnabled'");
5688 print "Upgrade to $DBversion done ('Remove preferences controlling broken Amazon features (Bug 8679')\n";
5689 SetVersion ($DBversion);
5692 $DBversion = "3.09.00.032";
5693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5694 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'defaultSortField' AND value = 'callnumber'");
5695 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'OPACdefaultSortField' AND value = 'callnumber'");
5696 print "Upgrade to $DBversion done (Bug 8657 - Default sort by call number does not work. Correcting system preference value.)\n";
5697 SetVersion ($DBversion);
5701 $DBversion = '3.09.00.033';
5702 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5703 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
5704 print "Upgrade to $DBversion done (Add OpacSuppressionByIPRange syspref)\n";
5705 SetVersion ($DBversion);
5708 $DBversion ="3.09.00.034";
5709 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5710 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'PERSO_NAME' WHERE frameworkcode = 'PERSO_CODE'");
5711 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'CORPO_NAME' WHERE frameworkcode = 'ORGO_CODE'");
5712 print "Upgrade to $DBversion done (Bug 8207: correct typo in authority types)\n";
5713 SetVersion ($DBversion);
5716 $DBversion = "3.09.00.035";
5717 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5719 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');
5722 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
5724 print "Upgrade to $DBversion done (Adding PrefillItem and SubfieldsToUseWhenPrefill sysprefs)\n";
5725 SetVersion ($DBversion);
5728 $DBversion = "3.09.00.036";
5729 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5730 # biblioitems changes
5731 $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5732 $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5733 # preferences changes
5734 $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')");
5735 $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')");
5737 print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5738 SetVersion ($DBversion);
5741 $DBversion = "3.09.00.037";
5742 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5743 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('UseTransportCostMatrix',0,'Use Transport Cost Matrix when filling holds','','YesNo')");
5745 $dbh->do("CREATE TABLE `transport_cost` (
5746 `frombranch` varchar(10) NOT NULL,
5747 `tobranch` varchar(10) NOT NULL,
5748 `cost` decimal(6,2) NOT NULL,
5749 `disable_transfer` tinyint(1) NOT NULL DEFAULT 0,
5750 CHECK ( `frombranch` <> `tobranch` ), -- a dud check, mysql does not support that
5751 PRIMARY KEY (`frombranch`, `tobranch`),
5752 CONSTRAINT `transport_cost_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5753 CONSTRAINT `transport_cost_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5754 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5756 print "Upgrade to $DBversion done (creating `transport_cost` table; adding UseTransportCostMatrix systempref, in circulation)\n";
5757 SetVersion($DBversion);
5760 $DBversion ="3.09.00.038";
5761 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5762 $dbh->do("ALTER TABLE borrower_attributes CHANGE attribute attribute VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
5763 print "Upgrade to $DBversion done (Increase the maximum size of a borrower attribute value)\n";
5764 SetVersion($DBversion);
5767 $DBversion ="3.09.00.039";
5768 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5769 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('DidYouMeanFromAuthorities','0','Suggest searches based on authority file.','YesNo');");
5770 print "Upgrade to $DBversion done (Add system preference DidYouMeanFromAuthorities)\n";
5771 SetVersion($DBversion);
5774 $DBversion = "3.09.00.040";
5775 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5776 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');");
5777 print "Upgrade to $DBversion done (Add IncludeSeeFromInSearches system preference)\n";
5778 SetVersion ($DBversion);
5781 $DBversion = "3.09.00.041";
5782 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5784 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportRemoveFields','','List of fields for non export in circulation.pl (separated by a space)','','');
5786 print "Upgrade to $DBversion done (Add system preference ExportRemoveFields)\n";
5787 SetVersion($DBversion);
5790 $DBversion = "3.09.00.042";
5791 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5793 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportWithCsvProfile','','Set a profile name for CSV export','','');
5795 print "Upgrade to $DBversion done (Adds New System preference ExportWithCsvProfile)\n";
5796 SetVersion($DBversion)
5799 $DBversion = "3.09.00.043";
5800 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5802 ALTER TABLE aqorders
5803 ADD parent_ordernumber int(11) DEFAULT NULL
5807 SET parent_ordernumber = ordernumber;
5809 print "Upgrade to $DBversion done (Adding parent_ordernumber in aqorders)\n";
5810 SetVersion($DBversion);
5813 $DBversion = '3.09.00.044';
5814 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5815 $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
5816 $dbh->do("UPDATE statistics SET statistics.ccode = ( SELECT items.ccode FROM items WHERE statistics.itemnumber = items.itemnumber )");
5817 $dbh->do("UPDATE statistics SET statistics.ccode = (
5818 SELECT deleteditems.ccode FROM deleteditems
5819 WHERE statistics.itemnumber = deleteditems.itemnumber
5820 ) WHERE statistics.ccode IS NULL");
5821 print "Upgrade done ( Added Collection Code to Statistics table. )\n";
5822 SetVersion ($DBversion);
5825 $DBversion = "3.09.00.045";
5826 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5827 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 10 ) NULL DEFAULT NULL");
5828 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.";
5829 SetVersion($DBversion);
5832 $DBversion = "3.09.00.046";
5833 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5834 $dbh->do("ALTER TABLE `accountlines` ADD `accountlines_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
5835 print "Upgrade to $DBversion done (adding accountlines_id field in accountlines table)\n";
5836 SetVersion($DBversion);
5839 $DBversion = "3.09.00.047";
5840 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5841 # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5842 my $prefvalue = 'anywhere';
5843 if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
5844 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
5846 print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
5847 SetVersion($DBversion);
5850 $DBversion = "3.09.00.048";
5851 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5852 $dbh->do("ALTER TABLE authorised_values MODIFY lib varchar(200)");
5853 $dbh->do("ALTER TABLE authorised_values MODIFY lib_opac varchar(200)");
5855 print "Upgrade to $DBversion done (Raise the length of Authorised Values descriptions)\n";
5856 SetVersion($DBversion);
5859 $DBversion ="3.09.00.049";
5860 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5861 $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');");
5862 $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');");
5863 $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');");
5864 $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');");
5865 print "Upgrade to $DBversion done (Add OPACMobileUserCSS, OpacMainUserBlockMobile, OpacShowLibrariesPulldownMobile and OpacShowFiltersPulldownMobile sysprefs)\n";
5866 SetVersion($DBversion);
5869 $DBversion = "3.09.00.050";
5870 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5871 $dbh->do("ALTER TABLE authorised_values MODIFY category varchar(16) NOT NULL DEFAULT '';");
5872 $dbh->do("INSERT INTO authorised_values (category, authorised_value, lib) VALUES
5873 ('REPORT_GROUP', 'CIRC', 'Circulation'),
5874 ('REPORT_GROUP', 'CAT', 'Catalog'),
5875 ('REPORT_GROUP', 'PAT', 'Patrons'),
5876 ('REPORT_GROUP', 'ACQ', 'Acquisitions'),
5877 ('REPORT_GROUP', 'ACC', 'Accounts');");
5879 $dbh->do("ALTER TABLE reports_dictionary ADD report_area varchar(6) DEFAULT NULL;");
5880 $dbh->do("UPDATE reports_dictionary SET report_area = CASE area
5887 $dbh->do("ALTER TABLE reports_dictionary DROP area;");
5888 $dbh->do("ALTER TABLE reports_dictionary ADD KEY dictionary_area_idx (report_area);");
5890 $dbh->do("ALTER TABLE saved_sql ADD report_area varchar(6) DEFAULT NULL;");
5891 $dbh->do("ALTER TABLE saved_sql ADD report_group varchar(80) DEFAULT NULL;");
5892 $dbh->do("ALTER TABLE saved_sql ADD report_subgroup varchar(80) DEFAULT NULL;");
5893 $dbh->do("ALTER TABLE saved_sql ADD KEY sql_area_group_idx (report_group, report_subgroup);");
5895 print "Upgrade to $DBversion done saved_sql new fields report_group and report_area; authorised_values.category 16 char \n";
5896 SetVersion($DBversion);
5899 $DBversion = "3.09.00.051";
5900 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5902 CREATE TABLE aqinvoices (
5903 invoiceid int(11) NOT NULL AUTO_INCREMENT,
5904 invoicenumber mediumtext NOT NULL,
5905 booksellerid int(11) NOT NULL,
5906 shipmentdate date default NULL,
5907 billingdate date default NULL,
5908 closedate date default NULL,
5909 shipmentcost decimal(28,6) default NULL,
5910 shipmentcost_budgetid int(11) default NULL,
5911 PRIMARY KEY (invoiceid),
5912 CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5913 CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5914 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5917 # Fill this new table with existing invoices
5918 my $sth = $dbh->prepare("
5919 SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid, aqorders.datereceived
5921 LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5922 WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5923 AND aqorders.booksellerinvoicenumber != ''
5924 GROUP BY aqorders.booksellerinvoicenumber
5927 my $results = $sth->fetchall_arrayref({});
5928 $sth = $dbh->prepare("
5929 INSERT INTO aqinvoices (invoicenumber, booksellerid, shipmentdate) VALUES (?,?,?)
5931 foreach(@$results) {
5932 $sth->execute($_->{invoicenumber}, $_->{booksellerid}, $_->{datereceived});
5935 # Add the column in aqorders, fill it with correct value
5936 # and then drop booksellerinvoicenumber column
5938 ALTER TABLE aqorders
5939 ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5940 ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5944 UPDATE aqorders, aqinvoices
5945 SET aqorders.invoiceid = aqinvoices.invoiceid
5946 WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5950 ALTER TABLE aqorders
5951 DROP COLUMN booksellerinvoicenumber
5954 print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5955 SetVersion ($DBversion);
5958 $DBversion = "3.09.00.052";
5959 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5960 $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');");
5961 $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');");
5962 $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');");
5963 print "Upgrade to $DBversion done (Add systempreferences to decrease loan length on high demand items decreaseLoanHighHolds, decreaseLoanHighHoldsValue and decreaseLoanHighHoldsDuration) \n";
5964 SetVersion ($DBversion);
5967 $DBversion = "3.09.00.053";
5968 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5970 q|CREATE TABLE `import_auths` (
5971 import_record_id int(11) NOT NULL,
5972 matched_authid int(11) default NULL,
5973 control_number varchar(25) default NULL,
5974 authorized_heading varchar(128) default NULL,
5975 original_source varchar(25) default NULL,
5976 CONSTRAINT import_auths_ibfk_1 FOREIGN KEY (import_record_id)
5977 REFERENCES import_records (import_record_id) ON DELETE CASCADE ON UPDATE CASCADE,
5978 KEY matched_authid (matched_authid)
5979 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
5981 $dbh->do("ALTER TABLE import_batches
5982 CHANGE COLUMN num_biblios num_records int(11) NOT NULL default 0,
5983 ADD COLUMN record_type enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio'");
5984 $dbh->do("UPDATE import_batches SET record_type='auth' WHERE import_batch_id IN
5985 (SELECT import_batch_id FROM import_records WHERE record_type='auth')");
5987 print "Upgrade to $DBversion done (Added support for staging authorities)\n";
5988 SetVersion ($DBversion);
5991 $DBversion = "3.09.00.054";
5992 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5993 $dbh->do("ALTER TABLE aqorders CHANGE COLUMN gst gstrate DECIMAL(6,4) DEFAULT NULL");
5994 print "Upgrade to $DBversion done (Change column name in aqorders gst --> gstrate)\n";
5995 SetVersion($DBversion);
5998 $DBversion = "3.09.00.055";
5999 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6000 $dbh->do("ALTER TABLE aqorders ADD discount float(6,4) DEFAULT NULL AFTER gstrate");
6001 print "Upgrade to $DBversion done (Add discount field in aqorders table)\n";
6002 SetVersion($DBversion);
6005 $DBversion ="3.09.00.056";
6006 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6007 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('AuthDisplayHierarchy','0','Display authority hierarchies','','YesNo')");
6008 print "Upgrade to $DBversion done (Add system preference AuthDisplayHierarchy)\n";
6009 SetVersion($DBversion);
6012 $DBversion = "3.09.00.057";
6013 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6014 $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL AFTER basketgroupid;");
6015 $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL AFTER deliveryplace;");
6016 print "Upgrade to $DBversion done (Bug 5356: Added billingplace, deliveryplace to the aqbasket table)\n";
6017 SetVersion($DBversion);
6020 $DBversion ="3.09.00.058";
6021 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6022 $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');");
6023 $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');");
6024 print "Upgrade to $DBversion done (Add Did You Mean? configuration)\n";
6025 SetVersion($DBversion);
6028 $DBversion ="3.09.00.059";
6029 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6030 $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');");
6031 print "Upgrade to $DBversion done (Add system preference BlockReturnOfWithdrawnItems)\n";
6032 SetVersion($DBversion);
6035 $DBversion = "3.09.00.060";
6036 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6037 $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')");
6038 print "Upgrade to $DBversion done (Added HoldsToPullStartDate syspref)\n";
6039 SetVersion($DBversion);
6042 $DBversion = "3.09.00.061";
6043 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6044 $dbh->do("UPDATE systempreferences set value=0 WHERE variable='OPACItemsResultsDisplay' AND value='statuses'");
6045 $dbh->do("UPDATE systempreferences set value=1 WHERE variable='OPACItemsResultsDisplay' AND value='itemdetails'");
6046 $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'");
6047 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";
6048 SetVersion ($DBversion);
6051 $DBversion = "3.09.00.062";
6052 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6053 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='NoZebra'");
6054 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='QueryRemoveStopwords'");
6055 print "Upgrade to $DBversion done (Disable obsolete NoZebra and QueryRemoveStopwords sysprefs)\n";
6056 SetVersion ($DBversion);
6059 $DBversion = "3.09.00.063";
6060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6061 my $gst_booksellers = $dbh->selectcol_arrayref("SELECT DISTINCT(gstrate) FROM aqbooksellers");
6062 my $gist_syspref = C4::Context->preference("gist");
6063 # remove the undef values and construct and array with the syspref and the supplier values
6064 my @gstrates = map { defined $_ ? $_ : () } @$gst_booksellers;
6065 push @gstrates, split ('\|', $gist_syspref);
6066 # we want to compare integer (or float)
6067 $_ = $_ + 0 for @gstrates;
6068 use List::MoreUtils qw/uniq/;
6069 # remove duplicate values
6070 @gstrates = uniq sort @gstrates;
6071 my $new_syspref_value = join '|', @gstrates;
6072 # update the syspref with the new values
6073 my $sth = $dbh->prepare("UPDATE systempreferences set value=? WHERE variable='gist'");
6074 $sth->execute( $new_syspref_value );
6076 print "Upgrade to $DBversion done (Bug 8832, Set the syspref gist with the existing values)\n";
6077 SetVersion ($DBversion);
6080 $DBversion = "3.09.00.064";
6081 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6082 $dbh->do('ALTER TABLE items ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6083 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the items table)\n";
6084 SetVersion ($DBversion);
6087 $DBversion = "3.09.00.065";
6088 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6089 $dbh->do('ALTER TABLE deleteditems ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6090 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the deleteditems table)\n";
6091 SetVersion ($DBversion);
6094 $DBversion = "3.09.00.066";
6095 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6096 $dbh->do("DELETE FROM systempreferences WHERE variable='DidYouMeanFromAuthorities'");
6097 print "Upgrade to $DBversion done (Bug 9107: remove DidYouMeanFromAuthorities syspref)\n";
6098 SetVersion ($DBversion);
6101 $DBversion = "3.09.00.067";
6102 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6103 $dbh->do("ALTER TABLE statistics CHANGE COLUMN ccode ccode varchar(10) NULL");
6104 print "Upgrade to $DBversion done (Bug 9064: statistics.ccode potentially wrongly defined)\n";
6105 SetVersion ($DBversion);
6108 $DBversion = "3.10.00.00";
6109 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6110 print "Upgrade to $DBversion done (release tag)\n";
6111 SetVersion ($DBversion);
6114 $DBversion = "3.11.00.001";
6115 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6116 $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')");
6117 print "Upgrade to $DBversion done (Bug 2832 - Add alphabet syspref)\n";
6120 $DBversion = "3.11.00.002";
6121 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6123 DELETE from aqorders_items where ordernumber NOT IN (SELECT ordernumber FROM aqorders);
6126 ALTER TABLE aqorders_items
6127 ADD CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber)
6128 ON DELETE CASCADE ON UPDATE CASCADE;
6130 print "Upgrade to $DBversion done (Bug 9030: Add constraint on aqorders_items.ordernumber)\n";
6131 SetVersion ($DBversion);
6134 $DBversion = "3.11.00.003";
6135 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6136 $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')");
6137 print "Upgrade to $DBversion done (Bug 7189: Add system preference RefundLostItemFeeOnReturn)\n";
6138 SetVersion($DBversion);
6141 $DBversion = "3.11.00.004";
6142 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6144 ALTER TABLE subscription ADD COLUMN closed INT(1) NOT NULL DEFAULT 0 AFTER enddate;
6147 print "Upgrade to $DBversion done (Bug 8782: Add field subscription.closed)\n";
6148 SetVersion($DBversion);
6151 $DBversion = "3.11.00.005";
6152 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6153 $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;});
6155 $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;});
6157 $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;});
6159 print "Upgrade to $DBversion done (Bug 7919: Display of values depending on the connexion library)\n";
6160 SetVersion($DBversion);
6163 $DBversion = "3.11.00.006";
6164 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6166 UPDATE virtualshelves SET sortfield="copyrightdate" where sortfield="year";
6168 print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
6169 SetVersion($DBversion);
6172 $DBversion = "3.11.00.007";
6173 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6174 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ar', 'language', 'de', 'Arabisch')");
6175 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hy', 'language', 'de', 'Armenisch')");
6176 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'bg', 'language', 'de', 'Bulgarisch')");
6177 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'zh', 'language', 'de', 'Chinesisch')");
6178 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'cs', 'language', 'de', 'Tschechisch')");
6179 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'da', 'language', 'de', 'Dänisch')");
6180 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nl', 'language', 'de', 'Niederländisch')");
6181 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'en', 'language', 'de', 'Englisch')");
6182 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fi', 'language', 'de', 'Finnisch')");
6183 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fr', 'language', 'de', 'Französisch')");
6184 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'fr', 'Laotien')");
6185 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'de', 'Laotisch')");
6186 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'el', 'language', 'de', 'Griechisch (Nach 1453)')");
6187 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'he', 'language', 'de', 'Hebräisch')");
6188 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hi', 'language', 'de', 'Hindi')");
6189 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hu', 'language', 'de', 'Ungarisch')");
6190 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'id', 'language', 'de', 'Indonesisch')");
6191 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'it', 'language', 'de', 'Italienisch')");
6192 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ja', 'language', 'de', 'Japanisch')");
6193 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ko', 'language', 'de', 'Koreanisch')");
6194 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'la', 'language', 'de', 'Latein')");
6195 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'fr', 'Galicien')");
6196 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'de', 'Galizisch')");
6197 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nb', 'language', 'de', 'Norwegisch bokmål')");
6198 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nn', 'language', 'de', 'Norwegisch nynorsk')");
6199 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fa', 'language', 'de', 'Persisch')");
6200 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pl', 'language', 'de', 'Polnisch')");
6201 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pt', 'language', 'de', 'Portugiesisch')");
6202 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ro', 'language', 'de', 'Rumänisch')");
6203 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ru', 'language', 'de', 'Russisch')");
6204 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'fr', 'Serbe')");
6205 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'de', 'Serbisch')");
6206 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'es', 'language', 'de', 'Spanisch')");
6207 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sv', 'language', 'de', 'Schwedisch')");
6208 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'fr', 'Tétoum')");
6209 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'de', 'Tetum')");
6210 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'th', 'language', 'de', 'Thailändisch')");
6211 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tr', 'language', 'de', 'Türkisch')");
6212 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'uk', 'language', 'de', 'Ukrainisch')");
6213 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'fr', 'Ourdou')");
6214 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'de', 'Urdu')");
6215 print "Upgrade to $DBversion done (Bug 9056: add German and a couple of French translations to language_descriptions)\n";
6216 SetVersion ($DBversion);
6219 $DBversion = "3.11.00.008";
6220 if (CheckVersion($DBversion)) {
6222 CREATE TABLE IF NOT EXISTS `borrower_modifications` (
6223 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6224 `verification_token` varchar(255) NOT NULL DEFAULT '',
6225 `borrowernumber` int(11) NOT NULL DEFAULT '0',
6226 `cardnumber` varchar(16) DEFAULT NULL,
6227 `surname` mediumtext,
6230 `othernames` mediumtext,
6232 `streetnumber` varchar(10) DEFAULT NULL,
6233 `streettype` varchar(50) DEFAULT NULL,
6234 `address` mediumtext,
6238 `zipcode` varchar(25) DEFAULT NULL,
6242 `mobile` varchar(50) DEFAULT NULL,
6246 `B_streetnumber` varchar(10) DEFAULT NULL,
6247 `B_streettype` varchar(50) DEFAULT NULL,
6248 `B_address` varchar(100) DEFAULT NULL,
6250 `B_city` mediumtext,
6252 `B_zipcode` varchar(25) DEFAULT NULL,
6255 `B_phone` mediumtext,
6256 `dateofbirth` date DEFAULT NULL,
6257 `branchcode` varchar(10) DEFAULT NULL,
6258 `categorycode` varchar(10) DEFAULT NULL,
6259 `dateenrolled` date DEFAULT NULL,
6260 `dateexpiry` date DEFAULT NULL,
6261 `gonenoaddress` tinyint(1) DEFAULT NULL,
6262 `lost` tinyint(1) DEFAULT NULL,
6263 `debarred` date DEFAULT NULL,
6264 `debarredcomment` varchar(255) DEFAULT NULL,
6265 `contactname` mediumtext,
6266 `contactfirstname` text,
6267 `contacttitle` text,
6268 `guarantorid` int(11) DEFAULT NULL,
6269 `borrowernotes` mediumtext,
6270 `relationship` varchar(100) DEFAULT NULL,
6271 `ethnicity` varchar(50) DEFAULT NULL,
6272 `ethnotes` varchar(255) DEFAULT NULL,
6273 `sex` varchar(1) DEFAULT NULL,
6274 `password` varchar(30) DEFAULT NULL,
6275 `flags` int(11) DEFAULT NULL,
6276 `userid` varchar(75) DEFAULT NULL,
6277 `opacnote` mediumtext,
6278 `contactnote` varchar(255) DEFAULT NULL,
6279 `sort1` varchar(80) DEFAULT NULL,
6280 `sort2` varchar(80) DEFAULT NULL,
6281 `altcontactfirstname` varchar(255) DEFAULT NULL,
6282 `altcontactsurname` varchar(255) DEFAULT NULL,
6283 `altcontactaddress1` varchar(255) DEFAULT NULL,
6284 `altcontactaddress2` varchar(255) DEFAULT NULL,
6285 `altcontactaddress3` varchar(255) DEFAULT NULL,
6286 `altcontactstate` text,
6287 `altcontactzipcode` varchar(50) DEFAULT NULL,
6288 `altcontactcountry` text,
6289 `altcontactphone` varchar(50) DEFAULT NULL,
6290 `smsalertnumber` varchar(50) DEFAULT NULL,
6291 `privacy` int(11) DEFAULT NULL,
6292 PRIMARY KEY (`verification_token`,`borrowernumber`),
6293 KEY `verification_token` (`verification_token`),
6294 KEY `borrowernumber` (`borrowernumber`)
6295 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6299 INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
6300 ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'),
6301 ('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'),
6302 ('PatronSelfRegistrationDefaultCategory', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'),
6303 ('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'),
6304 ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'),
6305 ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free');
6309 INSERT INTO letter ( `module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content` )
6310 VALUES ( 'members', 'OPAC_REG_VERIFY', '', 'Opac Self-Registration Verification Email', '1', 'Verify Your Account', 'Hello!
6312 Your library account has been created. Please verify your email address by clicking this link to complete the signup process:
6314 http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>>
6316 If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
6319 print "Upgrade to $DBversion done (Bug 7067: Add Patron Self Registration)\n";
6320 SetVersion ($DBversion);
6323 $DBversion = "3.11.00.009";
6324 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6326 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
6327 ('SeparateHoldings', '0', 'Separate current branch holdings from other holdings', NULL, 'YesNo'),
6328 ('SeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings', 'homebranch|holdingbranch', 'Choice'),
6329 ('OpacSeparateHoldings', '0', 'Separate current branch holdings from other holdings (OPAC)', NULL, 'YesNo'),
6330 ('OpacSeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings (OPAC)', 'homebranch|holdingbranch', 'Choice')
6333 print "Upgrade to $DBversion done (Bug 7674: Add systempreferences SeparateHoldings, SeparateHoldingsBranch, OpacSeparateHoldings and OpacSeparateHoldingsBranch) \n";
6334 SetVersion ($DBversion);
6337 $DBversion = "3.11.00.010";
6338 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6339 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('RenewalSendNotice', '0', '', NULL, 'YesNo')");
6341 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
6342 ('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>>.');
6344 print "Upgrade to $DBversion done (Bug 9151 - Renewal notice according to patron alert preferences)\n";
6345 SetVersion($DBversion);
6348 $DBversion = "3.11.00.011";
6349 if ( CheckVersion($DBversion) ) {
6350 $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');");
6351 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','Media file extensions','','free');");
6352 print "Upgrade to $DBversion done (Bug 8377: Add HTML5MediaEnabled and HTML5MediaExtensions sysprefs)\n";
6353 SetVersion ($DBversion);
6356 $DBversion = "3.11.00.012";
6357 if ( CheckVersion($DBversion) ) {
6358 $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')");
6359 print "Upgrade to $DBversion done (Bug 9206: Only allow place holds in records that the patron don't have in his possession)\n";
6360 SetVersion($DBversion);
6363 $DBversion = "3.11.00.013";
6364 if ( CheckVersion($DBversion) ) {
6365 $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')");
6366 print "Upgrade to $DBversion done (Bug 9162 - Add a system preference to set which notes fields appears on title notes/description separator)\n";
6367 SetVersion($DBversion);
6370 $DBversion = "3.11.00.014";
6371 if ( CheckVersion($DBversion) ) {
6372 $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' )");
6373 $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserJS', '', 'Define custom javascript for inclusion in the SCO module', 'free' )");
6374 print "Upgrade to $DBversion done (Bug 9009: Add SCOUserCSS and SCOUserJS sysprefs)\n";
6377 $DBversion = "3.11.00.015";
6378 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6379 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissuesCharge', '1', 'Rental charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6380 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissuesCharge', '1', 'MANUAL_INV charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6381 print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissuesCharge and ManInvInNoissuesCharge.)\n";
6382 SetVersion($DBversion);
6385 $DBversion = "3.11.00.016";
6386 if ( CheckVersion($DBversion) ) {
6388 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";
6391 UPDATE userflags SET flagdesc="Edit Authorities" where flagdesc="Allow to edit authorities";
6394 UPDATE userflags SET flagdesc="Allow access to the reports module" where flagdesc="Allow to access to the reports module";
6397 UPDATE userflags SET flagdesc="Set library management parameters (deprecated)" where flagdesc="Set library management parameters";
6400 UPDATE userflags SET flagdesc="Manage serial subscriptions" where flagdesc="Allow to manage serials subscriptions";
6403 UPDATE userflags SET flagdesc="Manage patrons fines and fees" where flagdesc="Update borrower charges";
6406 UPDATE userflags SET flagdesc="Check out and check in items" where flagdesc="Circulate books";
6409 UPDATE userflags SET flagdesc="Manage Koha system settings (Administration panel)" where flagdesc="Set Koha system parameters";
6412 UPDATE userflags SET flagdesc="Add or modify patrons" where flagdesc="Add or modify borrowers";
6415 UPDATE userflags SET flagdesc="Use all tools (expand for granular tools permissions)" where flagdesc="Use tools (export, import, barcodes)";
6418 UPDATE userflags SET flagdesc="Allow staff members to modify permissions for other staff members" where flagdesc="Set user permissions";
6421 UPDATE permissions SET description="Perform batch modification of patrons" where description="Perform batch modifivation of patrons";
6424 print "Upgrade to $DBversion done (Bug 9382 (updated with bug 9745) - refresh permission descriptions to make more sense)\n";
6425 SetVersion ($DBversion);
6428 $DBversion ="3.11.00.017";
6429 if ( CheckVersion($DBversion) ) {
6430 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');");
6431 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');");
6432 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');");
6433 print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n";
6434 SetVersion($DBversion);
6437 $DBversion = "3.11.00.018";
6438 if ( CheckVersion($DBversion) ) {
6439 $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')");
6440 $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')");
6441 print "Upgrade to $DBversion done (Bug 9395: Problem with callnumber and standard number search in OPAC and Staff Client)\n";
6442 SetVersion ($DBversion);
6445 $DBversion = "3.11.00.019";
6446 if ( CheckVersion($DBversion) ) {
6447 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorityField100', 'afrey50 ba0', NULL, NULL, 'Textarea')");
6448 print "Upgrade to $DBversion done (Bug 9145 - Add syspref UNIMARCAuthorityField100)\n";
6449 SetVersion ($DBversion);
6452 $DBversion = "3.11.00.020";
6453 if ( CheckVersion($DBversion) ) {
6454 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')");
6455 print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n";
6456 SetVersion($DBversion);
6459 $DBversion ="3.11.00.021";
6460 if ( CheckVersion($DBversion) ) {
6461 $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');");
6462 print "Upgrade to $DBversion done (Bug 5888 - Subject search pop-up for the OPAC)\n";
6463 SetVersion($DBversion);
6466 $DBversion = "3.11.00.022";
6467 if ( CheckVersion($DBversion) ) {
6469 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('Persona',0,'Use Mozilla Persona for login','','YesNo')"
6471 print "Upgrade to $DBversion done (Bug 9587 - Allow login via Persona)\n";
6472 SetVersion($DBversion);
6475 $DBversion = "3.11.00.023";
6476 if ( CheckVersion($DBversion) ) {
6477 $dbh->do("UPDATE z3950servers SET host = 'lx2.loc.gov', port = 210, db = 'LCDB', syntax = 'USMARC', encoding = 'utf8' WHERE name = 'LIBRARY OF CONGRESS'");
6478 print "Upgrade to $DBversion done (Bug 9520 - Update default LOC Z39.50 target)\n";
6479 SetVersion($DBversion);
6482 $DBversion = "3.11.00.024";
6483 if ( CheckVersion($DBversion) ) {
6484 $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');");
6485 print "Upgrade to $DBversion done (Bug 5079: Add OpacItemLocation syspref)\n";
6486 SetVersion ($DBversion);
6489 $DBversion = "3.11.00.025";
6490 if ( CheckVersion($DBversion) ) {
6492 "CREATE TABLE linktracker (
6493 id int(11) NOT NULL AUTO_INCREMENT,
6494 biblionumber int(11) DEFAULT NULL,
6495 itemnumber int(11) DEFAULT NULL,
6496 borrowernumber int(11) DEFAULT NULL,
6498 timeclicked datetime DEFAULT NULL,
6500 KEY bibidx (biblionumber),
6501 KEY itemidx (itemnumber),
6502 KEY borridx (borrowernumber),
6503 KEY dateidx (timeclicked)
6504 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
6507 INSERT INTO systempreferences (variable,value,explanation,options,type)
6508 VALUES('TrackClicks','0','Track links clicked',NULL,'Integer')" );
6510 "Upgrade to $DBversion done (Adds feature Bug 8917, the ability to track links clicked)\n";
6511 SetVersion($DBversion);
6514 $DBversion = "3.11.00.026";
6515 if ( CheckVersion($DBversion) ) {
6517 ALTER TABLE import_records ADD INDEX batch_id_record_type ( import_batch_id, record_type );
6519 print "Upgrade to $DBversion done (Bug 9207: Add new index batch_id_record_type to import_records)\n";
6520 SetVersion($DBversion);
6523 $DBversion = "3.11.00.027";
6524 if ( CheckVersion($DBversion) ) {
6526 INSERT INTO permissions ( module_bit, code, description )
6527 VALUES ( '1', 'overdues_report', 'Execute overdue items report' )
6529 # add new permission for users with all report permissions and circulation remaining permission
6531 INSERT INTO user_permissions (borrowernumber, module_bit, code)
6532 SELECT user_permissions.borrowernumber, 1, 'overdues_report'
6533 FROM user_permissions
6534 LEFT JOIN borrowers USING(borrowernumber)
6535 WHERE borrowers.flags & (1 << 16)
6536 AND user_permissions.code = 'circulate_remaining_permissions'
6538 print "Upgrade to $DBversion done ( Add circ permission overdues_report )\n";
6539 SetVersion($DBversion);
6542 $DBversion = "3.11.00.028";
6543 if ( CheckVersion($DBversion) ) {
6544 $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' );");
6545 print "Upgrade to $DBversion done (Bug 9756 - Patron self registration missing the system preference PatronSelfRegistrationAdditionalInstructions)\n";
6546 SetVersion($DBversion);
6549 $DBversion = "3.11.00.029";
6550 if (CheckVersion($DBversion)) {
6551 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo')");
6552 print "Upgrade to $DBversion done (Bug 9239: Make it possible for Koha to use QueryParser)\n";
6553 SetVersion ($DBversion);
6556 $DBversion = "3.11.00.030";
6557 if ( CheckVersion($DBversion) ) {
6558 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');");
6559 print "Upgrade to $DBversion done (Add system preference FinesIncludeGracePeriod)\n";
6560 SetVersion($DBversion);
6563 $DBversion = "3.11.00.100";
6564 if ( CheckVersion($DBversion) ) {
6565 print "Upgrade to $DBversion done (3.12-alpha release)\n";
6566 SetVersion ($DBversion);
6569 $DBversion = "3.11.00.101";
6570 if ( CheckVersion($DBversion) ) {
6571 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short')");
6572 print "Upgrade to $DBversion done (Bug 9341: Problem with UNIMARC authors facets)\n";
6573 SetVersion ($DBversion);
6576 $DBversion = "3.11.00.102";
6577 if ( CheckVersion($DBversion) ) {
6579 DELETE FROM systempreferences WHERE variable='NoZebra'
6582 DELETE FROM systempreferences WHERE variable='QueryRemoveStopwords'
6584 print "Upgrade to $DBversion done (Remove deprecated NoZebra and QueryRemoveStopwords sysprefs)\n";
6585 SetVersion($DBversion);
6588 $DBversion = "3.11.00.103";
6589 if ( CheckVersion($DBversion) ) {
6590 $dbh->do("DELETE FROM systempreferences WHERE variable = 'insecure';");
6591 print "Upgrade to $DBversion done (Bug 9827 - Remove 'insecure' system preference)\n";
6592 SetVersion($DBversion);
6595 $DBversion = "3.11.00.104";
6596 if ( CheckVersion($DBversion) ) {
6597 print "Upgrade to $DBversion done (3.12-alpha2 release)\n";
6598 SetVersion ($DBversion);
6601 $DBversion = "3.11.00.105";
6602 if ( CheckVersion($DBversion) ) {
6603 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
6604 $sth = $dbh->prepare(
6605 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '029'"
6608 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6610 for my $frameworkcode ( keys %$frameworkcodes ) {
6612 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6613 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6614 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6615 ('029', 'a', 'OCLC library identifier', 'OCLC library identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6616 ('029', 'b', 'System control number', 'System control number', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6617 ('029', 'c', 'OAI set name', 'OAI set name', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6618 ('029', 't', 'Content type identifier', 'Content type identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL)
6622 for my $tag ( '863', '864', '865' ) {
6623 $sth = $dbh->prepare(
6624 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '$tag'"
6627 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6629 for my $frameworkcode ( keys %$frameworkcodes ) {
6631 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6632 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6633 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6634 ('$tag', '6', 'Linkage', 'Linkage', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6635 ('$tag', '8', 'Field link and sequence number', 'Field link and sequence number', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6636 ('$tag', 'a', 'First level of enumeration', 'First level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6637 ('$tag', 'b', 'Second level of enumeration', 'Second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6638 ('$tag', 'c', 'Third level of enumeration', 'Third level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6639 ('$tag', 'd', 'Fourth level of enumeration', 'Fourth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6640 ('$tag', 'e', 'Fifth level of enumeration', 'Fifth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6641 ('$tag', 'f', 'Sixth level of enumeration', 'Sixth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6642 ('$tag', 'g', 'Alternative numbering scheme, first level of enumeration', 'Alternative numbering scheme, first level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6643 ('$tag', 'h', 'Alternative numbering scheme, second level of enumeration', 'Alternative numbering scheme, second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6644 ('$tag', 'i', 'First level of chronology', 'First level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6645 ('$tag', 'j', 'Second level of chronology', 'Second level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6646 ('$tag', 'k', 'Third level of chronology', 'Third level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6647 ('$tag', 'l', 'Fourth level of chronology', 'Fourth level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6648 ('$tag', 'm', 'Alternative numbering scheme, chronology', 'Alternative numbering scheme, chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6649 ('$tag', 'n', 'Converted Gregorian year', 'Converted Gregorian year', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6650 ('$tag', 'o', 'Type of unit', 'Type of unit', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6651 ('$tag', 'p', 'Piece designation', 'Piece designation', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6652 ('$tag', 'q', 'Piece physical condition', 'Piece physical condition', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6653 ('$tag', 's', 'Copyright article-fee code', 'Copyright article-fee code', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6654 ('$tag', 't', 'Copy number', 'Copy number', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6655 ('$tag', 'v', 'Issuing date', 'Issuing date', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6656 ('$tag', 'w', 'Break indicator', 'Break indicator', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6657 ('$tag', 'x', 'Nonpublic note', 'Nonpublic note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6658 ('$tag', 'z', 'Public note', 'Public note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL)
6663 print "Upgrade to $DBversion done (Bug 9353: Missing subfields on MARC21 frameworks)\n";
6664 SetVersion($DBversion);
6668 $DBversion = "3.11.00.106";
6669 if ( CheckVersion($DBversion) ) {
6670 $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('19', 'plugins', 'Koha plugins', '0')");
6671 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
6672 ('19', 'manage', 'Manage plugins ( install / uninstall )'),
6673 ('19', 'tool', 'Use tool plugins'),
6674 ('19', 'report', 'Use report plugins'),
6675 ('19', 'configure', 'Configure plugins')
6677 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','0','Enable or disable the ability to use Koha Plugins.','','YesNo')");
6680 CREATE TABLE IF NOT EXISTS plugin_data (
6681 plugin_class varchar(255) NOT NULL,
6682 plugin_key varchar(255) NOT NULL,
6684 PRIMARY KEY (plugin_class,plugin_key)
6685 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6688 print "Upgrade to $DBversion done (Bug 7804: Added plugin system.)\n";
6689 SetVersion($DBversion);
6692 $DBversion = "3.11.00.107";
6693 if ( CheckVersion($DBversion) ) {
6694 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice')");
6695 print "Upgrade to $DBversion done (Bug 9014: Add syspref TimeFormat)\n";
6696 SetVersion ($DBversion);
6699 $DBversion = "3.11.00.108";
6700 if ( CheckVersion($DBversion) ) {
6701 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
6702 $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');");
6703 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;");
6704 print "Upgrade to $DBversion done (Bug 7241: Fix on circulation logs)\n";
6705 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";
6706 SetVersion($DBversion);
6709 $DBversion = "3.11.00.109";
6710 if ( CheckVersion($DBversion) ) {
6711 $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');");
6712 print "Upgrade to $DBversion done (Bug 9403: Add DisplayIconsXSLT)\n";
6713 SetVersion ($DBversion);
6716 $DBversion = "3.11.00.110";
6717 if ( CheckVersion($DBversion) ) {
6718 $dbh->do("ALTER TABLE pending_offline_operations CHANGE barcode barcode VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
6719 $dbh->do("ALTER TABLE pending_offline_operations ADD amount DECIMAL( 28, 6 ) NULL DEFAULT NULL");
6720 print "Upgrade to $DBversion done (Bug 8220 - Allow koc uploads to go to process queue)\n";
6721 SetVersion ($DBversion);
6724 $DBversion = "3.11.00.111";
6725 if ( CheckVersion($DBversion) ) {
6726 my $sth = $dbh->prepare("
6727 SELECT module, code, branchcode, content
6729 WHERE content LIKE '%<fine>%'
6732 my $sth_update = $dbh->prepare("UPDATE letter SET content = ? WHERE module = ? AND code = ? AND branchcode = ?");
6733 while(my $row = $sth->fetchrow_hashref){
6734 $row->{content} =~ s/<fine>\w+<\/fine>/<<items.fine>>/;
6735 $sth_update->execute($row->{content}, $row->{module}, $row->{code}, $row->{branchcode});
6737 print "Upgrade to $DBversion done (use new <<items.fine>> syntax in notices)\n";
6738 SetVersion($DBversion);
6741 $DBversion = "3.11.00.112";
6742 if ( CheckVersion($DBversion) ) {
6744 ALTER TABLE issuingrules ADD COLUMN renewalperiod int(4) DEFAULT NULL AFTER renewalsallowed
6747 UPDATE issuingrules SET renewalperiod = issuelength
6749 print "Upgrade to $DBversion done (Bug 8365: Add colum issuingrules.renewalperiod)\n";
6750 SetVersion ($DBversion);
6753 $DBversion = "3.11.00.113";
6754 if ( CheckVersion($DBversion) ) {
6756 ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6757 ADD INDEX ( show_in_pulldown )
6759 print "Upgrade to $DBversion done (Bug 9257 - Add groups to normal search pulldown)\n";
6760 SetVersion ($DBversion);
6763 $DBversion = "3.11.00.115";
6764 if ( CheckVersion($DBversion) ) {
6765 $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')");
6766 $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')");
6767 print "Upgrade to $DBversion done (Bug 7740: Add syspref HighlightOwnItemsOnOPAC)\n";
6768 SetVersion ($DBversion);
6771 $DBversion = "3.11.00.116";
6772 if ( CheckVersion($DBversion) ) {
6773 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN serialid;});
6774 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN subscription;});
6775 $dbh->do(q{ALTER TABLE aqorders ADD COLUMN subscriptionid INT(11) DEFAULT NULL;});
6776 $dbh->do(q{ALTER TABLE aqorders ADD CONSTRAINT aqorders_subscriptionid FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE;});
6777 $dbh->do(q{ALTER TABLE subscription ADD COLUMN reneweddate DATE DEFAULT NULL;});
6778 print "Upgrade to $DBversion done (Bug 5343: table aqorders: DROP serialid and subscription fields and ADD subscriptionid, table subscription: ADD reneweddate)\n";
6779 SetVersion ($DBversion);
6782 $DBversion = "3.11.00.200";
6783 if ( CheckVersion($DBversion) ) {
6784 print "Upgrade to $DBversion done (3.12-beta1 release)\n";
6785 SetVersion ($DBversion);
6788 $DBversion = "3.11.00.201";
6789 if ( CheckVersion($DBversion) ) {
6790 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'BIBSYS' AND host LIKE 'z3950.bibsys.no'");
6791 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'NORBOK' AND host LIKE 'z3950.nb.no'");
6792 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'SAMBOK' AND host LIKE 'z3950.nb.no'");
6793 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'DEICHMAN' AND host like 'z3950.deich.folkebibl.no'");
6794 print "Upgrade to $DBversion done (Bug 9498 - Update encoding for Norwegian sample Z39.50 servers)\n";
6795 SetVersion($DBversion);
6798 $DBversion = "3.11.00.202";
6799 if ( CheckVersion($DBversion) ) {
6800 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ca', 'language', 'Catalan','2013-01-12' )");
6801 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ca','cat')");
6802 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'es', 'Catalán')");
6803 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'en', 'Catalan')");
6804 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'fr', 'Catalan')");
6805 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'ca', 'Català')");
6806 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'de', 'Katalanisch')");
6807 print "Upgrade to $DBversion done (Bug 9381: Add Catalan laguage)\n";
6808 SetVersion ($DBversion);
6811 $DBversion = "3.11.00.203";
6812 if ( CheckVersion($DBversion) ) {
6813 $dbh->do(q{ALTER TABLE suggestions CHANGE COLUMN title title VARCHAR(255) DEFAULT NULL;});
6814 print "Upgrade to $DBversion done (Bug 2046 - increasing title column length for suggestions)\n";
6815 SetVersion ($DBversion);
6818 $DBversion = "3.11.00.300";
6819 if ( CheckVersion($DBversion) ) {
6820 print "Upgrade to $DBversion done (3.12-beta3 release)\n";
6821 SetVersion ($DBversion);
6824 $DBversion = "3.11.00.301";
6825 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6828 ALTER TABLE `issues`
6829 ADD KEY `itemnumber_idx` (`itemnumber`),
6830 ADD KEY `branchcode_idx` (`branchcode`),
6831 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6834 ALTER TABLE `old_issues`
6835 ADD KEY `branchcode_idx` (`branchcode`),
6836 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6840 ALTER TABLE `items` ADD KEY `itype_idx` (`itype`)
6843 ALTER TABLE `deleteditems` ADD KEY `itype_idx` (`itype`)
6847 ALTER TABLE `biblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6850 ALTER TABLE `deletedbiblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6854 ALTER TABLE `statistics`
6855 ADD KEY `branch_idx` (`branch`),
6856 ADD KEY `proccode_idx` (`proccode`),
6857 ADD KEY `type_idx` (`type`),
6858 ADD KEY `usercode_idx` (`usercode`),
6859 ADD KEY `itemnumber_idx` (`itemnumber`),
6860 ADD KEY `itemtype_idx` (`itemtype`),
6861 ADD KEY `borrowernumber_idx` (`borrowernumber`),
6862 ADD KEY `associatedborrower_idx` (`associatedborrower`),
6863 ADD KEY `ccode_idx` (`ccode`)
6866 print "Upgrade to $DBversion done (Bug 9681: Add some database indexes)\n";
6867 SetVersion($DBversion);
6870 $DBversion = "3.12.00.000";
6871 if ( CheckVersion($DBversion) ) {
6872 print "Upgrade to $DBversion done (3.12.0 release)\n";
6873 SetVersion ($DBversion);
6876 $DBversion = '3.13.00.000';
6877 if ( CheckVersion($DBversion) ) {
6878 print "Upgrade to $DBversion done (start the journey to Koha Pi)\n";
6879 SetVersion ($DBversion);
6882 $DBversion = "3.13.00.001";
6883 if ( CheckVersion($DBversion) ) {
6884 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
6885 $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
6887 CREATE TABLE `courses` (
6888 `course_id` int(11) NOT NULL AUTO_INCREMENT,
6889 `department` varchar(20) DEFAULT NULL,
6890 `course_number` varchar(255) DEFAULT NULL,
6891 `section` varchar(255) DEFAULT NULL,
6892 `course_name` varchar(255) DEFAULT NULL,
6893 `term` varchar(20) DEFAULT NULL,
6894 `staff_note` mediumtext,
6895 `public_note` mediumtext,
6896 `students_count` varchar(20) DEFAULT NULL,
6897 `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
6898 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6899 PRIMARY KEY (`course_id`)
6900 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6904 CREATE TABLE `course_instructors` (
6905 `course_id` int(11) NOT NULL,
6906 `borrowernumber` int(11) NOT NULL,
6907 PRIMARY KEY (`course_id`,`borrowernumber`),
6908 KEY `borrowernumber` (`borrowernumber`)
6909 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6913 ALTER TABLE `course_instructors`
6914 ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
6915 ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6919 CREATE TABLE `course_items` (
6920 `ci_id` int(11) NOT NULL AUTO_INCREMENT,
6921 `itemnumber` int(11) NOT NULL,
6922 `itype` varchar(10) DEFAULT NULL,
6923 `ccode` varchar(10) DEFAULT NULL,
6924 `holdingbranch` varchar(10) DEFAULT NULL,
6925 `location` varchar(80) DEFAULT NULL,
6926 `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
6927 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6928 PRIMARY KEY (`ci_id`),
6929 UNIQUE KEY `itemnumber` (`itemnumber`),
6930 KEY `holdingbranch` (`holdingbranch`)
6931 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6935 ALTER TABLE `course_items`
6936 ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6937 ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6941 CREATE TABLE `course_reserves` (
6942 `cr_id` int(11) NOT NULL AUTO_INCREMENT,
6943 `course_id` int(11) NOT NULL,
6944 `ci_id` int(11) NOT NULL,
6945 `staff_note` mediumtext,
6946 `public_note` mediumtext,
6947 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6948 PRIMARY KEY (`cr_id`),
6949 UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
6950 KEY `course_id` (`course_id`)
6951 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6955 ALTER TABLE `course_reserves`
6956 ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
6960 INSERT INTO permissions (module_bit, code, description) VALUES
6961 (18, 'manage_courses', 'Add, edit and delete courses'),
6962 (18, 'add_reserves', 'Add course reserves'),
6963 (18, 'delete_reserves', 'Remove course reserves')
6968 print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
6969 SetVersion($DBversion);
6972 $DBversion = "3.13.00.002";
6973 if ( CheckVersion($DBversion) ) {
6974 $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6975 print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6976 SetVersion ($DBversion);
6979 $DBversion = '3.13.00.003';
6980 if ( CheckVersion($DBversion) ) {
6981 $dbh->do("ALTER TABLE serial DROP itemnumber");
6982 print "Upgrade to $DBversion done (Bug 7718 - Remove itemnumber column from serials table)\n";
6983 SetVersion($DBversion);
6986 $DBversion = "3.13.00.004";
6987 if(CheckVersion($DBversion)) {
6989 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo')"
6991 print "Upgrade to $DBversion done (Bug 9722: Allow users to add notes when placing a hold in OPAC)\n";
6992 SetVersion($DBversion);
6995 $DBversion = "3.13.00.005";
6996 if(CheckVersion($DBversion)) {
6997 my $intra= C4::Context->preference("intranetstylesheet");
6998 #if this pref is not blank or starting with http, https or / [root], then
6999 #add an additional / to the front
7000 if($intra && $intra !~ /^(\/|https?)/) {
7001 $dbh->do("UPDATE systempreferences SET value=? WHERE variable=?",
7002 undef,('/'.$intra,"intranetstylesheet"));
7003 print "WARNING: Your system preference intranetstylesheet has been prefixed with a slash to make it an absolute path.\n";
7005 print "Upgrade to $DBversion done (Bug 10052: Make intranetstylesheet and intranetcolorstylesheet behave exactly like their opac counterparts)\n";
7006 SetVersion ($DBversion);
7009 $DBversion = "3.13.00.006";
7010 if ( CheckVersion($DBversion) ) {
7013 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
7017 "Upgrade to $DBversion done (Bug 10120 - Fines on item return controlled by a systempreference)\n";
7018 SetVersion($DBversion);
7021 $DBversion = "3.13.00.007";
7022 if ( CheckVersion($DBversion) ) {
7023 $dbh->do("UPDATE systempreferences SET variable='OpacHoldNotes' WHERE variable='OpacShowHoldNotes'");
7024 print "Upgrade to $DBversion done (Bug 10343: Rename OpacShowHoldNotes to OpacHoldNotes)\n";
7025 SetVersion($DBversion);
7028 $DBversion = "3.13.00.008";
7029 if ( CheckVersion($DBversion) ) {
7031 CREATE TABLE IF NOT EXISTS borrower_files (
7032 file_id int(11) NOT NULL AUTO_INCREMENT,
7033 borrowernumber int(11) NOT NULL,
7034 file_name varchar(255) NOT NULL,
7035 file_type varchar(255) NOT NULL,
7036 file_description varchar(255) DEFAULT NULL,
7037 file_content longblob NOT NULL,
7038 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7039 PRIMARY KEY (file_id),
7040 KEY borrowernumber (borrowernumber),
7041 CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7042 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7044 print "Upgrade to $DBversion done (Bug 10443: make sure borrower_files table exists)\n";
7045 SetVersion($DBversion);
7048 $DBversion = "3.13.00.009";
7049 if ( CheckVersion($DBversion) ) {
7050 $dbh->do("ALTER TABLE aqorders DROP COLUMN biblioitemnumber");
7051 print "Upgrade to $DBversion done (Bug 9987 - Drop column aqorders.biblioitemnumber)\n";
7052 SetVersion($DBversion);
7055 $DBversion = "3.13.00.010";
7056 if ( CheckVersion($DBversion) ) {
7059 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
7063 "Upgrade to $DBversion done (Bug 10366 - Add system preference to enabling warning librarian when invoice is duplicated)\n";
7064 SetVersion($DBversion);
7067 $DBversion = "3.13.00.011";
7068 if ( CheckVersion($DBversion) ) {
7069 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it'");
7070 print "Upgrade to $DBversion done (Bug 9519: Wrong language code for Italian in the advanced search language limitations)\n";
7071 SetVersion($DBversion);
7074 $DBversion = "3.13.00.012";
7075 if ( CheckVersion($DBversion) ) {
7076 $dbh->do("ALTER TABLE issuingrules MODIFY COLUMN overduefinescap decimal(28,6) DEFAULT NULL;");
7077 print "Upgrade to $DBversion done (Bug 10490: Correct datatype for overduefinescap in issuingrules)\n";
7078 SetVersion($DBversion);
7081 $DBversion ="3.13.00.013";
7082 if ( CheckVersion($DBversion) ) {
7083 $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');");
7084 print "Upgrade to $DBversion done (Bug 9576: add AllowTooManyOverride syspref to enable or disable issue limit confirmation)\n";
7085 SetVersion($DBversion);
7088 $DBversion = "3.13.00.014";
7089 if ( CheckVersion($DBversion) ) {
7090 $dbh->do("ALTER TABLE courses MODIFY COLUMN department varchar(80) DEFAULT NULL;");
7091 $dbh->do("ALTER TABLE courses MODIFY COLUMN term varchar(80) DEFAULT NULL;");
7092 print "Upgrade to $DBversion done (Bug 10604: correct width of courses.department and courses.term)\n";
7093 SetVersion($DBversion);
7096 $DBversion = "3.13.00.015";
7097 if ( CheckVersion($DBversion) ) {
7099 "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')"
7101 print "Upgrade to $DBversion done (Bug 7494: Add itemBarcodeFallbackSearch syspref)\n";
7102 SetVersion($DBversion);
7105 $DBversion = "3.13.00.016";
7106 if ( CheckVersion($DBversion) ) {
7108 ALTER TABLE items CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7112 ALTER TABLE deleteditems CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7116 UPDATE saved_sql SET savedsql = REPLACE(savedsql, 'wthdrawn', 'withdrawn')
7120 UPDATE marc_subfield_structure SET kohafield = 'items.withdrawn' WHERE kohafield = 'items.wthdrawn'
7123 print "Upgrade to $DBversion done (Bug 10550 - Fix database typo wthdrawn)\n";
7124 SetVersion($DBversion);
7127 $DBversion = "3.13.00.017";
7128 if ( CheckVersion($DBversion) ) {
7130 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientKey','','Client key for OverDrive integration','30','Free')"
7133 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientSecret','','Client key for OverDrive integration','30','YesNo')"
7136 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer')"
7138 print "Upgrade to $DBversion done (Bug 10320 - Show results from library's OverDrive collection in OPAC search)\n";
7139 SetVersion($DBversion);
7142 $DBversion = "3.13.00.018";
7143 if ( CheckVersion($DBversion) ) {
7144 $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7146 CREATE TABLE aqorders_transfers (
7147 ordernumber_from int(11) NULL,
7148 ordernumber_to int(11) NULL,
7149 timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7150 UNIQUE KEY ordernumber_from (ordernumber_from),
7151 UNIQUE KEY ordernumber_to (ordernumber_to),
7152 CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7153 CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7154 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7156 print "Upgrade to $DBversion done (Bug 5349: Add aqorders_transfers table)\n";
7157 SetVersion($DBversion);
7160 $DBversion = "3.13.00.019";
7161 if ( CheckVersion($DBversion) ) {
7162 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255) AFTER summary;");
7163 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL AFTER checkinmsg;");
7164 print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
7165 SetVersion($DBversion);
7168 $DBversion = "3.13.00.020";
7169 if ( CheckVersion($DBversion) ) {
7170 $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')");
7171 $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')");
7172 print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7173 SetVersion($DBversion);
7176 $DBversion ="3.13.00.021";
7177 if ( CheckVersion($DBversion) ) {
7178 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ConfirmFutureHolds','0','Number of days for confirming future holds','','Integer');");
7179 print "Upgrade to $DBversion done (Bug 9761: Add ConfirmFutureHolds pref)\n";
7180 SetVersion($DBversion);
7183 $DBversion = "3.13.00.022";
7184 if ( CheckVersion($DBversion) ) {
7185 $dbh->do("DELETE from auth_tag_structure WHERE tagfield IN ('68a','68b')");
7186 $dbh->do("DELETE from auth_subfield_structure WHERE tagfield IN ('68a','68b')");
7187 print "Upgrade to $DBversion done (Bug 10687 - Delete erroneous tags 68a and 68b on default MARC21 auth framework)\n";
7188 SetVersion($DBversion);
7191 $DBversion = "3.13.00.023";
7192 if ( CheckVersion($DBversion) ) {
7193 $dbh->do("ALTER TABLE borrowers CHANGE password password VARCHAR(60);");
7194 print "Upgrade to $DBversion done (Bug 9611 upgrading password storage system)\n";
7195 SetVersion($DBversion);
7198 $DBversion = "3.13.00.024";
7199 if ( CheckVersion($DBversion) ) {
7200 $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;});
7201 print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n";
7204 $DBversion = "3.13.00.025";
7205 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7206 $dbh->do("ALTER TABLE oai_sets_mappings ADD COLUMN operator varchar(8) NOT NULL default 'equal' AFTER marcsubfield;");
7207 print "Upgrade to $DBversion done (Bug 9295: OAI notequal: add operator column to OAI mappings table)\n";
7208 SetVersion ($DBversion);
7211 $DBversion = "3.13.00.026";
7212 if ( CheckVersion($DBversion) ) {
7214 ALTER TABLE auth_subfield_structure ADD COLUMN defaultvalue TEXT DEFAULT NULL AFTER frameworkcode
7216 print "Upgrade to $DBversion done (Bug 10602: Add the column auth_subfield_structure.defaultvalue)\n";
7217 SetVersion($DBversion);
7220 $DBversion = "3.13.00.027";
7221 if ( CheckVersion($DBversion) ) {
7222 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo')");
7223 print "Upgrade to $DBversion done (Bug 10240: Add syspref AllowOfflineCirculation)\n";
7224 SetVersion ($DBversion);
7227 $DBversion = "3.13.00.028";
7228 if ( CheckVersion($DBversion) ) {
7230 ALTER TABLE export_format ADD type VARCHAR(255) DEFAULT 'marc' AFTER encoding
7233 ALTER TABLE export_format CHANGE marcfields content mediumtext NOT NULL
7235 print "Upgrade to $DBversion done (Bug 10853: Add new field export_format.type and rename export_format.marcfields with export_format.content)\n";
7236 SetVersion($DBversion);
7239 $DBversion = "3.13.00.029";
7240 if ( CheckVersion($DBversion) ) {
7242 INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type )
7243 VALUES ( "issues to claim", "Default CSV export for serial issue claims",
7244 "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate",
7247 print "Upgrade to $DBversion done (Bug 10854: Add the default CSV profile for claiming issues)\n";
7248 SetVersion($DBversion);
7251 $DBversion = "3.13.00.030";
7252 if ( CheckVersion($DBversion) ) {
7254 DELETE FROM patronimage WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowers.cardnumber = patronimage.cardnumber)
7258 ALTER TABLE patronimage ADD borrowernumber INT( 11 ) NULL FIRST
7261 $dbh->{AutoCommit} = 0;
7262 $dbh->{RaiseError} = 1;
7266 UPDATE patronimage LEFT JOIN borrowers USING ( cardnumber ) SET patronimage.borrowernumber = borrowers.borrowernumber
7272 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber) failed! Transaction aborted because $@\n";
7273 eval { $dbh->rollback };
7277 ALTER TABLE patronimage DROP FOREIGN KEY patronimage_fk1
7280 ALTER TABLE patronimage DROP PRIMARY KEY, ADD PRIMARY KEY( borrowernumber )
7283 ALTER TABLE patronimage DROP cardnumber
7286 ALTER TABLE patronimage ADD FOREIGN KEY ( borrowernumber ) REFERENCES borrowers ( borrowernumber ) ON DELETE CASCADE ON UPDATE CASCADE
7289 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber)\n";
7290 SetVersion($DBversion);
7293 $dbh->{AutoCommit} = 1;
7294 $dbh->{RaiseError} = 0;
7297 $DBversion = "3.13.00.031";
7298 if ( CheckVersion($DBversion) ) {
7301 CREATE TABLE IF NOT EXISTS `patron_lists` (
7302 patron_list_id int(11) NOT NULL AUTO_INCREMENT,
7303 name varchar(255) CHARACTER SET utf8 NOT NULL,
7304 owner int(11) NOT NULL,
7305 PRIMARY KEY (patron_list_id),
7307 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7311 ALTER TABLE `patron_lists`
7312 ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7316 CREATE TABLE patron_list_patrons (
7317 patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT,
7318 patron_list_id int(11) NOT NULL,
7319 borrowernumber int(11) NOT NULL,
7320 PRIMARY KEY (patron_list_patron_id),
7321 KEY patron_list_id (patron_list_id),
7322 KEY borrowernumber (borrowernumber)
7323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7327 ALTER TABLE `patron_list_patrons`
7328 ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
7329 ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7333 INSERT INTO permissions (module_bit, code, description) VALUES
7334 (13, 'manage_patron_lists', 'Add, edit and delete patron lists and their contents')
7337 print "Upgrade to $DBversion done (Bug 10565 - Add a 'Patron List' feature for storing and manipulating collections of patrons)\n";
7338 SetVersion($DBversion);
7341 $DBversion = "3.13.00.032";
7342 if ( CheckVersion($DBversion) ) {
7343 $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus varchar(16) DEFAULT 'new' AFTER parent_ordernumber");
7344 $dbh->do("UPDATE aqorders SET orderstatus='ordered' WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)");
7346 UPDATE aqorders SET orderstatus='partial'
7347 WHERE quantity > quantityreceived
7348 AND quantityreceived > 0
7349 AND ordernumber IN (
7350 SELECT parent_ordernumber
7352 SELECT DISTINCT(parent_ordernumber)
7354 WHERE ordernumber != parent_ordernumber
7357 AND basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)
7359 $dbh->do("UPDATE aqorders SET orderstatus='complete' WHERE quantity=quantityreceived");
7360 $dbh->do("UPDATE aqorders SET orderstatus='cancelled' WHERE datecancellationprinted IS NOT NULL");
7361 print "Upgrade to $DBversion done (Bug 5336: Add the new column aqorders.orderstatus)\n";
7362 SetVersion($DBversion);
7365 $DBversion = "3.13.00.033";
7366 if ( CheckVersion($DBversion) ) {
7368 DROP TABLE IF EXISTS subscription_frequencies
7371 CREATE TABLE subscription_frequencies (
7372 id INTEGER NOT NULL AUTO_INCREMENT,
7373 description TEXT NOT NULL,
7374 displayorder INT DEFAULT NULL,
7375 unit ENUM('day','week','month','year') DEFAULT NULL,
7376 unitsperissue INTEGER NOT NULL DEFAULT '1',
7377 issuesperunit INTEGER NOT NULL DEFAULT '1',
7379 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7383 DROP TABLE IF EXISTS subscription_numberpatterns
7386 CREATE TABLE subscription_numberpatterns (
7387 id INTEGER NOT NULL AUTO_INCREMENT,
7388 label VARCHAR(255) NOT NULL,
7389 displayorder INTEGER DEFAULT NULL,
7390 description TEXT NOT NULL,
7391 numberingmethod VARCHAR(255) NOT NULL,
7392 label1 VARCHAR(255) DEFAULT NULL,
7393 add1 INTEGER DEFAULT NULL,
7394 every1 INTEGER DEFAULT NULL,
7395 whenmorethan1 INTEGER DEFAULT NULL,
7396 setto1 INTEGER DEFAULT NULL,
7397 numbering1 VARCHAR(255) DEFAULT NULL,
7398 label2 VARCHAR(255) DEFAULT NULL,
7399 add2 INTEGER DEFAULT NULL,
7400 every2 INTEGER DEFAULT NULL,
7401 whenmorethan2 INTEGER DEFAULT NULL,
7402 setto2 INTEGER DEFAULT NULL,
7403 numbering2 VARCHAR(255) DEFAULT NULL,
7404 label3 VARCHAR(255) DEFAULT NULL,
7405 add3 INTEGER DEFAULT NULL,
7406 every3 INTEGER DEFAULT NULL,
7407 whenmorethan3 INTEGER DEFAULT NULL,
7408 setto3 INTEGER DEFAULT NULL,
7409 numbering3 VARCHAR(255) DEFAULT NULL,
7411 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7415 INSERT INTO subscription_frequencies (description, unit, unitsperissue, issuesperunit, displayorder)
7417 ('2/day', 'day', 1, 2, 1),
7418 ('1/day', 'day', 1, 1, 2),
7419 ('3/week', 'week', 1, 3, 3),
7420 ('1/week', 'week', 1, 1, 4),
7421 ('1/2 weeks', 'week', 2, 1, 5),
7422 ('1/3 weeks', 'week', 3, 1, 6),
7423 ('1/month', 'month', 1, 1, 7),
7424 ('1/2 months', 'month', 2, 1, 8),
7425 ('1/3 months', 'month', 3, 1, 9),
7426 ('2/year', 'month', 6, 1, 10),
7427 ('1/year', 'year', 1, 1, 11),
7428 ('1/2 year', 'year', 2, 1, 12),
7429 ('Irregular', NULL, 1, 1, 13)
7432 # Used to link existing subscription to newly created frequencies
7433 my $frequencies_mapping = { # keys are old frequency numbers, values are the new ones
7434 1 => 2, # daily (n/week)
7439 6 => 8, # 1/2 months (6/year)
7440 7 => 9, # 1/3 months (1/quarter)
7441 8 => 9, # 1/quarter (seasonal)
7444 11 => 12, # 1/2 years
7446 16 => 13, # Without periodicity
7447 32 => 13, # Irregular
7452 INSERT INTO subscription_numberpatterns
7453 (label, displayorder, description, numberingmethod,
7454 label1, add1, every1, whenmorethan1, setto1, numbering1,
7455 label2, add2, every2, whenmorethan2, setto2, numbering2,
7456 label3, add3, every3, whenmorethan3, setto3, numbering3)
7458 ('Number', 1, 'Simple Numbering method', 'No.{X}',
7459 'Number', 1, 1, 99999, 1, NULL,
7460 NULL, NULL, NULL, NULL, NULL, NULL,
7461 NULL, NULL, NULL, NULL, NULL, NULL),
7463 ('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
7464 'Volume', 1, 48, 99999, 1, NULL,
7465 'Number', 1, 4, 12, 1, NULL,
7466 'Issue', 1, 1, 4, 1, NULL),
7468 ('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
7469 'Volume', 1, 12, 99999, 1, NULL,
7470 'Number', 1, 1, 12, 1, NULL,
7471 NULL, NULL, NULL, NULL, NULL, NULL),
7473 ('Seasonal', 4, 'Season Year', '{X} {Y}',
7474 'Season', 1, 1, 3, 0, 'season',
7475 'Year', 1, 4, 99999, 1, NULL,
7476 NULL, NULL, NULL, NULL, NULL, NULL)
7480 ALTER TABLE subscription
7481 MODIFY COLUMN numberpattern INTEGER DEFAULT NULL,
7482 MODIFY COLUMN periodicity INTEGER DEFAULT NULL
7485 # Update existing subscriptions
7488 SELECT subscriptionid, periodicity, numberingmethod,
7489 add1, every1, whenmorethan1, setto1,
7490 add2, every2, whenmorethan2, setto2,
7491 add3, every3, whenmorethan3, setto3
7493 ORDER BY subscriptionid
7495 my $sth = $dbh->prepare($query);
7497 my $insert_numberpatterns_sth = $dbh->prepare(qq|
7498 INSERT INTO subscription_numberpatterns
7499 (label, displayorder, description, numberingmethod,
7500 label1, add1, every1, whenmorethan1, setto1, numbering1,
7501 label2, add2, every2, whenmorethan2, setto2, numbering2,
7502 label3, add3, every3, whenmorethan3, setto3, numbering3)
7504 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
7506 my $check_numberpatterns_sth = $dbh->prepare(qq|
7507 SELECT * FROM subscription_numberpatterns
7508 WHERE (add1 = ? OR (add1 IS NULL AND ? IS NULL)) AND (add2 = ? OR (add2 IS NULL AND ? IS NULL))
7509 AND (add3 = ? OR (add3 IS NULL AND ? IS NULL)) AND (every1 = ? OR (every1 IS NULL AND ? IS NULL))
7510 AND (every2 = ? OR (every2 IS NULL AND ? IS NULL)) AND (every3 = ? OR (every3 IS NULL AND ? IS NULL))
7511 AND (whenmorethan1 = ? OR (whenmorethan1 IS NULL AND ? IS NULL)) AND (whenmorethan2 = ? OR (whenmorethan2 IS NULL AND ? IS NULL))
7512 AND (whenmorethan3 = ? OR (whenmorethan3 IS NULL AND ? IS NULL)) AND (setto1 = ? OR (setto1 IS NULL AND ? IS NULL))
7513 AND (setto2 = ? OR (setto2 IS NULL AND ? IS NULL)) AND (setto3 = ? OR (setto3 IS NULL AND ? IS NULL))
7514 AND (numberingmethod = ? OR (numberingmethod IS NULL AND ? IS NULL))
7517 my $update_subscription_sth = $dbh->prepare(qq|
7519 SET numberpattern = ?,
7521 WHERE subscriptionid = ?
7525 while(my $sub = $sth->fetchrow_hashref) {
7526 $check_numberpatterns_sth->execute(
7527 $sub->{add1}, $sub->{add1}, $sub->{add2}, $sub->{add2}, $sub->{add3}, $sub->{add3},
7528 $sub->{every1}, $sub->{every1}, $sub->{every2}, $sub->{every2}, $sub->{every3}, $sub->{every3},
7529 $sub->{whenmorethan1}, $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan2},
7530 $sub->{whenmorethan3}, $sub->{whenmorethan3}, $sub->{setto1}, $sub->{setto1}, $sub->{setto2},
7531 $sub->{setto2}, $sub->{setto3}, $sub->{setto3}, $sub->{numberingmethod}, $sub->{numberingmethod}
7533 my $p = $check_numberpatterns_sth->fetchrow_hashref;
7535 # Pattern already exists, link to it
7536 $update_subscription_sth->execute($p->{id},
7537 $frequencies_mapping->{$sub->{periodicity}},
7538 $sub->{subscriptionid});
7540 # Create a new numbering pattern for this subscription
7541 my $ok = $insert_numberpatterns_sth->execute(
7542 "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
7543 "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
7544 "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
7545 "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
7548 my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
7549 # Link to subscription_numberpatterns and subscription_frequencies
7550 $update_subscription_sth->execute($id,
7551 $frequencies_mapping->{$sub->{periodicity}},
7552 $sub->{subscriptionid});
7558 # Remove now useless columns
7560 ALTER TABLE subscription
7561 DROP COLUMN numberingmethod,
7564 DROP COLUMN whenmorethan1,
7568 DROP COLUMN whenmorethan2,
7572 DROP COLUMN whenmorethan3,
7575 DROP COLUMN issuesatonce,
7576 DROP COLUMN hemisphere,
7577 ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
7578 ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
7579 ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
7580 ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
7581 ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
7584 # Set firstacquidate if not already set (firstacquidate is now mandatory)
7585 my $get_first_planneddate_sth = $dbh->prepare(qq|
7588 WHERE subscriptionid = ?
7592 my $update_firstacquidate_sth = $dbh->prepare(qq|
7594 SET firstacquidate = ?
7595 WHERE subscriptionid = ?
7597 my $get_subscriptions_sth = $dbh->prepare(qq|
7598 SELECT subscriptionid, startdate
7600 WHERE firstacquidate IS NULL
7601 OR firstacquidate = '0000-00-00'
7603 $get_subscriptions_sth->execute;
7604 while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) {
7605 # Try to get the planned date of the first serial
7606 $get_first_planneddate_sth->execute($subscriptionid);
7607 my ($first_planneddate) = $get_first_planneddate_sth->fetchrow;
7608 if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) {
7609 $update_firstacquidate_sth->execute($first_planneddate, $subscriptionid);
7611 # Defaults to subscription start date
7612 $update_firstacquidate_sth->execute($startdate, $subscriptionid);
7616 print "Upgrade to $DBversion done (Bug 7688: add subscription_frequencies and subscription_numberpatterns tables)\n";
7617 SetVersion($DBversion);
7620 $DBversion = "3.13.00.034";
7621 if ( CheckVersion($DBversion) ) {
7623 ALTER TABLE `import_batches`
7624 CHANGE `item_action` `item_action`
7625 ENUM( 'always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore', 'replace' )
7626 NOT NULL DEFAULT 'always_add'
7628 print "Upgrade to $DBversion done (Bug 7131 - way to overlay items in in marc import)\n";
7629 SetVersion($DBversion);
7632 $DBversion ="3.13.00.035";
7633 if ( CheckVersion($DBversion) ) {
7635 CREATE TABLE borrower_debarments (
7636 borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT,
7637 borrowernumber int(11) NOT NULL,
7638 expiration date DEFAULT NULL,
7639 `type` enum('SUSPENSION','OVERDUES','MANUAL') NOT NULL DEFAULT 'MANUAL',
7641 manager_id int(11) DEFAULT NULL,
7642 created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
7643 updated timestamp NULL DEFAULT NULL,
7644 PRIMARY KEY (borrower_debarment_id),
7645 KEY borrowernumber (borrowernumber) ,
7646 CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
7647 ON DELETE CASCADE ON UPDATE CASCADE
7648 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7651 # debarments with end date
7653 INSERT INTO borrower_debarments ( borrowernumber, expiration, comment ) SELECT borrowernumber, debarred, debarredcomment FROM borrowers WHERE debarred IS NOT NULL AND debarred <> '9999-12-31'
7655 # debarments with no end date
7657 INSERT INTO borrower_debarments ( borrowernumber, comment ) SELECT borrowernumber, debarredcomment FROM borrowers WHERE debarred = '9999-12-31'
7661 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
7662 ('AutoRemoveOverduesRestrictions','0','Defines whether an OVERDUES debarment should be lifted automatically if all overdue items are returned by the patron.','YesNo')
7665 print "Upgrade to $DBversion done (Bug 2720 - Overdues which debar automatically should undebar automatically when returned)\n";
7666 SetVersion($DBversion);
7669 $DBversion = "3.13.00.036";
7670 if ( CheckVersion($DBversion) ) {
7672 INSERT INTO systempreferences (variable, value, explanation, options, type)
7673 VALUES ('StaffDetailItemSelection', '1', 'Enable item selection in record detail page', NULL, 'YesNo')
7675 print "Upgrade to $DBversion done (Add system preference StaffDetailItemSelection)\n";
7676 SetVersion($DBversion);
7679 $DBversion = "3.13.00.037";
7680 if ( CheckVersion($DBversion) ) {
7681 #add phone if it is not there already (explains the ignore option)
7683 INSERT IGNORE INTO message_transport_types (message_transport_type) values ('phone');
7685 print "Upgrade to $DBversion done (Bug 10572: Add phone to message_transport_types table for new installs)\n";
7686 SetVersion($DBversion);
7689 $DBversion = "3.13.00.038";
7690 if ( CheckVersion($DBversion) ) {
7691 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
7692 print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
7693 SetVersion($DBversion);
7696 $DBversion = "3.13.00.039";
7697 if ( CheckVersion($DBversion) ) {
7699 ALTER TABLE aqbasket ADD branch varchar(10) default NULL
7702 ALTER TABLE aqbasket
7703 ADD CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch)
7704 REFERENCES branches (branchcode)
7705 ON UPDATE CASCADE ON DELETE SET NULL
7708 DROP TABLE IF EXISTS aqbasketusers
7711 CREATE TABLE aqbasketusers (
7712 basketno int(11) NOT NULL,
7713 borrowernumber int(11) NOT NULL,
7714 PRIMARY KEY (basketno,borrowernumber),
7715 CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON DELETE CASCADE ON UPDATE CASCADE,
7716 CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7717 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7720 INSERT INTO permissions (module_bit, code, description)
7721 VALUES (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them')
7724 print "Upgrade to $DBversion done (Add branch and users list to baskets. "
7725 . "New permission order_manage_all)\n";
7726 SetVersion($DBversion);
7729 $DBversion = "3.13.00.040";
7730 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7731 $dbh->do("CREATE TABLE IF NOT EXISTS marc_modification_templates (
7732 template_id int(11) NOT NULL auto_increment,
7734 PRIMARY KEY (template_id)
7735 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
7739 CREATE TABLE IF NOT EXISTS marc_modification_template_actions (
7740 mmta_id int(11) NOT NULL auto_increment,
7741 template_id int(11) NOT NULL,
7742 ordering int(3) NOT NULL,
7743 action enum('delete_field','update_field','move_field','copy_field') NOT NULL,
7744 field_number smallint(6) NOT NULL default '0',
7745 from_field varchar(3) NOT NULL,
7746 from_subfield varchar(1) NULL,
7747 field_value varchar(100) default NULL,
7748 to_field varchar(3) default NULL,
7749 to_subfield varchar(1) default NULL,
7750 to_regex_search text,
7751 to_regex_replace text,
7752 to_regex_modifiers varchar(8) default '',
7753 conditional enum('if','unless') default NULL,
7754 conditional_field varchar(3) default NULL,
7755 conditional_subfield varchar(1) default NULL,
7756 conditional_comparison enum('exists','not_exists','equals','not_equals') default NULL,
7757 conditional_value text,
7758 conditional_regex tinyint(1) NOT NULL default '0',
7760 PRIMARY KEY (mmta_id),
7761 CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
7762 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7765 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'marc_modification_templates', 'Manage marc modification templates')");
7767 print "Upgrade to $DBversion done ( Bug 8015: Added tables for MARC Modification Framework )\n";
7768 SetVersion($DBversion);
7771 $DBversion = "3.13.00.041";
7772 if(CheckVersion($DBversion)) {
7774 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');
7776 print "Upgrade to $DBversion done (Bug 10986: Added AcqItemSetSubfieldsWhenReceived syspref)\n";
7777 SetVersion($DBversion);
7780 $DBversion = "3.13.00.042";
7781 if(CheckVersion($DBversion)) {
7782 print "Upgrade to $DBversion done (Koha 3.14 beta)\n";
7783 SetVersion($DBversion);
7786 $DBversion = "3.13.00.043";
7787 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7788 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
7789 print "Upgrade to $DBversion done (Bug 11196: Add system preference SearchEngine if missing )\n";
7790 SetVersion($DBversion);
7793 $DBversion = "3.14.00.000";
7794 if ( CheckVersion($DBversion) ) {
7795 print "Upgrade to $DBversion done (3.14.0 release)\n";
7796 SetVersion ($DBversion);
7799 $DBversion = '3.15.00.000';
7800 if ( CheckVersion($DBversion) ) {
7801 print "Upgrade to $DBversion done (the road goes ever on)\n";
7802 SetVersion ($DBversion);
7805 $DBversion = "3.15.00.001";
7806 if ( CheckVersion($DBversion) ) {
7807 $dbh->do("UPDATE systempreferences SET value='clear' where variable = 'CircAutoPrintQuickSlip' and value = '0'");
7808 $dbh->do("UPDATE systempreferences SET value='qslip' where variable = 'CircAutoPrintQuickSlip' and value = '1'");
7809 $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'");
7810 print "Upgrade to $DBversion done (Bug 11040: Add option to print full slip when checking out a null barcode)\n";
7811 SetVersion($DBversion);
7814 $DBversion = "3.15.00.002";
7815 if(CheckVersion($DBversion)) {
7816 $dbh->do("ALTER TABLE deleteditems MODIFY materials text;");
7817 print "Upgrade to $DBversion done (Bug 11275: alter deleteditems.materials from varchar(10) to text)\n";
7818 SetVersion($DBversion);
7821 $DBversion = "3.15.00.003";
7822 if ( CheckVersion($DBversion) ) {
7825 SET description = ''
7826 WHERE description IN (
7831 ' Account Management fee',
7832 'Payment,thanks', 'Payment,thanks - ',
7836 print "Upgrade to $DBversion done (Bug 2546: Update fine descriptions)\n";
7837 SetVersion($DBversion);
7840 $DBversion = "3.15.00.004";
7841 if ( CheckVersion($DBversion) ) {
7842 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
7844 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
7845 kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link,
7846 defaultvalue) VALUES
7847 ('015', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7848 ('020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7849 ('024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7850 ('027', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7851 ('800', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7852 ('810', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7853 ('811', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7854 ('830', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL);
7857 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
7858 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
7859 ('', '020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', ''),
7860 ('', '024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', '');
7863 print "Upgrade to $DBversion done (Bug 10970 - Update MARC21 frameworks to Update Nr. 17 - DB update)\n";
7864 SetVersion($DBversion);
7867 $DBversion = "3.15.00.005";
7868 if ( CheckVersion($DBversion) ) {
7869 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo');");
7870 print "Upgrade to $DBversion done (Bug 8230: Add AcquisitionDetails system preference)\n";
7871 SetVersion ($DBversion);
7874 $DBversion = "3.15.00.006";
7875 if(CheckVersion($DBversion)) {
7877 ALTER TABLE `borrowers`
7878 ADD KEY `surname_idx` (`surname`(255)),
7879 ADD KEY `firstname_idx` (`firstname`(255)),
7880 ADD KEY `othernames_idx` (`othernames`(255))
7882 print "Upgrade to $DBversion done (Bug 11249 - Add DB indexes on borrower names)\n";
7883 SetVersion($DBversion);
7886 $DBversion = "3.15.00.007";
7887 if ( CheckVersion($DBversion) ) {
7888 $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7889 $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7890 $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7891 $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7892 print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7893 SetVersion ($DBversion);
7896 $DBversion = "3.15.00.008";
7897 if ( CheckVersion($DBversion) ) {
7899 ALTER TABLE collections_tracking CHANGE ctId collections_tracking_id integer(11) NOT NULL auto_increment;
7901 print "Upgrade to $DBversion done (Bug 11384) - change name of collections_tracker.ctId column)\n";
7902 SetVersion ($DBversion);
7905 $DBversion = "3.15.00.009";
7906 if ( CheckVersion($DBversion) ) {
7908 ALTER TABLE suggestions MODIFY suggesteddate DATE NOT NULL
7910 print "Upgrade to $DBversion done (Bug 11391) - drop default value on suggestions.suggesteddate column)\n";
7911 SetVersion ($DBversion);
7914 $DBversion = "3.15.00.010";
7915 if(CheckVersion($DBversion)) {
7916 $dbh->do("ALTER TABLE deleteditems DROP COLUMN marc");
7917 print "Upgrade to $DBversion done (Bug 6331: remove obsolete column in deleteditems.marc)\n";
7918 SetVersion ($DBversion);
7921 $DBversion = "3.15.00.011";
7922 if(CheckVersion($DBversion)) {
7923 $dbh->do("UPDATE marc_subfield_structure SET maxlength=9999 WHERE maxlength IS NULL OR maxlength=0;");
7924 print "Upgrade to $DBversion done (Bug 8018: set 9999 as default max length for subfields)\n";
7925 SetVersion ($DBversion);
7928 $DBversion = "3.15.00.012";
7929 if ( CheckVersion($DBversion) ) {
7931 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'force_checkout', 'Force checkout if a limitation exists')
7934 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_restrictions', 'Manage restrictions for accounts')
7937 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7938 SELECT user_permissions.borrowernumber, 1, 'force_checkout'
7939 FROM user_permissions
7940 LEFT JOIN borrowers USING(borrowernumber)
7941 WHERE borrowers.flags & (1 << 1)
7944 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7945 SELECT user_permissions.borrowernumber, 1, 'manage_restrictions'
7946 FROM user_permissions
7947 LEFT JOIN borrowers USING(borrowernumber)
7948 WHERE borrowers.flags & (1 << 1)
7951 print "Upgrade to $DBversion done (Bug 10863 - Add permissions force_checkout and manage_restrictions)\n";
7952 SetVersion($DBversion);
7955 $DBversion = "3.15.00.013";
7956 if(CheckVersion($DBversion)) {
7958 UPDATE systempreferences
7959 SET explanation = 'Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")'
7960 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7964 UPDATE systempreferences
7966 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7969 print "Upgrade to $DBversion done (Bug 11237: Update explanation and default value for AcqItemSetSubfieldsWhenReceived syspref)\n";
7970 SetVersion($DBversion);
7973 $DBversion = "3.15.00.014";
7974 if (CheckVersion($DBversion)) {
7975 $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');");
7976 print "Upgrade to $DBversion done (Bug 11415: add system preference for automatic self checkout receipt printing)\n";
7977 SetVersion($DBversion);
7980 $DBversion = "3.15.00.015";
7981 if (CheckVersion($DBversion)) {
7982 $dbh->do("INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
7983 ('OpacSuggestionManagedBy',1,'','Show the name of the staff member who managed a suggestion in OPAC','YesNo');");
7984 print "Upgrade to $DBversion done (Bug 10907: Add OpacSuggestionManagedBy system preference)\n";
7985 SetVersion($DBversion);
7988 $DBversion = "3.15.00.016";
7989 if (CheckVersion($DBversion)) {
7990 $dbh->do("ALTER TABLE biblioitems CHANGE url url TEXT NULL DEFAULT NULL");
7991 $dbh->do("ALTER TABLE deletedbiblioitems CHANGE url url TEXT NULL DEFAULT NULL");
7992 print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n";
7993 SetVersion($DBversion);
7996 $DBversion = "3.15.00.017";
7997 if(CheckVersion($DBversion)) {
7999 UPDATE systempreferences
8000 SET explanation = 'Define the contents of UNIMARC authority control field 100 position 08-35'
8001 WHERE variable = "UNIMARCAuthorityField100"
8004 UPDATE systempreferences
8005 SET explanation = 'Define the contents of MARC21 authority control field 008 position 06-39'
8006 WHERE variable = "MARCAuthorityControlField008"
8009 UPDATE systempreferences
8010 SET explanation = 'Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html'
8011 WHERE variable = "MARCOrgCode"
8013 print "Upgrade to $DBversion done (Bug 11611 - fix possible confusion between UNIMARC and MARC21 in some sysprefs)\n";
8014 SetVersion($DBversion);
8017 $DBversion = "3.15.00.018";
8018 if ( CheckVersion($DBversion) ) {
8019 $dbh->{AutoCommit} = 0;
8020 $dbh->{RaiseError} = 1;
8023 $dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|);
8026 my $av_added = $dbh->do(q|
8027 INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
8028 SELECT 'ROADTYPE', roadtypeid, road_type, road_type
8032 my $rt_deleted = $dbh->do(q|
8033 DELETE FROM roadtype
8036 if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
8038 DROP TABLE roadtype;
8041 print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
8042 SetVersion($DBversion);
8044 print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
8048 $dbh->{AutoCommit} = 1;
8049 $dbh->{RaiseError} = 0;
8052 $DBversion = "3.15.00.019";
8053 if ( CheckVersion($DBversion) ) {
8054 $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')");
8055 print "Upgrade to $DBversion done (Bug 11256: Add system preference OpacMaxItemsToDisplay)\n";
8056 SetVersion($DBversion);
8059 $DBversion = "3.15.00.020";
8060 if ( CheckVersion($DBversion) ) {
8062 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')
8064 print "Upgrade to $DBversion done (Bug 11343: Add system preference MaxItemsForBatch )\n";
8065 SetVersion($DBversion);
8068 $DBversion = "3.15.00.021";
8069 if(CheckVersion($DBversion)) {
8071 ALTER TABLE `action_logs`
8073 ADD KEY `timestamp_idx` (`timestamp`),
8074 ADD KEY `user_idx` (`user`),
8075 ADD KEY `module_idx` (`module`(255)),
8076 ADD KEY `action_idx` (`action`(255)),
8077 ADD KEY `object_idx` (`object`),
8078 ADD KEY `info_idx` (`info`(255))
8080 print "Upgrade to $DBversion done (Bug 3445: Add indexes to action_logs table)\n";
8081 SetVersion($DBversion);
8084 $DBversion = "3.15.00.022";
8085 if (CheckVersion($DBversion)) {
8087 DELETE FROM systempreferences WHERE variable= "memberofinstitution"
8089 print "Upgrade to $DBversion done (Bug 11751: Remove memberofinstitytion system preference)\n";
8090 SetVersion($DBversion);
8093 $DBversion = "3.15.00.023";
8094 if ( CheckVersion($DBversion) ) {
8096 INSERT INTO systempreferences (variable,value,options,explanation,type)
8097 VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free');
8099 print "Upgrade to $DBversion done (Bug 10861: Add CardnumberLength syspref)\n";
8100 SetVersion ($DBversion);
8103 $DBversion = "3.15.00.024";
8104 if ( CheckVersion($DBversion) ) {
8106 DELETE FROM systempreferences WHERE variable = 'NoZebraIndexes'
8108 print "Upgrade to $DBversion done (Bug 10012 - remove last vestiges of NoZebra)\n";
8109 SetVersion($DBversion);
8112 $DBversion = "3.15.00.025";
8113 if ( CheckVersion($DBversion) ) {
8115 DROP TABLE aqorderdelivery;
8117 print "Upgrade to $DBversion done (Bug 11928 - remove unused table)\n";
8118 SetVersion($DBversion);
8121 $DBversion = "3.15.00.026";
8122 if ( CheckVersion($DBversion) ) {
8124 UPDATE language_descriptions SET description = 'Հայերեն' WHERE subtag = 'hy' AND lang = 'hy';
8126 print "Upgrade to $DBversion done (Bug 11973 - Fix Armenian language description)\n";
8127 SetVersion($DBversion);
8130 $DBversion = "3.15.00.027";
8131 if (CheckVersion($DBversion)) {
8133 ALTER TABLE opac_news ADD branchcode varchar(10) DEFAULT NULL
8135 ADD CONSTRAINT opac_news_branchcode_ibfk
8136 FOREIGN KEY (branchcode)
8137 REFERENCES branches (branchcode)
8138 ON DELETE CASCADE ON UPDATE CASCADE;
8140 print "Upgrade to $DBversion done (Bug 7567: Add branchcode to opac_news)\n";
8141 SetVersion($DBversion);
8144 $DBversion = "3.15.00.028";
8145 if(CheckVersion($DBversion)) {
8147 ALTER TABLE issuingrules ADD norenewalbefore int(4) default NULL AFTER renewalperiod
8149 print "Upgrade to $DBversion done (Bug 7413: Allow OPAC renewal x days before due date)\n";
8150 SetVersion($DBversion);
8153 $DBversion = "3.15.00.029";
8154 if ( CheckVersion($DBversion) ) {
8156 UPDATE borrower_debarments SET expiration = NULL WHERE expiration = '9999-12-31'
8158 print "Upgrade to $DBversion done (Bug 11846 - correct borrower_debarments with expiration 9999-12-31)\n";
8159 SetVersion($DBversion);
8162 $DBversion = "3.15.00.030";
8163 if(CheckVersion($DBversion)) {
8165 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')
8167 print "Upgrade to $DBversion done (Bug 12052: Add OPACMySummaryNote syspref)\n";
8168 SetVersion($DBversion);
8171 $DBversion = "3.15.00.031";
8172 if ( CheckVersion($DBversion) ) {
8173 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'writeoff', 'Write off fines and fees')");
8174 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'remaining_permissions', 'Remaining permissions for managing fines and fees')");
8175 print "Upgrade to $DBversion done (Bug 9448 - Add separate permission for writing off fees)\n";
8176 SetVersion ($DBversion);
8179 $DBversion = "3.15.00.032";
8180 if ( CheckVersion($DBversion) ) {
8181 $dbh->do("ALTER TABLE aqorders CHANGE notes order_internalnote MEDIUMTEXT;");
8182 $dbh->do("ALTER TABLE aqorders ADD COLUMN order_vendornote MEDIUMTEXT AFTER order_internalnote;");
8183 print "Upgrade to $DBversion done (Bug 9416 - In each order, add a new note made for the vendor)\n";
8184 SetVersion ($DBversion);
8187 $DBversion = "3.15.00.033";
8188 if ( CheckVersion($DBversion) ) {
8189 $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')");
8190 print "Upgrade to $DBversion done (Bug 10951: Add NoLoginInstructions pref)\n";
8191 SetVersion($DBversion);
8194 $DBversion = "3.15.00.034";
8195 if ( CheckVersion($DBversion) ) {
8196 $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')");
8197 print "Upgrade to $DBversion done (Bug 10986: system preferences to limit languages in advanced search )\n";
8198 SetVersion ($DBversion);
8201 $DBversion = "3.15.00.035";
8202 if ( CheckVersion($DBversion) ) {
8203 #insert a notice for sharing a list and accepting a share
8205 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8206 VALUES ( 'members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
8208 One of our patrons, <<borrowers.firstname>> <<borrowers.surname>>, invites you to share a list <<listname>> in our library catalog.
8210 To access this shared list, please click on the following URL or copy-and-paste it into your browser address bar.
8214 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.
8221 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8222 VALUES ( 'members', 'SHARE_ACCEPT', '', 'Notification about an accepted share', '0', 'Share on list <<listname>> accepted', 'Dear patron,
8224 We want to inform you that <<borrowers.firstname>> <<borrowers.surname>> accepted your invitation to share your list <<listname>> in our library catalog.
8230 print "Upgrade to $DBversion done (Bug 9032: Share a list)\n";
8231 SetVersion($DBversion);
8234 $DBversion = "3.15.00.036";
8235 if ( CheckVersion($DBversion) ) {
8237 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
8238 VALUES('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo')
8241 print "Upgrade to $DBversion done (Bug 10859 - Add system preference AllowMultipleIssuesOnABiblio)\n";
8242 SetVersion($DBversion);
8245 $DBversion = "3.15.00.037";
8246 if(CheckVersion($DBversion)) {
8248 ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) DEFAULT NULL AFTER checkinmsgtype
8251 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
8252 ('SIP_MEDIA_TYPE', '000', 'Other'),
8253 ('SIP_MEDIA_TYPE', '001', 'Book'),
8254 ('SIP_MEDIA_TYPE', '002', 'Magazine'),
8255 ('SIP_MEDIA_TYPE', '003', 'Bound journal'),
8256 ('SIP_MEDIA_TYPE', '004', 'Audio tape'),
8257 ('SIP_MEDIA_TYPE', '005', 'Video tape'),
8258 ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'),
8259 ('SIP_MEDIA_TYPE', '007', 'Diskette'),
8260 ('SIP_MEDIA_TYPE', '008', 'Book with diskette'),
8261 ('SIP_MEDIA_TYPE', '009', 'Book with CD'),
8262 ('SIP_MEDIA_TYPE', '010', 'Book with audio tape')
8264 print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n";
8265 SetVersion($DBversion);
8268 $DBversion = '3.15.00.038';
8269 if ( CheckVersion($DBversion) ) {
8271 INSERT INTO systempreferences (
8279 'DisplayLibraryFacets', 'holding', 'home|holding|both', 'Defines which library facets to display.', 'Choice'
8282 print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n";
8283 SetVersion ($DBversion);
8286 $DBversion = "3.15.00.039";
8287 if ( CheckVersion($DBversion) ) {
8290 ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
8294 ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
8298 ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
8302 CREATE TABLE overduerules_transport_types(
8303 id INT(11) NOT NULL AUTO_INCREMENT,
8304 branchcode varchar(10) NOT NULL DEFAULT '',
8305 categorycode VARCHAR(10) NOT NULL DEFAULT '',
8306 letternumber INT(1) NOT NULL DEFAULT 1,
8307 message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
8309 CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
8310 CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
8311 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8314 my $sth = $dbh->prepare( q{
8315 SELECT * FROM overduerules;
8319 my $sth_insert_mtt = $dbh->prepare( q{
8320 INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
8322 while ( my $row = $sth->fetchrow_hashref ) {
8323 my $branchcode = $row->{branchcode};
8324 my $categorycode = $row->{categorycode};
8325 for my $letternumber ( 1 .. 3 ) {
8326 next unless $row->{"letter$letternumber"};
8327 $sth_insert_mtt->execute(
8328 $branchcode, $categorycode, $letternumber, 'email'
8333 print "Upgrade done (Bug 9016: Adds multi transport types management for notices)\n";
8334 SetVersion($DBversion);
8337 $DBversion = "3.15.00.040";
8338 if ( CheckVersion($DBversion) ) {
8340 UPDATE message_transports SET letter_code='HOLD' WHERE letter_code='HOLD_PHONE' OR letter_code='HOLD_PRINT'
8343 UPDATE letter SET code='HOLD', message_transport_type='print' WHERE code='HOLD_PRINT'
8346 UPDATE letter SET code='HOLD', message_transport_type='phone' WHERE code='HOLD_PHONE'
8348 print "Upgrade to $DBversion done (Bug 10845: Multi transport types for holds)\n";
8349 SetVersion($DBversion);
8352 $DBversion = "3.15.00.041";
8353 if ( CheckVersion($DBversion) ) {
8354 my $name = $dbh->selectcol_arrayref(q|
8355 SELECT name FROM letter WHERE code="HOLD"
8361 message_transport_type="phone",
8363 WHERE code="HOLD_PHONE"
8369 message_transport_type="phone",
8371 WHERE code="PREDUE_PHONE"
8377 message_transport_type="phone",
8379 WHERE code="OVERDUE_PHONE"
8382 print "Upgrade to $DBversion done (Bug 11867: Update letters *_PHONE)\n";
8383 SetVersion($DBversion);
8386 $DBversion = "3.15.00.042";
8387 if ( CheckVersion($DBversion) ) {
8389 INSERT INTO systempreferences
8390 (variable,value,explanation,options,type)
8392 ('SpecifyReturnDate',0,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
8394 print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
8395 SetVersion($DBversion);
8398 $DBversion = "3.15.00.043";
8399 if ( CheckVersion($DBversion) ) {
8400 $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')");
8401 print "Upgrade to $DBversion done (Bug 7180: Added MarcFieldsToOrder syspref)\n";
8402 SetVersion ($DBversion);
8405 $DBversion = "3.15.00.044";
8406 if ( CheckVersion($DBversion) ) {
8407 $dbh->do("ALTER TABLE currency ADD isocode VARCHAR(5) default NULL AFTER symbol;");
8408 print "Upgrade to $DBversion done (Added isocode to the currency table)\n";
8409 SetVersion($DBversion);
8412 $DBversion = "3.15.00.045";
8413 if ( CheckVersion($DBversion) ) {
8415 INSERT INTO systempreferences (variable,value,explanation,options,type)
8417 'BlockExpiredPatronOpacActions',
8419 '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',
8424 $dbh->do("ALTER TABLE `categories` ADD COLUMN `BlockExpiredPatronOpacActions` TINYINT(1) DEFAULT -1 NOT NULL AFTER category_type");
8425 print "Upgraded to $DBversion done (Bug 6739 - expired patrons not blocked from opac actions)\n";
8426 SetVersion ($DBversion);
8429 $DBversion = "3.15.00.046";
8430 if ( CheckVersion($DBversion) ) {
8432 ALTER TABLE search_history ADD COLUMN type VARCHAR(16) NOT NULL DEFAULT 'biblio' AFTER query_cgi
8434 print "Upgrade to $DBversion done (Bug 10807 - Add db field search_history.type)\n";
8435 SetVersion($DBversion);
8438 $DBversion = "3.15.00.047";
8439 if ( CheckVersion($DBversion) ) {
8441 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableSearchHistory','0','','Enable or disable search history','YesNo')
8443 print "Upgrade to $DBversion done (Bug 10862: Add EnableSearchHistory syspref)\n";
8444 SetVersion($DBversion);
8447 $DBversion = "3.15.00.048";
8448 if ( CheckVersion($DBversion) ) {
8449 $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')");
8450 $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')");
8451 print "Upgrade to $DBversion done (Bug 10195: Records hidden with OpacSuppression can still be accessed)\n";
8452 SetVersion($DBversion);
8455 $DBversion = "3.15.00.049";
8456 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8457 $dbh->do("ALTER TABLE biblioitems DROP INDEX isbn");
8458 $dbh->do("ALTER TABLE biblioitems DROP INDEX issn");
8459 $dbh->do("ALTER TABLE biblioitems
8460 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8461 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8463 $dbh->do("ALTER TABLE biblioitems
8464 ADD INDEX isbn ( isbn ( 255 ) ),
8465 ADD INDEX issn ( issn ( 255 ) )
8468 $dbh->do("ALTER TABLE deletedbiblioitems DROP INDEX isbn");
8469 $dbh->do("ALTER TABLE deletedbiblioitems
8470 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8471 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8473 $dbh->do("ALTER TABLE deletedbiblioitems
8474 ADD INDEX isbn ( isbn ( 255 ) )
8477 print "Upgrade to $DBversion done (Bug 5377 - Biblioitems isbn and issn fields too small for multiple ISBN and ISSN)\n";
8478 SetVersion($DBversion);
8481 $DBversion = "3.15.00.050";
8482 if ( CheckVersion($DBversion) ) {
8484 INSERT INTO systempreferences (
8490 'AggressiveMatchOnISBN',
8492 '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',
8497 print "Upgrade to $DBversion done (Bug 10500 - Improve isbn matching when importing records)\n";
8498 SetVersion($DBversion);
8501 $DBversion = "3.15.00.051";
8502 if ( CheckVersion($DBversion) ) {
8503 print "Upgrade to $DBversion done (Koha 3.16 beta)\n";
8504 SetVersion($DBversion);
8507 $DBversion = "3.15.00.052";
8508 if ( CheckVersion($DBversion) ) {
8509 print "Upgrade to $DBversion done (Koha 3.16 RC)\n";
8510 SetVersion($DBversion);
8513 $DBversion = "3.16.00.000";
8514 if ( CheckVersion($DBversion) ) {
8515 print "Upgrade to $DBversion done (3.16.0 release)\n";
8516 SetVersion ($DBversion);
8519 $DBversion = '3.17.00.000';
8520 if ( CheckVersion($DBversion) ) {
8521 print "Upgrade to $DBversion done (there is no time to rest on our laurels)\n";
8522 SetVersion ($DBversion);
8525 $DBversion = '3.17.00.001';
8526 if ( CheckVersion($DBversion) ) {
8527 $dbh->do("UPDATE systempreferences SET variable = 'AuthoritySeparator' WHERE variable = 'authoritysep'");
8528 print "Upgrade to $DBversion done (Bug 10330 - Rename system preference authoritysep to AuthoritySeparator)\n";
8529 SetVersion ($DBversion);
8532 $DBversion = "3.17.00.002";
8533 if (CheckVersion($DBversion)) {
8534 $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')");
8536 CREATE TABLE IF NOT EXISTS `misc_files` (
8537 `file_id` int(11) NOT NULL AUTO_INCREMENT,
8538 `table_tag` varchar(255) NOT NULL,
8539 `record_id` int(11) NOT NULL,
8540 `file_name` varchar(255) NOT NULL,
8541 `file_type` varchar(255) NOT NULL,
8542 `file_description` varchar(255) DEFAULT NULL,
8543 `file_content` longblob NOT NULL, -- file content
8544 `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8545 PRIMARY KEY (`file_id`),
8546 KEY `table_tag` (`table_tag`),
8547 KEY `record_id` (`record_id`)
8548 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8550 print "Upgrade to $DBversion done (Bug 3050 - Add an option to upload scanned invoices)\n";
8551 SetVersion($DBversion);
8554 $DBversion = "3.17.00.003";
8555 if (CheckVersion($DBversion)) {
8556 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = '0|1|force' WHERE variable = 'OPACItemHolds'");
8557 print "Upgrade to $DBversion done (Bug 7825 - Changed OPACItemHolds syspref to Choice)\n";
8558 SetVersion($DBversion);
8561 $DBversion = "3.17.00.004";
8562 if (CheckVersion($DBversion)) {
8563 $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER category_type");
8564 print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
8565 SetVersion($DBversion);
8568 $DBversion = "3.17.00.005";
8569 if (CheckVersion($DBversion)) {
8571 ALTER TABLE issuingrules
8572 ADD maxsuspensiondays INT(11) DEFAULT NULL AFTER finedays;
8574 print "Upgrade to $DBversion done (Bug 12230: Add new issuing rule maxsuspensiondays)\n";
8575 SetVersion($DBversion);
8578 $DBversion = "3.17.00.006";
8579 if ( CheckVersion($DBversion) ) {
8580 $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')");
8581 $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')");
8582 print "Upgrade to $DBversion done (Bug 7720 - Ambiguity in OPAC Details location.)\n";
8583 SetVersion($DBversion);
8586 $DBversion = "3.17.00.007";
8587 if (CheckVersion($DBversion)) {
8588 $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');");
8589 print "Upgrade to $DBversion done (Bug 11629 - Add ability to update not for loan status on checkin)\n";
8590 SetVersion($DBversion);
8593 $DBversion = "3.17.00.008";
8594 if ( CheckVersion($DBversion) ) {
8596 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACAcquisitionDetails','0', '','Show the acquisition details at the OPAC','YesNo')
8598 print "Upgrade to $DBversion done (Bug 11169 - Add OPACAcquisitionDetails syspref)\n";
8599 SetVersion($DBversion);
8602 $DBversion = "3.17.00.009";
8603 if ( CheckVersion($DBversion) ) {
8605 DELETE FROM systempreferences WHERE variable = 'UseTablesortForCirc'
8608 print "Upgrade to $DBversion done (Bug 11703 - Remove UseTablesortForCirc syspref)\n";
8609 SetVersion($DBversion);
8612 $DBversion = "3.17.00.010";
8613 if ( CheckVersion($DBversion) ) {
8614 $dbh->do("DELETE FROM systempreferences WHERE variable='opacsmallimage'");
8615 print "Upgrade to $DBversion done (Bug 11347 - PROG/CCSR deprecation: Remove opacsmallimage system preference)\n";
8616 SetVersion($DBversion);
8619 $DBversion = "3.17.00.011";
8620 if ( CheckVersion($DBversion) ) {
8621 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'hr', 'language', 'Croatian','2014-07-24' )");
8622 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'hr','hrv')");
8623 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'hr', 'Hrvatski')");
8624 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'en', 'Croatian')");
8625 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'fr', 'Croate')");
8626 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'de', 'Kroatisch')");
8627 print "Upgrade to $DBversion done (Bug 12649: Add Croatian language)\n";
8628 SetVersion ($DBversion);
8631 $DBversion = "3.17.00.012";
8632 if ( CheckVersion($DBversion) ) {
8633 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowFiltersPulldownMobile'");
8634 print "Upgrade to $DBversion done ( Bug 12512 - PROG/CCSR deprecation: Remove OpacShowFiltersPulldownMobile system preference )\n";
8635 SetVersion ($DBversion);
8638 $DBversion = "3.17.00.013";
8639 if ( CheckVersion($DBversion) ) {
8640 $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')");
8641 print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n";
8642 SetVersion ($DBversion);
8645 $DBversion = '3.17.00.014';
8646 if ( CheckVersion($DBversion) ) {
8648 INSERT INTO systempreferences (variable,value,explanation,type) VALUES
8649 ('OverdueNoticeCalendar',0,'Take calendar into consideration when working out sending overdue notices','YesNo')
8651 print "Upgrade to $DBversion done (Bug 12529 - Adding a syspref to allow the overdue notices to consider the calendar when generating notices)\n";
8652 SetVersion($DBversion);
8655 $DBversion = "3.17.00.015";
8656 if ( CheckVersion($DBversion) ) {
8658 CREATE TABLE IF NOT EXISTS columns_settings (
8659 module varchar(255) NOT NULL,
8660 page varchar(255) NOT NULL,
8661 tablename varchar(255) NOT NULL,
8662 columnname varchar(255) NOT NULL,
8663 cannot_be_toggled int(1) NOT NULL DEFAULT 0,
8664 is_hidden int(1) NOT NULL DEFAULT 0,
8665 PRIMARY KEY(module, page, tablename, columnname)
8666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
8668 print "Upgrade to $DBversion done (Bug 10212 - Create new table columns_settings)\n";
8669 SetVersion ($DBversion);
8672 $DBversion = "3.17.00.016";
8673 if ( CheckVersion($DBversion) ) {
8674 $dbh->do("CREATE TABLE aqcontacts (
8675 id int(11) NOT NULL auto_increment,
8676 name varchar(100) default NULL,
8677 position varchar(100) default NULL,
8678 phone varchar(100) default NULL,
8679 altphone varchar(100) default NULL,
8680 fax varchar(100) default NULL,
8681 email varchar(100) default NULL,
8683 claimacquisition BOOLEAN NOT NULL DEFAULT 0,
8684 claimissues BOOLEAN NOT NULL DEFAULT 0,
8685 acqprimary BOOLEAN NOT NULL DEFAULT 0,
8686 serialsprimary BOOLEAN NOT NULL DEFAULT 0,
8687 booksellerid int(11) not NULL,
8689 CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
8690 REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8691 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8692 $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8693 email, notes, booksellerid, claimacquisition, claimissues, acqprimary, serialsprimary)
8694 SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8695 contnotes, id, 1, 1, 1, 1 FROM aqbooksellers;");
8696 $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8697 DROP COLUMN contpos, DROP COLUMN contphone,
8698 DROP COLUMN contaltphone, DROP COLUMN contfax,
8699 DROP COLUMN contemail, DROP COLUMN contnotes;");
8700 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
8701 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
8702 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
8703 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
8704 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
8705 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
8706 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
8707 print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8708 SetVersion($DBversion);
8711 $DBversion = "3.17.00.017";
8712 if ( CheckVersion($DBversion) ) {
8713 # Correct invalid recordtypes (should be very exceptional)
8715 UPDATE z3950servers set recordtype='biblio' WHERE recordtype NOT IN ('authority','biblio')
8717 # Correct invalid server types (should also be very exceptional)
8719 UPDATE z3950servers set type='zed' WHERE type <> 'zed'
8723 ALTER TABLE z3950servers
8725 DROP COLUMN description,
8726 DROP COLUMN position,
8727 MODIFY COLUMN id int NOT NULL AUTO_INCREMENT FIRST,
8728 MODIFY COLUMN recordtype enum('authority','biblio') NOT NULL DEFAULT 'biblio',
8729 CHANGE COLUMN name servername mediumtext NOT NULL,
8730 CHANGE COLUMN type servertype enum('zed','sru') NOT NULL DEFAULT 'zed',
8731 ADD COLUMN sru_options varchar(255) default NULL,
8732 ADD COLUMN sru_fields mediumtext default NULL,
8733 ADD COLUMN add_xslt mediumtext default NULL
8735 print "Upgrade to $DBversion done (Bug 6536: Z3950 improvements)\n";
8736 SetVersion ($DBversion);
8739 $DBversion = "3.17.00.018";
8740 if ( CheckVersion($DBversion) ) {
8741 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('HoldsInNoissuesCharge', '0', 'Hold charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
8742 print "Upgrade to $DBversion done (Bug 12205: Add HoldsInNoissuesCharge systempreference)\n";
8743 SetVersion($DBversion);
8746 $DBversion = "3.17.00.019";
8747 if ( CheckVersion($DBversion) ) {
8748 $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')"
8750 print "Upgrade to $DBversion done (Bug 6149: Operator highlighted in search results)\n";
8751 SetVersion($DBversion);
8754 $DBversion = "3.17.00.020";
8755 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8756 $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')");
8757 print "Upgrade to $DBversion done (Bug 8735 - Expire holds waiting only on days the library is open)\n";
8758 SetVersion ($DBversion);
8761 $DBversion = "3.17.00.021";
8762 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8763 my $pref = C4::Context->preference('HomeOrHoldingBranch');
8764 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
8765 VALUES ('StaffSearchResultsDisplayBranch', ?,'homebranch|holdingbranch','Controls the display of the home or holding branch for staff search results','choice')", undef, $pref);
8766 print "Upgrade to $DBversion done (Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch)\n";
8767 SetVersion ($DBversion);
8770 $DBversion = '3.17.00.022';
8771 if ( CheckVersion($DBversion) ) {
8772 my @temp= $dbh->selectrow_array(qq|
8774 FROM marc_subfield_structure
8775 WHERE kohafield='permanent_location' OR kohafield='items.permanent_location'
8777 print "Upgrade to $DBversion done (Bug 7817: Check for permanent_location)\n";
8779 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";
8781 SetVersion($DBversion);
8784 $DBversion = "3.17.00.023";
8785 if ( CheckVersion($DBversion) ) {
8787 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')
8789 print "Upgrade to $DBversion done (Bug 11169 - Add AcqItemSetSubfieldsWhenReceiptIsCancelled syspref)\n";
8790 SetVersion($DBversion);
8793 $DBversion = "3.17.00.024";
8794 if(CheckVersion($DBversion)) {
8796 ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8799 ALTER TABLE old_issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8802 ALTER TABLE issuingrules ADD auto_renew BOOLEAN default FALSE AFTER norenewalbefore
8804 print "Upgrade to $DBversion done (Bug 11577: [ENH] Automatic renewal feature)\n";
8805 SetVersion($DBversion);
8808 $DBversion = '3.17.00.025';
8809 if ( CheckVersion($DBversion) ) {
8811 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')
8813 print "Upgrade to $DBversion done (Bug 12728: Checked syspref StatisticsFields)\n";
8816 $DBversion = "3.17.00.026";
8817 if ( CheckVersion($DBversion) ) {
8818 if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
8819 $dbh->do("UPDATE marc_subfield_structure SET liblibrarian = 'Encoded bitrate', libopac = 'Encoded bitrate' WHERE tagfield = '347' AND tagsubfield = 'f'");
8820 $dbh->do("UPDATE marc_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','610','611','710','711','810','811') AND tagsubfield = 'c'");
8821 $dbh->do("UPDATE auth_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','410','411','510','511','710','711') AND tagsubfield = 'c'");
8822 print "Upgrade to $DBversion done (Bug 12435 - Update MARC21 frameworks to Update No. 18 (April 2014))\n";
8824 SetVersion($DBversion);
8827 $DBversion = "3.17.00.027";
8828 if ( CheckVersion($DBversion) ) {
8830 DELETE FROM systempreferences WHERE variable = 'SearchEngine'
8832 print "Upgrade to $DBversion done (Bug 12538 - Remove SearchEngine syspref)\n";
8833 SetVersion($DBversion);
8836 $DBversion = "3.17.00.028";
8837 if ( CheckVersion($DBversion) ) {
8839 INSERT INTO systempreferences (variable,value) VALUES('OpacCustomSearch','');
8841 print "Upgrade to $DBversion done (Bug 12296 - search box replaceable with a system preference)\n";
8842 SetVersion($DBversion);
8845 $DBversion = "3.17.00.029";
8846 if ( CheckVersion($DBversion) ) {
8847 $dbh->do("ALTER TABLE `items` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8848 $dbh->do("ALTER TABLE `deleteditems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8849 $dbh->do("ALTER TABLE `biblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8850 $dbh->do("ALTER TABLE `deletedbiblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8851 print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
8852 SetVersion ($DBversion);
8855 $DBversion = "3.17.00.030";
8856 if ( CheckVersion($DBversion) ) {
8859 INSERT INTO systempreferences (variable, value, options, explanation, type )
8861 ('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'YesNo'),
8862 ('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8863 ('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8864 ('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
8865 ('UsageStatsLibraryType', 'public', 'public|university', 'The library type to be shown on the Hea Koha community website', 'Choice'),
8866 ('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
8867 ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo')
8869 print "Upgrade to $DBversion done (Bug 11926: Add UsageStats systempreferences (HEA))\n";
8870 SetVersion ($DBversion);
8873 $DBversion = "3.17.00.031";
8874 if ( CheckVersion($DBversion) ) {
8875 $dbh->do("ALTER TABLE saved_sql CHANGE report_name report_name VARCHAR( 255 ) NOT NULL DEFAULT '' ");
8876 print "Upgrade to $DBversion done (Bug 2969: Report Name should be mandatory for saved reports)\n";
8877 SetVersion ($DBversion);
8880 $DBversion = "3.17.00.032";
8881 if ( CheckVersion($DBversion) ) {
8883 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReplytoDefault', '', NULL, 'The default email address to be set as replyto.', 'Free')"
8886 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReturnpathDefault', '', NULL, 'The default email address to be set as return-path', 'Free')"
8888 $dbh->do("ALTER TABLE branches ADD branchreplyto mediumtext AFTER branchemail");
8889 $dbh->do("ALTER TABLE branches ADD branchreturnpath mediumtext AFTER branchreplyto");
8890 print "Upgrade to $DBversion done (Bug 9530: Adding replyto and returnpath addresses.)\n";
8891 SetVersion($DBversion);
8894 $DBversion = "3.17.00.033";
8895 if ( CheckVersion($DBversion) ) {
8897 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
8898 VALUES('FacetMaxCount', '20','Specify the max facet count for each category',NULL,'Integer')
8900 print "Upgrade to $DBversion done (Bug 13088 - Allow the user to specify a max amount of facets to show)\n";
8901 SetVersion($DBversion);
8904 $DBversion = "3.17.00.034";
8905 if ( CheckVersion($DBversion) ) {
8907 ALTER TABLE aqorders DROP COLUMN cancelledby;
8910 print "Upgrade to $DBversion done (Bug 11007 - DROP column aqorders.cancelledby)\n";
8911 SetVersion($DBversion);
8914 $DBversion = "3.17.00.035";
8915 if ( CheckVersion($DBversion) ) {
8917 ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0 after claimdate
8921 SET claims_count = 1
8922 WHERE claimdate IS NOT NULL
8924 print "Upgrade to $DBversion done (Bug 5342: Add claims_count field in serial table)\n";
8925 SetVersion($DBversion);
8928 $DBversion = "3.17.00.036";
8929 if ( CheckVersion($DBversion) ) {
8930 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowLibrariesPulldownMobile'");
8931 print "Upgrade to $DBversion done ( Bug 12513 - PROG/CCSR deprecation: Remove OpacShowLibrariesPulldownMobile system preference )\n";
8932 SetVersion ($DBversion);
8935 $DBversion = "3.17.00.037";
8936 if ( CheckVersion($DBversion) ) {
8937 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlockMobile'");
8938 print "Upgrade to $DBversion done ( Bug 12246 - PROG/CCSR deprecation: Remove OpacMainUserBlockMobile system preference )\n";
8939 SetVersion ($DBversion);
8942 $DBversion = "3.17.00.038";
8943 if ( CheckVersion($DBversion) ) {
8944 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACMobileUserCSS'");
8945 print "Upgrade to $DBversion done ( Bug 12245 - PROG/CCSR deprecation: Remove OPACMobileUserCSS system preference )\n";
8946 SetVersion ($DBversion);
8949 $DBversion = "3.17.00.039";
8950 if ( CheckVersion($DBversion) ) {
8951 $dbh->do("INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
8952 ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes')");
8953 print "Upgrade to $DBversion done (Bug 12539 - PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm)\n";
8954 SetVersion ($DBversion);
8957 $DBversion = "3.17.00.040";
8958 if ( CheckVersion($DBversion) ) {
8959 my $opac_theme = C4::Context->preference( 'opacthemes' );
8960 if ( !defined $opac_theme || $opac_theme eq 'prog' || $opac_theme eq 'ccsr' ) {
8961 $dbh->do("UPDATE systempreferences SET value='bootstrap' WHERE variable='opacthemes'");
8963 print "Upgrade to $DBversion done (Bug 12223: 'prog' and 'ccsr' themes removed)\n";
8964 SetVersion($DBversion);
8967 $DBversion = "3.17.00.041";
8968 if ( CheckVersion($DBversion) ) {
8969 print "Upgrade to $DBversion done (Bug 11346: Deprecate the 'prog' and 'CCSR' themes)\n";
8970 SetVersion($DBversion);
8973 $DBversion = "3.17.00.042";
8974 if ( CheckVersion($DBversion) ) {
8975 $dbh->do("DELETE FROM systempreferences WHERE variable='yuipath'");
8976 print "Upgrade to $DBversion done (Bug 12494: Remove yuipath system preference)\n";
8977 SetVersion ($DBversion);
8980 $DBversion = "3.17.00.043";
8981 if ( CheckVersion($DBversion) ) {
8983 ALTER TABLE aqorders
8984 ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted
8986 print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n";
8987 SetVersion ($DBversion);
8990 $DBversion = "3.17.00.044";
8991 if ( CheckVersion($DBversion) ) {
8993 INSERT IGNORE INTO systempreferences
8994 (variable,value,explanation,options,type)
8995 VALUES('OnSiteCheckouts','0','Enable/Disable the on-site checkouts feature','','YesNo');
8998 INSERT IGNORE INTO systempreferences
8999 (variable,value,explanation,options,type)
9000 VALUES('OnSiteCheckoutsForce','0','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','','YesNo');
9003 ALTER TABLE issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9006 ALTER TABLE old_issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9008 print "Upgrade to $DBversion done (Bug 10860: Add new system preference OnSiteCheckouts + fields [old_]issues.onsite_checkout)\n";
9009 SetVersion($DBversion);
9012 $DBversion = "3.17.00.045";
9013 if ( CheckVersion($DBversion) ) {
9015 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9016 ('LocalHoldsPriority', '0', NULL, 'Enables the LocalHoldsPriority feature', 'YesNo'),
9017 ('LocalHoldsPriorityItemControl', 'holdingbranch', 'holdingbranch|homebranch', 'decides if the feature operates using the item''s home or holding library.', 'Choice'),
9018 ('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')
9020 print "Upgrade to $DBversion done (Bug 11126 - Make the holds system optionally give precedence to local holds)\n";
9021 SetVersion($DBversion);
9024 $DBversion = "3.17.00.046";
9025 if ( CheckVersion($DBversion) ) {
9027 CREATE TABLE IF NOT EXISTS items_search_fields (
9028 name VARCHAR(255) NOT NULL,
9029 label VARCHAR(255) NOT NULL,
9030 tagfield CHAR(3) NOT NULL,
9031 tagsubfield CHAR(1) NULL DEFAULT NULL,
9032 authorised_values_category VARCHAR(16) NULL DEFAULT NULL,
9034 CONSTRAINT items_search_fields_authorised_values_category
9035 FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
9036 ON DELETE SET NULL ON UPDATE CASCADE
9037 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9039 print "Upgrade to $DBversion done (Bug 11425: Add items_search_fields table)\n";
9040 SetVersion($DBversion);
9043 $DBversion = "3.17.00.047";
9044 if ( CheckVersion($DBversion) ) {
9046 ALTER TABLE collections
9047 CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL,
9048 ADD INDEX ( colBranchcode ),
9049 ADD CONSTRAINT collections_ibfk_1 FOREIGN KEY (colBranchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
9051 print "Upgrade to $DBversion done (Bug 8836 - Resurrect Rotating Collections)\n";
9052 SetVersion($DBversion);
9055 $DBversion = "3.17.00.048";
9056 if ( CheckVersion($DBversion) ) {
9058 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')
9060 print "Upgrade to $DBversion done (Bug 12448 - Add RentalFeesCheckoutConfirmation syspref)\n";
9061 SetVersion($DBversion);
9064 $DBversion = "3.17.00.049";
9065 if ( CheckVersion($DBversion) ) {
9066 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'am', 'language', 'Amharic','2014-10-29')");
9067 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'am','amh')");
9068 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'am', 'አማርኛ')");
9069 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'en', 'Amharic')");
9071 $dbh->do("UPDATE language_descriptions SET description = 'لعربية' WHERE subtag = 'ar' AND type = 'language' AND lang = 'ar'");
9073 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'az', 'language', 'Azerbaijani','2014-10-30')");
9074 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'az','aze')");
9075 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'az', 'Azərbaycan dili')");
9076 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'en', 'Azerbaijani')");
9078 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'be', 'language', 'Byelorussian','2014-10-30')");
9079 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'be','bel')");
9080 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'be', 'Беларуская мова')");
9081 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'en', 'Byelorussian')");
9083 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'bn', 'language', 'Bengali','2014-10-30')");
9084 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'bn','ben')");
9085 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'bn', 'বাংলা')");
9086 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'en', 'Bengali')");
9088 $dbh->do("UPDATE language_descriptions SET description = 'Български' WHERE subtag = 'bg' AND type = 'language' AND lang = 'bg'");
9089 $dbh->do("UPDATE language_descriptions SET description = 'Ceština' WHERE subtag = 'cs' AND type = 'language' AND lang = 'cs'");
9090 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικά' WHERE subtag = 'el' AND type = 'language' AND lang = 'el'");
9091 $dbh->do("UPDATE language_descriptions SET description = 'Español' WHERE subtag = 'es' AND type = 'language' AND lang = 'es'");
9093 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'eu', 'language', 'Basque','2014-10-30')");
9094 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'eu','eus')");
9095 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'eu', 'Euskera')");
9096 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'en', 'Basque')");
9098 $dbh->do("UPDATE language_descriptions SET description = 'فارسى' WHERE subtag = 'fa' AND type = 'language' AND lang = 'fa'");
9099 $dbh->do("UPDATE language_descriptions SET description = 'Suomi' WHERE subtag = 'fi' AND type = 'language' AND lang = 'fi'");
9101 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'fo', 'language', 'Faroese','2014-10-30')");
9102 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'fo','fao')");
9103 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'fo', 'Føroyskt')");
9104 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'en', 'Faroese')");
9106 $dbh->do("UPDATE language_descriptions SET description = 'Français' WHERE subtag = 'fr' AND type = 'language' AND lang = 'fr'");
9107 $dbh->do("UPDATE language_descriptions SET description = 'עִבְרִית' WHERE subtag = 'he' AND type = 'language' AND lang = 'he'");
9108 $dbh->do("UPDATE language_descriptions SET description = 'हिन्दी' WHERE subtag = 'hi' AND type = 'language' AND lang = 'hi'");
9110 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'is', 'language', 'Icelandic','2014-10-30')");
9111 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'is','ice')");
9112 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'is', 'Íslenska')");
9113 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'en', 'Icelandic')");
9115 $dbh->do("UPDATE language_descriptions SET description = '日本語' WHERE subtag = 'ja' AND type = 'language' AND lang = 'ja'");
9117 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Kannada','2014-10-30')");
9118 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka','kan')");
9119 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ಕನ್ನಡ')");
9120 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Kannada')");
9122 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'km', 'language', 'Khmer','2014-10-30')");
9123 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'km','khm')");
9124 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'km', 'language', 'km', 'ភាសាខ្មែរ')");
9125 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'km', 'language', 'en', 'Khmer')");
9127 $dbh->do("UPDATE language_descriptions SET description = '한국어' WHERE subtag = 'ko' AND type = 'language' AND lang = 'ko'");
9129 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ku', 'language', 'Kurdish','2014-05-13')");
9130 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ku','kur')");
9131 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'ku', 'کوردی')");
9132 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'en', 'Kurdish')");
9133 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'fr', 'Kurde')");
9134 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'de', 'Kurdisch')");
9135 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'es', 'Kurdo')");
9137 $dbh->do("UPDATE language_descriptions SET description = 'ພາສາລາວ' WHERE subtag = 'lo' AND type = 'language' AND lang = 'lo'");
9139 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mi', 'language', 'Maori','2014-10-30')");
9140 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mi','mri')");
9141 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'mi', 'Te Reo Māori')");
9142 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'en', 'Maori')");
9144 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mn', 'language', 'Mongolian','2014-10-30')");
9145 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mn','mon')");
9146 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'mn', 'Mонгол')");
9147 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'en', 'Mongolian')");
9149 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mr', 'language', 'Marathi','2014-10-30')");
9150 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mr','mar')");
9151 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'mr', 'मराठी')");
9152 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'en', 'Marathi')");
9154 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ms', 'language', 'Malay','2014-10-30')");
9155 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ms','may')");
9156 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'ms', 'Bahasa melayu')");
9157 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'en', 'Malay')");
9159 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'nb'");
9160 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'en'");
9161 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'fr'");
9162 $dbh->do("UPDATE language_descriptions SET description = 'Norwegisch bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'de'");
9164 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ne', 'language', 'Nepali','2014-10-30')");
9165 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ne','nep')");
9166 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)VALUES ( 'ne', 'language', 'ne', 'नेपाली')");
9167 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ne', 'language', 'en', 'Nepali')");
9169 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'pbr', 'language', 'Pangwa','2014-10-30')");
9170 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'pbr','pbr')");
9171 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'pbr', 'Ekipangwa')");
9172 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'en', 'Pangwa')");
9174 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'prs', 'language', 'Dari','2014-10-30')");
9175 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'prs','prs')");
9176 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'prs', 'درى')");
9177 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'en', 'Dari')");
9179 $dbh->do("UPDATE language_descriptions SET description = 'Português' WHERE subtag = 'pt' AND type = 'language' AND lang = 'pt'");
9180 $dbh->do("UPDATE language_descriptions SET description = 'Român' WHERE subtag = 'ro' AND type = 'language' AND lang = 'ro'");
9181 $dbh->do("UPDATE language_descriptions SET description = 'Русский' WHERE subtag = 'ru' AND type = 'language' AND lang = 'ru'");
9183 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'rw', 'language', 'Kinyarwanda','2014-10-30')");
9184 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'rw','kin')");
9185 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'rw', 'Ikinyarwanda')");
9186 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'en', 'Kinyarwanda')");
9188 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sd', 'language', 'Sindhi','2014-10-30')");
9189 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sd','snd')");
9190 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'sd', 'سنڌي')");
9191 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'en', 'Sindhi')");
9193 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sk', 'language', 'Slovak','2014-10-30')");
9194 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sk','slk')");
9195 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'sk', 'Slovenčina')");
9196 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'en', 'Slovak')");
9198 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sl', 'language', 'Slovene','2014-10-30')");
9199 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sl','slv')");
9200 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'sl', 'Slovenščina')");
9201 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'en', 'Slovene')");
9203 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sq', 'language', 'Albanian','2014-10-30')");
9204 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sq','sqi')");
9205 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'sq', 'Shqip')");
9206 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'en', 'Albanian')");
9208 $dbh->do("UPDATE language_descriptions SET description = 'Cрпски' WHERE subtag = 'sr' AND type = 'language' AND lang = 'sr'");
9210 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sw', 'language', 'Swahili','2014-10-30')");
9211 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sw','swa')");
9212 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'sw', 'Kiswahili')");
9213 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'en', 'Swahili')");
9215 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ta', 'language', 'Tamil','2014-10-30')");
9216 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ta','tam')");
9217 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'ta', 'தமிழ்')");
9218 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'en', 'Tamil')");
9220 $dbh->do("UPDATE language_descriptions SET description = 'Tetun' WHERE subtag = 'tet' AND type = 'language' AND lang = 'tet'");
9221 $dbh->do("UPDATE language_descriptions SET description = 'ภาษาไทย' WHERE subtag = 'th' AND type = 'language' AND lang = 'th'");
9223 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'tl', 'language', 'Tagalog','2014-10-30')");
9224 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'tl','tgl')");
9225 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'tl', 'Tagalog')");
9226 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'en', 'Tagalog')");
9228 $dbh->do("UPDATE language_descriptions SET description = 'Türkçe' WHERE subtag = 'tr' AND type = 'language' AND lang = 'tr'");
9229 $dbh->do("UPDATE language_descriptions SET description = 'Українська' WHERE subtag = 'uk' AND type = 'language' AND lang = 'uk'");
9230 $dbh->do("UPDATE language_descriptions SET description = 'اردو' WHERE subtag = 'ur' AND type = 'language' AND lang = 'ur'");
9232 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'vi', 'language', 'Vietnamese','2014-10-30')");
9233 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'vi','vie')");
9234 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'vi', '㗂越')");
9235 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'en', 'Vietnamese')");
9237 $dbh->do("UPDATE language_descriptions SET description = '中文' WHERE subtag = 'zh' AND type = 'language' AND lang = 'zh'");
9238 $dbh->do("UPDATE language_descriptions SET description = '' WHERE subtag = 'Arab,script' AND type = 'Arab' AND lang = 'العربية'");
9240 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Armn', 'script', 'Armenian','2014-10-30')");
9241 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Armn', 'script', 'Armn', 'Հայոց այբուբեն')");
9242 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Armn', 'script', 'en', 'Armenian')");
9244 $dbh->do("UPDATE language_descriptions SET description = 'Кирилица' WHERE subtag = 'Cyrl' AND type = 'script' AND lang = 'Cyrl'");
9246 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Ethi', 'script', 'Ethiopic','2014-10-30')");
9247 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Ethi', 'script', 'Ethi', 'ግዕዝ')");
9248 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Ethi', 'script', 'en', 'Ethiopic')");
9250 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικό αλφάβητο' WHERE subtag = 'Grek' AND type = 'script' AND lang = 'Grek'");
9251 $dbh->do("UPDATE language_descriptions SET description = '简体字' WHERE subtag = 'Hans' AND type = 'script' AND lang = 'Hans'");
9252 $dbh->do("UPDATE language_descriptions SET description = '繁體字' WHERE subtag = 'Hant' AND type = 'script' AND lang = 'Hant'");
9253 $dbh->do("UPDATE language_descriptions SET description = 'אָלֶף־בֵּית עִבְרִי' WHERE subtag = 'Hebr' AND type = 'script' AND lang = 'Hebr'");
9255 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Jpan', 'script', 'Japanese','2014-10-30')");
9256 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Jpan', 'script', 'Jpan', '漢字')");
9257 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Jpan', 'script', 'en', 'Japanese')");
9259 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Knda', 'script', 'Kannada','2014-10-30')");
9260 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Knda', 'script', 'Knda', 'ಕನ್ನಡ ಲಿಪಿ')");
9261 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Knda', 'script', 'en', 'Kannada')");
9263 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Kore', 'script', 'Korean','2014-10-30')");
9264 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Kore', 'script', 'Kore', '한글')");
9265 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Kore', 'script', 'en', 'Korean')");
9267 $dbh->do("UPDATE language_descriptions SET description = 'ອັກສອນລາວ' WHERE subtag = 'Laoo' AND type = 'script' AND lang = 'Laoo'");
9269 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AL', 'region', 'Albania','2014-10-30')");
9270 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'en', 'Albania')");
9271 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'sq', 'Shqipërisë')");
9273 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AZ', 'region', 'Azerbaijan','2014-10-30')");
9274 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'en', 'Azerbaijan')");
9275 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'az', 'Azərbaycan')");
9277 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BE', 'region', 'Belgium','2014-10-30')");
9278 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'en', 'Belgium')");
9279 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'nl', 'België')");
9281 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BR', 'region', 'Brazil','2014-10-30')");
9282 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'en', 'Brazil')");
9283 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'pt', 'Brasil')");
9285 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BY', 'region', 'Belarus','2014-10-30')");
9286 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'en', 'Belarus')");
9287 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'be', 'Беларусь')");
9289 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CA', 'region', 'fr', 'Canada')");
9291 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CH', 'region', 'Switzerland','2014-10-30')");
9292 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'en', 'Switzerland')");
9293 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'de', 'Schweiz')");
9295 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CN', 'region', 'China','2014-10-30')");
9296 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'en', 'China')");
9297 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'zh', '中国')");
9299 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CZ', 'region', 'Czech Republic','2014-10-30')");
9300 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'en', 'Czech Republic')");
9301 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'cs', 'Česká republika')");
9303 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'DE', 'region', 'Germany','2014-10-30')");
9304 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'en', 'Germany')");
9305 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'de', 'Deutschland')");
9307 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DK', 'region', 'en', 'Denmark')");
9309 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ES', 'region', 'Spain','2014-10-30')");
9310 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'en', 'Spain')");
9311 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'es', 'España')");
9313 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FI', 'region', 'Finland','2014-10-30')");
9314 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'en', 'Finland')");
9315 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'fi', 'Suomi')");
9317 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FO', 'region', 'Faroe Islands','2014-10-30')");
9318 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'en', 'Faroe Islands')");
9319 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'fo', 'Føroyar')");
9321 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'GR', 'region', 'Greece','2014-10-30')");
9322 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'en', 'Greece')");
9323 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'el', 'Ελλάδα')");
9325 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HR', 'region', 'Croatia','2014-10-30')");
9326 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'en', 'Croatia')");
9327 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'hr', 'Hrvatska')");
9329 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HU', 'region', 'Hungary','2014-10-30')");
9330 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'en', 'Hungary')");
9331 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'hu', 'Magyarország')");
9333 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ID', 'region', 'Indonesia','2014-10-30')");
9334 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'en', 'Indonesia')");
9335 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'id', 'Indonesia')");
9337 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IS', 'region', 'Iceland','2014-10-30')");
9338 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'en', 'Iceland')");
9339 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'is', 'Ísland')");
9341 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IT', 'region', 'Italy','2014-10-30')");
9342 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'en', 'Italy')");
9343 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'it', 'Italia')");
9345 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'JP', 'region', 'Japan','2014-10-30')");
9346 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'en', 'Japan')");
9347 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'ja', '日本')");
9349 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KE', 'region', 'Kenya','2014-10-30')");
9350 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'en', 'Kenya')");
9351 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'rw', 'Kenya')");
9353 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KH', 'region', 'Cambodia','2014-10-30')");
9354 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'en', 'Cambodia')");
9355 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'km', 'កម្ពុជា')");
9357 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KP', 'region', 'North Korea','2014-10-30')");
9358 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'en', 'North Korea')");
9359 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'ko', '조선민주주의인민공화국')");
9361 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'LK', 'region', 'Sri Lanka','2014-10-30')");
9362 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'en', 'Sri Lanka')");
9363 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'ta', 'இலங்கை')");
9365 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'MY', 'region', 'Malaysia','2014-10-30')");
9366 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'en', 'Malaysia')");
9367 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'ms', 'Malaysia')");
9369 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NE', 'region', 'Niger','2014-10-30')");
9370 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'en', 'Niger')");
9371 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'ne', 'Niger')");
9373 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NL', 'region', 'Netherlands','2014-10-30')");
9374 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'en', 'Netherlands')");
9375 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'nl', 'Nederland')");
9377 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NO', 'region', 'Norway','2014-10-30')");
9378 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'en', 'Norway')");
9379 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'ne', 'Noreg')");
9380 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'nn', 'Noreg')");
9382 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PH', 'region', 'Philippines','2014-10-30')");
9383 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'en', 'Philippines')");
9384 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'tl', 'Pilipinas')");
9386 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PK', 'region', 'Pakistan','2014-10-30')");
9387 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'en', 'Pakistan')");
9388 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'sd', 'پاكستان')");
9390 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PL', 'region', 'Poland','2014-10-30')");
9391 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'en', 'Poland')");
9392 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'pl', 'Polska')");
9394 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PT', 'region', 'Portugal','2014-10-30')");
9395 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'en', 'Portugal')");
9396 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'pt', 'Portugal')");
9398 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RO', 'region', 'Romania','2014-10-30')");
9399 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'en', 'Romania')");
9400 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'ro', 'România')");
9402 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RU', 'region', 'Russia','2014-10-30')");
9403 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'en', 'Russia')");
9404 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'ru', 'Россия')");
9406 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RW', 'region', 'Rwanda','2014-10-30')");
9407 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'en', 'Rwanda')");
9408 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'rw', 'Rwanda')");
9410 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SE', 'region', 'Sweden','2014-10-30')");
9411 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'en', 'Sweden')");
9412 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'sv', 'Sverige')");
9414 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SI', 'region', 'Slovenia','2014-10-30')");
9415 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'en', 'Slovenia')");
9416 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'sl', 'Slovenija')");
9418 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SK', 'region', 'Slovakia','2014-10-30')");
9419 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'en', 'Slovakia')");
9420 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'sk', 'Slovensko')");
9422 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TH', 'region', 'Thailand','2014-10-30')");
9423 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'en', 'Thailand')");
9424 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'th', 'ประเทศไทย')");
9426 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TR', 'region', 'Turkey','2014-10-30')");
9427 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'en', 'Turkey')");
9428 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'tr', 'Türkiye')");
9430 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TW', 'region', 'Taiwan','2014-10-30')");
9431 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'en', 'Taiwan')");
9432 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'zh', '台灣')");
9434 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'UA', 'region', 'Ukraine','2014-10-30')");
9435 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'en', 'Ukraine')");
9436 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'uk', 'Україна')");
9438 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'VN', 'region', 'Vietnam','2014-10-30')");
9439 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'en', 'Vietnam')");
9440 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'vi', 'Việt Nam')");
9442 print "Upgrade to $DBversion done (Bug 12250: Update descriptions for languages, scripts and regions)\n";
9443 SetVersion($DBversion);
9446 $DBversion = "3.17.00.050";
9447 if ( CheckVersion($DBversion) ) {
9449 INSERT INTO permissions (module_bit, code, description) VALUES
9450 (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)')
9452 print "Upgrade to $DBversion done (Bug 12403: Add permission tools_records_batchdelitem)\n";
9453 SetVersion($DBversion);
9456 $DBversion = "3.17.00.051";
9457 if ( CheckVersion($DBversion) ) {
9458 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('GoogleIndicTransliteration','0','','GoogleIndicTransliteration on the OPAC.','YesNo')");
9459 print "Upgrade to $DBversion done (Bug 13211: Added system preferences GoogleIndicTransliteration on the OPAC)\n";
9460 SetVersion($DBversion);
9463 $DBversion = "3.17.00.052";
9464 if ( CheckVersion($DBversion) ) {
9466 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');
9470 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');
9472 print "Upgrade to $DBversion done (Bug 9043: Add system preference OpacAdvSearchOptions and OpacAdvSearchMoreOptions)\n";
9473 SetVersion ($DBversion);
9476 $DBversion = "3.17.00.053";
9477 if ( CheckVersion($DBversion) ) {
9479 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)');
9483 INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
9487 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)');
9490 # The delete_all_items permission should be added to users having the edit_items permission.
9492 INSERT INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, module_bit, "delete_all_items" FROM user_permissions WHERE code="edit_items";
9497 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');
9501 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');
9504 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";
9505 SetVersion($DBversion);
9508 $DBversion = "3.17.00.054";
9509 if (CheckVersion($DBversion)) {
9511 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9512 ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo')
9514 print "Upgrade to $DBversion done (Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds)\n";
9515 SetVersion($DBversion);
9518 $DBversion = "3.17.00.055";
9519 if ( CheckVersion($DBversion) ) {
9520 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEnable', '0', NULL, 'Enable communication with the Norwegian national patron database.', 'YesNo')");
9521 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEndpoint', '', NULL, 'Which NL endpoint to use.', 'Free')");
9522 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBUsername', '', NULL, 'Username for communication with the Norwegian national patron database.', 'Free')");
9523 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBPassword', '', NULL, 'Password for communication with the Norwegian national patron database.', 'Free')");
9524 $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')");
9526 CREATE TABLE borrower_sync (
9527 borrowersyncid int(11) NOT NULL AUTO_INCREMENT,
9528 borrowernumber int(11) NOT NULL,
9529 synctype varchar(32) NOT NULL,
9530 sync tinyint(1) NOT NULL DEFAULT '0',
9531 syncstatus varchar(10) DEFAULT NULL,
9532 lastsync varchar(50) DEFAULT NULL,
9533 hashed_pin varchar(64) DEFAULT NULL,
9534 PRIMARY KEY (borrowersyncid),
9535 KEY borrowernumber (borrowernumber),
9536 CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9537 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
9539 print "Upgrade to $DBversion done (Bug 11401 - Add support for Norwegian national library card)\n";
9540 SetVersion($DBversion);
9543 $DBversion = "3.17.00.056";
9544 if ( CheckVersion($DBversion) ) {
9546 UPDATE systempreferences SET value = 'pubdate,itemtype,language,sorting,location' WHERE variable='OpacAdvSearchOptions'
9550 UPDATE systempreferences SET value = 'pubdate,itemtype,language,subtype,sorting,location' WHERE variable='OpacAdvSearchMoreOptions'
9553 print "Upgrade to $DBversion done (Bug 9043 - Update the values for OpacAdvSearchOptions and OpacAdvSearchOptions)\n";
9554 SetVersion($DBversion);
9557 $DBversion = "3.17.00.057";
9558 if ( CheckVersion($DBversion) ) {
9559 print "Upgrade to $DBversion done (Koha 3.18 beta)\n";
9560 SetVersion ($DBversion);
9563 $DBversion = "3.17.00.058";
9564 if( CheckVersion($DBversion) ){
9565 $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')");
9566 $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')");
9567 $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')");
9568 print "Upgrade to $DBversion done (Bug 8337: System preferences for longoverdue cron)\n";
9569 SetVersion($DBversion);
9572 $DBversion = "3.17.00.059";
9573 if ( CheckVersion($DBversion) ) {
9575 UPDATE permissions SET description = "Add and delete budgets (but can't modifiy budgets)" WHERE description = "Add and delete budgets (but cant modify budgets)";
9577 print "Upgrade to $DBversion done (Bug 10749: Fix typo in budget_add_del permission description)\n";
9578 SetVersion ($DBversion);
9581 $DBversion = "3.17.00.060";
9582 if ( CheckVersion($DBversion) ) {
9583 my $count_l = $dbh->selectcol_arrayref(q|
9584 SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
9586 my $count_mq = $dbh->selectcol_arrayref(q|
9587 SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
9589 my $count_ott = $dbh->selectcol_arrayref(q|
9590 SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
9592 my $count_mt = $dbh->selectcol_arrayref(q|
9593 SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
9595 my $count_bmtp = $dbh->selectcol_arrayref(q|
9596 SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
9600 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 ) {
9601 $deleted = $dbh->do(q|
9602 DELETE FROM message_transport_types where message_transport_type='feed'
9604 $deleted = $deleted ne '0E0' ? 1 : 0;
9607 print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
9608 SetVersion($DBversion);
9611 $DBversion = "3.18.00.000";
9612 if ( CheckVersion($DBversion) ) {
9613 print "Upgrade to $DBversion done (3.18.0 release)\n";
9614 SetVersion($DBversion);
9617 $DBversion = "3.19.00.000";
9618 if ( CheckVersion($DBversion) ) {
9619 print "Upgrade to $DBversion done (there's life after 3.18)\n";
9620 SetVersion ($DBversion);
9623 $DBversion = "3.19.00.001";
9624 if ( CheckVersion($DBversion) ) {
9626 UPDATE systempreferences
9627 SET options = 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription'
9628 WHERE variable = 'UsageStatsLibraryType'
9630 if ( C4::Context->preference("UsageStatsLibraryType") eq "university" ) {
9631 C4::Context->set_preference("UsageStatsLibraryType", "academic")
9633 print "Upgrade to $DBversion done (Bug 13436: Add more options to UsageStatsLibraryType)\n";
9634 SetVersion ($DBversion);
9637 $DBversion = "3.19.00.002";
9638 if ( CheckVersion($DBversion) ) {
9640 UPDATE suggestions SET branchcode="" WHERE branchcode="__ANY__"
9642 print "upgrade to $DBversion done (Bug 10753: replace __ANY__ with empty string in suggestions.branchcode)\n";
9643 SetVersion ($DBversion);
9646 $DBversion = "3.19.00.003";
9647 if ( CheckVersion($DBversion) ) {
9648 my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1");
9651 print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n";
9652 print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n";
9653 print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)";
9656 ALTER TABLE borrowers
9658 ADD UNIQUE userid (userid)
9660 print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n";
9663 SetVersion($DBversion);
9666 $DBversion = "3.19.00.004";
9667 if ( CheckVersion($DBversion) ) {
9668 my $pref_value = C4::Context->preference('OpacExportOptions');
9669 $pref_value =~ s/\|/,/g; # multiple is separated by ,
9671 UPDATE systempreferences
9674 WHERE variable = 'OpacExportOptions'
9675 }, {}, $pref_value );
9676 print "Upgrade to $DBversion done (Bug 13346: OpacExportOptions is now multiple)\n";
9677 SetVersion ($DBversion);
9680 $DBversion = "3.19.00.005";
9681 if(CheckVersion($DBversion)) {
9683 ALTER TABLE authorised_values MODIFY COLUMN category VARCHAR(32) NOT NULL DEFAULT ''
9687 ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
9690 print "Upgrade to $DBversion done (Bug 13379 - Modify authorised_values.category to varchar(32))\n";
9691 SetVersion($DBversion);
9694 $DBversion = "3.19.00.006";
9695 if ( CheckVersion($DBversion) ) {
9696 $dbh->do(q|SET foreign_key_checks = 0|);
9697 my $sth = $dbh->table_info( '','','','TABLE' );
9698 my ( $cat, $schema, $name, $type, $remarks );
9699 while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
9700 my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
9701 $table_sth->execute;
9702 my @table = $table_sth->fetchrow_array;
9703 unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
9704 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9707 $dbh->do(q|SET foreign_key_checks = 1|);;
9709 print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n";
9710 SetVersion($DBversion);
9713 $DBversion = "3.19.00.007";
9714 if ( CheckVersion($DBversion) ) {
9715 my $orphan_budgets = $dbh->selectall_arrayref(q|
9716 SELECT budget_id, budget_name, budget_code
9718 WHERE budget_parent_id IS NOT NULL
9719 AND budget_parent_id NOT IN (
9720 SELECT DISTINCT budget_id FROM aqbudgets
9722 |, { Slice => {} } );
9724 if ( @$orphan_budgets ) {
9725 for my $b ( @$orphan_budgets ) {
9726 print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n";
9728 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n";
9730 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n";
9732 SetVersion($DBversion);
9735 $DBversion = "3.19.00.008";
9736 if ( CheckVersion($DBversion) ) {
9737 my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
9743 WHERE b.budget_id = o.budget_id
9747 if ( $number_of_orders_not_linked->[0] > 0 ) {
9749 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)
9751 my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
9753 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 );
9755 my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
9758 SET budget_id = $budget_id
9762 WHERE b.budget_id = o.budget_id
9768 ALTER TABLE aqorders
9769 ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
9772 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";
9773 SetVersion($DBversion);
9776 $DBversion = "3.19.00.009";
9777 if ( CheckVersion($DBversion) ) {
9779 UPDATE suggestions s SET s.budgetid = NULL
9783 WHERE b.budget_id = s.budgetid
9788 ALTER TABLE suggestions
9789 ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9792 print "Upgrade to $DBversion done (Bug 13007 - Add new foreign key suggestions.budgetid)\n";
9793 SetVersion($DBversion);
9796 $DBversion = "3.19.00.010";
9797 if ( CheckVersion($DBversion) ) {
9798 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SessionRestrictionByIP','1','Check for Change in Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')");
9799 print "Upgrade to $DBversion done (Bug 5511 - SessionRestrictionByIP)\n";
9800 SetVersion ($DBversion);
9803 $DBversion = "3.19.00.011";
9804 if ( CheckVersion($DBversion) ) {
9806 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
9807 (20, 'lists', 'Lists', 0)
9810 INSERT INTO permissions (module_bit, code, description) VALUES
9811 (20, 'delete_public_lists', 'Delete public lists')
9813 print "Upgrade to $DBversion done (Bug 13417: Add permission to delete public lists)\n";
9814 SetVersion ($DBversion);
9817 $DBversion = "3.19.00.012";
9818 if(CheckVersion($DBversion)) {
9820 ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext
9824 ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext
9827 print "Upgrade to $DBversion done (Bug 13523 - Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n";
9828 SetVersion($DBversion);
9831 $DBversion = "3.19.00.013";
9832 if ( CheckVersion($DBversion) ) {
9834 INSERT INTO permissions (module_bit, code, description) VALUES
9835 (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)')
9837 print "Upgrade to $DBversion done (Bug 11395: Add permission tools_records_batchmod)\n";
9838 SetVersion($DBversion);
9841 $DBversion = "3.19.00.014";
9842 if ( CheckVersion($DBversion) ) {
9844 CREATE TABLE aqorder_users (
9845 ordernumber int(11) NOT NULL,
9846 borrowernumber int(11) NOT NULL,
9847 PRIMARY KEY (ordernumber, borrowernumber),
9848 CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9849 CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9850 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9854 INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
9855 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')
9857 print "Upgrade to $DBversion done (Bug 12648: Add letter ACQ_NOTIF_ON_RECEIV )\n";
9858 SetVersion ($DBversion);
9861 $DBversion = "3.19.00.015";
9862 if ( CheckVersion($DBversion) ) {
9864 ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id);
9866 print "Upgrade to $DBversion done (Bug 11430 - Add primary key for search_history)\n";
9867 SetVersion($DBversion);
9870 $DBversion = "3.19.00.016";
9871 if(CheckVersion($DBversion)) {
9873 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9874 ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'),
9875 ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'),
9876 ('ORDER_CANCELLATION_REASON', 2, 'Restocking')
9879 my $already_existing_reasons = $dbh->selectcol_arrayref(q{
9880 SELECT DISTINCT( cancellationreason )
9882 }, { Slice => {} });
9884 my $update_orders_sth = $dbh->prepare(q{
9886 SET cancellationreason = ?
9887 WHERE cancellationreason = ?
9890 my $insert_av_sth = $dbh->prepare(q{
9891 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9892 ('ORDER_CANCELLATION_REASON', ?, ?)
9895 for my $reason ( @$already_existing_reasons ) {
9896 next unless $reason;
9897 $insert_av_sth->execute( $i, $reason );
9898 $update_orders_sth->execute( $i, $reason );
9901 print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n";
9902 SetVersion($DBversion);
9905 $DBversion = '3.19.00.017';
9906 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
9907 # First create the column
9908 $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL");
9909 # Now update the column
9910 if (C4::Context->preference("AllowOnShelfHolds")){
9911 # Pref is on, set allow for all rules
9912 $dbh->do("UPDATE issuingrules SET onshelfholds=1");
9914 # If the preference is not set, leave off
9915 $dbh->do("UPDATE issuingrules SET onshelfholds=0");
9917 # Remove from the systempreferences table
9918 $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'");
9920 # First create the column
9921 $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL");
9922 # Now update the column
9923 my $opacitemholds = C4::Context->preference("OPACItemHolds") || '';
9924 if (lc ($opacitemholds) eq 'force') {
9925 $opacitemholds = 'F';
9928 $opacitemholds = $opacitemholds ? 'Y' : 'N';
9930 # Set allow for all rules
9931 $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'");
9933 # Remove from the systempreferences table
9934 $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'");
9936 print "Upgrade to $DBversion done (Bug 5786 - Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n";
9937 SetVersion ($DBversion);
9940 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
9942 # if there is anything in the atomicupdate, read and execute it.
9944 opendir( my $dirh, C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate' );
9945 my $old_delimiter = $/;
9947 while (readdir $dirh) {
9948 next unless $_ =~ /\.sql$/; # skip non SQL files
9949 print "DEV atomic update : $_ \n";
9950 my $installer = C4::Installer->new();
9951 my $rv = $installer->load_sql( C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/' . $_ )? 0: 1;
9957 =head2 TableExists($table)
9964 local $dbh->{PrintError} = 0;
9965 local $dbh->{RaiseError} = 1;
9966 $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
9972 =head2 DropAllForeignKeys($table)
9974 Drop all foreign keys of the table $table
9978 sub DropAllForeignKeys {
9980 # get the table description
9981 my $sth = $dbh->prepare("SHOW CREATE TABLE $table");
9983 my $vsc_structure = $sth->fetchrow;
9984 # split on CONSTRAINT keyword
9985 my @fks = split /CONSTRAINT /,$vsc_structure;
9988 # isolate what is before FOREIGN KEY, if there is something, it's a foreign key to drop
9989 $_ = /(.*) FOREIGN KEY.*/;
9992 # we have found 1 foreign, drop it
9993 $dbh->do("ALTER TABLE $table DROP FOREIGN KEY $id");
10000 =head2 TransformToNum
10002 Transform the Koha version from a 4 parts string
10003 to a number, with just 1 .
10007 sub TransformToNum {
10008 my $version = shift;
10009 # remove the 3 last . to have a Perl number
10010 $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
10011 # three X's at the end indicate that you are testing patch with dbrev
10012 # change it into 999
10013 # prevents error on a < comparison between strings (should be: lt)
10014 $version =~ s/XXX$/999/;
10020 set the DBversion in the systempreferences
10025 return if $_[0]=~ /XXX$/;
10026 #you are testing a patch with a db revision; do not change version
10027 my $kohaversion = TransformToNum($_[0]);
10028 if (C4::Context->preference('Version')) {
10029 my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
10030 $finish->execute($kohaversion);
10032 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')");
10033 $finish->execute($kohaversion);
10035 C4::Context::clear_syspref_cache(); # invalidate cached preferences
10038 =head2 CheckVersion
10040 Check whether a given update should be run when passed the proposed version
10041 number. The update will always be run if the proposed version is greater
10042 than the current database version and less than or equal to the version in
10043 kohaversion.pl. The update is also run if the version contains XXX, though
10044 this behavior will be changed following the adoption of non-linear updates
10045 as implemented in bug 7167.
10050 my ($proposed_version) = @_;
10051 my $version_number = TransformToNum($proposed_version);
10053 # The following line should be deleted when bug 7167 is pushed
10054 return 1 if ( $proposed_version =~ m/XXX/ );
10056 if ( C4::Context->preference("Version") < $version_number
10057 && $version_number <= TransformToNum( C4::Context->final_linear_version ) )