Increment version for 3.22.13 release
[koha.git] / installer / data / mysql / updatedatabase.pl
blob790feb9b6814513aebb7f095678a4446d232dd25
1 #!/usr/bin/perl
3 # Database Updater
4 # This script checks for required updates to the database.
6 # Parts copyright Catalyst IT 2011
8 # Part of the Koha Library Software www.koha-community.org
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 # Bugs/ToDo:
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!
30 use strict;
31 use warnings;
33 # CPAN modules
34 use DBI;
35 use Getopt::Long;
36 # Koha modules
37 use C4::Context;
38 use C4::Installer;
39 use Koha::Database;
40 use Koha;
41 use Koha::DateUtils;
43 use MARC::Record;
44 use MARC::File::XML ( BinaryEncoding => 'utf8' );
46 use File::Path qw(remove_tree);
47 use File::Spec;
49 # FIXME - The user might be installing a new database, so can't rely
50 # on /etc/koha.conf anyway.
52 my $debug = 0;
54 my (
55 $sth, $sti,
56 $query,
57 %existingtables, # tables already in database
58 %types,
59 $table,
60 $column,
61 $type, $null, $key, $default, $extra,
62 $prefitem, # preference item in systempreferences table
65 my $schema = Koha::Database->new()->schema();
67 my $silent;
68 GetOptions(
69 's' =>\$silent
71 my $dbh = C4::Context->dbh;
72 $|=1; # flushes output
74 local $dbh->{RaiseError} = 0;
76 # Record the version we are coming from
78 my $original_version = C4::Context->preference("Version");
80 # Deal with virtualshelves
81 my $DBversion = "3.00.00.001";
82 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
83 # update virtualshelves table to
85 $dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
86 $dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
87 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
88 $dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
89 # drop all foreign keys : otherwise, we can't drop itemnumber field.
90 DropAllForeignKeys('virtualshelfcontents');
91 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
92 # create the new foreign keys (on biblionumber)
93 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
94 # re-create the foreign key on virtualshelf
95 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
96 $dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
97 print "Upgrade to $DBversion done (virtualshelves)\n";
98 SetVersion ($DBversion);
102 $DBversion = "3.00.00.002";
103 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
104 $dbh->do("DROP TABLE sessions");
105 $dbh->do("CREATE TABLE `sessions` (
106 `id` varchar(32) NOT NULL,
107 `a_session` text NOT NULL,
108 UNIQUE KEY `id` (`id`)
109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
110 print "Upgrade to $DBversion done (sessions uses CGI::session, new table structure for sessions)\n";
111 SetVersion ($DBversion);
115 $DBversion = "3.00.00.003";
116 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
117 if (C4::Context->preference("opaclanguages") eq "fr") {
118 $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')");
119 } else {
120 $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')");
122 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
123 SetVersion ($DBversion);
127 $DBversion = "3.00.00.004";
128 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
129 $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')");
130 print "Upgrade to $DBversion done (adding DebugLevel systempref, in 'Admin' tab)\n";
131 SetVersion ($DBversion);
134 $DBversion = "3.00.00.005";
135 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
136 $dbh->do("CREATE TABLE `tags` (
137 `entry` varchar(255) NOT NULL default '',
138 `weight` bigint(20) NOT NULL default 0,
139 PRIMARY KEY (`entry`)
140 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
142 $dbh->do("CREATE TABLE `nozebra` (
143 `server` varchar(20) NOT NULL,
144 `indexname` varchar(40) NOT NULL,
145 `value` varchar(250) NOT NULL,
146 `biblionumbers` longtext NOT NULL,
147 KEY `indexname` (`server`,`indexname`),
148 KEY `value` (`server`,`value`))
149 ENGINE=InnoDB DEFAULT CHARSET=utf8;
151 print "Upgrade to $DBversion done (adding tags and nozebra tables )\n";
152 SetVersion ($DBversion);
155 $DBversion = "3.00.00.006";
156 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
157 $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate='0000-00-00'");
158 print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n";
159 SetVersion ($DBversion);
162 $DBversion = "3.00.00.007";
163 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
164 $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')");
165 print "Upgrade to $DBversion done (set SessionStorage variable)\n";
166 SetVersion ($DBversion);
169 $DBversion = "3.00.00.008";
170 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
171 $dbh->do("ALTER TABLE `biblio` ADD `datecreated` DATE NOT NULL AFTER `timestamp` ;");
172 $dbh->do("UPDATE biblio SET datecreated=timestamp");
173 print "Upgrade to $DBversion done (biblio creation date)\n";
174 SetVersion ($DBversion);
177 $DBversion = "3.00.00.009";
178 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
180 # Create backups of call number columns
181 # in case default migration needs to be customized
183 # UPGRADE NOTE: temp_upg_biblioitems_call_num should be dropped
184 # after call numbers have been transformed to the new structure
186 # Not bothering to do the same with deletedbiblioitems -- assume
187 # default is good enough.
188 $dbh->do("CREATE TABLE `temp_upg_biblioitems_call_num` AS
189 SELECT `biblioitemnumber`, `biblionumber`,
190 `classification`, `dewey`, `subclass`,
191 `lcsort`, `ccode`
192 FROM `biblioitems`");
194 # biblioitems changes
195 $dbh->do("ALTER TABLE `biblioitems` CHANGE COLUMN `volumeddesc` `volumedesc` TEXT,
196 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
197 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
198 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
199 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
200 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
201 ADD `totalissues` INT(10) AFTER `cn_sort`");
203 # default mapping of call number columns:
204 # cn_class = concatentation of classification + dewey,
205 # trimmed to fit -- assumes that most users do not
206 # populate both classification and dewey in a single record
207 # cn_item = subclass
208 # cn_source = left null
209 # cn_sort = lcsort
211 # After upgrade, cn_sort will have to be set based on whatever
212 # default call number scheme user sets as a preference. Misc
213 # script will be added at some point to do that.
215 $dbh->do("UPDATE `biblioitems`
216 SET cn_class = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
217 cn_item = subclass,
218 `cn_sort` = `lcsort`
221 # Now drop the old call number columns
222 $dbh->do("ALTER TABLE `biblioitems` DROP COLUMN `classification`,
223 DROP COLUMN `dewey`,
224 DROP COLUMN `subclass`,
225 DROP COLUMN `lcsort`,
226 DROP COLUMN `ccode`");
228 # deletedbiblio changes
229 $dbh->do("ALTER TABLE `deletedbiblio` ALTER COLUMN `frameworkcode` SET DEFAULT '',
230 DROP COLUMN `marc`,
231 ADD `datecreated` DATE NOT NULL AFTER `timestamp`");
232 $dbh->do("UPDATE deletedbiblio SET datecreated = timestamp");
234 # deletedbiblioitems changes
235 $dbh->do("ALTER TABLE `deletedbiblioitems`
236 MODIFY `publicationyear` TEXT,
237 CHANGE `volumeddesc` `volumedesc` TEXT,
238 MODIFY `collectiontitle` MEDIUMTEXT DEFAULT NULL AFTER `volumedesc`,
239 MODIFY `collectionissn` TEXT DEFAULT NULL AFTER `collectiontitle`,
240 MODIFY `collectionvolume` MEDIUMTEXT DEFAULT NULL AFTER `collectionissn`,
241 MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
242 MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
243 MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
244 MODIFY `marc` LONGBLOB,
245 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
246 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
247 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
248 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
249 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
250 ADD `totalissues` INT(10) AFTER `cn_sort`,
251 ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
252 ADD KEY `isbn` (`isbn`),
253 ADD KEY `publishercode` (`publishercode`)
256 $dbh->do("UPDATE `deletedbiblioitems`
257 SET `cn_class` = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
258 `cn_item` = `subclass`,
259 `cn_sort` = `lcsort`
261 $dbh->do("ALTER TABLE `deletedbiblioitems`
262 DROP COLUMN `classification`,
263 DROP COLUMN `dewey`,
264 DROP COLUMN `subclass`,
265 DROP COLUMN `lcsort`,
266 DROP COLUMN `ccode`
269 # deleteditems changes
270 $dbh->do("ALTER TABLE `deleteditems`
271 MODIFY `barcode` VARCHAR(20) DEFAULT NULL,
272 MODIFY `price` DECIMAL(8,2) DEFAULT NULL,
273 MODIFY `replacementprice` DECIMAL(8,2) DEFAULT NULL,
274 DROP `bulk`,
275 MODIFY `itemcallnumber` VARCHAR(30) DEFAULT NULL AFTER `wthdrawn`,
276 MODIFY `holdingbranch` VARCHAR(10) DEFAULT NULL,
277 DROP `interim`,
278 MODIFY `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER `paidfor`,
279 DROP `cutterextra`,
280 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
281 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
282 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
283 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
284 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`,
285 MODIFY `marc` LONGBLOB AFTER `uri`,
286 DROP KEY `barcode`,
287 DROP KEY `itembarcodeidx`,
288 DROP KEY `itembinoidx`,
289 DROP KEY `itembibnoidx`,
290 ADD UNIQUE KEY `delitembarcodeidx` (`barcode`),
291 ADD KEY `delitembinoidx` (`biblioitemnumber`),
292 ADD KEY `delitembibnoidx` (`biblionumber`),
293 ADD KEY `delhomebranch` (`homebranch`),
294 ADD KEY `delholdingbranch` (`holdingbranch`)");
295 $dbh->do("UPDATE deleteditems SET `ccode` = `itype`");
296 $dbh->do("ALTER TABLE deleteditems DROP `itype`");
297 $dbh->do("UPDATE `deleteditems` SET `cn_sort` = `itemcallnumber`");
299 # items changes
300 $dbh->do("ALTER TABLE `items` ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
301 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
302 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
303 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
304 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`
306 $dbh->do("ALTER TABLE `items`
307 DROP KEY `itembarcodeidx`,
308 ADD UNIQUE KEY `itembarcodeidx` (`barcode`)");
310 # map items.itype to items.ccode and
311 # set cn_sort to itemcallnumber -- as with biblioitems.cn_sort,
312 # will have to be subsequently updated per user's default
313 # classification scheme
314 $dbh->do("UPDATE `items` SET `cn_sort` = `itemcallnumber`,
315 `ccode` = `itype`");
317 $dbh->do("ALTER TABLE `items` DROP `cutterextra`,
318 DROP `itype`");
320 print "Upgrade to $DBversion done (major changes to biblio, biblioitems, items, and deleted* versions of same\n";
321 SetVersion ($DBversion);
324 $DBversion = "3.00.00.010";
325 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
326 $dbh->do("CREATE INDEX `userid` ON borrowers (`userid`) ");
327 print "Upgrade to $DBversion done (userid index added)\n";
328 SetVersion ($DBversion);
331 $DBversion = "3.00.00.011";
332 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
333 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
334 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
335 $dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
336 $dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
337 $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
338 print "Upgrade to $DBversion done (added branchcategory type)\n";
339 SetVersion ($DBversion);
342 $DBversion = "3.00.00.012";
343 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
344 $dbh->do("CREATE TABLE `class_sort_rules` (
345 `class_sort_rule` varchar(10) NOT NULL default '',
346 `description` mediumtext,
347 `sort_routine` varchar(30) NOT NULL default '',
348 PRIMARY KEY (`class_sort_rule`),
349 UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
350 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
351 $dbh->do("CREATE TABLE `class_sources` (
352 `cn_source` varchar(10) NOT NULL default '',
353 `description` mediumtext,
354 `used` tinyint(4) NOT NULL default 0,
355 `class_sort_rule` varchar(10) NOT NULL default '',
356 PRIMARY KEY (`cn_source`),
357 UNIQUE KEY `cn_source_idx` (`cn_source`),
358 KEY `used_idx` (`used`),
359 CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`)
360 REFERENCES `class_sort_rules` (`class_sort_rule`)
361 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
362 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type)
363 VALUES('DefaultClassificationSource','ddc',
364 'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'free')");
365 $dbh->do("INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
366 ('dewey', 'Default filing rules for DDC', 'Dewey'),
367 ('lcc', 'Default filing rules for LCC', 'LCC'),
368 ('generic', 'Generic call number filing rules', 'Generic')");
369 $dbh->do("INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
370 ('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
371 ('lcc', 'Library of Congress Classification', 1, 'lcc'),
372 ('udc', 'Universal Decimal Classification', 0, 'generic'),
373 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
374 ('z', 'Other/Generic Classification Scheme', 0, 'generic')");
375 print "Upgrade to $DBversion done (classification sources added)\n";
376 SetVersion ($DBversion);
379 $DBversion = "3.00.00.013";
380 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
381 $dbh->do("CREATE TABLE `import_batches` (
382 `import_batch_id` int(11) NOT NULL auto_increment,
383 `template_id` int(11) default NULL,
384 `branchcode` varchar(10) default NULL,
385 `num_biblios` int(11) NOT NULL default 0,
386 `num_items` int(11) NOT NULL default 0,
387 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
388 `overlay_action` enum('replace', 'create_new', 'use_template') NOT NULL default 'create_new',
389 `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
390 `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
391 `file_name` varchar(100),
392 `comments` mediumtext,
393 PRIMARY KEY (`import_batch_id`),
394 KEY `branchcode` (`branchcode`)
395 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
396 $dbh->do("CREATE TABLE `import_records` (
397 `import_record_id` int(11) NOT NULL auto_increment,
398 `import_batch_id` int(11) NOT NULL,
399 `branchcode` varchar(10) default NULL,
400 `record_sequence` int(11) NOT NULL default 0,
401 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
402 `import_date` DATE default NULL,
403 `marc` longblob NOT NULL,
404 `marcxml` longtext NOT NULL,
405 `marcxml_old` longtext NOT NULL,
406 `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
407 `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
408 `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted') NOT NULL default 'staged',
409 `import_error` mediumtext,
410 `encoding` varchar(40) NOT NULL default '',
411 `z3950random` varchar(40) default NULL,
412 PRIMARY KEY (`import_record_id`),
413 CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
414 REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
415 KEY `branchcode` (`branchcode`),
416 KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
418 $dbh->do("CREATE TABLE `import_record_matches` (
419 `import_record_id` int(11) NOT NULL,
420 `candidate_match_id` int(11) NOT NULL,
421 `score` int(11) NOT NULL default 0,
422 CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
423 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
424 KEY `record_score` (`import_record_id`, `score`)
425 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
426 $dbh->do("CREATE TABLE `import_biblios` (
427 `import_record_id` int(11) NOT NULL,
428 `matched_biblionumber` int(11) default NULL,
429 `control_number` varchar(25) default NULL,
430 `original_source` varchar(25) default NULL,
431 `title` varchar(128) default NULL,
432 `author` varchar(80) default NULL,
433 `isbn` varchar(14) default NULL,
434 `issn` varchar(9) default NULL,
435 `has_items` tinyint(1) NOT NULL default 0,
436 CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
437 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
438 KEY `matched_biblionumber` (`matched_biblionumber`),
439 KEY `title` (`title`),
440 KEY `isbn` (`isbn`)
441 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
442 $dbh->do("CREATE TABLE `import_items` (
443 `import_items_id` int(11) NOT NULL auto_increment,
444 `import_record_id` int(11) NOT NULL,
445 `itemnumber` int(11) default NULL,
446 `branchcode` varchar(10) default NULL,
447 `status` enum('error', 'staged', 'imported', 'reverted') NOT NULL default 'staged',
448 `marcxml` longtext NOT NULL,
449 `import_error` mediumtext,
450 PRIMARY KEY (`import_items_id`),
451 CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
452 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
453 KEY `itemnumber` (`itemnumber`),
454 KEY `branchcode` (`branchcode`)
455 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
457 $dbh->do("INSERT INTO `import_batches`
458 (`overlay_action`, `import_status`, `batch_type`, `file_name`)
459 SELECT distinct 'create_new', 'staged', 'z3950', `file`
460 FROM `marc_breeding`");
462 $dbh->do("INSERT INTO `import_records`
463 (`import_batch_id`, `import_record_id`, `record_sequence`, `marc`, `record_type`, `status`,
464 `encoding`, `z3950random`, `marcxml`, `marcxml_old`)
465 SELECT `import_batch_id`, `id`, 1, `marc`, 'biblio', 'staged', `encoding`, `z3950random`, '', ''
466 FROM `marc_breeding`
467 JOIN `import_batches` ON (`file_name` = `file`)");
469 $dbh->do("INSERT INTO `import_biblios`
470 (`import_record_id`, `title`, `author`, `isbn`)
471 SELECT `import_record_id`, `title`, `author`, `isbn`
472 FROM `marc_breeding`
473 JOIN `import_records` ON (`import_record_id` = `id`)");
475 $dbh->do("UPDATE `import_batches`
476 SET `num_biblios` = (
477 SELECT COUNT(*)
478 FROM `import_records`
479 WHERE `import_batch_id` = `import_batches`.`import_batch_id`
480 )");
482 $dbh->do("DROP TABLE `marc_breeding`");
484 print "Upgrade to $DBversion done (import_batches et al. added)\n";
485 SetVersion ($DBversion);
488 $DBversion = "3.00.00.014";
489 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
490 $dbh->do("ALTER TABLE subscription ADD lastbranch VARCHAR(4)");
491 print "Upgrade to $DBversion done (userid index added)\n";
492 SetVersion ($DBversion);
495 $DBversion = "3.00.00.015";
496 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
497 $dbh->do("CREATE TABLE `saved_sql` (
498 `id` int(11) NOT NULL auto_increment,
499 `borrowernumber` int(11) default NULL,
500 `date_created` datetime default NULL,
501 `last_modified` datetime default NULL,
502 `savedsql` text,
503 `last_run` datetime default NULL,
504 `report_name` varchar(255) default NULL,
505 `type` varchar(255) default NULL,
506 `notes` text,
507 PRIMARY KEY (`id`),
508 KEY boridx (`borrowernumber`)
509 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
510 $dbh->do("CREATE TABLE `saved_reports` (
511 `id` int(11) NOT NULL auto_increment,
512 `report_id` int(11) default NULL,
513 `report` longtext,
514 `date_run` datetime default NULL,
515 PRIMARY KEY (`id`)
516 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
517 print "Upgrade to $DBversion done (saved_sql and saved_reports added)\n";
518 SetVersion ($DBversion);
521 $DBversion = "3.00.00.016";
522 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
523 $dbh->do(" CREATE TABLE reports_dictionary (
524 id int(11) NOT NULL auto_increment,
525 name varchar(255) default NULL,
526 description text,
527 date_created datetime default NULL,
528 date_modified datetime default NULL,
529 saved_sql text,
530 area int(11) default NULL,
531 PRIMARY KEY (id)
532 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
533 print "Upgrade to $DBversion done (reports_dictionary) added)\n";
534 SetVersion ($DBversion);
537 $DBversion = "3.00.00.017";
538 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
539 $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
540 $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)");
541 $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
542 $dbh->do("UPDATE action_logs SET action_id = if (\@a, \@a:=\@a+1, \@a:=1)");
543 $dbh->do("ALTER TABLE action_logs MODIFY action_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY");
544 print "Upgrade to $DBversion done (added column to action_logs)\n";
545 SetVersion ($DBversion);
548 $DBversion = "3.00.00.018";
549 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
550 $dbh->do("ALTER TABLE `zebraqueue`
551 ADD `done` INT NOT NULL DEFAULT '0',
552 ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
554 print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
555 SetVersion ($DBversion);
558 $DBversion = "3.00.00.019";
559 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
560 $dbh->do("ALTER TABLE biblio MODIFY biblionumber INT(11) NOT NULL AUTO_INCREMENT");
561 $dbh->do("ALTER TABLE biblioitems MODIFY biblioitemnumber INT(11) NOT NULL AUTO_INCREMENT");
562 $dbh->do("ALTER TABLE items MODIFY itemnumber INT(11) NOT NULL AUTO_INCREMENT");
563 print "Upgrade to $DBversion done (made bib/item PKs auto_increment)\n";
564 SetVersion ($DBversion);
567 $DBversion = "3.00.00.020";
568 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
569 $dbh->do("ALTER TABLE deleteditems
570 DROP KEY `delitembarcodeidx`,
571 ADD KEY `delitembarcodeidx` (`barcode`)");
572 print "Upgrade to $DBversion done (dropped uniqueness of key on deleteditems.barcode)\n";
573 SetVersion ($DBversion);
576 $DBversion = "3.00.00.021";
577 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
578 $dbh->do("ALTER TABLE items CHANGE homebranch homebranch VARCHAR(10)");
579 $dbh->do("ALTER TABLE deleteditems CHANGE homebranch homebranch VARCHAR(10)");
580 $dbh->do("ALTER TABLE statistics CHANGE branch branch VARCHAR(10)");
581 $dbh->do("ALTER TABLE subscription CHANGE lastbranch lastbranch VARCHAR(10)");
582 print "Upgrade to $DBversion done (extended missed branchcode columns to 10 chars)\n";
583 SetVersion ($DBversion);
586 $DBversion = "3.00.00.022";
587 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
588 $dbh->do("ALTER TABLE items
589 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
590 $dbh->do("ALTER TABLE deleteditems
591 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
592 print "Upgrade to $DBversion done (adding damaged column to items table)\n";
593 SetVersion ($DBversion);
596 $DBversion = "3.00.00.023";
597 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
598 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
599 VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
600 print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
601 SetVersion ($DBversion);
603 $DBversion = "3.00.00.024";
604 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
605 $dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
606 print "Upgrade to $DBversion done (changing itemtype to (10))\n";
607 SetVersion ($DBversion);
610 $DBversion = "3.00.00.025";
611 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
612 $dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
613 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
614 if(C4::Context->preference('item-level_itypes')){
615 $dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
617 print "Upgrade to $DBversion done (reintroduce items.itype - fill from itemtype)\n ";
618 SetVersion ($DBversion);
621 $DBversion = "3.00.00.026";
622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
623 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
624 VALUES ('HomeOrHoldingBranch','homebranch','homebranch|holdingbranch','With independent branches turned on this decides whether to check the items holdingbranch or homebranch at circulatilon','choice')");
625 print "Upgrade to $DBversion done (adding new system preference for choosing whether homebranch or holdingbranch is checked in circulation)\n";
626 SetVersion ($DBversion);
629 $DBversion = "3.00.00.027";
630 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
631 $dbh->do("CREATE TABLE `marc_matchers` (
632 `matcher_id` int(11) NOT NULL auto_increment,
633 `code` varchar(10) NOT NULL default '',
634 `description` varchar(255) NOT NULL default '',
635 `record_type` varchar(10) NOT NULL default 'biblio',
636 `threshold` int(11) NOT NULL default 0,
637 PRIMARY KEY (`matcher_id`),
638 KEY `code` (`code`),
639 KEY `record_type` (`record_type`)
640 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
641 $dbh->do("CREATE TABLE `matchpoints` (
642 `matcher_id` int(11) NOT NULL,
643 `matchpoint_id` int(11) NOT NULL auto_increment,
644 `search_index` varchar(30) NOT NULL default '',
645 `score` int(11) NOT NULL default 0,
646 PRIMARY KEY (`matchpoint_id`),
647 CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
648 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
649 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
650 $dbh->do("CREATE TABLE `matchpoint_components` (
651 `matchpoint_id` int(11) NOT NULL,
652 `matchpoint_component_id` int(11) NOT NULL auto_increment,
653 sequence int(11) NOT NULL default 0,
654 tag varchar(3) NOT NULL default '',
655 subfields varchar(40) NOT NULL default '',
656 offset int(4) NOT NULL default 0,
657 length int(4) NOT NULL default 0,
658 PRIMARY KEY (`matchpoint_component_id`),
659 KEY `by_sequence` (`matchpoint_id`, `sequence`),
660 CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
661 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
662 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
663 $dbh->do("CREATE TABLE `matchpoint_component_norms` (
664 `matchpoint_component_id` int(11) NOT NULL,
665 `sequence` int(11) NOT NULL default 0,
666 `norm_routine` varchar(50) NOT NULL default '',
667 KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
668 CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
669 REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
670 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
671 $dbh->do("CREATE TABLE `matcher_matchpoints` (
672 `matcher_id` int(11) NOT NULL,
673 `matchpoint_id` int(11) NOT NULL,
674 CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
675 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
676 CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
677 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
678 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
679 $dbh->do("CREATE TABLE `matchchecks` (
680 `matcher_id` int(11) NOT NULL,
681 `matchcheck_id` int(11) NOT NULL auto_increment,
682 `source_matchpoint_id` int(11) NOT NULL,
683 `target_matchpoint_id` int(11) NOT NULL,
684 PRIMARY KEY (`matchcheck_id`),
685 CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
686 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
687 CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
688 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
689 CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
690 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
691 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
692 print "Upgrade to $DBversion done (added C4::Matcher serialization tables)\n ";
693 SetVersion ($DBversion);
696 $DBversion = "3.00.00.028";
697 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
698 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
699 VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
700 print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
701 SetVersion ($DBversion);
705 $DBversion = "3.00.00.029";
706 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
707 $dbh->do("ALTER TABLE `import_batches` ADD `matcher_id` int(11) NULL AFTER `import_batch_id`");
708 print "Upgrade to $DBversion done (adding matcher_id to import_batches)\n";
709 SetVersion ($DBversion);
712 $DBversion = "3.00.00.030";
713 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
714 $dbh->do("
715 CREATE TABLE services_throttle (
716 service_type varchar(10) NOT NULL default '',
717 service_count varchar(45) default NULL,
718 PRIMARY KEY (service_type)
719 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
721 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
722 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')");
723 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
724 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')");
725 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
726 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')");
727 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
728 VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free')");
729 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
730 VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo')");
731 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
732 VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo')");
733 print "Upgrade to $DBversion done (adding services throttle table and sysprefs for xISBN)\n";
734 SetVersion ($DBversion);
737 $DBversion = "3.00.00.031";
738 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
740 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryStemming',1,'If ON, enables query stemming',NULL,'YesNo')");
741 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryFuzzy',1,'If ON, enables fuzzy option for searches',NULL,'YesNo')");
742 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryWeightFields',1,'If ON, enables field weighting',NULL,'YesNo')");
743 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo')");
744 $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')");
745 $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')");
746 $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')");
747 $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')");
748 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice')");
749 $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')");
750 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortOrder',NULL,'Specify the default sort order','asc|dsc|za|az','Choice')");
751 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
752 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
753 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
754 $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')");
755 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
756 $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')");
757 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice')");
758 $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')");
759 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
760 $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')");
761 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
762 $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')");
763 $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')");
764 $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')");
765 $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')");
766 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
768 print "Upgrade to $DBversion done (adding additional system preference)\n";
769 SetVersion ($DBversion);
772 $DBversion = "3.00.00.032";
773 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
774 $dbh->do("UPDATE `marc_subfield_structure` SET `kohafield` = 'items.wthdrawn' WHERE `kohafield` = 'items.withdrawn'");
775 print "Upgrade to $DBversion done (fixed MARC framework references to items.withdrawn)\n";
776 SetVersion ($DBversion);
779 $DBversion = "3.00.00.033";
780 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
781 $dbh->do("INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0)");
782 print "Upgrade to $DBversion done (Adding permissions flag for staff member access modification. )\n";
783 SetVersion ($DBversion);
786 $DBversion = "3.00.00.034";
787 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
788 $dbh->do("ALTER TABLE `virtualshelves` ADD COLUMN `sortfield` VARCHAR(16) ");
789 print "Upgrade to $DBversion done (Adding sortfield for Virtual Shelves. )\n";
790 SetVersion ($DBversion);
793 $DBversion = "3.00.00.035";
794 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
795 $dbh->do("UPDATE marc_subfield_structure
796 SET authorised_value = 'cn_source'
797 WHERE kohafield IN ('items.cn_source', 'biblioitems.cn_source')
798 AND (authorised_value is NULL OR authorised_value = '')");
799 print "Upgrade to $DBversion done (MARC frameworks: make classification source a drop-down)\n";
800 SetVersion ($DBversion);
803 $DBversion = "3.00.00.036";
804 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
805 $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');");
806 print "Upgrade to $DBversion done (OPACItemsResultsDisplay systempreference added)\n";
807 SetVersion ($DBversion);
810 $DBversion = "3.00.00.037";
811 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
812 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactfirstname` varchar(255)");
813 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactsurname` varchar(255)");
814 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress1` varchar(255)");
815 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress2` varchar(255)");
816 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress3` varchar(255)");
817 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactzipcode` varchar(50)");
818 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactphone` varchar(50)");
819 print "Upgrade to $DBversion done (Adding Alternative Contact Person information to borrowers table)\n";
820 SetVersion ($DBversion);
823 $DBversion = "3.00.00.038";
824 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
825 $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'");
826 $dbh->do("DELETE FROM `systempreferences` WHERE variable='hideBiblioNumber'");
827 print "Upgrade to $DBversion done ('alter finesMode systempreference, remove superfluous syspref.')\n";
828 SetVersion ($DBversion);
831 $DBversion = "3.00.00.039";
832 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
833 $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')");
834 $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')");
835 $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')");
836 # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
837 print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
838 SetVersion ($DBversion);
841 $DBversion = "3.00.00.040";
842 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
843 $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')");
844 $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')");
845 print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
846 SetVersion ($DBversion);
850 $DBversion = "3.00.00.041";
851 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
852 # Strictly speaking it is not necessary to explicitly change
853 # NULL values to 0, because the ALTER TABLE statement will do that.
854 # However, setting them first avoids a warning.
855 $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL");
856 $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL");
857 $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL");
858 $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL");
859 $dbh->do("ALTER TABLE items
860 MODIFY notforloan tinyint(1) NOT NULL default 0,
861 MODIFY damaged tinyint(1) NOT NULL default 0,
862 MODIFY itemlost tinyint(1) NOT NULL default 0,
863 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
864 $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
865 $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
866 $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
867 $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
868 $dbh->do("ALTER TABLE deleteditems
869 MODIFY notforloan tinyint(1) NOT NULL default 0,
870 MODIFY damaged tinyint(1) NOT NULL default 0,
871 MODIFY itemlost tinyint(1) NOT NULL default 0,
872 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
873 print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
874 SetVersion ($DBversion);
877 $DBversion = "3.00.00.04";
878 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
879 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
880 print "Upgrade to $DBversion done (disallow NULL in aqbooksellers.name; part of fix for bug 1251)\n";
881 SetVersion ($DBversion);
884 $DBversion = "3.00.00.043";
885 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
886 $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");
887 print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
888 SetVersion ($DBversion);
891 $DBversion = "3.00.00.044";
892 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
893 $dbh->do("ALTER TABLE deletedborrowers
894 ADD `altcontactfirstname` varchar(255) default NULL,
895 ADD `altcontactsurname` varchar(255) default NULL,
896 ADD `altcontactaddress1` varchar(255) default NULL,
897 ADD `altcontactaddress2` varchar(255) default NULL,
898 ADD `altcontactaddress3` varchar(255) default NULL,
899 ADD `altcontactzipcode` varchar(50) default NULL,
900 ADD `altcontactphone` varchar(50) default NULL
902 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
903 ('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
904 ('language','en','Set the default language in the staff client.',NULL,'Languages'),
905 ('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
906 ('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
908 print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
909 SetVersion ($DBversion);
912 #-- http://www.w3.org/International/articles/language-tags/
914 #-- RFC4646
915 $DBversion = "3.00.00.045";
916 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
917 $dbh->do("
918 CREATE TABLE language_subtag_registry (
919 subtag varchar(25),
920 type varchar(25), -- language-script-region-variant-extension-privateuse
921 description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
922 added date,
923 KEY `subtag` (`subtag`)
924 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
926 #-- TODO: add suppress_scripts
927 #-- this maps three letter codes defined in iso639.2 back to their
928 #-- two letter equivilents in rfc4646 (LOC maintains iso639+)
929 $dbh->do("CREATE TABLE language_rfc4646_to_iso639 (
930 rfc4646_subtag varchar(25),
931 iso639_2_code varchar(25),
932 KEY `rfc4646_subtag` (`rfc4646_subtag`)
933 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
935 $dbh->do("CREATE TABLE language_descriptions (
936 subtag varchar(25),
937 type varchar(25),
938 lang varchar(25),
939 description varchar(255),
940 KEY `lang` (`lang`)
941 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
943 #-- bi-directional support, keyed by script subcode
944 $dbh->do("CREATE TABLE language_script_bidi (
945 rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
946 bidi varchar(3), -- rtl ltr
947 KEY `rfc4646_subtag` (`rfc4646_subtag`)
948 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
950 #-- BIDI Stuff, Arabic and Hebrew
951 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
952 VALUES( 'Arab', 'rtl')");
953 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
954 VALUES( 'Hebr', 'rtl')");
956 #-- TODO: need to map language subtags to script subtags for detection
957 #-- of bidi when script is not specified (like ar, he)
958 $dbh->do("CREATE TABLE language_script_mapping (
959 language_subtag varchar(25),
960 script_subtag varchar(25),
961 KEY `language_subtag` (`language_subtag`)
962 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
964 #-- Default mappings between script and language subcodes
965 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
966 VALUES( 'ar', 'Arab')");
967 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
968 VALUES( 'he', 'Hebr')");
970 print "Upgrade to $DBversion done (adding language subtag registry and basic BiDi support NOTE: You should import the subtag registry SQL)\n";
971 SetVersion ($DBversion);
974 $DBversion = "3.00.00.046";
975 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
976 $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
977 CHANGE `weeklength` `weeklength` int(11) default '0'");
978 $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
979 $dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
980 print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
981 SetVersion ($DBversion);
984 $DBversion = "3.00.00.047";
985 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
986 $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');");
987 print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
988 SetVersion ($DBversion);
991 $DBversion = "3.00.00.048";
992 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
993 $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
994 print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
995 SetVersion ($DBversion);
998 $DBversion = "3.00.00.049";
999 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1000 $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
1001 print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
1002 SetVersion ($DBversion);
1005 $DBversion = "3.00.00.050";
1006 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1007 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
1008 print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
1009 SetVersion ($DBversion);
1012 $DBversion = "3.00.00.051";
1013 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1014 $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
1015 print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
1016 SetVersion ($DBversion);
1019 $DBversion = "3.00.00.052";
1020 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1021 $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
1022 print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
1023 SetVersion ($DBversion);
1026 $DBversion = "3.00.00.053";
1027 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1028 $dbh->do("CREATE TABLE `printers_profile` (
1029 `prof_id` int(4) NOT NULL auto_increment,
1030 `printername` varchar(40) NOT NULL,
1031 `tmpl_id` int(4) NOT NULL,
1032 `paper_bin` varchar(20) NOT NULL,
1033 `offset_horz` float default NULL,
1034 `offset_vert` float default NULL,
1035 `creep_horz` float default NULL,
1036 `creep_vert` float default NULL,
1037 `unit` char(20) NOT NULL default 'POINT',
1038 PRIMARY KEY (`prof_id`),
1039 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1040 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1042 $dbh->do("CREATE TABLE `labels_profile` (
1043 `tmpl_id` int(4) NOT NULL,
1044 `prof_id` int(4) NOT NULL,
1045 UNIQUE KEY `tmpl_id` (`tmpl_id`),
1046 UNIQUE KEY `prof_id` (`prof_id`)
1047 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1048 print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
1049 SetVersion ($DBversion);
1052 $DBversion = "3.00.00.054";
1053 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1054 $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';");
1055 print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
1056 SetVersion ($DBversion);
1059 $DBversion = "3.00.00.055";
1060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1061 $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
1062 print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
1063 SetVersion ($DBversion);
1065 $DBversion = "3.00.00.056";
1066 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1067 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
1068 $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) ");
1069 } else {
1070 $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) ");
1072 $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
1073 print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
1074 SetVersion ($DBversion);
1077 $DBversion = "3.00.00.057";
1078 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1079 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
1080 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
1081 $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');");
1082 $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');");
1083 $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');");
1084 SetVersion ($DBversion);
1087 $DBversion = "3.00.00.058";
1088 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1089 $dbh->do("ALTER TABLE `opac_news`
1090 CHANGE `lang` `lang` VARCHAR( 25 )
1091 CHARACTER SET utf8
1092 COLLATE utf8_general_ci
1093 NOT NULL default ''");
1094 print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
1095 SetVersion ($DBversion);
1098 $DBversion = "3.00.00.059";
1099 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1101 $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
1102 `tmpl_id` int(4) NOT NULL auto_increment,
1103 `tmpl_code` char(100) default '',
1104 `tmpl_desc` char(100) default '',
1105 `page_width` float default '0',
1106 `page_height` float default '0',
1107 `label_width` float default '0',
1108 `label_height` float default '0',
1109 `topmargin` float default '0',
1110 `leftmargin` float default '0',
1111 `cols` int(2) default '0',
1112 `rows` int(2) default '0',
1113 `colgap` float default '0',
1114 `rowgap` float default '0',
1115 `active` int(1) default NULL,
1116 `units` char(20) default 'PX',
1117 `fontsize` int(4) NOT NULL default '3',
1118 PRIMARY KEY (`tmpl_id`)
1119 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1120 $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
1121 `prof_id` int(4) NOT NULL auto_increment,
1122 `printername` varchar(40) NOT NULL,
1123 `tmpl_id` int(4) NOT NULL,
1124 `paper_bin` varchar(20) NOT NULL,
1125 `offset_horz` float default NULL,
1126 `offset_vert` float default NULL,
1127 `creep_horz` float default NULL,
1128 `creep_vert` float default NULL,
1129 `unit` char(20) NOT NULL default 'POINT',
1130 PRIMARY KEY (`prof_id`),
1131 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1132 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1133 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1134 print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
1135 SetVersion ($DBversion);
1138 $DBversion = "3.00.00.060";
1139 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1140 $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
1141 `cardnumber` varchar(16) NOT NULL,
1142 `mimetype` varchar(15) NOT NULL,
1143 `imagefile` mediumblob NOT NULL,
1144 PRIMARY KEY (`cardnumber`),
1145 CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1146 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1147 print "Upgrade to $DBversion done ( Added patronimage table. )\n";
1148 SetVersion ($DBversion);
1151 $DBversion = "3.00.00.061";
1152 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1153 $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
1154 print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
1155 SetVersion ($DBversion);
1158 $DBversion = "3.00.00.062";
1159 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1160 $dbh->do("CREATE TABLE `old_issues` (
1161 `borrowernumber` int(11) default NULL,
1162 `itemnumber` int(11) default NULL,
1163 `date_due` date default NULL,
1164 `branchcode` varchar(10) default NULL,
1165 `issuingbranch` varchar(18) default NULL,
1166 `returndate` date default NULL,
1167 `lastreneweddate` date default NULL,
1168 `return` varchar(4) default NULL,
1169 `renewals` tinyint(4) default NULL,
1170 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1171 `issuedate` date default NULL,
1172 KEY `old_issuesborridx` (`borrowernumber`),
1173 KEY `old_issuesitemidx` (`itemnumber`),
1174 KEY `old_bordate` (`borrowernumber`,`timestamp`),
1175 CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1176 ON DELETE SET NULL ON UPDATE SET NULL,
1177 CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1178 ON DELETE SET NULL ON UPDATE SET NULL
1179 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1180 $dbh->do("CREATE TABLE `old_reserves` (
1181 `borrowernumber` int(11) default NULL,
1182 `reservedate` date default NULL,
1183 `biblionumber` int(11) default NULL,
1184 `constrainttype` varchar(1) default NULL,
1185 `branchcode` varchar(10) default NULL,
1186 `notificationdate` date default NULL,
1187 `reminderdate` date default NULL,
1188 `cancellationdate` date default NULL,
1189 `reservenotes` mediumtext,
1190 `priority` smallint(6) default NULL,
1191 `found` varchar(1) default NULL,
1192 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1193 `itemnumber` int(11) default NULL,
1194 `waitingdate` date default NULL,
1195 KEY `old_reserves_borrowernumber` (`borrowernumber`),
1196 KEY `old_reserves_biblionumber` (`biblionumber`),
1197 KEY `old_reserves_itemnumber` (`itemnumber`),
1198 KEY `old_reserves_branchcode` (`branchcode`),
1199 CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1200 ON DELETE SET NULL ON UPDATE SET NULL,
1201 CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1202 ON DELETE SET NULL ON UPDATE SET NULL,
1203 CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1204 ON DELETE SET NULL ON UPDATE SET NULL
1205 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1207 # move closed transactions to old_* tables
1208 $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
1209 $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
1210 $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1211 $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1213 print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
1214 SetVersion ($DBversion);
1217 $DBversion = "3.00.00.063";
1218 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1219 $dbh->do("ALTER TABLE deleteditems
1220 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
1221 ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
1222 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1223 $dbh->do("ALTER TABLE items
1224 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
1225 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1226 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";
1227 SetVersion ($DBversion);
1230 $DBversion = "3.00.00.064";
1231 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1232 $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');");
1233 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
1234 $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
1235 $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
1236 $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
1237 print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
1238 SetVersion ($DBversion);
1241 $DBversion = "3.00.00.065";
1242 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1243 $dbh->do("CREATE TABLE `patroncards` (
1244 `cardid` int(11) NOT NULL auto_increment,
1245 `batch_id` varchar(10) NOT NULL default '1',
1246 `borrowernumber` int(11) NOT NULL,
1247 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1248 PRIMARY KEY (`cardid`),
1249 KEY `patroncards_ibfk_1` (`borrowernumber`),
1250 CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1251 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1252 print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
1253 SetVersion ($DBversion);
1256 $DBversion = "3.00.00.066";
1257 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1258 $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
1259 DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
1261 print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
1262 SetVersion ($DBversion);
1265 $DBversion = "3.00.00.067";
1266 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1267 $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
1268 print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
1269 SetVersion ($DBversion);
1272 $DBversion = "3.00.00.068";
1273 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1274 $dbh->do("CREATE TABLE `permissions` (
1275 `module_bit` int(11) NOT NULL DEFAULT 0,
1276 `code` varchar(30) DEFAULT NULL,
1277 `description` varchar(255) DEFAULT NULL,
1278 PRIMARY KEY (`module_bit`, `code`),
1279 CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
1280 ON DELETE CASCADE ON UPDATE CASCADE
1281 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1282 $dbh->do("CREATE TABLE `user_permissions` (
1283 `borrowernumber` int(11) NOT NULL DEFAULT 0,
1284 `module_bit` int(11) NOT NULL DEFAULT 0,
1285 `code` varchar(30) DEFAULT NULL,
1286 CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1287 ON DELETE CASCADE ON UPDATE CASCADE,
1288 CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
1289 REFERENCES `permissions` (`module_bit`, `code`)
1290 ON DELETE CASCADE ON UPDATE CASCADE
1291 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1293 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
1294 (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
1295 (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
1296 (13, 'edit_calendar', 'Define days when the library is closed'),
1297 (13, 'moderate_comments', 'Moderate patron comments'),
1298 (13, 'edit_notices', 'Define notices'),
1299 (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
1300 (13, 'view_system_logs', 'Browse the system logs'),
1301 (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
1302 (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
1303 (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
1304 (13, 'export_catalog', 'Export bibliographic and holdings data'),
1305 (13, 'import_patrons', 'Import patron data'),
1306 (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
1307 (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
1308 (13, 'schedule_tasks', 'Schedule tasks to run')");
1310 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
1312 print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
1313 SetVersion ($DBversion);
1315 $DBversion = "3.00.00.069";
1316 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1317 $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
1318 print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
1319 SetVersion ($DBversion);
1322 $DBversion = "3.00.00.070";
1323 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1324 $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
1325 $sth->execute;
1326 my ($value) = $sth->fetchrow;
1327 $value =~ s/2.3.1/2.5.1/;
1328 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
1329 print "Update yuipath syspref to 2.5.1 if necessary\n";
1330 SetVersion ($DBversion);
1333 $DBversion = "3.00.00.071";
1334 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1335 $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
1336 # fill the new field with the previous systempreference value, then drop the syspref
1337 my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
1338 $sth->execute;
1339 my ($serialsadditems) = $sth->fetchrow();
1340 $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
1341 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1342 print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
1343 SetVersion ($DBversion);
1346 $DBversion = "3.00.00.072";
1347 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1348 $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring mediumtext DEFAULT NULL AFTER printingtype");
1349 print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
1350 SetVersion ($DBversion);
1353 $DBversion = "3.00.00.073";
1354 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1355 $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
1356 $dbh->do(q#
1357 CREATE TABLE `tags_all` (
1358 `tag_id` int(11) NOT NULL auto_increment,
1359 `borrowernumber` int(11) NOT NULL,
1360 `biblionumber` int(11) NOT NULL,
1361 `term` varchar(255) NOT NULL,
1362 `language` int(4) default NULL,
1363 `date_created` datetime NOT NULL,
1364 PRIMARY KEY (`tag_id`),
1365 KEY `tags_borrowers_fk_1` (`borrowernumber`),
1366 KEY `tags_biblionumber_fk_1` (`biblionumber`),
1367 CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
1368 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1369 CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1370 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1371 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1373 $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
1374 $dbh->do(q#
1375 CREATE TABLE `tags_approval` (
1376 `term` varchar(255) NOT NULL,
1377 `approved` int(1) NOT NULL default '0',
1378 `date_approved` datetime default NULL,
1379 `approved_by` int(11) default NULL,
1380 `weight_total` int(9) NOT NULL default '1',
1381 PRIMARY KEY (`term`),
1382 KEY `tags_approval_borrowers_fk_1` (`approved_by`),
1383 CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
1384 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1385 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1387 $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
1388 $dbh->do(q#
1389 CREATE TABLE `tags_index` (
1390 `term` varchar(255) NOT NULL,
1391 `biblionumber` int(11) NOT NULL,
1392 `weight` int(9) NOT NULL default '1',
1393 PRIMARY KEY (`term`,`biblionumber`),
1394 KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
1395 CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
1396 REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
1397 CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1398 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1399 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1401 $dbh->do(q#
1402 INSERT INTO `systempreferences` VALUES
1403 ('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=',''),
1404 ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
1405 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
1406 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
1407 ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
1408 ('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.',''),
1409 ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
1410 ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
1411 ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
1412 ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
1413 ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
1415 print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
1416 SetVersion ($DBversion);
1419 $DBversion = "3.00.00.074";
1420 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1421 $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
1422 where imageurl not like 'http%'
1423 and imageurl is not NULL
1424 and imageurl != '') );
1425 print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
1426 SetVersion ($DBversion);
1429 $DBversion = "3.00.00.075";
1430 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1431 $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
1432 print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
1433 SetVersion ($DBversion);
1436 $DBversion = "3.00.00.076";
1437 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1438 $dbh->do("ALTER TABLE import_batches
1439 ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
1440 $dbh->do("ALTER TABLE import_batches
1441 ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
1442 NOT NULL default 'always_add' AFTER nomatch_action");
1443 $dbh->do("ALTER TABLE import_batches
1444 MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
1445 NOT NULL default 'create_new'");
1446 $dbh->do("ALTER TABLE import_records
1447 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
1448 'ignored') NOT NULL default 'staged'");
1449 $dbh->do("ALTER TABLE import_items
1450 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
1452 print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
1453 SetVersion ($DBversion);
1456 $DBversion = "3.00.00.077";
1457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1458 # drop these tables only if they exist and none of them are empty
1459 # these tables are not defined in the packaged 2.2.9, but since it is believed
1460 # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
1461 # some care is taken.
1462 my ($print_error) = $dbh->{PrintError};
1463 $dbh->{PrintError} = 0;
1464 my ($raise_error) = $dbh->{RaiseError};
1465 $dbh->{RaiseError} = 1;
1467 my $count = 0;
1468 my $do_drop = 1;
1469 eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
1470 if ($count > 0) {
1471 $do_drop = 0;
1473 eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
1474 if ($count > 0) {
1475 $do_drop = 0;
1477 eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
1478 if ($count > 0) {
1479 $do_drop = 0;
1482 if ($do_drop) {
1483 $dbh->do("DROP TABLE IF EXISTS `categorytable`");
1484 $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
1485 $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
1488 $dbh->{PrintError} = $print_error;
1489 $dbh->{RaiseError} = $raise_error;
1490 print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
1491 SetVersion ($DBversion);
1494 $DBversion = "3.00.00.078";
1495 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1496 my ($print_error) = $dbh->{PrintError};
1497 $dbh->{PrintError} = 0;
1499 unless ($dbh->do("SELECT 1 FROM browser")) {
1500 $dbh->{PrintError} = $print_error;
1501 $dbh->do("CREATE TABLE `browser` (
1502 `level` int(11) NOT NULL,
1503 `classification` varchar(20) NOT NULL,
1504 `description` varchar(255) NOT NULL,
1505 `number` bigint(20) NOT NULL,
1506 `endnode` tinyint(4) NOT NULL
1507 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1509 $dbh->{PrintError} = $print_error;
1510 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1511 SetVersion ($DBversion);
1514 $DBversion = "3.00.00.079";
1515 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1516 my ($print_error) = $dbh->{PrintError};
1517 $dbh->{PrintError} = 0;
1519 $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
1520 ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
1521 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1522 SetVersion ($DBversion);
1525 $DBversion = "3.00.00.080";
1526 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1527 $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
1528 $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
1529 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
1530 print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
1531 SetVersion ($DBversion);
1534 $DBversion = "3.00.00.081";
1535 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1536 $dbh->do("CREATE TABLE `borrower_attribute_types` (
1537 `code` varchar(10) NOT NULL,
1538 `description` varchar(255) NOT NULL,
1539 `repeatable` tinyint(1) NOT NULL default 0,
1540 `unique_id` tinyint(1) NOT NULL default 0,
1541 `opac_display` tinyint(1) NOT NULL default 0,
1542 `password_allowed` tinyint(1) NOT NULL default 0,
1543 `staff_searchable` tinyint(1) NOT NULL default 0,
1544 `authorised_value_category` varchar(10) default NULL,
1545 PRIMARY KEY (`code`)
1546 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1547 $dbh->do("CREATE TABLE `borrower_attributes` (
1548 `borrowernumber` int(11) NOT NULL,
1549 `code` varchar(10) NOT NULL,
1550 `attribute` varchar(30) default NULL,
1551 `password` varchar(30) default NULL,
1552 KEY `borrowernumber` (`borrowernumber`),
1553 KEY `code_attribute` (`code`, `attribute`),
1554 CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1555 ON DELETE CASCADE ON UPDATE CASCADE,
1556 CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1557 ON DELETE CASCADE ON UPDATE CASCADE
1558 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1559 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
1560 print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
1561 SetVersion ($DBversion);
1564 $DBversion = "3.00.00.082";
1565 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1566 $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
1567 print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
1568 SetVersion ($DBversion);
1571 $DBversion = "3.00.00.083";
1572 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1573 $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
1574 print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
1575 SetVersion ($DBversion);
1577 $DBversion = "3.00.00.084";
1578 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1579 $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')");
1580 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
1581 print "Upgrade to $DBversion done (add new sysprefs)\n";
1582 SetVersion ($DBversion);
1585 $DBversion = "3.00.00.085";
1586 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1587 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1588 $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
1589 $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
1590 $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
1591 $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
1592 $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
1593 $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
1595 print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
1596 SetVersion ($DBversion);
1599 $DBversion = "3.00.00.086";
1600 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1601 $dbh->do(
1602 "CREATE TABLE `tmp_holdsqueue` (
1603 `biblionumber` int(11) default NULL,
1604 `itemnumber` int(11) default NULL,
1605 `barcode` varchar(20) default NULL,
1606 `surname` mediumtext NOT NULL,
1607 `firstname` text,
1608 `phone` text,
1609 `borrowernumber` int(11) NOT NULL,
1610 `cardnumber` varchar(16) default NULL,
1611 `reservedate` date default NULL,
1612 `title` mediumtext,
1613 `itemcallnumber` varchar(30) default NULL,
1614 `holdingbranch` varchar(10) default NULL,
1615 `pickbranch` varchar(10) default NULL,
1616 `notes` text
1617 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1619 $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')");
1620 $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')");
1622 print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
1623 SetVersion ($DBversion);
1626 $DBversion = "3.00.00.087";
1627 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1628 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
1629 $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')");
1630 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1631 SetVersion ($DBversion);
1634 $DBversion = "3.00.00.088";
1635 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1636 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
1637 $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')");
1638 $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')");
1639 $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')");
1640 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1641 SetVersion ($DBversion);
1644 $DBversion = "3.00.00.089";
1645 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1646 $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')");
1647 print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
1648 SetVersion ($DBversion);
1651 $DBversion = "3.00.00.090";
1652 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1653 $dbh->do("
1654 CREATE TABLE `branch_borrower_circ_rules` (
1655 `branchcode` VARCHAR(10) NOT NULL,
1656 `categorycode` VARCHAR(10) NOT NULL,
1657 `maxissueqty` int(4) default NULL,
1658 PRIMARY KEY (`categorycode`, `branchcode`),
1659 CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1660 ON DELETE CASCADE ON UPDATE CASCADE,
1661 CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1662 ON DELETE CASCADE ON UPDATE CASCADE
1663 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1665 $dbh->do("
1666 CREATE TABLE `default_borrower_circ_rules` (
1667 `categorycode` VARCHAR(10) NOT NULL,
1668 `maxissueqty` int(4) default NULL,
1669 PRIMARY KEY (`categorycode`),
1670 CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1671 ON DELETE CASCADE ON UPDATE CASCADE
1672 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1674 $dbh->do("
1675 CREATE TABLE `default_branch_circ_rules` (
1676 `branchcode` VARCHAR(10) NOT NULL,
1677 `maxissueqty` int(4) default NULL,
1678 PRIMARY KEY (`branchcode`),
1679 CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1680 ON DELETE CASCADE ON UPDATE CASCADE
1681 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1683 $dbh->do("
1684 CREATE TABLE `default_circ_rules` (
1685 `singleton` enum('singleton') NOT NULL default 'singleton',
1686 `maxissueqty` int(4) default NULL,
1687 PRIMARY KEY (`singleton`)
1688 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1690 print "Upgrade to $DBversion done (added several circ rules tables)\n";
1691 SetVersion ($DBversion);
1695 $DBversion = "3.00.00.091";
1696 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1697 $dbh->do(<<'END_SQL');
1698 ALTER TABLE borrowers
1699 ADD `smsalertnumber` varchar(50) default NULL
1700 END_SQL
1702 $dbh->do(<<'END_SQL');
1703 CREATE TABLE `message_attributes` (
1704 `message_attribute_id` int(11) NOT NULL auto_increment,
1705 `message_name` varchar(20) NOT NULL default '',
1706 `takes_days` tinyint(1) NOT NULL default '0',
1707 PRIMARY KEY (`message_attribute_id`),
1708 UNIQUE KEY `message_name` (`message_name`)
1709 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1710 END_SQL
1712 $dbh->do(<<'END_SQL');
1713 CREATE TABLE `message_transport_types` (
1714 `message_transport_type` varchar(20) NOT NULL,
1715 PRIMARY KEY (`message_transport_type`)
1716 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1717 END_SQL
1719 $dbh->do(<<'END_SQL');
1720 CREATE TABLE `message_transports` (
1721 `message_attribute_id` int(11) NOT NULL,
1722 `message_transport_type` varchar(20) NOT NULL,
1723 `is_digest` tinyint(1) NOT NULL default '0',
1724 `letter_module` varchar(20) NOT NULL default '',
1725 `letter_code` varchar(20) NOT NULL default '',
1726 PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
1727 KEY `message_transport_type` (`message_transport_type`),
1728 KEY `letter_module` (`letter_module`,`letter_code`),
1729 CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1730 CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
1731 CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
1732 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1733 END_SQL
1735 $dbh->do(<<'END_SQL');
1736 CREATE TABLE `borrower_message_preferences` (
1737 `borrower_message_preference_id` int(11) NOT NULL auto_increment,
1738 `borrowernumber` int(11) NOT NULL default '0',
1739 `message_attribute_id` int(11) default '0',
1740 `days_in_advance` int(11) default '0',
1741 `wants_digets` tinyint(1) NOT NULL default '0',
1742 PRIMARY KEY (`borrower_message_preference_id`),
1743 KEY `borrowernumber` (`borrowernumber`),
1744 KEY `message_attribute_id` (`message_attribute_id`),
1745 CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1746 CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
1747 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1748 END_SQL
1750 $dbh->do(<<'END_SQL');
1751 CREATE TABLE `borrower_message_transport_preferences` (
1752 `borrower_message_preference_id` int(11) NOT NULL default '0',
1753 `message_transport_type` varchar(20) NOT NULL default '0',
1754 PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1755 KEY `message_transport_type` (`message_transport_type`),
1756 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,
1757 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
1758 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1759 END_SQL
1761 $dbh->do(<<'END_SQL');
1762 CREATE TABLE `message_queue` (
1763 `message_id` int(11) NOT NULL auto_increment,
1764 `borrowernumber` int(11) NOT NULL,
1765 `subject` text,
1766 `content` text,
1767 `message_transport_type` varchar(20) NOT NULL,
1768 `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
1769 `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1770 KEY `message_id` (`message_id`),
1771 KEY `borrowernumber` (`borrowernumber`),
1772 KEY `message_transport_type` (`message_transport_type`),
1773 CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1774 CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
1775 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1776 END_SQL
1778 $dbh->do(<<'END_SQL');
1779 INSERT INTO `systempreferences`
1780 (variable,value,explanation,options,type)
1781 VALUES
1782 ('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
1783 END_SQL
1785 $dbh->do( <<'END_SQL');
1786 INSERT INTO `letter`
1787 (module, code, name, title, content)
1788 VALUES
1789 ('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>>'),
1790 ('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
1791 ('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>>'),
1792 ('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
1793 ('circulation','EVENT','Upcoming Library Event','Upcoming Library Event','Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nThis is a reminder of an upcoming library event in which you have expressed interest.');
1794 END_SQL
1796 my @sql_scripts = (
1797 'installer/data/mysql/en/mandatory/message_transport_types.sql',
1798 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
1799 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
1802 my $installer = C4::Installer->new();
1803 foreach my $script ( @sql_scripts ) {
1804 my $full_path = $installer->get_file_path_from_name($script);
1805 my $error = $installer->load_sql($full_path);
1806 warn $error if $error;
1809 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";
1810 SetVersion ($DBversion);
1813 $DBversion = "3.00.00.092";
1814 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1815 $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')");
1816 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
1817 print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
1818 SetVersion ($DBversion);
1821 $DBversion = "3.00.00.093";
1822 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1823 $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1824 $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1825 print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
1826 SetVersion ($DBversion);
1829 $DBversion = "3.00.00.094";
1830 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1831 $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
1832 print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
1833 SetVersion ($DBversion);
1836 $DBversion = "3.00.00.095";
1837 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1838 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1839 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
1840 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
1842 print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
1843 SetVersion ($DBversion);
1846 $DBversion = "3.00.00.096";
1847 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1848 $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
1849 $sth->execute();
1850 if (my $row = $sth->fetchrow_hashref) {
1851 $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
1853 print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
1854 SetVersion ($DBversion);
1857 $DBversion = '3.00.00.097';
1858 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1860 $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
1861 $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
1862 $dbh->do('ALTER TABLE message_queue ADD content_type text');
1863 $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
1865 print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
1866 SetVersion($DBversion);
1869 $DBversion = '3.00.00.098';
1870 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1872 $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
1873 $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
1875 print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
1876 SetVersion($DBversion);
1879 $DBversion = '3.00.00.099';
1880 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1881 $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')");
1882 print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
1883 SetVersion($DBversion);
1886 $DBversion = '3.00.00.100';
1887 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1888 $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
1889 print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
1890 SetVersion($DBversion);
1893 $DBversion = '3.00.00.101';
1894 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1895 $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1896 $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1897 print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
1898 SetVersion($DBversion);
1901 $DBversion = '3.00.00.102';
1902 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1903 $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
1904 $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
1905 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
1906 # before setting constraint, delete any unvalid data
1907 $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
1908 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
1909 print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
1910 SetVersion($DBversion);
1913 $DBversion = "3.00.00.103";
1914 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1915 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1916 print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
1917 SetVersion ($DBversion);
1920 $DBversion = "3.00.00.104";
1921 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1922 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1923 print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
1924 SetVersion ($DBversion);
1927 $DBversion = '3.00.00.105';
1928 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
1930 # it is possible that this syspref is already defined since the feature was added some time ago.
1931 unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
1932 $dbh->do(<<'END_SQL');
1933 INSERT INTO `systempreferences`
1934 (variable,value,explanation,options,type)
1935 VALUES
1936 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
1937 END_SQL
1939 print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
1940 SetVersion($DBversion);
1943 $DBversion = "3.00.00.106";
1944 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1945 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1947 # db revision 105 didn't apply correctly, so we're rolling this into 106
1948 $dbh->do("INSERT INTO `systempreferences`
1949 (variable,value,explanation,options,type)
1950 VALUES
1951 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
1953 print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
1954 $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
1955 $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
1956 SetVersion ($DBversion);
1959 $DBversion = '3.00.00.107';
1960 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1961 $dbh->do(<<'END_SQL');
1962 UPDATE systempreferences
1963 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
1964 WHERE variable = 'OPACShelfBrowser'
1965 AND explanation NOT LIKE '%WARNING%'
1966 END_SQL
1967 $dbh->do(<<'END_SQL');
1968 UPDATE systempreferences
1969 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
1970 WHERE variable = 'CataloguingLog'
1971 AND explanation NOT LIKE '%WARNING%'
1972 END_SQL
1973 $dbh->do(<<'END_SQL');
1974 UPDATE systempreferences
1975 SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
1976 WHERE variable = 'NoZebra'
1977 AND explanation NOT LIKE '%WARNING%'
1978 END_SQL
1979 print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
1980 SetVersion ($DBversion);
1983 $DBversion = '3.01.00.000';
1984 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1985 print "Upgrade to $DBversion done (start of 3.1)\n";
1986 SetVersion ($DBversion);
1989 $DBversion = '3.01.00.001';
1990 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1991 $dbh->do("
1992 CREATE TABLE hold_fill_targets (
1993 `borrowernumber` int(11) NOT NULL,
1994 `biblionumber` int(11) NOT NULL,
1995 `itemnumber` int(11) NOT NULL,
1996 `source_branchcode` varchar(10) default NULL,
1997 `item_level_request` tinyint(4) NOT NULL default 0,
1998 PRIMARY KEY `itemnumber` (`itemnumber`),
1999 KEY `bib_branch` (`biblionumber`, `source_branchcode`),
2000 CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
2001 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2002 CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
2003 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2004 CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
2005 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2006 CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
2007 REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2008 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2010 $dbh->do("
2011 ALTER TABLE tmp_holdsqueue
2012 ADD item_level_request tinyint(4) NOT NULL default 0
2015 print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
2016 SetVersion($DBversion);
2019 $DBversion = '3.01.00.002';
2020 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2021 # use statistics where available
2022 $dbh->do("
2023 ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
2025 $dbh->do("
2026 UPDATE issues iss
2027 SET issuedate = (
2028 SELECT max(datetime)
2029 FROM statistics
2030 WHERE type = 'issue'
2031 AND itemnumber = iss.itemnumber
2032 AND borrowernumber = iss.borrowernumber
2034 WHERE issuedate IS NULL;
2036 $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
2038 # default to last renewal date
2039 $dbh->do("
2040 UPDATE issues
2041 SET issuedate = lastreneweddate
2042 WHERE issuedate IS NULL
2043 and lastreneweddate IS NOT NULL
2046 my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
2047 if ($num_bad_issuedates > 0) {
2048 print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
2049 "Please check the issues table in your database.";
2051 print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
2052 SetVersion($DBversion);
2055 $DBversion = "3.01.00.003";
2056 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2057 $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')");
2058 print "Upgrade to $DBversion done (add new syspref)\n";
2059 SetVersion ($DBversion);
2062 $DBversion = '3.01.00.004';
2063 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2064 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACDisplayRequestPriority','0','Show patrons the priority level on holds in the OPAC','','YesNo')");
2065 print "Upgrade to $DBversion done (added OPACDisplayRequestPriority system preference)\n";
2066 SetVersion ($DBversion);
2069 $DBversion = '3.01.00.005';
2070 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2071 $dbh->do("
2072 INSERT INTO `letter` (module, code, name, title, content)
2073 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>>')
2075 $dbh->do("INSERT INTO `message_attributes` (message_attribute_id, message_name, takes_days) values(4, 'Hold Filled', 0)");
2076 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'sms', 0, 'reserves', 'HOLD')");
2077 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'email', 0, 'reserves', 'HOLD')");
2078 print "Upgrade to $DBversion done (Add letter for holds notifications)\n";
2079 SetVersion ($DBversion);
2082 $DBversion = '3.01.00.006';
2083 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2084 $dbh->do("ALTER TABLE `biblioitems` ADD KEY issn (issn)");
2085 print "Upgrade to $DBversion done (add index on biblioitems.issn)\n";
2086 SetVersion ($DBversion);
2089 $DBversion = "3.01.00.007";
2090 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2091 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetmainUserblock'");
2092 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetuserjs'");
2093 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacheader'");
2094 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacMainUserBlock'");
2095 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacNav'");
2096 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacuserjs'");
2097 $dbh->do("UPDATE `systempreferences` SET options='30|10', type='Textarea' WHERE variable='OAI-PMH:Set'");
2098 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetstylesheet'");
2099 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetcolorstylesheet'");
2100 $dbh->do("UPDATE `systempreferences` SET options='10' WHERE variable='globalDueDate'");
2101 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='numSearchResults'");
2102 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='OPACnumSearchResults'");
2103 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='ReservesMaxPickupDelay'");
2104 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='TransfersMaxDaysWarning'");
2105 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='StaticHoldsQueueWeight'");
2106 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='holdCancelLength'");
2107 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='XISBNDailyLimit'");
2108 $dbh->do("UPDATE `systempreferences` SET type='Float' WHERE variable='gist'");
2109 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorUsername'");
2110 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorPassword'");
2111 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10' WHERE variable='ISBD'");
2112 $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'");
2113 print "Upgrade to $DBversion done (fix display of many sysprefs)\n";
2114 SetVersion ($DBversion);
2117 $DBversion = '3.01.00.008';
2118 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2120 $dbh->do("CREATE TABLE branch_transfer_limits (
2121 limitId int(8) NOT NULL auto_increment,
2122 toBranch varchar(4) NOT NULL,
2123 fromBranch varchar(4) NOT NULL,
2124 itemtype varchar(4) NOT NULL,
2125 PRIMARY KEY (limitId)
2126 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
2129 $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')");
2131 print "Upgrade to $DBversion done (added branch_transfer_limits table and UseBranchTransferLimits system preference)\n";
2132 SetVersion ($DBversion);
2135 $DBversion = "3.01.00.009";
2136 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2137 $dbh->do("ALTER TABLE permissions MODIFY `code` varchar(64) DEFAULT NULL");
2138 $dbh->do("ALTER TABLE user_permissions MODIFY `code` varchar(64) DEFAULT NULL");
2139 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'circulate_remaining_permissions', 'Remaining circulation permissions')");
2140 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'override_renewals', 'Override blocked renewals')");
2141 print "Upgrade to $DBversion done (added subpermissions for circulate permission)\n";
2144 $DBversion = '3.01.00.010';
2145 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2146 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `attribute` VARCHAR(64) DEFAULT NULL");
2147 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `password` VARCHAR(64) DEFAULT NULL");
2148 print "Upgrade to $DBversion done (bug 2687: increase length of borrower attribute fields)\n";
2149 SetVersion ($DBversion);
2152 $DBversion = '3.01.00.011';
2153 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2155 # Yes, the old value was ^M terminated.
2156 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);";
2158 my $intranetuserjs = C4::Context->preference('intranetuserjs');
2159 if ($intranetuserjs and $intranetuserjs eq $bad_value) {
2160 my $sql = <<'END_SQL';
2161 UPDATE systempreferences
2162 SET value = ''
2163 WHERE variable = 'intranetuserjs'
2164 END_SQL
2165 $dbh->do($sql);
2167 print "Upgrade to $DBversion done (removed bogus intranetuserjs syspref)\n";
2168 SetVersion($DBversion);
2171 $DBversion = "3.01.00.012";
2172 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2173 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo')");
2174 $dbh->do("
2175 CREATE TABLE `branch_item_rules` (
2176 `branchcode` varchar(10) NOT NULL,
2177 `itemtype` varchar(10) NOT NULL,
2178 `holdallowed` tinyint(1) default NULL,
2179 PRIMARY KEY (`itemtype`,`branchcode`),
2180 KEY `branch_item_rules_ibfk_2` (`branchcode`),
2181 CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
2182 CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2183 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2185 $dbh->do("
2186 CREATE TABLE `default_branch_item_rules` (
2187 `itemtype` varchar(10) NOT NULL,
2188 `holdallowed` tinyint(1) default NULL,
2189 PRIMARY KEY (`itemtype`),
2190 CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
2191 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2193 $dbh->do("
2194 ALTER TABLE default_branch_circ_rules
2195 ADD COLUMN holdallowed tinyint(1) NULL
2197 $dbh->do("
2198 ALTER TABLE default_circ_rules
2199 ADD COLUMN holdallowed tinyint(1) NULL
2201 print "Upgrade to $DBversion done (Add tables and system preferences for holds policies)\n";
2202 SetVersion ($DBversion);
2205 $DBversion = '3.01.00.013';
2206 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2207 $dbh->do("
2208 CREATE TABLE item_circulation_alert_preferences (
2209 id int(11) AUTO_INCREMENT,
2210 branchcode varchar(10) NOT NULL,
2211 categorycode varchar(10) NOT NULL,
2212 item_type varchar(10) NOT NULL,
2213 notification varchar(16) NOT NULL,
2214 PRIMARY KEY (id),
2215 KEY (branchcode, categorycode, item_type, notification)
2216 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2219 $dbh->do(q{ ALTER TABLE `message_queue` ADD metadata text DEFAULT NULL AFTER content; });
2220 $dbh->do(q{ ALTER TABLE `message_queue` ADD letter_code varchar(64) DEFAULT NULL AFTER metadata; });
2222 $dbh->do(q{
2223 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2224 ('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.');
2226 $dbh->do(q{
2227 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2228 ('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>>.');
2231 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (5, 'Item Check-in', 0);});
2232 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (6, 'Item Checkout', 0);});
2234 $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');});
2235 $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');});
2236 $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');});
2237 $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');});
2239 print "Upgrade to $DBversion done (data for Email Checkout Slips project)\n";
2240 SetVersion ($DBversion);
2243 $DBversion = "3.01.00.014";
2244 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2245 $dbh->do("ALTER TABLE `branch_transfer_limits` CHANGE `itemtype` `itemtype` VARCHAR( 4 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL");
2246 $dbh->do("ALTER TABLE `branch_transfer_limits` ADD `ccode` VARCHAR( 10 ) NULL ;");
2247 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2248 VALUES (
2249 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice'
2250 );");
2252 print "Upgrade to $DBversion done ( Updated table for Branch Transfer Limits)\n";
2253 SetVersion ($DBversion);
2256 $DBversion = '3.01.00.015';
2257 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2258 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsClientCode', '0', 'Client Code for using Syndetics Solutions content','','free')");
2260 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEnabled', '0', 'Turn on Syndetics Enhanced Content','','YesNo')");
2262 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImages', '0', 'Display Cover Images from Syndetics','','YesNo')");
2264 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsTOC', '0', 'Display Table of Content information from Syndetics','','YesNo')");
2266 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSummary', '0', 'Display Summary Information from Syndetics','','YesNo')");
2268 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEditions', '0', 'Display Editions from Syndetics','','YesNo')");
2270 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsExcerpt', '0', 'Display Excerpts and first chapters on OPAC from Syndetics','','YesNo')");
2272 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsReviews', '0', 'Display Reviews on OPAC from Syndetics','','YesNo')");
2274 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAuthorNotes', '0', 'Display Notes about the Author on OPAC from Syndetics','','YesNo')");
2276 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAwards', '0', 'Display Awards on OPAC from Syndetics','','YesNo')");
2278 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSeries', '0', 'Display Series information on OPAC from Syndetics','','YesNo')");
2280 $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')");
2282 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from Amazon Web Services','','YesNo')");
2284 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from Amazon Web Services','','YesNo')");
2286 $dbh->do("UPDATE systempreferences SET variable='AmazonEnabled' WHERE variable = 'AmazonContent'");
2288 $dbh->do("UPDATE systempreferences SET variable='OPACAmazonEnabled' WHERE variable = 'OPACAmazonContent'");
2290 print "Upgrade to $DBversion done (added Syndetics Enhanced Content system preferences)\n";
2291 SetVersion ($DBversion);
2294 $DBversion = "3.01.00.016";
2295 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2296 $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')");
2297 print "Upgrade to $DBversion done (Added Babeltheque syspref)\n";
2298 SetVersion ($DBversion);
2301 $DBversion = "3.01.00.017";
2302 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2303 $dbh->do("ALTER TABLE `subscription` ADD `staffdisplaycount` VARCHAR(10) NULL;");
2304 $dbh->do("ALTER TABLE `subscription` ADD `opacdisplaycount` VARCHAR(10) NULL;");
2305 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2306 VALUES (
2307 'StaffSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the Staff client', 'Integer'
2308 );");
2309 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2310 VALUES (
2311 'OPACSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the OPAC', 'Integer'
2312 );");
2314 print "Upgrade to $DBversion done ( Updated table for Serials Display)\n";
2315 SetVersion ($DBversion);
2318 $DBversion = "3.01.00.018";
2319 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2320 $dbh->do("ALTER TABLE deletedborrowers ADD `smsalertnumber` varchar(50) default NULL");
2321 print "Upgrade to $DBversion done (added deletedborrowers.smsalertnumber, missed in 3.00.00.091)\n";
2322 SetVersion ($DBversion);
2325 $DBversion = "3.01.00.019";
2326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2327 $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')");
2328 print "Upgrade to $DBversion done (adding OPACShowCheckoutName systempref)\n";
2329 SetVersion ($DBversion);
2332 $DBversion = "3.01.00.020";
2333 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2334 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesID','','See:http://librarything.com/forlibraries/','','free')");
2335 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesEnabled','0','Enable or Disable Library Thing for Libraries Features','','YesNo')");
2336 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesTabbedView','0','Put LibraryThingForLibraries Content in Tabs.','','YesNo')");
2337 print "Upgrade to $DBversion done (adding LibraryThing for Libraries sysprefs)\n";
2338 SetVersion ($DBversion);
2341 $DBversion = "3.01.00.021";
2342 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2343 my $enable_reviews = C4::Context->preference('OPACAmazonEnabled') ? '1' : '0';
2344 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonReviews', '$enable_reviews', 'Display Amazon readers reviews on OPAC','','YesNo')");
2345 print "Upgrade to $DBversion done (adding OPACAmazonReviews syspref)\n";
2346 SetVersion ($DBversion);
2349 $DBversion = '3.01.00.022';
2350 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2351 $dbh->do("ALTER TABLE `labels_conf` MODIFY COLUMN `formatstring` mediumtext DEFAULT NULL");
2352 print "Upgrade to $DBversion done (bug 2945: increase size of labels_conf.formatstring)\n";
2353 SetVersion ($DBversion);
2356 $DBversion = '3.01.00.023';
2357 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2358 $dbh->do("ALTER TABLE biblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2359 $dbh->do("ALTER TABLE deletedbiblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2360 $dbh->do("ALTER TABLE import_biblios MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2361 $dbh->do("ALTER TABLE suggestions MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2362 print "Upgrade to $DBversion done (bug 2765: increase width of isbn column in several tables)\n";
2363 SetVersion ($DBversion);
2366 $DBversion = "3.01.00.024";
2367 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2368 $dbh->do("ALTER TABLE labels MODIFY COLUMN batch_id int(10) NOT NULL default 1;");
2369 print "Upgrade to $DBversion done (change labels.batch_id from varchar to int)\n";
2370 SetVersion ($DBversion);
2373 $DBversion = '3.01.00.025';
2374 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2375 $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')");
2377 print "Upgrade to $DBversion done (added ceilingDueDate system preference)\n";
2378 SetVersion ($DBversion);
2381 $DBversion = '3.01.00.026';
2382 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2383 $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')");
2385 print "Upgrade to $DBversion done (added numReturnedItemsToShow system preference)\n";
2386 SetVersion ($DBversion);
2389 $DBversion = '3.01.00.027';
2390 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2391 $dbh->do("ALTER TABLE zebraqueue CHANGE `biblio_auth_number` `biblio_auth_number` bigint(20) unsigned NOT NULL default 0");
2392 print "Upgrade to $DBversion done (Increased size of zebraqueue biblio_auth_number to address bug 3148.)\n";
2393 SetVersion ($DBversion);
2396 $DBversion = '3.01.00.028';
2397 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2398 my $enable_reviews = C4::Context->preference('AmazonEnabled') ? '1' : '0';
2399 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonReviews', '$enable_reviews', 'Display Amazon reviews on staff interface','','YesNo')");
2400 print "Upgrade to $DBversion done (added AmazonReviews)\n";
2401 SetVersion ($DBversion);
2404 $DBversion = '3.01.00.029';
2405 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2406 $dbh->do(q( UPDATE language_rfc4646_to_iso639
2407 SET iso639_2_code = 'spa'
2408 WHERE rfc4646_subtag = 'es'
2409 AND iso639_2_code = 'rus' )
2411 print "Upgrade to $DBversion done (fixed bug 2599: using Spanish search limit retrieves Russian results)\n";
2412 SetVersion ($DBversion);
2415 $DBversion = "3.01.00.030";
2416 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2417 $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')");
2418 print "Upgrade to $DBversion done (added AllowNotForLoanOverride system preference)\n";
2419 SetVersion ($DBversion);
2422 $DBversion = "3.01.00.031";
2423 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2424 $dbh->do("ALTER TABLE branch_transfer_limits
2425 MODIFY toBranch varchar(10) NOT NULL,
2426 MODIFY fromBranch varchar(10) NOT NULL,
2427 MODIFY itemtype varchar(10) NULL");
2428 print "Upgrade to $DBversion done (fix column widths in branch_transfer_limits)\n";
2429 SetVersion ($DBversion);
2432 $DBversion = "3.01.00.032";
2433 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2434 $dbh->do(<<ENDOFRENEWAL);
2435 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');
2436 ENDOFRENEWAL
2437 print "Upgrade to $DBversion done (Change the field)\n";
2438 SetVersion ($DBversion);
2441 $DBversion = "3.01.00.033";
2442 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2443 $dbh->do(q/
2444 ALTER TABLE borrower_message_preferences
2445 MODIFY borrowernumber int(11) default NULL,
2446 ADD categorycode varchar(10) default NULL AFTER borrowernumber,
2447 ADD KEY `categorycode` (`categorycode`),
2448 ADD CONSTRAINT `borrower_message_preferences_ibfk_3`
2449 FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
2450 ON DELETE CASCADE ON UPDATE CASCADE
2452 print "Upgrade to $DBversion done (DB changes to allow patron category defaults for messaging preferences)\n";
2453 SetVersion ($DBversion);
2456 $DBversion = "3.01.00.034";
2457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2458 $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
2459 print "Upgrade to $DBversion done (Adding graceperiod column to subscription table)\n";
2460 SetVersion ($DBversion);
2463 $DBversion = '3.01.00.035';
2464 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2465 $dbh->do(q{ ALTER TABLE `subscription` ADD location varchar(80) NULL DEFAULT '' AFTER callnumber; });
2466 print "Upgrade to $DBversion done (Adding location to subscription table)\n";
2467 SetVersion ($DBversion);
2470 $DBversion = '3.01.00.036';
2471 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2472 $dbh->do("UPDATE systempreferences SET explanation = 'Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd'
2473 WHERE variable = 'IntranetBiblioDefaultView'
2474 AND explanation = 'IntranetBiblioDefaultView'");
2475 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = 'normal|marc|isbd|labeled_marc'
2476 WHERE variable = 'IntranetBiblioDefaultView'");
2477 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewISBD','1','Allow display of ISBD view of bibiographic records','','YesNo')");
2478 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo')");
2479 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo')");
2480 print "Upgrade to $DBversion done (new viewISBD, viewLabeledMARC, viewMARC sysprefs and tweak IntranetBiblioDefaultView)\n";
2481 SetVersion ($DBversion);
2484 $DBversion = '3.01.00.037';
2485 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2486 $dbh->do('ALTER TABLE authorised_values ADD KEY `lib` (`lib`)');
2487 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo')");
2488 SetVersion ($DBversion);
2489 print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
2492 $DBversion = "3.01.00.038";
2493 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2494 # update branches table
2496 $dbh->do("ALTER TABLE branches ADD `branchzip` varchar(25) default NULL AFTER `branchaddress3`");
2497 $dbh->do("ALTER TABLE branches ADD `branchcity` mediumtext AFTER `branchzip`");
2498 $dbh->do("ALTER TABLE branches ADD `branchcountry` text AFTER `branchcity`");
2499 $dbh->do("ALTER TABLE branches ADD `branchurl` mediumtext AFTER `branchemail`");
2500 $dbh->do("ALTER TABLE branches ADD `branchnotes` mediumtext AFTER `branchprinter`");
2501 print "Upgrade to $DBversion done (add ZIP, city, country, URL, and notes column to branches)\n";
2502 SetVersion ($DBversion);
2505 $DBversion = '3.01.00.039';
2506 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2507 $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')");
2508 $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')");
2509 SetVersion ($DBversion);
2510 print "Upgrade to $DBversion done (added SpineLabelFormat and SpineLabelAutoPrint sysprefs)\n";
2513 $DBversion = '3.01.00.040';
2514 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2515 $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')");
2516 $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')");
2517 SetVersion ($DBversion);
2518 print "Upgrade to $DBversion done (AllowHoldDateInFuture and OPACAllowHoldDateInFuture sysprefs)\n";
2521 $DBversion = '3.01.00.041';
2522 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2523 $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')");
2524 SetVersion ($DBversion);
2525 print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that if you use enhanced content from Amazon, this should be set right away.)\n";
2528 $DBversion = '3.01.00.042';
2529 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2530 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACFineNoRenewals','99999','Fine Limit above which user canmot renew books via OPAC','','Integer')");
2531 SetVersion ($DBversion);
2532 print "Upgrade to $DBversion done (added OPACFineNoRenewals syspref)\n";
2535 $DBversion = '3.01.00.043';
2536 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2537 $dbh->do('ALTER TABLE items ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2538 $dbh->do('UPDATE items SET permanent_location = location');
2539 $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 )', '')");
2540 $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')");
2541 $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')");
2542 SetVersion ($DBversion);
2543 print "Upgrade to $DBversion done (amended Item added NewItemsDefaultLocation, InProcessingToShelvingCart, ReturnToShelvingCart sysprefs)\n";
2546 $DBversion = '3.01.00.044';
2547 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2548 $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')");
2549 SetVersion ($DBversion);
2550 print "Upgrade to $DBversion done (added DisplayClearScreenButton system preference)\n";
2553 $DBversion = '3.01.00.045';
2554 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2555 $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')");
2556 SetVersion ($DBversion);
2557 print "Upgrade to $DBversion done (added a preference to hide the patrons name in the staff catalog)\n";
2560 $DBversion = "3.01.00.046";
2561 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2562 # update borrowers table
2564 $dbh->do("ALTER TABLE borrowers ADD `country` text AFTER zipcode");
2565 $dbh->do("ALTER TABLE borrowers ADD `B_country` text AFTER B_zipcode");
2566 $dbh->do("ALTER TABLE deletedborrowers ADD `country` text AFTER zipcode");
2567 $dbh->do("ALTER TABLE deletedborrowers ADD `B_country` text AFTER B_zipcode");
2568 print "Upgrade to $DBversion done (add country and B_country to borrowers)\n";
2569 SetVersion ($DBversion);
2572 $DBversion = '3.01.00.047';
2573 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2574 $dbh->do("ALTER TABLE items MODIFY itemcallnumber varchar(255);");
2575 $dbh->do("ALTER TABLE deleteditems MODIFY itemcallnumber varchar(255);");
2576 $dbh->do("ALTER TABLE tmp_holdsqueue MODIFY itemcallnumber varchar(255);");
2577 SetVersion ($DBversion);
2578 print " Upgrade to $DBversion done (bug 2761: change max length of itemcallnumber to 255 from 30)\n";
2581 $DBversion = '3.01.00.048';
2582 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2583 $dbh->do("UPDATE userflags SET flagdesc='View Catalog (Librarian Interface)' WHERE bit=2;");
2584 $dbh->do("UPDATE userflags SET flagdesc='Edit Catalog (Modify bibliographic/holdings data)' WHERE bit=9;");
2585 $dbh->do("UPDATE userflags SET flagdesc='Allow to edit authorities' WHERE bit=14;");
2586 $dbh->do("UPDATE userflags SET flagdesc='Allow to access to the reports module' WHERE bit=16;");
2587 $dbh->do("UPDATE userflags SET flagdesc='Allow to manage serials subscriptions' WHERE bit=15;");
2588 SetVersion ($DBversion);
2589 print " Upgrade to $DBversion done (bug 2611: fix spelling/capitalization in permission flag descriptions)\n";
2592 $DBversion = '3.01.00.049';
2593 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2594 $dbh->do("UPDATE permissions SET description = 'Perform inventory (stocktaking) of your catalog' WHERE code = 'inventory';");
2595 SetVersion ($DBversion);
2596 print "Upgrade to $DBversion done (bug 2611: changed catalogue to catalog per the standard)\n";
2599 $DBversion = '3.01.00.050';
2600 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2601 $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&amp;title=TITLE&amp;st=xl&amp;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');");
2602 SetVersion ($DBversion);
2603 print "Upgrade to $DBversion done (bug 1934: Add OPACSearchForTitleIn syspref)\n";
2606 $DBversion = '3.01.00.051';
2607 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2608 $dbh->do("UPDATE systempreferences SET explanation='Fine limit above which user cannot renew books via OPAC' WHERE variable='OPACFineNoRenewals';");
2609 $dbh->do("UPDATE systempreferences SET explanation='If set to ON, a clear screen button will appear on the circulation page.' WHERE variable='DisplayClearScreenButton';");
2610 SetVersion ($DBversion);
2611 print "Upgrade to $DBversion done (fixed typos in new sysprefs)\n";
2614 $DBversion = '3.01.00.052';
2615 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2616 $dbh->do('ALTER TABLE deleteditems ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2617 SetVersion ($DBversion);
2618 print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
2621 $DBversion = '3.01.00.053';
2622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2623 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
2624 system("perl $upgrade_script");
2625 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";
2626 SetVersion ($DBversion);
2629 $DBversion = '3.01.00.054';
2630 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2631 $dbh->do("ALTER TABLE borrowers ADD `B_address2` text AFTER B_address");
2632 $dbh->do("ALTER TABLE borrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2633 $dbh->do("ALTER TABLE deletedborrowers ADD `B_address2` text AFTER B_address");
2634 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2635 SetVersion ($DBversion);
2636 print "Upgrade to $DBversion done (bug 1600, bug 3454: add altcontactcountry and B_address2 to borrowers and deletedborrowers)\n";
2639 $DBversion = '3.01.00.055';
2640 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2641 $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}&amp;title={TITLE}&amp;st=xl&amp;ac=qr" target="_blank">Online Stores (Bookfinder.com)</a></li>' WHERE variable='OPACSearchForTitleIn'|);
2642 SetVersion ($DBversion);
2643 print "Upgrade to $DBversion done (changed OPACSearchForTitleIn per requests in bug 1934)\n";
2646 $DBversion = '3.01.00.056';
2647 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2648 $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');");
2649 SetVersion ($DBversion);
2650 print "Upgrade to $DBversion done (Bug 1172 : Add OPACPatronDetails syspref)\n";
2653 $DBversion = '3.01.00.057';
2654 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2655 $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');");
2656 SetVersion ($DBversion);
2657 print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
2660 $DBversion = '3.01.00.058';
2661 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2662 $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2663 $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2664 $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2665 SetVersion ($DBversion);
2666 print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
2669 $DBversion = '3.01.00.059';
2670 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2671 $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')");
2672 SetVersion ($DBversion);
2673 print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
2676 $DBversion = '3.01.00.060';
2677 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2678 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
2679 $dbh->do('DROP TABLE IF EXISTS messages');
2680 $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
2681 `borrowernumber` int(11) NOT NULL,
2682 `branchcode` varchar(4) default NULL,
2683 `message_type` varchar(1) NOT NULL,
2684 `message` text NOT NULL,
2685 `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2686 PRIMARY KEY (`message_id`)
2687 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
2689 print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
2690 SetVersion ($DBversion);
2693 $DBversion = '3.01.00.061';
2694 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2695 $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')");
2696 print "Upgrade to $DBversion done ( Added ShowPatronImageInWebBasedSelfCheck system preference )\n";
2697 SetVersion ($DBversion);
2700 $DBversion = "3.01.00.062";
2701 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2702 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'manage_csv_profiles', 'Manage CSV export profiles')");
2703 $dbh->do(q/
2704 CREATE TABLE `export_format` (
2705 `export_format_id` int(11) NOT NULL auto_increment,
2706 `profile` varchar(255) NOT NULL,
2707 `description` mediumtext NOT NULL,
2708 `marcfields` mediumtext NOT NULL,
2709 PRIMARY KEY (`export_format_id`)
2710 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
2712 print "Upgrade to $DBversion done (added csv export profiles)\n";
2715 $DBversion = "3.01.00.063";
2716 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2717 $dbh->do("
2718 CREATE TABLE `fieldmapping` (
2719 `id` int(11) NOT NULL auto_increment,
2720 `field` varchar(255) NOT NULL,
2721 `frameworkcode` char(4) NOT NULL default '',
2722 `fieldcode` char(3) NOT NULL,
2723 `subfieldcode` char(1) NOT NULL,
2724 PRIMARY KEY (`id`)
2725 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2727 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";
2730 $DBversion = '3.01.00.065';
2731 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2732 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
2733 $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
2734 $sth->execute();
2736 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
2738 while(my $row = $sth->fetchrow_hashref){
2739 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
2742 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
2744 SetVersion ($DBversion);
2745 print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2748 $DBversion = '3.01.00.066';
2749 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2750 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2752 my $maxreserves = C4::Context->preference('maxreserves');
2753 $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2754 $sth->execute($maxreserves);
2756 $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2758 $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2760 SetVersion ($DBversion);
2761 print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2764 $DBversion = "3.01.00.067";
2765 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2766 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
2767 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
2768 print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
2769 SetVersion ($DBversion);
2772 $DBversion = "3.01.00.068";
2773 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2774 $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
2775 print "Upgrade to $DBversion done (Adding finedays in issuingrules table)\n";
2776 SetVersion ($DBversion);
2780 $DBversion = "3.01.00.069";
2781 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2782 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableOpacSearchHistory', '1', '', 'Enable or disable opac search history', 'YesNo')");
2784 my $create = <<SEARCHHIST;
2785 CREATE TABLE IF NOT EXISTS `search_history` (
2786 `userid` int(11) NOT NULL,
2787 `sessionid` varchar(32) NOT NULL,
2788 `query_desc` varchar(255) NOT NULL,
2789 `query_cgi` varchar(255) NOT NULL,
2790 `total` int(11) NOT NULL,
2791 `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2792 KEY `userid` (`userid`),
2793 KEY `sessionid` (`sessionid`)
2794 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
2795 SEARCHHIST
2796 $dbh->do($create);
2798 print "Upgrade to $DBversion done (added OPAC search history preference and table)\n";
2801 $DBversion = "3.01.00.070";
2802 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2803 $dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
2804 print "Upgrade to $DBversion done (Added a lib_opac field in authorised_values table)\n";
2807 $DBversion = "3.01.00.071";
2808 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2809 $dbh->do("ALTER TABLE `subscription` ADD `enddate` date default NULL");
2810 $dbh->do("ALTER TABLE subscriptionhistory CHANGE enddate histenddate DATE default NULL");
2811 print "Upgrade to $DBversion done ( Adding enddate to subscription)\n";
2814 # Acquisitions update
2816 $DBversion = "3.01.00.072";
2817 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2818 $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')");
2819 # create a new syspref for the 'Mr anonymous' patron
2820 $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,'')");
2821 # fill AnonymousPatron with AnonymousSuggestion value (copy)
2822 my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='AnonSuggestions'");
2823 $sth->execute;
2824 my ($value) = $sth->fetchrow() || 0;
2825 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='AnonymousPatron'");
2826 # set AnonymousSuggestion do YesNo
2827 # 1st, set the value (1/True if it had a borrowernumber)
2828 $dbh->do("UPDATE systempreferences SET value=1 WHERE variable='AnonSuggestions' AND value>0");
2829 # 2nd, change the type to Choice
2830 $dbh->do("UPDATE systempreferences SET type='YesNo' WHERE variable='AnonSuggestions'");
2831 # borrower reading record privacy : 0 : forever, 1 : laws, 2 : don't keep at all
2832 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
2833 print "Upgrade to $DBversion done (add new syspref and column in borrowers)\n";
2834 SetVersion ($DBversion);
2837 $DBversion = '3.01.00.073';
2838 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2839 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2840 $dbh->do(<<'END_SQL');
2841 CREATE TABLE IF NOT EXISTS `aqcontract` (
2842 `contractnumber` int(11) NOT NULL auto_increment,
2843 `contractstartdate` date default NULL,
2844 `contractenddate` date default NULL,
2845 `contractname` varchar(50) default NULL,
2846 `contractdescription` mediumtext,
2847 `booksellerid` int(11) not NULL,
2848 PRIMARY KEY (`contractnumber`),
2849 CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2850 REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2851 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2852 END_SQL
2853 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2854 print "Upgrade to $DBversion done (adding aqcontract table)\n";
2855 SetVersion ($DBversion);
2858 $DBversion = '3.01.00.074';
2859 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2860 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `basketname` varchar(50) default NULL AFTER `basketno`");
2861 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `note` mediumtext AFTER `basketname`");
2862 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `booksellernote` mediumtext AFTER `note`");
2863 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `contractnumber` int(11) AFTER `booksellernote`");
2864 $dbh->do("ALTER TABLE `aqbasket` ADD FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`)");
2865 print "Upgrade to $DBversion done (edit aqbasket table done)\n";
2866 SetVersion ($DBversion);
2869 $DBversion = '3.01.00.075';
2870 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2871 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `uncertainprice` tinyint(1)");
2873 print "Upgrade to $DBversion done (adding uncertainprices)\n";
2874 SetVersion ($DBversion);
2877 $DBversion = '3.01.00.076';
2878 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2879 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2880 $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` (
2881 `id` int(11) NOT NULL auto_increment,
2882 `name` varchar(50) default NULL,
2883 `closed` tinyint(1) default NULL,
2884 `booksellerid` int(11) NOT NULL,
2885 PRIMARY KEY (`id`),
2886 KEY `booksellerid` (`booksellerid`),
2887 CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2888 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
2889 $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
2890 $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
2891 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
2892 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2893 print "Upgrade to $DBversion done (adding basketgroups)\n";
2894 SetVersion ($DBversion);
2896 $DBversion = '3.01.00.077';
2897 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2899 $dbh->do("SET FOREIGN_KEY_CHECKS=0 ");
2900 # create a mapping table holding the info we need to match orders to budgets
2901 $dbh->do('DROP TABLE IF EXISTS fundmapping');
2902 $dbh->do(
2903 q|CREATE TABLE fundmapping AS
2904 SELECT aqorderbreakdown.ordernumber, branchcode, bookfundid, budgetdate, entrydate
2905 FROM aqorderbreakdown JOIN aqorders ON aqorderbreakdown.ordernumber = aqorders.ordernumber|);
2906 # match the new type of the corresponding field
2907 $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)');
2908 # System did not ensure budgetdate was valid historically
2909 $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = '0000-00-00' OR budgetdate IS NULL|);
2910 # We save the map in fundmapping in case you need later processing
2911 $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|);
2912 # these can speed processing up
2913 $dbh->do(q|CREATE INDEX fundmaporder ON fundmapping (ordernumber)|);
2914 $dbh->do(q|CREATE INDEX fundmapid ON fundmapping (bookfundid)|);
2916 $dbh->do("DROP TABLE IF EXISTS `aqbudgetperiods` ");
2918 $dbh->do(qq|
2919 CREATE TABLE `aqbudgetperiods` (
2920 `budget_period_id` int(11) NOT NULL auto_increment,
2921 `budget_period_startdate` date NOT NULL,
2922 `budget_period_enddate` date NOT NULL,
2923 `budget_period_active` tinyint(1) default '0',
2924 `budget_period_description` mediumtext,
2925 `budget_period_locked` tinyint(1) default NULL,
2926 `sort1_authcat` varchar(10) default NULL,
2927 `sort2_authcat` varchar(10) default NULL,
2928 PRIMARY KEY (`budget_period_id`)
2929 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |);
2931 $dbh->do(<<ADDPERIODS);
2932 INSERT INTO aqbudgetperiods (budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_locked)
2933 SELECT DISTINCT startdate, enddate, NOW() BETWEEN startdate and enddate, concat(startdate," ",enddate),NOT NOW() BETWEEN startdate AND enddate from aqbudget
2934 ADDPERIODS
2935 # SORRY , NO AQBUDGET/AQBOOKFUND -> AQBUDGETS IMPORT JUST YET,
2936 # BUT A NEW CLEAN AQBUDGETS TABLE CREATE FOR NOW..
2937 # DROP TABLE IF EXISTS `aqbudget`;
2938 #CREATE TABLE `aqbudget` (
2939 # `bookfundid` varchar(10) NOT NULL default ',
2940 # `startdate` date NOT NULL default 0,
2941 # `enddate` date default NULL,
2942 # `budgetamount` decimal(13,2) default NULL,
2943 # `aqbudgetid` tinyint(4) NOT NULL auto_increment,
2944 # `branchcode` varchar(10) default NULL,
2945 DropAllForeignKeys('aqbudget');
2946 #$dbh->do("drop table aqbudget;");
2949 my $maxbudgetid = $dbh->selectcol_arrayref(<<IDsBUDGET);
2950 SELECT MAX(aqbudgetid) from aqbudget
2951 IDsBUDGET
2953 $$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
2955 $dbh->do(<<BUDGETAUTOINCREMENT);
2956 ALTER TABLE aqbudget AUTO_INCREMENT=$$maxbudgetid[0]
2957 BUDGETAUTOINCREMENT
2959 $dbh->do(<<BUDGETNAME);
2960 ALTER TABLE aqbudget RENAME `aqbudgets`
2961 BUDGETNAME
2963 $dbh->do(<<BUDGETS);
2964 ALTER TABLE `aqbudgets`
2965 CHANGE COLUMN aqbudgetid `budget_id` int(11) NOT NULL AUTO_INCREMENT,
2966 CHANGE COLUMN branchcode `budget_branchcode` varchar(10) default NULL,
2967 CHANGE COLUMN budgetamount `budget_amount` decimal(28,6) NOT NULL default '0.00',
2968 CHANGE COLUMN bookfundid `budget_code` varchar(30) default NULL,
2969 ADD COLUMN `budget_parent_id` int(11) default NULL,
2970 ADD COLUMN `budget_name` varchar(80) default NULL,
2971 ADD COLUMN `budget_encumb` decimal(28,6) default '0.00',
2972 ADD COLUMN `budget_expend` decimal(28,6) default '0.00',
2973 ADD COLUMN `budget_notes` mediumtext,
2974 ADD COLUMN `budget_description` mediumtext,
2975 ADD COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2976 ADD COLUMN `budget_amount_sublevel` decimal(28,6) AFTER `budget_amount`,
2977 ADD COLUMN `budget_period_id` int(11) default NULL,
2978 ADD COLUMN `sort1_authcat` varchar(80) default NULL,
2979 ADD COLUMN `sort2_authcat` varchar(80) default NULL,
2980 ADD COLUMN `budget_owner_id` int(11) default NULL,
2981 ADD COLUMN `budget_permission` int(1) default '0';
2982 BUDGETS
2984 $dbh->do(<<BUDGETCONSTRAINTS);
2985 ALTER TABLE `aqbudgets`
2986 ADD CONSTRAINT `aqbudgets_ifbk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
2987 BUDGETCONSTRAINTS
2988 # $dbh->do(<<BUDGETPKDROP);
2989 #ALTER TABLE `aqbudgets`
2990 # DROP PRIMARY KEY
2991 #BUDGETPKDROP
2992 # $dbh->do(<<BUDGETPKADD);
2993 #ALTER TABLE `aqbudgets`
2994 # ADD PRIMARY KEY budget_id
2995 #BUDGETPKADD
2998 my $query_period= $dbh->prepare(qq|SELECT budget_period_id from aqbudgetperiods where budget_period_startdate=? and budget_period_enddate=?|);
2999 my $query_bookfund= $dbh->prepare(qq|SELECT * from aqbookfund where bookfundid=?|);
3000 my $selectbudgets=$dbh->prepare(qq|SELECT * from aqbudgets|);
3001 my $updatebudgets=$dbh->prepare(qq|UPDATE aqbudgets SET budget_period_id= ? , budget_name=?, budget_branchcode=? where budget_id=?|);
3002 $selectbudgets->execute;
3003 while (my $databudget=$selectbudgets->fetchrow_hashref){
3004 $query_period->execute ($$databudget{startdate},$$databudget{enddate});
3005 my ($budgetperiodid)=$query_period->fetchrow;
3006 $query_bookfund->execute ($$databudget{budget_code});
3007 my $databf=$query_bookfund->fetchrow_hashref;
3008 my $branchcode=$$databudget{budget_branchcode}||$$databf{branchcode};
3009 $updatebudgets->execute($budgetperiodid,$$databf{bookfundname},$branchcode,$$databudget{budget_id});
3011 $dbh->do(<<BUDGETDROPDATES);
3012 ALTER TABLE `aqbudgets`
3013 DROP startdate,
3014 DROP enddate
3015 BUDGETDROPDATES
3018 $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
3019 $dbh->do("CREATE TABLE `aqbudgets_planning` (
3020 `plan_id` int(11) NOT NULL auto_increment,
3021 `budget_id` int(11) NOT NULL,
3022 `budget_period_id` int(11) NOT NULL,
3023 `estimated_amount` decimal(28,6) default NULL,
3024 `authcat` varchar(30) NOT NULL,
3025 `authvalue` varchar(30) NOT NULL,
3026 `display` tinyint(1) DEFAULT 1,
3027 PRIMARY KEY (`plan_id`),
3028 CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
3029 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
3031 $dbh->do("ALTER TABLE `aqorders`
3032 ADD COLUMN `budget_id` tinyint(4) NOT NULL,
3033 ADD COLUMN `budgetgroup_id` int(11) NOT NULL,
3034 ADD COLUMN `sort1_authcat` varchar(10) default NULL,
3035 ADD COLUMN `sort2_authcat` varchar(10) default NULL" );
3036 # We need to map the orders to the budgets
3037 # For Historic reasons this is more complex than it should be on occasions
3038 my $budg_arr = $dbh->selectall_arrayref(
3039 q|SELECT aqbudgets.budget_id, aqbudgets.budget_code, aqbudgetperiods.budget_period_startdate,
3040 aqbudgetperiods.budget_period_enddate
3041 FROM aqbudgets JOIN aqbudgetperiods ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id
3042 ORDER BY budget_code, budget_period_startdate|, { Slice => {} });
3043 # We arbitarily order on start date, this means if you have overlapping periods the order will be
3044 # linked to the latest matching budget YMMV
3045 my $b_sth = $dbh->prepare(
3046 'UPDATE fundmapping set aqbudgetid = ? where bookfundid =? AND budgetdate >= ? AND budgetdate <= ?');
3047 for my $b ( @{$budg_arr}) {
3048 $b_sth->execute($b->{budget_id}, $b->{budget_code}, $b->{budget_period_startdate}, $b->{budget_period_enddate});
3050 # move the budgetids to aqorders
3051 $dbh->do(q|UPDATE aqorders, fundmapping SET aqorders.budget_id = fundmapping.aqbudgetid
3052 WHERE aqorders.ordernumber = fundmapping.ordernumber AND fundmapping.aqbudgetid IS NOT NULL|);
3053 # NB fundmapping is left as an accontants trail also if you have budgetids that werent set
3054 # you can decide what to do with them
3056 $dbh->do(
3057 q|UPDATE aqorders, aqbudgets SET aqorders.budgetgroup_id = aqbudgets.budget_period_id
3058 WHERE aqorders.budget_id = aqbudgets.budget_id|);
3059 # cannot do until aqorderbreakdown removed
3060 # $dbh->do("DROP TABLE aqbookfund ");
3061 # $dbh->do("ALTER TABLE aqorders ADD FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON UPDATE CASCADE " ); ????
3062 $dbh->do("SET FOREIGN_KEY_CHECKS=1 ");
3064 print "Upgrade to $DBversion done (Adding new aqbudgetperiods, aqbudgets and aqbudget_planning tables )\n";
3065 SetVersion ($DBversion);
3070 $DBversion = '3.01.00.078';
3071 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3072 $dbh->do("ALTER TABLE aqbudgetperiods ADD COLUMN budget_period_total decimal(28,6)");
3073 print "Upgrade to $DBversion done (adds 'budget_period_total' column to aqbudgetperiods table)\n";
3074 SetVersion($DBversion);
3078 $DBversion = '3.01.00.079';
3079 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3080 $dbh->do("ALTER TABLE currency ADD COLUMN active tinyint(1)");
3082 print "Upgrade to $DBversion done (adds 'active' column to currencies table)\n";
3083 SetVersion($DBversion);
3086 $DBversion = '3.01.00.080';
3087 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3088 $dbh->do(<<BUDG_PERM );
3089 INSERT INTO permissions (module_bit, code, description) VALUES
3090 (11, 'vendors_manage', 'Manage vendors'),
3091 (11, 'contracts_manage', 'Manage contracts'),
3092 (11, 'period_manage', 'Manage periods'),
3093 (11, 'budget_manage', 'Manage budgets'),
3094 (11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
3095 (11, 'planning_manage', 'Manage budget plannings'),
3096 (11, 'order_manage', 'Manage orders & basket'),
3097 (11, 'group_manage', 'Manage orders & basketgroups'),
3098 (11, 'order_receive', 'Manage orders & basket'),
3099 (11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
3100 BUDG_PERM
3102 print "Upgrade to $DBversion done (adds permissions for the acquisitions module)\n";
3103 SetVersion($DBversion);
3107 $DBversion = '3.01.00.081';
3108 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3109 $dbh->do("ALTER TABLE aqbooksellers ADD COLUMN `gstrate` decimal(6,4) default NULL");
3110 if (my $gist=C4::Context->preference("gist")){
3111 my $sql=$dbh->prepare("UPDATE aqbooksellers set `gstrate`=? ");
3112 $sql->execute($gist) ;
3114 print "Upgrade to $DBversion done (added per-supplier gstrate setting)\n";
3115 SetVersion($DBversion);
3118 $DBversion = "3.01.00.082";
3119 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3120 if (C4::Context->preference("opaclanguages") eq "fr") {
3121 $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')#);
3122 } else {
3123 $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')");
3125 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
3126 SetVersion ($DBversion);
3129 $DBversion = "3.01.00.083";
3130 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3131 $dbh->do(qq|
3132 CREATE TABLE `aqorders_items` (
3133 `ordernumber` int(11) NOT NULL,
3134 `itemnumber` int(11) NOT NULL,
3135 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
3136 PRIMARY KEY (`itemnumber`),
3137 KEY `ordernumber` (`ordernumber`)
3138 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
3141 $dbh->do(qq| DROP TABLE aqorderbreakdown |);
3142 $dbh->do('DROP TABLE aqbookfund');
3143 print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
3144 SetVersion ($DBversion);
3147 $DBversion = "3.01.00.084";
3148 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3149 $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') #);
3151 print "Upgrade to $DBversion done (CurrencyFormat syspref added)\n";
3152 SetVersion ($DBversion);
3155 $DBversion = "3.01.00.085";
3156 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3157 $dbh->do("ALTER table aqorders drop column title");
3158 $dbh->do("ALTER TABLE `aqorders` CHANGE `budget_id` `budget_id` INT( 11 ) NOT NULL");
3159 print "Upgrade to $DBversion done update budget_id size that should not be a tinyint\n";
3160 SetVersion ($DBversion);
3163 $DBversion = "3.01.00.086";
3164 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3165 $dbh->do(<<SUGGESTIONS);
3166 ALTER table suggestions
3167 ADD budgetid INT(11),
3168 ADD branchcode VARCHAR(10) default NULL,
3169 ADD acceptedby INT(11) default NULL,
3170 ADD accepteddate date default NULL,
3171 ADD suggesteddate date default NULL,
3172 ADD manageddate date default NULL,
3173 ADD rejectedby INT(11) default NULL,
3174 ADD rejecteddate date default NULL,
3175 ADD collectiontitle text default NULL,
3176 ADD itemtype VARCHAR(30) default NULL
3178 SUGGESTIONS
3179 print "Upgrade to $DBversion done (Suggestions)\n";
3180 SetVersion ($DBversion);
3183 $DBversion = "3.01.00.087";
3184 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3185 $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;");
3186 print "Upgrade to $DBversion done (Drop column budget_amount_sublevel from aqbudgets)\n";
3187 SetVersion ($DBversion);
3190 $DBversion = "3.01.00.088";
3191 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3192 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo') #);
3194 print "Upgrade to $DBversion done (intranetbookbag syspref added)\n";
3195 SetVersion ($DBversion);
3198 $DBversion = "3.01.00.090";
3199 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3200 $dbh->do("
3201 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3202 (16, 'execute_reports', 'Execute SQL reports'),
3203 (16, 'create_reports', 'Create SQL Reports')
3206 print "Upgrade to $DBversion done (granular permissions for guided reports added)\n";
3207 SetVersion ($DBversion);
3210 $DBversion = "3.01.00.091";
3211 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3212 $dbh->do("
3213 UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions'
3214 WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1
3217 print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
3218 SetVersion ($DBversion);
3221 $DBversion = "3.01.00.092";
3222 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3223 if (C4::Context->preference("opaclanguages") =~ /fr/) {
3224 $dbh->do(qq{
3225 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');
3227 }else{
3228 $dbh->do(qq{
3229 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');
3232 print "Upgrade to $DBversion done (Added RoutingListAddReserves syspref)\n";
3233 SetVersion ($DBversion);
3236 $DBversion = "3.01.00.093";
3237 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3238 $dbh->do(qq{
3239 ALTER TABLE biblioitems ADD INDEX issn_idx (issn);
3241 print "Upgrade to $DBversion done (added index to ISSN)\n";
3242 SetVersion ($DBversion);
3245 $DBversion = "3.01.00.094";
3246 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3247 $dbh->do(qq{
3248 ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10) default NULL, ADD deliverycomment VARCHAR(255) default NULL;
3251 print "Upgrade to $DBversion done (adding deliveryplace deliverycomment to basketgroups)\n";
3252 SetVersion ($DBversion);
3255 $DBversion = "3.01.00.095";
3256 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3257 $dbh->do(qq{
3258 ALTER TABLE items ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number";
3260 $dbh->do(qq{
3261 ALTER TABLE items ADD UNIQUE INDEX itemsstocknumberidx (stocknumber);
3263 $dbh->do(qq{
3264 ALTER TABLE deleteditems ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number of deleted items";
3266 $dbh->do(qq{
3267 ALTER TABLE deleteditems ADD UNIQUE INDEX deleteditemsstocknumberidx (stocknumber);
3269 if (C4::Context->preference('marcflavour') eq 'UNIMARC'){
3270 $dbh->do(qq{
3271 INSERT IGNORE INTO marc_subfield_structure (frameworkcode,tagfield, tagsubfield, tab, repeatable, mandatory,kohafield)
3272 SELECT DISTINCT (frameworkcode),995,"j",10,0,0,"items.stocknumber" from biblio_framework ;
3274 #Previously, copynumber was used as stocknumber
3275 $dbh->do(qq{
3276 UPDATE items set stocknumber=copynumber;
3278 $dbh->do(qq{
3279 UPDATE items set copynumber=NULL;
3282 print "Upgrade to $DBversion done (stocknumber field added)\n";
3283 SetVersion ($DBversion);
3286 $DBversion = "3.01.00.096";
3287 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3288 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPdfTemplate','','Uploads a PDF template to use for printing baskets','NULL','Upload')");
3289 $dbh->do("UPDATE systempreferences SET variable='OrderPdfFormat' WHERE variable='pdfformat'");
3290 print "Upgrade to $DBversion done (PDF orders system preferences added and updated)\n";
3291 SetVersion ($DBversion);
3294 $DBversion = "3.01.00.097";
3295 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3296 $dbh->do(qq{
3297 ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10) NOT NULL AFTER deliverycomment;
3300 print "Upgrade to $DBversion done (Adding billingplace to aqbasketgroups)\n";
3301 SetVersion ($DBversion);
3304 $DBversion = "3.01.00.098";
3305 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3306 $dbh->do(qq{
3307 ALTER TABLE auth_subfield_structure MODIFY frameworkcode VARCHAR(10) NULL;
3310 print "Upgrade to $DBversion done (changing frameworkcode length in auth_subfield_structure)\n";
3311 SetVersion ($DBversion);
3314 $DBversion = "3.01.00.099";
3315 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3316 $dbh->do(qq{
3317 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3318 (9, 'edit_catalogue', 'Edit catalogue'),
3319 (9, 'fast_cataloging', 'Fast cataloging')
3322 print "Upgrade to $DBversion done (granular permissions for cataloging added)\n";
3323 SetVersion ($DBversion);
3326 $DBversion = "3.01.00.100";
3327 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3328 $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')");
3329 print "Upgrade to $DBversion done (added CAS authentication system preferences)\n";
3330 SetVersion ($DBversion);
3333 $DBversion = "3.01.00.101";
3334 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3335 $dbh->do(
3336 "INSERT INTO systempreferences
3337 (variable, value, options, explanation, type)
3338 VALUES (
3339 'OverdueNoticeBcc', '', '',
3340 'Email address to Bcc outgoing notices sent by email',
3341 'free')
3343 print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
3344 SetVersion ($DBversion);
3346 $DBversion = "3.01.00.102";
3347 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3348 $dbh->do(
3349 "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
3351 print "Upgrade to $DBversion done (fixed spelling error in edit_catalogue permission)\n";
3352 SetVersion ($DBversion);
3355 $DBversion = "3.01.00.103";
3356 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3357 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
3358 print "Upgrade to $DBversion done (adding patron permissions for tags tool)\n";
3359 SetVersion ($DBversion);
3362 $DBversion = "3.01.00.104";
3363 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3365 my ($maninv_count, $borrnotes_count);
3366 eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
3367 if ($maninv_count == 0) {
3368 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
3370 eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
3371 if ($borrnotes_count == 0) {
3372 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
3375 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
3376 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
3378 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";
3379 SetVersion ($DBversion);
3383 $DBversion = "3.01.00.105";
3384 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3385 $dbh->do("
3386 CREATE TABLE `collections` (
3387 `colId` int(11) NOT NULL auto_increment,
3388 `colTitle` varchar(100) NOT NULL default '',
3389 `colDesc` text NOT NULL,
3390 `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
3391 PRIMARY KEY (`colId`)
3392 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3395 $dbh->do("
3396 CREATE TABLE `collections_tracking` (
3397 `ctId` int(11) NOT NULL auto_increment,
3398 `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
3399 `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
3400 PRIMARY KEY (`ctId`)
3401 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3403 $dbh->do("
3404 INSERT INTO permissions (module_bit, code, description)
3405 VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
3406 print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
3407 SetVersion ($DBversion);
3409 $DBversion = "3.01.00.106";
3410 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3411 $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' )");
3412 print "Upgrade to $DBversion done (added OpacAddMastheadLibraryPulldown system preferences)\n";
3413 SetVersion ($DBversion);
3416 $DBversion = '3.01.00.107';
3417 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3418 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
3419 system("perl $upgrade_script");
3420 print "Upgrade to $DBversion done (Migrated labels and patroncards tables and data to new schema.)\n";
3421 SetVersion ($DBversion);
3424 $DBversion = '3.01.00.108';
3425 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3426 $dbh->do(qq{
3427 ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
3428 ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
3429 ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator`
3431 print "Upgrade to $DBversion done (added separators for csv export)\n";
3432 SetVersion ($DBversion);
3435 $DBversion = "3.01.00.109";
3436 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3437 $dbh->do(qq{
3438 ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
3440 print "Upgrade to $DBversion done (added encoding for csv export)\n";
3441 SetVersion ($DBversion);
3444 $DBversion = '3.01.00.110';
3445 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3446 $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
3447 print "Upgrade to $DBversion done (Add enrolment period date support)\n";
3448 SetVersion ($DBversion);
3451 $DBversion = '3.01.00.111';
3452 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3453 print "Upgrade to $DBversion done (mark DBrev for 3.2-alpha release)\n";
3454 SetVersion ($DBversion);
3457 $DBversion = '3.01.00.112';
3458 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3459 $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');");
3460 print "Upgrade to $DBversion done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
3461 SetVersion ($DBversion);
3464 $DBversion = '3.01.00.113';
3465 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3466 my $value = C4::Context->preference("XSLTResultsDisplay");
3467 $dbh->do(
3468 "INSERT INTO systempreferences (variable,value,type)
3469 VALUES('OPACXSLTResultsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3470 $value = C4::Context->preference("XSLTDetailsDisplay");
3471 $dbh->do(
3472 "INSERT INTO systempreferences (variable,value,type)
3473 VALUES('OPACXSLTDetailsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3474 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";
3475 SetVersion ($DBversion);
3478 $DBversion = '3.01.00.114';
3479 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3480 $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')");
3481 $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')");
3482 $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')");
3483 print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
3484 SetVersion ($DBversion);
3487 $DBversion = '3.01.00.115';
3488 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3489 $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
3490 $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
3491 print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
3492 SetVersion ($DBversion);
3495 $DBversion = '3.01.00.116';
3496 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3497 if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
3498 $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
3500 print "Upgrade to $DBversion done (corrected default OrderPdfFormat value if still set wrong )\n";
3501 SetVersion ($DBversion);
3504 $DBversion = '3.01.00.117';
3505 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3506 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'por' WHERE rfc4646_subtag='pt' ");
3507 print "Upgrade to $DBversion done (corrected ISO 639-2 language code for Portuguese)\n";
3508 SetVersion ($DBversion);
3511 $DBversion = '3.01.00.118';
3512 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3513 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns
3514 WHERE table_name = 'aqbudgets_planning'
3515 AND column_name = 'display'");
3516 if ($count < 1) {
3517 $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1");
3519 print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n";
3520 SetVersion ($DBversion);
3523 $DBversion = '3.01.00.119';
3524 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3525 eval{require Locale::Currency::Format};
3526 if (!$@) {
3527 print "Upgrade to $DBversion done (Locale::Currency::Format installed.)\n";
3528 SetVersion ($DBversion);
3530 else {
3531 print "Upgrade to $DBversion done.\n";
3532 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";
3533 SetVersion ($DBversion);
3537 $DBversion = '3.01.00.120';
3538 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3539 $dbh->do(q{
3540 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');
3542 print "Upgrade to $DBversion done (bug 1080: add soundon system preference for circulation sounds)\n";
3543 SetVersion ($DBversion);
3546 $DBversion = '3.01.00.121';
3547 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3548 $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE DEFAULT NULL");
3549 $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3550 $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE DEFAULT NULL");
3551 $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3552 print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
3553 SetVersion ($DBversion);
3556 $DBversion = '3.01.00.122';
3557 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3558 $dbh->do(q{
3559 INSERT INTO systempreferences (variable,value,explanation,options,type)
3560 VALUES ('OAI-PMH:ConfFile', '', 'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','','File');
3562 print "Upgrade to $DBversion done. — Add a new system preference OAI-PMF:ConfFile\n";
3563 SetVersion ($DBversion);
3566 $DBversion = "3.01.00.123";
3567 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3568 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3569 (6, 'place_holds', 'Place holds for patrons')");
3570 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3571 (6, 'modify_holds_priority', 'Modify holds priority')");
3572 $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
3573 print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
3574 SetVersion ($DBversion);
3577 $DBversion = '3.01.00.124';
3578 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3579 $dbh->do("
3580 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>>).');
3582 print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
3583 SetVersion ($DBversion);
3586 $DBversion = '3.01.00.125';
3587 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3588 $dbh->do("
3589 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' );
3591 $dbh->do("
3592 INSERT INTO message_transport_types (message_transport_type) values ('print');
3594 print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
3595 SetVersion ($DBversion);
3598 $DBversion = "3.01.00.126";
3599 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3600 $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')");
3601 $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')");
3603 print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:AuthorizedIPs)\n";
3604 SetVersion ($DBversion);
3607 $DBversion = '3.01.00.127';
3608 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3609 $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
3610 print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
3611 SetVersion ($DBversion);
3614 $DBversion = '3.01.00.128';
3615 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3616 $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
3617 print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
3618 SetVersion ($DBversion);
3621 $DBversion = "3.01.00.129";
3622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3623 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
3624 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
3625 print "Upgrade to $DBversion done (Change permissions names for item batch modification / deletion)\n";
3627 SetVersion ($DBversion);
3630 $DBversion = "3.01.00.130";
3631 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3632 $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'");
3633 print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n";
3634 SetVersion ($DBversion);
3637 $DBversion = "3.01.00.131";
3638 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3639 $dbh->do(q{
3640 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
3642 print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
3643 SetVersion ($DBversion);
3646 $DBversion = "3.01.00.132";
3647 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3648 $dbh->do(q{
3649 ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
3651 print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
3652 SetVersion ($DBversion);
3655 $DBversion = '3.01.00.133';
3656 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3657 $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')");
3658 print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
3659 SetVersion ($DBversion);
3662 $DBversion = '3.01.00.134';
3663 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3664 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
3665 print "Upgrade to $DBversion done (adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page)\n";
3666 SetVersion ($DBversion);
3669 $DBversion = '3.01.00.135';
3670 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3671 $dbh->do("
3672 INSERT INTO `letter` (module, code, name, title, content) VALUES
3673 ('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')
3675 print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)\n";
3676 SetVersion ($DBversion);
3679 $DBversion = '3.01.00.136';
3680 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3681 $dbh->do(qq{
3682 INSERT INTO permissions (module_bit, code, description) VALUES
3683 ( 9, 'edit_items', 'Edit Items');});
3684 print "Upgrade to $DBversion done (Adding a new permission to edit items)\n";
3685 SetVersion ($DBversion);
3688 $DBversion = "3.01.00.137";
3689 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3690 $dbh->do("
3691 INSERT INTO permissions (module_bit, code, description) VALUES
3692 (15, 'check_expiration', 'Check the expiration of a serial'),
3693 (15, 'claim_serials', 'Claim missing serials'),
3694 (15, 'create_subscription', 'Create a new subscription'),
3695 (15, 'delete_subscription', 'Delete an existing subscription'),
3696 (15, 'edit_subscription', 'Edit an existing subscription'),
3697 (15, 'receive_serials', 'Serials receiving'),
3698 (15, 'renew_subscription', 'Renew a subscription'),
3699 (15, 'routing', 'Routing');
3701 print "Upgrade to $DBversion done (adding granular permissions for serials)\n";
3702 SetVersion ($DBversion);
3705 $DBversion = "3.01.00.138";
3706 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3707 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
3708 print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)\n";
3709 SetVersion ($DBversion);
3712 $DBversion = '3.01.00.139';
3713 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3714 $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
3715 print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
3716 SetVersion ($DBversion);
3719 $DBversion = '3.01.00.140';
3720 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3721 $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'TagsModeration' AND value is NULL");
3722 print "Upgrade to $DBversion done (bug 4312 TagsModeration changed from NULL to 0)\n";
3723 SetVersion ($DBversion);
3726 $DBversion = '3.01.00.141';
3727 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3728 $dbh->do(qq{DELETE FROM message_attributes WHERE message_attribute_id=3;});
3729 $dbh->do(qq{DELETE FROM letter WHERE code='EVENT' AND title='Upcoming Library Event';});
3730 print "Upgrade to $DBversion done Remove upcoming events messaging option (bug 2434)\n";
3731 SetVersion ($DBversion);
3734 $DBversion = '3.01.00.142';
3735 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3736 $dbh->do(qq{DELETE FROM message_transports WHERE message_attribute_id=3;});
3737 print "Upgrade to $DBversion done (Remove upcoming events messaging option part 2 (bug 2434))\n";
3738 SetVersion ($DBversion);
3741 $DBversion = '3.01.00.143';
3742 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3743 $dbh->do(qq{CREATE INDEX auth_value_idx ON authorised_values (authorised_value)});
3744 $dbh->do(qq{CREATE INDEX auth_val_cat_idx ON borrower_attribute_types (authorised_value_category)});
3745 print "Upgrade to $DBversion done (Create index on authorised_values and borrower_attribute_types (bug 4139))\n";
3746 SetVersion ($DBversion);
3749 $DBversion = '3.01.00.144';
3750 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3751 $dbh->do(qq{UPDATE systempreferences SET value='normal' where value='default' and variable='IntranetBiblioDefaultView'});
3752 print "Upgrade to $DBversion done (Update the 'default' to 'normal' for the IntranetBiblioDefaultView syspref (bug 5007))\n";
3753 SetVersion ($DBversion);
3756 $DBversion = "3.01.00.145";
3757 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3758 $dbh->do("ALTER TABLE borrowers ADD KEY `guarantorid` (guarantorid);");
3759 print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3760 SetVersion ($DBversion);
3763 $DBversion = '3.01.00.999';
3764 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3765 print "Upgrade to $DBversion done (3.2.0 release candidate)\n";
3766 SetVersion ($DBversion);
3769 $DBversion = "3.02.00.000";
3770 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3771 my $value = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'HomeOrHoldingBranch'");
3772 $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');");
3773 print "Upgrade to $DBversion done (Add HomeOrHoldingBranchReturn system preference)\n";
3774 SetVersion ($DBversion);
3777 $DBversion = "3.02.00.001";
3778 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3779 $dbh->do(q{DELETE FROM systempreferences WHERE variable IN (
3780 'holdCancelLength',
3781 'PINESISBN',
3782 'sortbynonfiling',
3783 'TemplateEncoding',
3784 'OPACSubscriptionDisplay',
3785 'OPACDisplayExtendedSubInfo',
3786 'OAI-PMH:Set',
3787 'OAI-PMH:Subset',
3788 'libraryAddress',
3789 'kohaspsuggest',
3790 'OrderPdfTemplate',
3791 'marc',
3792 'acquisitions',
3793 'MIME')
3796 print "Upgrade to $DBversion done (bug 3756: remove disused system preferences)\n";
3797 SetVersion ($DBversion);
3800 $DBversion = "3.02.00.002";
3801 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3802 $dbh->do(q{DELETE FROM systempreferences WHERE variable = 'OpacPrivacy'});
3803 print "Upgrade to $DBversion done (bug 3881: remove unused OpacPrivacy system preference)\n";
3804 SetVersion ($DBversion);
3807 $DBversion = "3.02.00.003";
3808 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3809 $dbh->do(q{UPDATE systempreferences SET variable = 'ILS-DI:AuthorizedIPs' WHERE variable = 'ILS-DI:Authorized_IPs'});
3810 print "Upgrade to $DBversion done (correct ILS-DI:AuthorizedIPs)\n";
3811 SetVersion ($DBversion);
3814 $DBversion = "3.02.00.004";
3815 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3816 print "Upgrade to $DBversion done (3.2.0 general release)\n";
3817 SetVersion ($DBversion);
3819 # This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3821 # apply updates that have already been done
3823 $DBversion = "3.03.00.001";
3824 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.005")) {
3825 $dbh->do("DELETE FROM subscriptionroutinglist WHERE borrowernumber IS NULL;");
3826 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `borrowernumber` int(11) NOT NULL;");
3827 $dbh->do("DELETE FROM subscriptionroutinglist WHERE subscriptionid IS NULL;");
3828 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `subscriptionid` int(11) NOT NULL;");
3829 $dbh->do("CREATE TEMPORARY TABLE del_subscriptionroutinglist
3830 SELECT s1.routingid FROM subscriptionroutinglist s1
3831 WHERE EXISTS (SELECT * FROM subscriptionroutinglist s2
3832 WHERE s2.borrowernumber = s1.borrowernumber
3833 AND s2.subscriptionid = s1.subscriptionid
3834 AND s2.routingid < s1.routingid);");
3835 $dbh->do("DELETE FROM subscriptionroutinglist
3836 WHERE routingid IN (SELECT routingid FROM del_subscriptionroutinglist);");
3837 $dbh->do("ALTER TABLE subscriptionroutinglist ADD UNIQUE (subscriptionid, borrowernumber);");
3838 $dbh->do("ALTER TABLE subscriptionroutinglist
3839 ADD CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`)
3840 REFERENCES `borrowers` (`borrowernumber`)
3841 ON DELETE CASCADE ON UPDATE CASCADE");
3842 $dbh->do("ALTER TABLE subscriptionroutinglist
3843 ADD CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`)
3844 REFERENCES `subscription` (`subscriptionid`)
3845 ON DELETE CASCADE ON UPDATE CASCADE");
3846 print "Upgrade to $DBversion done (Make subscriptionroutinglist more strict)\n";
3847 SetVersion ($DBversion);
3850 $DBversion = '3.03.00.002';
3851 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.006")) {
3852 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='arm' WHERE rfc4646_subtag='hy';");
3853 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='eng' WHERE rfc4646_subtag='en';");
3854 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'fi','fin');");
3855 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='fre' WHERE rfc4646_subtag='fr';");
3856 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'lo','lao');");
3857 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it';");
3858 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'sr','srp');");
3859 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'tet','tet');");
3860 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ur','urd');");
3862 print "Upgrade to $DBversion done (Correct language mappings)\n";
3863 SetVersion ($DBversion);
3866 $DBversion = '3.03.00.003';
3867 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.007")) {
3868 $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');");
3869 print "Upgrade to $DBversion done (Add UseTablesortForCirc syspref)\n";
3870 SetVersion ($DBversion);
3873 $DBversion = '3.03.00.004';
3874 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.001")) {
3875 my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ACCEPTED');
3876 $dbh->do(q/
3877 INSERT INTO `letter`
3878 (module, code, name, title, content)
3879 VALUES
3880 ('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>>')
3881 /) unless $count > 0;
3882 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'AVAILABLE');
3883 $dbh->do(q/
3884 INSERT INTO `letter`
3885 (module, code, name, title, content)
3886 VALUES
3887 ('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>>')
3888 /) unless $count > 0;
3889 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ORDERED');
3890 $dbh->do(q/
3891 INSERT INTO `letter`
3892 (module, code, name, title, content)
3893 VALUES
3894 ('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>>')
3895 /) unless $count > 0;
3896 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'REJECTED');
3897 $dbh->do(q/
3898 INSERT INTO `letter`
3899 (module, code, name, title, content)
3900 VALUES
3901 ('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>>')
3902 /) unless $count > 0;
3903 print "Upgrade to $DBversion done (bug 5127: add default templates for suggestion status change notifications)\n";
3904 SetVersion ($DBversion);
3907 $DBversion = '3.03.00.005';
3908 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3909 $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
3910 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
3913 $DBversion = '3.03.00.006';
3914 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.002")) {
3915 $dbh->do("ALTER TABLE deletedborrowers ADD `privacy` int(11) AFTER smsalertnumber;");
3916 $dbh->do("ALTER TABLE deletedborrowers CHANGE `cardnumber` `cardnumber` varchar(16);");
3917 print "Upgrade to $DBversion done (Fix differences between borrowers and deletedborrowers)\n";
3918 SetVersion ($DBversion);
3921 $DBversion = '3.03.00.007';
3922 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3923 $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL,
3924 ADD currency VARCHAR(3) default NULL,
3925 ADD price DECIMAL(28,6) default NULL,
3926 ADD total DECIMAL(28,6) default NULL;
3928 print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n";
3929 SetVersion ($DBversion);
3932 $DBversion = '3.03.00.008';
3933 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3934 $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')");
3935 print "Upgrade to $DBversion done (adding syspref OPACNoResultsFound to control what displays when no results are found for a search in the OPAC.)\n";
3936 SetVersion ($DBversion);
3939 $DBversion = '3.03.00.009';
3940 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.003")) {
3941 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetUserCSS','','Add CSS to be included in the Intranet',NULL,'free')");
3942 print "Upgrade to $DBversion done (Add IntranetUserCSS syspref)\n";
3943 SetVersion ($DBversion);
3946 $DBversion = "3.03.00.010";
3947 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.02.001")) {
3948 $dbh->do("UPDATE `marc_subfield_structure` SET liblibrarian = 'Distance from earth' WHERE liblibrarian = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3949 $dbh->do("UPDATE `marc_subfield_structure` SET libopac = 'Distance from earth' WHERE libopac = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3950 print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
3951 SetVersion ($DBversion);
3954 $DBversion = "3.03.00.011";
3955 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3956 $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3957 print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
3958 SetVersion ($DBversion);
3961 $DBversion = "3.03.00.012";
3962 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3963 $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')");
3964 print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
3965 SetVersion ($DBversion);
3968 $DBversion = "3.03.00.013";
3969 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3970 $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')");
3971 print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n";
3972 SetVersion ($DBversion);
3975 $DBversion = "3.03.00.014";
3976 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3977 $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')");
3978 $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')");
3979 $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')");
3980 print "Upgrade to $DBversion done (Add flexible shelf browser constraints)\n";
3981 SetVersion ($DBversion);
3984 $DBversion = "3.03.00.015";
3985 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3986 if ( C4::Context->preference("marcflavour") eq "MARC21" ) {
3987 my $sth = $dbh->prepare(
3988 "INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`,
3989 `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`)
3990 VALUES ( ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, '', 6, '', '', '', 0, -5, '', '', '', NULL)"
3992 $sth->execute('648');
3993 $sth->execute('654');
3994 $sth->execute('655');
3995 $sth->execute('656');
3996 $sth->execute('657');
3997 $sth->execute('658');
3998 $sth->execute('662');
3999 $sth->finish;
4000 print
4001 "Upgrade to $DBversion done (Bug 5619: Add subfield 9 to marc21 648,654,655,656,657,658,662)\n";
4003 SetVersion($DBversion);
4006 $DBversion = '3.03.00.016';
4007 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4008 # reimplement OpacPrivacy system preference
4009 $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')");
4010 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4011 $dbh->do("ALTER TABLE `deletedborrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
4012 print "Upgrade to $DBversion done (OpacPrivacy reimplementation)\n";
4013 SetVersion($DBversion);
4016 $DBversion = '3.03.00.017';
4017 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.001")) {
4018 $dbh->do("ALTER TABLE `currency` CHANGE `rate` `rate` FLOAT( 15, 5 ) NULL DEFAULT NULL;");
4019 print "Upgrade to $DBversion done (Enable currency rates >= 100)\n";
4020 SetVersion ($DBversion);
4023 $DBversion = '3.03.00.018';
4024 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.002")) {
4025 $dbh->do( q|update language_descriptions set description = 'Nederlands' where lang = 'nl' and subtag = 'nl'|);
4026 $dbh->do( q|update language_descriptions set description = 'Dansk' where lang = 'da' and subtag = 'da'|);
4027 print "Upgrade to $DBversion done (Correct language descriptions)\n";
4028 SetVersion ($DBversion);
4031 $DBversion = '3.03.00.019';
4032 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.003")) {
4033 # Fix bokmål
4034 $dbh->do("UPDATE language_subtag_registry SET description = 'Norwegian bokm&#229;l' WHERE subtag = 'nb';");
4035 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nb','nob');");
4036 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokm&#229;l' WHERE subtag = 'nb' AND lang = 'nb';");
4037 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokm&#229;l' WHERE subtag = 'nb' AND lang = 'en';");
4038 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokm&#229;l' WHERE subtag = 'nb' AND lang = 'fr';");
4039 # Add nynorsk
4040 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'nn', 'language', 'Norwegian nynorsk','2011-02-14' )");
4041 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nn','nno')");
4042 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nb', 'Norsk nynorsk')");
4043 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nn', 'Norsk nynorsk')");
4044 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'en', 'Norwegian nynorsk')");
4045 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'fr', 'Norvégien nynorsk')");
4046 print "Upgrade to $DBversion done (Correct language descriptions for Norwegian)\n";
4047 SetVersion ($DBversion);
4050 $DBversion = '3.03.00.020';
4051 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4052 $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')");
4053 $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')");
4054 print "Upgrade to $DBversion done (Bug 5811: Add sysprefs controlling overriding fines)\n";
4055 SetVersion($DBversion);
4058 $DBversion = '3.03.00.021';
4059 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.001")) {
4060 $dbh->do("ALTER TABLE items MODIFY enumchron TEXT");
4061 $dbh->do("ALTER TABLE deleteditems MODIFY enumchron TEXT");
4062 print "Upgrade to $DBversion done (bug 5642: longer serial enumeration)\n";
4063 SetVersion ($DBversion);
4066 $DBversion = '3.03.00.022';
4067 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4068 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo');");
4069 print "Upgrade to $DBversion done (Add AuthoritiesLog syspref)\n";
4070 SetVersion ($DBversion);
4073 # due to a mismatch in kohastructure.sql some koha will have missing columns in aqbasketgroup
4074 # this attempts to fix that
4075 $DBversion = '3.03.00.023';
4076 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.002")) {
4077 my $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'billingplace'");
4078 $sth->execute;
4079 $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4080 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliveryplace'");
4081 $sth->execute;
4082 $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4083 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliverycomment'");
4084 $sth->execute;
4085 $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") if ! $sth->fetchrow_hashref;
4086 print "Upgrade to $DBversion done (Reconcile aqbasketgroups)\n";
4087 SetVersion ($DBversion);
4090 $DBversion = '3.03.00.024';
4091 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4092 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo')");
4093 $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')");
4094 print "Upgrade to $DBversion done (Add syspref to force whole-subfield matching on subject tracings)\n";
4095 SetVersion($DBversion);
4098 $DBversion = "3.03.00.025";
4099 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4100 $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')");
4101 print "Upgrade to $DBversion done (Add syspref to control if user can choose pickup branch for holds)\n";
4102 SetVersion ($DBversion);
4105 $DBversion = '3.03.00.026';
4106 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.003")) {
4107 $dbh->do("UPDATE `message_attributes` SET message_name='Item Due' WHERE message_attribute_id=1 AND message_name LIKE 'Item DUE'");
4108 print "Upgrade to $DBversion done ( fix capitalization in message type )\n";
4109 SetVersion ($DBversion);
4112 $DBversion = '3.03.00.027';
4113 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4114 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('displayFacetCount', '0', NULL, NULL, 'YesNo')");
4115 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('maxRecordsForFacets', '20', NULL, NULL, 'Integer')");
4116 print "Upgrade to $DBversion done (Preferences for facet count)\n";
4117 SetVersion ($DBversion);
4120 $DBversion = "3.03.00.028";
4121 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4122 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('FacetLabelTruncationLength', 20, 'Truncate facets length to','','free')");
4123 print "Upgrade to $DBversion done (Add FacetLabelTruncationLength syspref to control facets displayed length)\n";
4124 SetVersion ($DBversion);
4127 $DBversion = "3.03.00.029";
4128 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4129 $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')");
4130 print "Upgrade to $DBversion done (Add syspref to control if user can choose branch when making purchase suggestion)\n";
4131 SetVersion ($DBversion);
4134 $DBversion = "3.03.00.030";
4135 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4136 $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')");
4137 $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')");
4138 print "Upgrade to $DBversion done (Add sysprefs to control custom favicons)\n";
4139 SetVersion ($DBversion);
4142 $DBversion = "3.03.00.031";
4143 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4144 $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');");
4145 print "Upgrade to $DBversion done (Add syspref FineNotifyAtCheckin)\n";
4146 SetVersion ($DBversion);
4149 $DBversion = '3.03.00.032';
4150 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4151 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', 1, 'Create searches on all subdivisions for subject tracings.','1','YesNo')");
4152 print "Upgrade to $DBversion done ( include subdivisions when generating subject tracing searches )\n";
4156 $DBversion = '3.03.00.033';
4157 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4158 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages', '1', '', NULL, 'YesNo')");
4159 print "Upgrade to $DBversion done (System pref StaffAuthorisedValueImages)\n";
4160 SetVersion ($DBversion);
4163 $DBversion = '3.03.00.034';
4164 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4165 $dbh->do("ALTER TABLE `categories` ADD `hidelostitems` tinyint(1) NOT NULL default '0' AFTER `reservefee`");
4166 print "Upgrade to $DBversion done (Add hidelostitems preference to borrower categories)\n";
4167 SetVersion ($DBversion);
4170 $DBversion = '3.03.00.035';
4171 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4172 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedate date default NULL AFTER issuelength");
4173 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedatecompare tinyint NOT NULL default 0 AFTER hardduedate");
4174 my $duedate;
4175 if (C4::Context->preference("globalDueDate")) {
4176 $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("globalDueDate") ), dateonly => 1, dateformat => 'iso' } ); };
4177 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = 0");
4178 } elsif (C4::Context->preference("ceilingDueDate")) {
4179 $duedate = eval { output_pref( { dt => dt_from_string( C4::Context->preference("ceilingDueDate") ), dateonly => 1, dateformat => 'iso' } ); };
4180 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = -1");
4182 $dbh->do("DELETE FROM `systempreferences` WHERE variable = 'globalDueDate' OR variable = 'ceilingDueDate'");
4183 print "Upgrade to $DBversion done (Move global and ceiling due dates to Circ Rules level)\n";
4184 SetVersion ($DBversion);
4187 $DBversion = '3.03.00.036';
4188 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4189 $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')");
4190 print "Upgrade to $DBversion done ( Make COinS optional in OPAC search results )\n";
4191 SetVersion ($DBversion);
4194 $DBversion = '3.03.00.037';
4195 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4196 $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')");
4197 $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')");
4198 print "Upgrade to $DBversion done (Add 'Display856uAsImage' and 'OPACDisplay856uAsImage' syspref)\n";
4199 SetVersion ($DBversion);
4202 $DBversion = '3.03.00.038';
4203 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4204 $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')");
4205 $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')");
4206 $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')");
4207 print "Upgrade to $DBversion done ( Add Self-checkout by Login system preferences )\n";
4210 $DBversion = "3.03.00.039";
4211 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4212 $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');");
4213 print "Upgrade to $DBversion done (Add syspref ShowReviewer)\n";
4216 $DBversion = "3.03.00.040";
4217 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4218 $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');");
4219 print "Upgrade to $DBversion done (Add syspref UseControlNumber)\n";
4222 $DBversion = "3.03.00.041";
4223 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4224 $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')");
4225 $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')");
4226 print "Upgrade to $DBversion done (Add sysprefs to control alternate holdings information display)\n";
4227 SetVersion ($DBversion);
4230 $DBversion = '3.03.00.042';
4231 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4232 stocknumber_checker();
4233 print "Upgrade to $DBversion done (5860 Index itemstocknumber)\n";
4234 SetVersion ($DBversion);
4237 sub stocknumber_checker { #code reused later on
4238 my @row;
4239 #drop the obsolete itemSStocknumber idx if it exists
4240 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemsstocknumberidx'");
4241 $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;") if @row;
4243 #check itemstocknumber idx; remove it if it is unique
4244 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx' AND non_unique=0");
4245 $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;") if @row;
4247 #add itemstocknumber index non-unique IF it still not exists
4248 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx'");
4249 $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);") unless @row;
4252 $DBversion = "3.03.00.043";
4253 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4255 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No')");
4256 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes')");
4258 print "Upgrade to $DBversion done ( add generic boolean YES_NO authorised_values pair )\n";
4259 SetVersion ($DBversion);
4262 $DBversion = '3.03.00.044';
4263 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4264 $dbh->do("ALTER TABLE `aqbasketgroups` ADD `freedeliveryplace` TEXT NULL AFTER `deliveryplace`;");
4265 print "Upgrade to $DBversion done (adding freedeliveryplace to basketgroups)\n";
4268 $DBversion = '3.03.00.045';
4269 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4270 #Remove obsolete columns from aqbooksellers if needed
4271 my $a = $dbh->selectall_hashref('SHOW columns from aqbooksellers','Field');
4272 my $sqldrop="ALTER TABLE aqbooksellers DROP COLUMN ";
4273 foreach(qw/deliverydays followupdays followupscancel invoicedisc nocalc specialty/) {
4274 $dbh->do($sqldrop.$_) if exists $a->{$_};
4276 #Remove obsolete column from aqbudgets if needed
4277 #The correct column is budget_notes
4278 $a = $dbh->selectall_hashref('SHOW columns from aqbudgets','Field');
4279 if(exists $a->{budget_description}) {
4280 $dbh->do("ALTER TABLE aqbudgets DROP COLUMN budget_description");
4282 print "Upgrade to $DBversion done (Remove obsolete columns from aqbooksellers and aqbudgets if needed)\n";
4283 SetVersion ($DBversion);
4286 $DBversion = "3.03.00.046";
4287 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4288 $dbh->do("ALTER TABLE overduerules ALTER delay1 SET DEFAULT NULL, ALTER delay2 SET DEFAULT NULL, ALTER delay3 SET DEFAULT NULL");
4289 print "Upgrade to $DBversion done (Setting NULL default value for delayn columns in table overduerules)\n";
4290 SetVersion($DBversion);
4293 $DBversion = '3.03.00.047';
4294 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4295 $dbh->do("ALTER TABLE borrowers ADD `state` mediumtext AFTER city;");
4296 $dbh->do("ALTER TABLE borrowers ADD `B_state` mediumtext AFTER B_city;");
4297 $dbh->do("ALTER TABLE borrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4298 $dbh->do("ALTER TABLE deletedborrowers ADD `state` mediumtext AFTER city;");
4299 $dbh->do("ALTER TABLE deletedborrowers ADD `B_state` mediumtext AFTER B_city;");
4300 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4301 print "Upgrade to $DBversion done (Add state field to patron's addresses)\n";
4304 $DBversion = '3.03.00.048';
4305 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4306 $dbh->do("ALTER TABLE branches ADD `branchstate` mediumtext AFTER `branchcity`;");
4307 print "Upgrade to $DBversion done (Add state to branch address)\n";
4308 SetVersion ($DBversion);
4311 $DBversion = '3.03.00.049';
4312 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4313 $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4314 $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4315 print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n";
4316 SetVersion($DBversion);
4319 $DBversion = "3.03.00.050";
4320 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4321 $dbh->do("
4322 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');
4324 print "Upgrade to $DBversion done (Adding OpacHiddenItems syspref)\n";
4325 SetVersion($DBversion);
4328 $DBversion = "3.03.00.051";
4329 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4330 print "Upgrade to $DBversion done (Remove spaces and dashes from message_attribute names)\n";
4331 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Due' WHERE message_name='Item Due'");
4332 $dbh->do("UPDATE message_attributes SET message_name = 'Advance_Notice' WHERE message_name='Advance Notice'");
4333 $dbh->do("UPDATE message_attributes SET message_name = 'Hold_Filled' WHERE message_name='Hold Filled'");
4334 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Check_in' WHERE message_name='Item Check-in'");
4335 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Checkout' WHERE message_name='Item Checkout'");
4336 SetVersion ($DBversion);
4339 $DBversion = "3.03.00.052";
4340 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4341 $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');");
4342 print "Upgrade to $DBversion done (Add syspref WaitingNotifyAtCheckin)\n";
4343 SetVersion ($DBversion);
4346 $DBversion = "3.04.00.000";
4347 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4348 print "Upgrade to $DBversion done Koha 3.4.0 release \n";
4349 SetVersion ($DBversion);
4352 $DBversion = "3.05.00.001";
4353 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4354 $dbh->do(qq{
4355 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');
4357 print "Upgrade to $DBversion done (Adds New System preference numSearchRSSResults)\n";
4358 SetVersion($DBversion);
4361 $DBversion = '3.05.00.002';
4362 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4363 #follow up fix 5860: some installs already past 3.3.0.42
4364 stocknumber_checker();
4365 print "Upgrade to $DBversion done (Fix for stocknumber index)\n";
4366 SetVersion ($DBversion);
4369 $DBversion = "3.05.00.003";
4370 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4371 $dbh->do(qq{
4372 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');
4374 print "Upgrade to $DBversion done (Adds New System preference OpacRenewalBranch)\n";
4375 SetVersion($DBversion);
4378 $DBversion = "3.05.00.004";
4379 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4380 $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');");
4381 print "Upgrade to $DBversion done (Add syspref ShowReviewerPhoto)\n";
4382 SetVersion($DBversion);
4385 $DBversion = "3.05.00.005";
4386 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4387 $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');");
4388 print "Upgrade to $DBversion done (Adds pref BasketConfirmations)\n";
4389 SetVersion($DBversion);
4392 $DBversion = "3.05.00.006";
4393 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4394 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea')");
4395 print "Upgrade to $DBversion done (Add syspref MARCAuthorityControlField008)\n";
4396 SetVersion ($DBversion);
4399 $DBversion = "3.05.00.007";
4400 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4401 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');");
4402 print "Upgrade to $DBversion done (Add syspref OpenLibraryCovers)\n";
4403 SetVersion($DBversion);
4406 $DBversion = "3.05.00.008";
4407 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4408 $dbh->do("ALTER TABLE `cities` ADD `city_state` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_name`;");
4409 $dbh->do("ALTER TABLE `cities` ADD `city_country` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_zipcode`;");
4410 print "Add state and country to cities table corresponding to new columns in borrowers\n";
4411 SetVersion($DBversion);
4414 $DBversion = "3.05.00.009";
4415 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4416 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4417 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE borrowernumber IS NULL");
4418 $dbh->do("DELETE FROM issues WHERE borrowernumber IS NULL");
4420 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4421 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE itemnumber IS NULL");
4422 $dbh->do("DELETE FROM issues WHERE itemnumber IS NULL");
4424 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4425 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)");
4426 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowernumber = issues.borrowernumber)");
4428 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4429 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)");
4430 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM items WHERE itemnumber = issues.itemnumber)");
4432 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_1`");
4433 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_2`");
4434 $dbh->do("ALTER TABLE issues ALTER COLUMN borrowernumber DROP DEFAULT");
4435 $dbh->do("ALTER TABLE issues ALTER COLUMN itemnumber DROP DEFAULT");
4436 $dbh->do("ALTER TABLE issues MODIFY COLUMN borrowernumber int(11) NOT NULL");
4437 $dbh->do("ALTER TABLE issues MODIFY COLUMN itemnumber int(11) NOT NULL");
4438 $dbh->do("ALTER TABLE issues DROP KEY `issuesitemidx`");
4439 $dbh->do("ALTER TABLE issues ADD PRIMARY KEY (`itemnumber`)");
4440 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4441 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4443 print "Upgrade to $DBversion done (issues referential integrity)\n";
4444 SetVersion ($DBversion);
4447 $DBversion = "3.05.00.010";
4448 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4449 $dbh->do("CREATE INDEX priorityfoundidx ON reserves (priority,found)");
4450 print "Create an index on reserves to speed up holds awaiting pickup report bug 5866\n";
4451 SetVersion($DBversion);
4455 $DBversion = "3.05.00.011";
4456 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4457 $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')");
4458 print "Upgrade to $DBversion done (add OPACResultsSidebar syspref (enh 6165))\n";
4459 SetVersion($DBversion);
4462 $DBversion = "3.05.00.012";
4463 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4464 $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')");
4465 print "Upgrade to $DBversion done (add RecordLocalUseOnReturn syspref (enh 6403))\n";
4466 SetVersion($DBversion);
4469 $DBversion = "3.05.00.013";
4470 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4471 $dbh->do(qq|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','0',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL)|);
4472 print "Upgrade to $DBversion done (Add syspref 'OpacKohaUrl')\n";
4473 SetVersion($DBversion);
4476 $DBversion = "3.05.00.014";
4477 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4478 $dbh->do("ALTER TABLE `borrowers` MODIFY `userid` VARCHAR(75)");
4479 print "Modified userid column length into 75 in borrowers\n";
4480 SetVersion($DBversion);
4483 $DBversion = "3.05.00.015";
4484 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4485 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectEnabled',0,'Enable Novelist Select content. Requires Novelist Profile and Password',NULL,'YesNo')");
4486 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectProfile',NULL,'Novelist Select user Password',NULL,'free')");
4487 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectPassword',NULL,'Enable Novelist user Profile',NULL,'free')");
4488 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectView','tab','Where to display Novelist Select content','tab|above|below|right','Choice')");
4489 print "Upgrade to $DBversion done (Add support for EBSCO's NoveList Select (enh 6902))\n";
4490 SetVersion($DBversion);
4493 $DBversion = '3.05.00.016';
4494 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4495 $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');");
4496 print "Upgrade to $DBversion done (Add EasyAnalyticalRecords syspref)\n";
4497 SetVersion ($DBversion);
4500 $DBversion = '3.05.00.017';
4501 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4502 if (C4::Context->preference("marcflavour") eq 'MARC21' ||
4503 C4::Context->preference("marcflavour") eq 'NORMARC'){
4504 $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)");
4505 $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)");
4506 print "Upgrade to $DBversion done (Add 773 subfield 9 and 0 to default framework)\n";
4507 SetVersion ($DBversion);
4508 } elsif (C4::Context->preference("marcflavour") eq 'UNIMARC'){
4509 $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)");
4510 print "Upgrade to $DBversion done (Add 461 subfield 9 to default framework)\n";
4511 SetVersion ($DBversion);
4515 $DBversion = "3.05.00.018";
4516 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4517 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacNavBottom','','Links after OpacNav links','70|10','Textarea')");
4518 print "Upgrade to $DBversion done (add OpacNavBottom syspref (enh 6825): if appropriate, you can split OpacNav into OpacNav and OpacNavBottom)\n";
4519 SetVersion($DBversion);
4522 $DBversion = "3.05.00.019";
4523 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4524 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4525 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4526 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4527 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4528 print "Upgrade to $DBversion done (remove duplicate VOKAL Book icons, bug 6862)\n";
4529 SetVersion($DBversion);
4532 $DBversion = "3.05.00.020";
4533 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4534 $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')");
4535 print "Upgrade to $DBversion done (Add syspref AcqViewBaskets)\n";
4536 SetVersion($DBversion);
4539 $DBversion = "3.05.00.021";
4540 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4541 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN display_checkout TINYINT(1) NOT NULL DEFAULT '0';");
4542 print "Upgrade to $DBversion done (Added a display_checkout field in borrower_attribute_types table)\n";
4543 SetVersion($DBversion);
4546 $DBversion = "3.05.00.022";
4547 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4548 $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");
4549 print "Upgrade to $DBversion done (6094: Fixing ModAuthority problems, add a need_merge_authorities table)\n";
4550 SetVersion($DBversion);
4553 $DBversion = "3.05.00.023";
4554 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4555 $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');");
4556 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";
4557 SetVersion($DBversion);
4560 $DBversion = "3.06.00.000";
4561 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4562 print "Upgrade to $DBversion done Koha 3.6.0 release \n";
4563 SetVersion ($DBversion);
4566 $DBversion = "3.07.00.001";
4567 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4568 my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred =1;", { Columns => [1] } );
4569 $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
4570 $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
4571 $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4572 $dbh->do("ALTER TABLE deletedborrowers MODIFY debarred DATE DEFAULT NULL;");
4573 $dbh->do("ALTER TABLE deletedborrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4574 print "Upgrade done (Change borrowers.debarred into Date )\n";
4575 SetVersion($DBversion);
4578 $DBversion = "3.07.00.002";
4579 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4580 $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';");
4581 print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n";
4582 SetVersion($DBversion);
4585 $DBversion = "3.07.00.003";
4586 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4587 $dbh->do(" UPDATE `message_attributes` SET message_name='Item_Due' WHERE message_name='Item_DUE'");
4588 print "Updating message_name in message_attributes\n";
4589 SetVersion($DBversion);
4592 $DBversion = "3.07.00.004";
4593 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4594 $dbh->do("ALTER TABLE `suggestions` ADD `patronreason` TEXT NULL AFTER `reason`");
4595 print "Upgrade to $DBversion done (Add column to suggestions table to store patrons' reasons for submitting a suggestion. )\n";
4596 SetVersion($DBversion);
4599 $DBversion = "3.07.00.005";
4600 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4601 $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')");
4602 print "Upgrade to $DBversion done (BorrowerUnwantedField syspref)\n";
4603 SetVersion ($DBversion);
4606 $DBversion = "3.07.00.006";
4607 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4608 $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');");
4609 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";
4610 SetVersion($DBversion);
4613 $DBversion = "3.07.00.007";
4614 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4615 $dbh->do("ALTER TABLE items MODIFY materials text;");
4616 print "Upgrade to $DBversion done alter items.material from varchar(10) to text \n";
4617 SetVersion($DBversion);
4620 $DBversion = '3.07.00.008';
4621 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4622 if (C4::Context->preference("marcflavour") eq 'MARC21') {
4623 if (C4::Context->preference("opaclanguages") eq "de") {
4624 $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, '');");
4625 } else {
4626 $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, '');");
4629 print "Upgrade to $DBversion done (add MARC21 field 545 to framework)\n";
4630 SetVersion ($DBversion);
4633 $DBversion = "3.07.00.009";
4634 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4635 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `claims_count` INT(11) DEFAULT 0, ADD COLUMN `claimed_date` DATE DEFAULT NULL AFTER `claims_count`");
4636 print "Upgrade to $DBversion done (Add claims_count and claimed_date fields in aqorders table)\n";
4637 SetVersion($DBversion);
4640 $DBversion = "3.07.00.010";
4641 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4642 $dbh->do(
4643 q|CREATE TABLE `biblioimages` (
4644 `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
4645 `biblionumber` int(11) NOT NULL,
4646 `mimetype` varchar(15) NOT NULL,
4647 `imagefile` mediumblob NOT NULL,
4648 `thumbnail` mediumblob NOT NULL,
4649 PRIMARY KEY (`imagenumber`),
4650 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4651 ) ENGINE=InnoDB DEFAULT CHARSET=utf8|
4653 $dbh->do(
4654 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|
4656 $dbh->do(
4657 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|
4659 $dbh->do(
4660 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')|
4662 $dbh->do(
4663 q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|
4665 print "Upgrade to $DBversion done (Added support for local cover images)\n";
4666 SetVersion($DBversion);
4669 $DBversion = "3.07.00.011";
4670 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4671 $dbh->do(<<ENDOFRENEWAL);
4672 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');
4673 ENDOFRENEWAL
4674 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";
4675 SetVersion($DBversion);
4678 $DBversion = "3.07.00.012";
4679 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4680 $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')");
4681 print "Upgrade to $DBversion add 'AllowItemsOnHoldCheckout' syspref \n";
4682 SetVersion ($DBversion);
4685 $DBversion = "3.07.00.013";
4686 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4687 $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');");
4688 print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n";
4689 SetVersion ($DBversion);
4692 $DBversion = "3.07.00.014";
4693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4694 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";
4695 SetVersion($DBversion);
4698 $DBversion = "3.07.00.015";
4699 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4700 my $sth = $dbh->prepare(q|
4701 SELECT COUNT(*) FROM marc_subfield_structure where kohafield="biblioitems.editionstatement"
4703 $sth->execute;
4704 my $already_exists = $sth->fetchrow;
4705 if ( not $already_exists ) {
4706 my $field = C4::Context->preference("marcflavour") eq "UNIMARC" ? "205" : "250";
4707 my $subfield = "a";
4708 my $sth = $dbh->prepare( q|
4709 UPDATE marc_subfield_structure SET kohafield = "biblioitems.editionstatement"
4710 WHERE tagfield = ? AND tagsubfield = ?
4712 $sth->execute( $field, $subfield );
4713 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement.)\n";
4714 } else {
4715 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement (already exists, nothing to do).)\n";
4717 SetVersion($DBversion);
4720 $DBversion = "3.07.00.016";
4721 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4722 $dbh->do("ALTER TABLE items ADD KEY `itemcallnumber` (itemcallnumber)");
4723 print "Upgrade to $DBversion done (Added index on items.itemcallnumber)\n";
4724 SetVersion($DBversion);
4727 $DBversion = "3.07.00.017";
4728 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4729 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo')");
4730 print "Upgrade to $DBversion done (Add sysprefs to control transfer when cancel all waiting holds)\n";
4731 SetVersion ($DBversion);
4734 $DBversion = "3.07.00.018";
4735 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4736 $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;");
4737 print "Upgrade to $DBversion done ( adding offline operations table )\n";
4738 SetVersion($DBversion);
4741 $DBversion = "3.07.00.019";
4742 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4743 $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");
4744 $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");
4745 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";
4746 SetVersion($DBversion);
4749 $DBversion = "3.07.00.020";
4750 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4751 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo');");
4752 print "Upgrade to $DBversion done (Bug 3516: Add the option to show patron images in the OPAC.)\n";
4753 SetVersion($DBversion);
4756 $DBversion = "3.07.00.021";
4757 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4758 $dbh->do(
4759 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerModule','Default','Chooses which linker module to use (see documentation).','Default|FirstMatchLastMatch','Choice');"
4761 $dbh->do(
4762 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free');"
4764 $dbh->do(
4765 "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');"
4767 $dbh->do(
4768 "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');"
4770 $dbh->do(
4771 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AutoCreateAuthorities',0,'Automatically create authorities that do not exist when cataloging records.',NULL,'YesNo');"
4773 $dbh->do(
4774 "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');"
4776 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";
4777 SetVersion($DBversion);
4780 $DBversion = "3.07.00.022";
4781 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4782 $dbh->do("DELETE FROM reviews WHERE biblionumber NOT IN (SELECT biblionumber from biblio)");
4783 $dbh->do("UPDATE reviews SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers)");
4784 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_2 FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
4785 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber ) ON UPDATE CASCADE ON DELETE SET NULL");
4786 print "Upgrade to $DBversion done (Bug 7493 - Add constraint linking OPAC comment biblionumber to biblio, OPAC comment borrowernumber to borrowers.)\n";
4787 SetVersion($DBversion);
4790 $DBversion = "3.07.00.023";
4791 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4792 $dbh->do("ALTER TABLE `message_transports` DROP FOREIGN KEY `message_transports_ibfk_3`");
4793 $dbh->do("ALTER TABLE `letter` DROP PRIMARY KEY");
4794 $dbh->do("ALTER TABLE `letter` ADD `branchcode` varchar(10) default NULL AFTER `code`");
4795 $dbh->do("ALTER TABLE `letter` ADD PRIMARY KEY (`module`,`code`, `branchcode`)");
4796 $dbh->do("ALTER TABLE `message_transports` ADD `branchcode` varchar(10) NOT NULL default ''");
4797 $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");
4798 $dbh->do("ALTER TABLE `letter` ADD `is_html` tinyint(1) default 0 AFTER `name`");
4800 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4801 VALUES ('circulation','ISSUESLIP','Issue Slip','Issue Slip', '<h3><<branches.branchname>></h3>
4802 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4803 (<<borrowers.cardnumber>>) <br />
4805 <<today>><br />
4807 <h4>Checked Out</h4>
4808 <checkedout>
4810 <<biblio.title>> <br />
4811 Barcode: <<items.barcode>><br />
4812 Date due: <<issues.date_due>><br />
4813 </p>
4814 </checkedout>
4816 <h4>Overdues</h4>
4817 <overdue>
4819 <<biblio.title>> <br />
4820 Barcode: <<items.barcode>><br />
4821 Date due: <<issues.date_due>><br />
4822 </p>
4823 </overdue>
4825 <hr>
4827 <h4 style=\"text-align: center; font-style:italic;\">News</h4>
4828 <news>
4829 <div class=\"newsitem\">
4830 <h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>
4831 <p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.new>></p>
4832 <p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<opac_news.timestamp>></p>
4833 <hr />
4834 </div>
4835 </news>', 1)");
4836 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4837 VALUES ('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '<h3><<branches.branchname>></h3>
4838 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4839 (<<borrowers.cardnumber>>) <br />
4841 <<today>><br />
4843 <h4>Checked Out Today</h4>
4844 <checkedout>
4846 <<biblio.title>> <br />
4847 Barcode: <<items.barcode>><br />
4848 Date due: <<issues.date_due>><br />
4849 </p>
4850 </checkedout>', 1)");
4851 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4852 VALUES ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '<h5>Date: <<today>></h5>
4854 <h3> Transfer to/Hold in <<branches.branchname>></h3>
4856 <h3><<borrowers.surname>>, <<borrowers.firstname>></h3>
4858 <ul>
4859 <li><<borrowers.cardnumber>></li>
4860 <li><<borrowers.phone>></li>
4861 <li> <<borrowers.address>><br />
4862 <<borrowers.address2>><br />
4863 <<borrowers.city >> <<borrowers.zipcode>>
4864 </li>
4865 <li><<borrowers.email>></li>
4866 </ul>
4867 <br />
4868 <h3>ITEM ON HOLD</h3>
4869 <h4><<biblio.title>></h4>
4870 <h5><<biblio.author>></h5>
4871 <ul>
4872 <li><<items.barcode>></li>
4873 <li><<items.itemcallnumber>></li>
4874 <li><<reserves.waitingdate>></li>
4875 </ul>
4876 <p>Notes:
4877 <pre><<reserves.reservenotes>></pre>
4878 </p>', 1)");
4879 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4880 VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
4881 <h3>Transfer to <<branches.branchname>></h3>
4883 <h3>ITEM</h3>
4884 <h4><<biblio.title>></h4>
4885 <h5><<biblio.author>></h5>
4886 <ul>
4887 <li><<items.barcode>></li>
4888 <li><<items.itemcallnumber>></li>
4889 </ul>', 1)");
4891 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free')");
4892 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free')");
4894 $dbh->do("UPDATE `letter` SET content = replace(content, '<<title>>', '<<biblio.title>>') WHERE code = 'HOLDPLACED'");
4896 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";
4897 SetVersion($DBversion);
4900 $DBversion = "3.07.00.024";
4901 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4902 $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')");
4903 $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')");
4904 print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
4907 $DBversion = "3.07.00.025";
4908 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4909 if (TableExists('bibliocoverimage')) {
4910 $dbh->do( q|DROP TABLE bibliocoverimage;| );
4911 $dbh->do(
4912 q|CREATE TABLE biblioimages (
4913 imagenumber int(11) NOT NULL AUTO_INCREMENT,
4914 biblionumber int(11) NOT NULL,
4915 mimetype varchar(15) NOT NULL,
4916 imagefile mediumblob NOT NULL,
4917 thumbnail mediumblob NOT NULL,
4918 PRIMARY KEY (imagenumber),
4919 CONSTRAINT bibliocoverimage_fk1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
4920 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
4923 print "Upgrade to $DBversion done (Correct table name for local cover images if needed. )\n";
4924 SetVersion($DBversion);
4927 $DBversion = "3.07.00.026";
4928 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4929 $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');");
4930 print "Upgrade to $DBversion done (Add syspref CalendarFirstDayOfWeek used to select the first day of week to use in the calendar. )\n";
4931 SetVersion($DBversion);
4934 $DBversion = "3.07.00.027";
4935 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4936 $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');});
4937 print "Upgrade to $DBversion done (Added system preference RoutingListNote for adding a general note to all routing lists.)\n";
4938 SetVersion($DBversion);
4941 $DBversion = "3.07.00.028";
4942 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4943 $dbh->do(qq{
4944 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');
4946 print "Upgrade to $DBversion done (Bug 6296 New System preference AllowPKIAuth)\n";
4949 $DBversion = "3.07.00.029";
4950 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4951 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;});
4952 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;});
4953 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;});
4954 $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;});
4956 $dbh->do(q{
4957 CREATE TABLE `oai_sets` (
4958 `id` int(11) NOT NULL auto_increment,
4959 `spec` varchar(80) NOT NULL UNIQUE,
4960 `name` varchar(80) NOT NULL,
4961 PRIMARY KEY (`id`)
4962 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4965 $dbh->do(q{
4966 CREATE TABLE `oai_sets_descriptions` (
4967 `set_id` int(11) NOT NULL,
4968 `description` varchar(255) NOT NULL,
4969 CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4970 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4973 $dbh->do(q{
4974 CREATE TABLE `oai_sets_mappings` (
4975 `set_id` int(11) NOT NULL,
4976 `marcfield` char(3) NOT NULL,
4977 `marcsubfield` char(1) NOT NULL,
4978 `marcvalue` varchar(80) NOT NULL,
4979 CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4980 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4983 $dbh->do(q{
4984 CREATE TABLE `oai_sets_biblios` (
4985 `biblionumber` int(11) NOT NULL,
4986 `set_id` int(11) NOT NULL,
4987 PRIMARY KEY (`biblionumber`, `set_id`),
4988 CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4989 CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4990 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4993 $dbh->do(q{
4994 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');
4997 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4998 SetVersion($DBversion);
5001 $DBversion = "3.07.00.030";
5002 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5003 $dbh->do("ALTER TABLE default_circ_rules ADD
5004 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5005 $dbh->do("ALTER TABLE branch_item_rules ADD
5006 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5007 $dbh->do("ALTER TABLE default_branch_circ_rules ADD
5008 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5009 $dbh->do("ALTER TABLE default_branch_item_rules ADD
5010 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5011 # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
5012 my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') || 'homebranch';
5013 $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
5014 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
5015 SetVersion($DBversion);
5018 $DBversion = "3.07.00.031";
5019 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5020 $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')");
5021 print "Upgrade to $DBversion done (Add syspref to tell Koha if ICU indexing is in use for Zebra or not.)\n";
5022 SetVersion ($DBversion);
5025 $DBversion = "3.07.00.032";
5026 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5027 $dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers)
5028 $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
5029 $dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents)
5030 $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");
5031 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1");
5032 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2");
5033 $dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3");
5034 $dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3");
5036 $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");
5037 $dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner");
5039 $dbh->do("CREATE TABLE virtualshelfshares
5040 (id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL,
5041 borrowernumber int, invitekey varchar(10), sharedate datetime,
5042 CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
5043 CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5045 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');");
5046 $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');");
5048 print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n";
5049 SetVersion($DBversion);
5052 $DBversion = "3.07.00.033";
5053 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5054 $dbh->do("ALTER TABLE branches ADD opac_info text;");
5055 print "Upgrade to $DBversion done add opac_info to branches \n";
5056 SetVersion($DBversion);
5059 $DBversion = "3.07.00.034";
5060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5061 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
5062 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255) NOT NULL DEFAULT '' AFTER `category_code`");
5063 $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
5064 print "Upgrade to $DBversion done (New fields category_code and class in borrower_attribute_types table)\n";
5065 SetVersion($DBversion);
5068 $DBversion = "3.07.00.035";
5069 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5070 $dbh->do("ALTER TABLE issues CHANGE date_due date_due datetime");
5071 $dbh->do("UPDATE issues SET date_due = CONCAT(SUBSTR(date_due,1,11),'23:59:00')");
5072 $dbh->do("ALTER TABLE issues CHANGE returndate returndate datetime");
5073 $dbh->do("ALTER TABLE issues CHANGE lastreneweddate lastreneweddate datetime");
5074 $dbh->do("ALTER TABLE issues CHANGE issuedate issuedate datetime");
5075 $dbh->do("ALTER TABLE old_issues CHANGE date_due date_due datetime");
5076 $dbh->do("ALTER TABLE old_issues CHANGE returndate returndate datetime");
5077 $dbh->do("ALTER TABLE old_issues CHANGE lastreneweddate lastreneweddate datetime");
5078 $dbh->do("ALTER TABLE old_issues CHANGE issuedate issuedate datetime");
5079 $dbh->do("UPDATE accountlines SET description = CONCAT(description,' 23:59') WHERE accounttype='F' OR accounttype='FU'"); #BUG-8253
5080 print "Upgrade to $DBversion done (Setting up issues and accountlines tables for hourly loans)\n";
5081 SetVersion($DBversion);
5084 $DBversion = "3.07.00.036";
5085 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5086 $dbh->do(qq{
5087 ALTER TABLE z3950servers ADD timeout INT( 11 ) NOT NULL DEFAULT '0' AFTER syntax;
5089 print "Upgrade to $DBversion done (New timeout field in z3950servers)\n";
5092 $DBversion = "3.07.00.037";
5093 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5094 $dbh->do("
5095 ALTER TABLE `marc_subfield_structure` ADD `maxlength` INT( 4 ) NOT NULL DEFAULT '9999';
5097 $dbh->do("
5098 UPDATE `marc_subfield_structure` SET maxlength=24 WHERE tagfield='000';
5100 $dbh->do("
5101 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='MARC21','40','9999') WHERE tagfield='008';
5103 $dbh->do("
5104 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='NORMARC','40','9999') WHERE tagfield='008';
5106 $dbh->do("
5107 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='UNIMARC','36','9999') WHERE tagfield='100';
5109 print "Upgrade to $DBversion done (Add new field maxlength to marc_subfield_structure)\n";
5110 SetVersion($DBversion);
5113 $DBversion = "3.07.00.038";
5114 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5115 $dbh->do(qq{
5116 INSERT INTO systempreferences(variable,value,explanation,options,type)
5117 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')
5119 print "Upgrade to $DBversion done (Added system preference 'UniqueItemFields')\n";
5120 SetVersion($DBversion);
5123 $DBversion = "3.07.00.039";
5124 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5125 $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')} );
5126 $dbh->do( qq{CREATE TABLE IF NOT EXISTS social_data
5127 ( isbn VARCHAR(30),
5128 num_critics INT,
5129 num_critics_pro INT,
5130 num_quotations INT,
5131 num_videos INT,
5132 score_avg DECIMAL(5,2),
5133 num_scores INT,
5134 PRIMARY KEY (isbn)
5135 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5136 } );
5137 $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')} );
5138 print "Upgrade to $DBversion done (added syspref and table for babeltheque (Babeltheque_url_js, babeltheque))\n";
5139 SetVersion($DBversion);
5142 $DBversion = "3.07.00.040";
5143 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5144 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('SocialNetworks','0','Enable/Disable social networks links in opac detail','','YesNo')} );
5145 print "Upgrade to $DBversion done (added syspref SocialNetworks, to display facebook/ggl+ and other buttons)\n";
5146 SetVersion($DBversion);
5151 $DBversion = "3.07.00.041";
5152 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5153 $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')");
5154 print "Upgrade to $DBversion done (Add system preference SubscriptionDuplicateDroppedInput)\n";
5155 SetVersion($DBversion);
5158 $DBversion = "3.07.00.042";
5159 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5160 $dbh->do("ALTER TABLE reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5161 $dbh->do("ALTER TABLE old_reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5163 $dbh->do("ALTER TABLE reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5164 $dbh->do("ALTER TABLE old_reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5166 $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')");
5168 print "Upgrade to $DBversion done (Add suspend fields to reserves table, add syspref AutoResumeSuspendedHolds)\n";
5169 SetVersion ($DBversion);
5172 $DBversion = "3.07.00.043";
5173 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5174 my $countXSLTDetailsDisplay = 0;
5175 my $valueXSLTDetailsDisplay = "";
5176 my $valueXSLTResultsDisplay = "";
5177 my $valueOPACXSLTDetailsDisplay = "";
5178 my $valueOPACXSLTResultsDisplay = "";
5179 #the line below test if database comes from a BibLibre's branch
5180 $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
5181 if ($countXSLTDetailsDisplay > 0)
5183 #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
5184 $dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
5185 $dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
5187 else
5189 $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
5190 $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
5191 $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
5192 $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
5193 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
5194 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
5195 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
5196 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
5198 print "Upgrade to $DBversion done (XSLT systempreference takes a path to file rather than YesNo)\n";
5199 SetVersion($DBversion);
5202 $DBversion = "3.07.00.044";
5203 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5204 $dbh->do("ALTER TABLE aqbooksellers ADD deliverytime INT DEFAULT NULL");
5205 print "Upgrade to $DBversion done (Add deliverytime field in aqbooksellers table)";
5206 SetVersion($DBversion);
5209 $DBversion = "3.07.00.045";
5210 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5211 $dbh->do("ALTER TABLE import_batches MODIFY COLUMN batch_type ENUM('batch','z3950','webservice') NOT NULL default 'batch'");
5212 print "Upgrade to $DBversion done (Add 'webservice' to batch_type enum)\n";
5213 SetVersion ($DBversion);
5216 $DBversion = "3.07.00.046";
5217 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5218 $dbh->do("ALTER TABLE issuingrules ADD COLUMN lengthunit varchar(10) DEFAULT 'days' AFTER issuelength");
5219 print "Upgrade to $DBversion done (Setting up issues tables for hourly loans (lengthunit fix))\n";
5220 SetVersion($DBversion);
5223 $DBversion = "3.07.00.047";
5224 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5225 $dbh->do("CREATE INDEX items_location ON items(location)");
5226 $dbh->do("CREATE INDEX items_ccode ON items(ccode)");
5227 print "Upgrade to $DBversion done (items_location and items_ccode indexes added for ShelfBrowser)\n";
5228 SetVersion($DBversion);
5231 $DBversion = "3.07.00.048";
5232 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5233 $dbh->do(
5234 q | CREATE TABLE ratings (
5235 borrowernumber int(11) NOT NULL,
5236 biblionumber int(11) NOT NULL,
5237 rating_value tinyint(1) NOT NULL,
5238 timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
5239 PRIMARY KEY (borrowernumber,biblionumber),
5240 CONSTRAINT ratings_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
5241 CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
5242 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
5245 $dbh->do(
5246 q /INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','disable',NULL,'disable|all|details','Choice') /
5249 print
5250 "Upgrade to $DBversion done (Add 'ratings' table and 'OpacStarRatings' syspref)\n";
5251 SetVersion($DBversion);
5254 $DBversion = "3.07.00.049";
5255 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5256 $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')");
5257 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5258 SetVersion($DBversion);
5261 $DBversion = "3.08.00.000";
5262 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5263 print "Upgrade to $DBversion done\n";
5264 SetVersion($DBversion);
5267 $DBversion = "3.09.00.001";
5268 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5269 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 1 ) NULL DEFAULT NULL");
5270 print "Upgrade to $DBversion done. (Bug 8002: Update patron attribute types table to allow NULL category_code)\n";
5271 SetVersion($DBversion);
5274 $DBversion = "3.09.00.002";
5275 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5276 $dbh->do("ALTER TABLE saved_sql
5277 ADD (
5278 cache_expiry INT NOT NULL DEFAULT 300,
5279 public BOOLEAN NOT NULL DEFAULT FALSE
5282 print "Upgrade to $DBversion done (Added cache_expiry and public fields in
5283 saved_reports table.)\n";
5284 SetVersion($DBversion);
5287 $DBversion = "3.09.00.003";
5288 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5289 $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');");
5290 print "Upgrade to $DBversion done (Added SvcMaxReportRows syspref)\n";
5291 SetVersion($DBversion);
5294 $DBversion = "3.09.00.004";
5295 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5296 $dbh->do("INSERT IGNORE INTO permissions (module_bit, code, description) VALUES('13', 'edit_patrons', 'Perform batch modifivation of patrons')");
5297 print "Upgrade to $DBversion done (Adds permissions flag for access to the patron modifications tool)\n";
5298 SetVersion($DBversion);
5301 $DBversion = "3.09.00.005";
5302 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5303 unless (TableExists('quotes')) {
5304 $dbh->do( qq{
5305 CREATE TABLE `quotes` (
5306 `id` int(11) NOT NULL AUTO_INCREMENT,
5307 `source` text DEFAULT NULL,
5308 `text` mediumtext NOT NULL,
5309 `timestamp` datetime NOT NULL,
5310 PRIMARY KEY (`id`)
5311 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5314 $dbh->do( qq{
5315 INSERT IGNORE INTO permissions VALUES (13, "edit_quotes","Edit quotes for quote-of-the-day feature");
5317 $dbh->do( qq{
5318 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');
5320 print "Upgrade to $DBversion done (Adding Quote of the Day Option.)\n";
5321 SetVersion($DBversion);
5324 $DBversion = "3.09.00.006";
5325 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5326 $dbh->do("UPDATE systempreferences SET
5327 variable = 'OPACShowHoldQueueDetails',
5328 value = CASE value WHEN '1' THEN 'priority' ELSE 'none' END,
5329 options = 'none|priority|holds|holds_priority',
5330 explanation = 'Show holds details in OPAC',
5331 type = 'Choice'
5332 WHERE variable = 'OPACDisplayRequestPriority'");
5333 print "Upgrade to $DBversion done (Changed system preference OPACDisplayRequestPriority -> OPACShowHoldQueueDetails)\n";
5334 SetVersion($DBversion);
5337 $DBversion = "3.09.00.007";
5338 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5339 unless(C4::Context->preference('ReservesControlBranch')){
5340 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights.','Choice')");
5342 print "Upgrade to $DBversion done (Insert ReservesControlBranch systempreference into systempreferences table )\n";
5343 SetVersion($DBversion);
5346 $DBversion = "3.09.00.008";
5347 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5348 $dbh->do("ALTER TABLE sessions ADD PRIMARY KEY (id);");
5349 $dbh->do("ALTER TABLE sessions DROP INDEX `id`;");
5350 print "Upgrade to $DBversion done (redefine the field id as PRIMARY KEY of sessions)\n";
5351 SetVersion($DBversion);
5354 $DBversion = "3.09.00.009";
5355 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5356 $dbh->do("ALTER TABLE branches ADD PRIMARY KEY (branchcode);");
5357 $dbh->do("ALTER TABLE branches DROP INDEX branchcode;");
5358 print "Upgrade to $DBversion done (redefine the field branchcode as PRIMARY KEY of branches)\n";
5359 SetVersion ($DBversion);
5362 $DBversion = "3.09.00.010";
5363 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5364 $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')");
5365 print "Upgrade to $DBversion done (Add system preference issuelostitem ))\n";
5366 SetVersion($DBversion);
5369 $DBversion = "3.09.00.011";
5370 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5371 $dbh->do("ALTER TABLE `biblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5372 $dbh->do("CREATE INDEX `ean` ON biblioitems (`ean`) ");
5373 $dbh->do("ALTER TABLE `deletedbiblioitems` ADD `ean` VARCHAR( 13 ) NULL AFTER issn");
5374 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
5375 $dbh->do("UPDATE marc_subfield_structure SET kohafield='biblioitems.ean' WHERE tagfield='073' and tagsubfield='a'");
5377 print "Upgrade to $DBversion done (Adding ean in biblioitems and deletedbiblioitems)\n";
5378 print "If you have records with ean, please run misc/batchRebuildBiblioTables.pl to populate bibliotems.ean\n" if (C4::Context->preference("marcflavour") eq 'UNIMARC');
5379 SetVersion($DBversion);
5382 $DBversion = "3.09.00.012";
5383 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5384 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo')");
5385 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo')");
5386 print "Upgrade to $DBversion done (Add system preference OpacBrowseResults ))\n";
5387 SetVersion($DBversion);
5390 $DBversion ="3.09.00.013";
5391 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5392 $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');");
5393 print "Upgrade to $DBversion done (Add system preference DefaultLanguageField008))\n";
5394 SetVersion($DBversion);
5397 $DBversion ="3.09.00.014";
5398 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5399 # add phone message transport type
5400 $dbh->do("INSERT INTO message_transport_types (message_transport_type) VALUES ('phone')");
5402 # adds HOLD_PHONE and PREDUE_PHONE letters (as placeholders)
5403 $dbh->do("INSERT INTO letter (module, code, name, title, content) VALUES
5404 ('reserves', 'HOLD_PHONE', 'Item Available for Pick-up (phone notice)', 'Item Available for Pick-up (phone notice)', 'Your item is available for pickup'),
5405 ('circulation', 'PREDUE_PHONE', 'Advance Notice of Item Due (phone notice)', 'Advance Notice of Item Due (phone notice)', 'Your item is due soon'),
5406 ('circulation', 'OVERDUE_PHONE', 'Overdue Notice (phone notice)', 'Overdue Notice (phone notice)', 'Your item is overdue')
5409 # add phone notifications to patron message preferences options
5410 $dbh->do("INSERT INTO message_transports
5411 (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES
5412 (4, 'phone', 0, 'reserves', 'HOLD_PHONE'),
5413 (2, 'phone', 0, 'circulation', 'PREDUE_PHONE')
5416 # add TalkingTechItivaPhoneNotification syspref
5417 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('TalkingTechItivaPhoneNotification',0,'If ON, enables Talking Tech I-tiva phone notifications',NULL,'YesNo');");
5419 print "Upgrade done (Support for Talking Tech i-tiva phone notification system)\n";
5420 SetVersion($DBversion);
5423 $DBversion = "3.09.00.015";
5424 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5425 $dbh->do(qq{
5426 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')
5428 print "Upgrade to $DBversion done (Add System preference StatisticsFields)\n";
5429 SetVersion($DBversion);
5432 $DBversion = "3.09.00.016";
5433 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5434 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo')");
5435 print "Upgrade to $DBversion done (Add syspref OPACShowBarcode)\n";
5436 SetVersion ($DBversion);
5439 $DBversion = "3.09.00.017";
5440 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5441 $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');");
5442 print "Upgrade to $DBversion done (Add customizable OpacNavRight region to the OPAC main page)\n";
5443 SetVersion ($DBversion);
5446 $DBversion = "3.09.00.018";
5447 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5448 $dbh->do("DROP TABLE IF EXISTS aqbudgetborrowers");
5449 $dbh->do("
5450 CREATE TABLE aqbudgetborrowers (
5451 budget_id int(11) NOT NULL,
5452 borrowernumber int(11) NOT NULL,
5453 PRIMARY KEY (budget_id, borrowernumber),
5454 CONSTRAINT aqbudgetborrowers_ibfk_1 FOREIGN KEY (budget_id)
5455 REFERENCES aqbudgets (budget_id)
5456 ON DELETE CASCADE ON UPDATE CASCADE,
5457 CONSTRAINT aqbudgetborrowers_ibfk_2 FOREIGN KEY (borrowernumber)
5458 REFERENCES borrowers (borrowernumber)
5459 ON DELETE CASCADE ON UPDATE CASCADE
5460 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5462 $dbh->do("
5463 INSERT INTO permissions (module_bit, code, description)
5464 VALUES (11, 'budget_manage_all', 'Manage all budgets')
5466 print "Upgrade to $DBversion done (Add aqbudgetborrowers table)\n";
5467 SetVersion($DBversion);
5470 $DBversion = "3.09.00.019";
5471 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5472 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo')");
5473 print "Upgrade to $DBversion done (Add OPACShowUnusedAuthorities system preference)\n";
5474 SetVersion ($DBversion);
5477 $DBversion = "3.09.00.020";
5478 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5479 $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')");
5480 $dbh->do("
5481 CREATE TABLE IF NOT EXISTS borrower_files (
5482 file_id int(11) NOT NULL AUTO_INCREMENT,
5483 borrowernumber int(11) NOT NULL,
5484 file_name varchar(255) NOT NULL,
5485 file_type varchar(255) NOT NULL,
5486 file_description varchar(255) DEFAULT NULL,
5487 file_content longblob NOT NULL,
5488 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5489 PRIMARY KEY (file_id),
5490 KEY borrowernumber (borrowernumber)
5491 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5493 $dbh->do("ALTER TABLE borrower_files ADD CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE");
5495 print "Upgrade to $DBversion done (Added borrow_files table, EnableBorrowerFiles syspref)\n";
5496 SetVersion($DBversion);
5499 $DBversion = "3.09.00.021";
5500 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5501 $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');");
5502 print "Upgrade to $DBversion done (Add syspref UpdateTotalIssuesOnCirc)\n";
5503 SetVersion($DBversion);
5506 $DBversion = "3.09.00.022";
5507 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5508 $dbh->do("ALTER TABLE search_history MODIFY COLUMN query_cgi text NOT NULL");
5509 print "Upgrade to $DBversion done (Change search_history.query_cgi type to text. bug 5981)\n";
5510 SetVersion($DBversion);
5513 $DBversion = "3.09.00.023";
5514 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5515 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
5516 print "Upgrade to $DBversion done (Add system preference SearchEngine )\n";
5517 SetVersion($DBversion);
5520 $DBversion ="3.09.00.024";
5521 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5522 $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')");
5523 print "Upgrade to $DBversion done (Add system preference IntranetSlipPrinterJS))\n";
5524 SetVersion($DBversion);
5527 $DBversion = "3.09.00.025";
5528 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5529 $dbh->do('START TRANSACTION');
5530 $dbh->do('CREATE TABLE tmp_reserves AS SELECT * FROM old_reserves LIMIT 0');
5531 $dbh->do('ALTER TABLE tmp_reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5532 $dbh->do("
5533 INSERT INTO tmp_reserves (
5534 borrowernumber, reservedate, biblionumber,
5535 constrainttype, branchcode, notificationdate,
5536 reminderdate, cancellationdate, reservenotes,
5537 priority, found, timestamp, itemnumber,
5538 waitingdate, expirationdate, lowestPriority,
5539 suspend, suspend_until
5540 ) SELECT
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
5547 FROM old_reserves ORDER BY reservedate
5549 $dbh->do('SET @ai = ( SELECT MAX( reserve_id ) FROM tmp_reserves )');
5550 $dbh->do('TRUNCATE old_reserves');
5551 $dbh->do('ALTER TABLE old_reserves ADD reserve_id INT( 11 ) NOT NULL PRIMARY KEY FIRST');
5552 $dbh->do('INSERT INTO old_reserves SELECT * FROM tmp_reserves WHERE reserve_id <= @ai');
5553 $dbh->do("
5554 INSERT INTO tmp_reserves (
5555 borrowernumber, reservedate, biblionumber,
5556 constrainttype, branchcode, notificationdate,
5557 reminderdate, cancellationdate, reservenotes,
5558 priority, found, timestamp, itemnumber,
5559 waitingdate, expirationdate, lowestPriority,
5560 suspend, suspend_until
5561 ) SELECT
5562 borrowernumber, reservedate, biblionumber,
5563 constrainttype, branchcode, notificationdate,
5564 reminderdate, cancellationdate, reservenotes,
5565 priority, found, timestamp, itemnumber,
5566 waitingdate, expirationdate, lowestPriority,
5567 suspend, suspend_until
5568 FROM reserves ORDER BY reservedate
5570 $dbh->do('TRUNCATE reserves');
5571 $dbh->do('ALTER TABLE reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
5572 $dbh->do('INSERT INTO reserves SELECT * FROM tmp_reserves WHERE reserve_id > COALESCE(@ai, 0)');
5573 $dbh->do('DROP TABLE tmp_reserves');
5574 $dbh->do('COMMIT');
5576 my $sth = $dbh->prepare("
5577 SELECT COUNT( * ) AS count
5578 FROM information_schema.COLUMNS
5579 WHERE COLUMN_NAME = 'reserve_id'
5580 AND (
5581 TABLE_NAME LIKE 'reserves'
5583 TABLE_NAME LIKE 'old_reserves'
5586 $sth->execute();
5587 my $row = $sth->fetchrow_hashref();
5588 die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} );
5590 print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n";
5591 SetVersion($DBversion);
5594 $DBversion = "3.09.00.026";
5595 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5596 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
5597 ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'),
5598 ( 3, 'manage_circ_rules', 'manage circulation rules')");
5599 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5600 SELECT borrowernumber, 3, 'parameters_remaining_permissions'
5601 FROM borrowers WHERE flags & (1 << 3)");
5602 # Give new subpermissions to all users that have 'parameters' permission flag (bit 3) set
5603 # see userflags table
5604 $dbh->do("INSERT INTO user_permissions (borrowernumber, module_bit, code)
5605 SELECT borrowernumber, 3, 'manage_circ_rules'
5606 FROM borrowers WHERE flags & (1 << 3)");
5607 print "Upgrade to $DBversion done (Added parameters subpermissions)\n";
5608 SetVersion($DBversion);
5611 $DBversion = '3.09.00.027';
5612 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5613 $dbh->do("ALTER TABLE issuingrules ADD overduefinescap decimal(28,6) DEFAULT NULL");
5614 my $maxfine = C4::Context->preference('MaxFine');
5615 if ($maxfine && $maxfine < 900) { # an arbitrary value that tells us it's not "some huge value"
5616 $dbh->do("UPDATE issuingrules SET overduefinescap=?",undef,$maxfine);
5617 $dbh->do("UPDATE systempreferences SET value = NULL WHERE variable = 'MaxFine'");
5619 $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'");
5620 print "Upgrade to $DBversion done (Bug 7420 add overduefinescap to circulation matrix)\n";
5621 SetVersion ($DBversion);
5624 $DBversion = "3.09.00.028";
5625 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5626 unless ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
5627 my %referencetypes = ( '00' => 'PERSO_NAME',
5628 '10' => 'CORPO_NAME',
5629 '11' => 'MEETI_NAME',
5630 '30' => 'UNIF_TITLE',
5631 '48' => 'CHRON_TERM',
5632 '50' => 'TOPIC_TERM',
5633 '51' => 'GEOGR_NAME',
5634 '55' => 'GENRE/FORM'
5636 my $query = q{SELECT DISTINCT authtypecode, tagfield
5637 FROM auth_subfield_structure
5638 WHERE (tagfield BETWEEN '400' AND '455' OR
5639 tagfield BETWEEN '500' and '555') AND tagsubfield='a' AND
5640 frameworkcode = '' AND ROW(authtypecode, tagfield) NOT IN
5641 (SELECT authtypecode, tagfield FROM auth_subfield_structure
5642 WHERE tagsubfield ='9' )};
5643 $sth = $dbh->prepare($query);
5644 $sth->execute;
5645 my $sth2 = $dbh->prepare(q{INSERT INTO auth_subfield_structure
5646 (authtypecode, tagfield, tagsubfield, liblibrarian, libopac,
5647 repeatable, mandatory, tab, authorised_value, value_builder,
5648 seealso, isurl, hidden, linkid, kohafield, frameworkcode)
5649 VALUES (?, ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, ?, NULL, NULL,
5650 NULL, 0, 1, '', '', '')});
5651 my $sth3 = $dbh->prepare(q{UPDATE auth_subfield_structure SET
5652 frameworkcode = ? WHERE authtypecode = ? AND
5653 tagfield = ? AND tagsubfield = 'a'});
5654 while (my $row = $sth->fetchrow_arrayref()) {
5655 my ($authtypecode, $field) = @$row;
5656 $sth2->execute($authtypecode, $field, substr($field, 0, 1));
5657 my $authtypemarker = substr $field, 1, 2;
5658 if ($authtypemarker && $referencetypes{$authtypemarker}) {
5659 $sth3->execute($referencetypes{$authtypemarker}, $authtypecode, $field);
5664 print "Upgrade to $DBversion done (Add thesaurus links for MARC21/NORMARC)\n";
5665 SetVersion($DBversion);
5668 $DBversion = "3.09.00.029"; # FIXME
5669 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5670 $dbh->do("UPDATE systempreferences SET options=concat(options,'|EAN13') WHERE variable='itemBarcodeInputFilter' AND options NOT LIKE '%EAN13%'");
5671 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice EAN13)\n";
5673 $dbh->do("UPDATE systempreferences SET options = concat(options,'|EAN13'), explanation = concat(explanation,'; EAN13 - incremental') WHERE variable = 'autoBarcode' AND options NOT LIKE '%EAN13%'");
5674 print "Upgrade to $DBversion done ( Added EAN13 barcode autogeneration sequence )\n";
5675 SetVersion($DBversion);
5678 $DBversion ="3.09.00.030";
5679 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5680 my $query = "SELECT value FROM systempreferences WHERE variable='opacstylesheet'";
5681 my $remote= $dbh->selectrow_arrayref($query);
5682 $dbh->do("DELETE from systempreferences WHERE variable='opacstylesheet'");
5683 if($remote && $remote->[0]) {
5684 $query="UPDATE systempreferences SET value=? WHERE variable='opaclayoutstylesheet'";
5685 $dbh->do($query,undef,$remote->[0]);
5686 print "NOTE: The URL of your remote opac css file has been moved to preference opaclayoutstylesheet.\n";
5688 print "Upgrade to $DBversion done (BZ 8263: Make OPAC stylesheet preferences more consistent)\n";
5689 SetVersion($DBversion);
5692 $DBversion = "3.09.00.031";
5693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5694 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonReviews'");
5695 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonSimilarItems'");
5696 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSAccessKeyID'");
5697 $dbh->do("DELETE FROM systempreferences WHERE variable='AWSPrivateKey'");
5698 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonReviews'");
5699 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonSimilarItems'");
5700 $dbh->do("DELETE FROM systempreferences WHERE variable='AmazonEnabled'");
5701 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACAmazonEnabled'");
5702 print "Upgrade to $DBversion done ('Remove preferences controlling broken Amazon features (Bug 8679')\n";
5703 SetVersion ($DBversion);
5706 $DBversion = "3.09.00.032";
5707 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5708 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'defaultSortField' AND value = 'callnumber'");
5709 $dbh->do("UPDATE systempreferences SET value = 'call_number' WHERE variable = 'OPACdefaultSortField' AND value = 'callnumber'");
5710 print "Upgrade to $DBversion done (Bug 8657 - Default sort by call number does not work. Correcting system preference value.)\n";
5711 SetVersion ($DBversion);
5715 $DBversion = '3.09.00.033';
5716 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5717 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSuppressionByIPRange','','Restrict the suppression to IP adresses outside of the IP range','','free');");
5718 print "Upgrade to $DBversion done (Add OpacSuppressionByIPRange syspref)\n";
5719 SetVersion ($DBversion);
5722 $DBversion ="3.09.00.034";
5723 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5724 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'PERSO_NAME' WHERE frameworkcode = 'PERSO_CODE'");
5725 $dbh->do("UPDATE auth_subfield_structure SET frameworkcode = 'CORPO_NAME' WHERE frameworkcode = 'ORGO_CODE'");
5726 print "Upgrade to $DBversion done (Bug 8207: correct typo in authority types)\n";
5727 SetVersion ($DBversion);
5730 $DBversion = "3.09.00.035";
5731 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5732 $dbh->do("
5733 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');
5735 $dbh->do(
5736 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
5738 print "Upgrade to $DBversion done (Adding PrefillItem and SubfieldsToUseWhenPrefill sysprefs)\n";
5739 SetVersion ($DBversion);
5742 $DBversion = "3.09.00.036";
5743 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5744 # biblioitems changes
5745 $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5746 $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5747 # preferences changes
5748 $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')");
5749 $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')");
5751 print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5752 SetVersion ($DBversion);
5755 $DBversion = "3.09.00.037";
5756 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5757 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('UseTransportCostMatrix',0,'Use Transport Cost Matrix when filling holds','','YesNo')");
5759 $dbh->do("CREATE TABLE `transport_cost` (
5760 `frombranch` varchar(10) NOT NULL,
5761 `tobranch` varchar(10) NOT NULL,
5762 `cost` decimal(6,2) NOT NULL,
5763 `disable_transfer` tinyint(1) NOT NULL DEFAULT 0,
5764 CHECK ( `frombranch` <> `tobranch` ), -- a dud check, mysql does not support that
5765 PRIMARY KEY (`frombranch`, `tobranch`),
5766 CONSTRAINT `transport_cost_ibfk_1` FOREIGN KEY (`frombranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5767 CONSTRAINT `transport_cost_ibfk_2` FOREIGN KEY (`tobranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
5768 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
5770 print "Upgrade to $DBversion done (creating `transport_cost` table; adding UseTransportCostMatrix systempref, in circulation)\n";
5771 SetVersion($DBversion);
5774 $DBversion ="3.09.00.038";
5775 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5776 $dbh->do("ALTER TABLE borrower_attributes CHANGE attribute attribute VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
5777 print "Upgrade to $DBversion done (Increase the maximum size of a borrower attribute value)\n";
5778 SetVersion($DBversion);
5781 $DBversion ="3.09.00.039";
5782 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5783 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('DidYouMeanFromAuthorities','0','Suggest searches based on authority file.','YesNo');");
5784 print "Upgrade to $DBversion done (Add system preference DidYouMeanFromAuthorities)\n";
5785 SetVersion($DBversion);
5788 $DBversion = "3.09.00.040";
5789 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5790 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');");
5791 print "Upgrade to $DBversion done (Add IncludeSeeFromInSearches system preference)\n";
5792 SetVersion ($DBversion);
5795 $DBversion = "3.09.00.041";
5796 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5797 $dbh->do(qq{
5798 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportRemoveFields','','List of fields for non export in circulation.pl (separated by a space)','','');
5800 print "Upgrade to $DBversion done (Add system preference ExportRemoveFields)\n";
5801 SetVersion($DBversion);
5804 $DBversion = "3.09.00.042";
5805 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5806 $dbh->do(qq{
5807 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ExportWithCsvProfile','','Set a profile name for CSV export','','');
5809 print "Upgrade to $DBversion done (Adds New System preference ExportWithCsvProfile)\n";
5810 SetVersion($DBversion)
5813 $DBversion = "3.09.00.043";
5814 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5815 $dbh->do("
5816 ALTER TABLE aqorders
5817 ADD parent_ordernumber int(11) DEFAULT NULL
5819 $dbh->do("
5820 UPDATE aqorders
5821 SET parent_ordernumber = ordernumber;
5823 print "Upgrade to $DBversion done (Adding parent_ordernumber in aqorders)\n";
5824 SetVersion($DBversion);
5827 $DBversion = '3.09.00.044';
5828 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5829 $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
5830 $dbh->do("UPDATE statistics SET statistics.ccode = ( SELECT items.ccode FROM items WHERE statistics.itemnumber = items.itemnumber )");
5831 $dbh->do("UPDATE statistics SET statistics.ccode = (
5832 SELECT deleteditems.ccode FROM deleteditems
5833 WHERE statistics.itemnumber = deleteditems.itemnumber
5834 ) WHERE statistics.ccode IS NULL");
5835 print "Upgrade done ( Added Collection Code to Statistics table. )\n";
5836 SetVersion ($DBversion);
5839 $DBversion = "3.09.00.045";
5840 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5841 $dbh->do("ALTER TABLE borrower_attribute_types MODIFY category_code VARCHAR( 10 ) NULL DEFAULT NULL");
5842 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.";
5843 SetVersion($DBversion);
5846 $DBversion = "3.09.00.046";
5847 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5848 $dbh->do("ALTER TABLE `accountlines` ADD `accountlines_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
5849 print "Upgrade to $DBversion done (adding accountlines_id field in accountlines table)\n";
5850 SetVersion($DBversion);
5853 $DBversion = "3.09.00.047";
5854 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5855 # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5856 my $prefvalue = 'anywhere';
5857 if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
5858 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
5860 print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
5861 SetVersion($DBversion);
5864 $DBversion = "3.09.00.048";
5865 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5866 $dbh->do("ALTER TABLE authorised_values MODIFY lib varchar(200)");
5867 $dbh->do("ALTER TABLE authorised_values MODIFY lib_opac varchar(200)");
5869 print "Upgrade to $DBversion done (Raise the length of Authorised Values descriptions)\n";
5870 SetVersion($DBversion);
5873 $DBversion ="3.09.00.049";
5874 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5875 $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');");
5876 $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');");
5877 $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');");
5878 $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');");
5879 print "Upgrade to $DBversion done (Add OPACMobileUserCSS, OpacMainUserBlockMobile, OpacShowLibrariesPulldownMobile and OpacShowFiltersPulldownMobile sysprefs)\n";
5880 SetVersion($DBversion);
5883 $DBversion = "3.09.00.050";
5884 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5885 $dbh->do("ALTER TABLE authorised_values MODIFY category varchar(16) NOT NULL DEFAULT '';");
5886 $dbh->do("INSERT INTO authorised_values (category, authorised_value, lib) VALUES
5887 ('REPORT_GROUP', 'CIRC', 'Circulation'),
5888 ('REPORT_GROUP', 'CAT', 'Catalog'),
5889 ('REPORT_GROUP', 'PAT', 'Patrons'),
5890 ('REPORT_GROUP', 'ACQ', 'Acquisitions'),
5891 ('REPORT_GROUP', 'ACC', 'Accounts');");
5893 $dbh->do("ALTER TABLE reports_dictionary ADD report_area varchar(6) DEFAULT NULL;");
5894 $dbh->do("UPDATE reports_dictionary SET report_area = CASE area
5895 WHEN 1 THEN 'CIRC'
5896 WHEN 2 THEN 'CAT'
5897 WHEN 3 THEN 'PAT'
5898 WHEN 4 THEN 'ACQ'
5899 WHEN 5 THEN 'ACC'
5900 END;");
5901 $dbh->do("ALTER TABLE reports_dictionary DROP area;");
5902 $dbh->do("ALTER TABLE reports_dictionary ADD KEY dictionary_area_idx (report_area);");
5904 $dbh->do("ALTER TABLE saved_sql ADD report_area varchar(6) DEFAULT NULL;");
5905 $dbh->do("ALTER TABLE saved_sql ADD report_group varchar(80) DEFAULT NULL;");
5906 $dbh->do("ALTER TABLE saved_sql ADD report_subgroup varchar(80) DEFAULT NULL;");
5907 $dbh->do("ALTER TABLE saved_sql ADD KEY sql_area_group_idx (report_group, report_subgroup);");
5909 print "Upgrade to $DBversion done saved_sql new fields report_group and report_area; authorised_values.category 16 char \n";
5910 SetVersion($DBversion);
5913 $DBversion = "3.09.00.051";
5914 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5915 $dbh->do("
5916 CREATE TABLE aqinvoices (
5917 invoiceid int(11) NOT NULL AUTO_INCREMENT,
5918 invoicenumber mediumtext NOT NULL,
5919 booksellerid int(11) NOT NULL,
5920 shipmentdate date default NULL,
5921 billingdate date default NULL,
5922 closedate date default NULL,
5923 shipmentcost decimal(28,6) default NULL,
5924 shipmentcost_budgetid int(11) default NULL,
5925 PRIMARY KEY (invoiceid),
5926 CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5927 CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5928 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5931 # Fill this new table with existing invoices
5932 my $sth = $dbh->prepare("
5933 SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid, aqorders.datereceived
5934 FROM aqorders
5935 LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5936 WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5937 AND aqorders.booksellerinvoicenumber != ''
5938 GROUP BY aqorders.booksellerinvoicenumber
5940 $sth->execute;
5941 my $results = $sth->fetchall_arrayref({});
5942 $sth = $dbh->prepare("
5943 INSERT INTO aqinvoices (invoicenumber, booksellerid, shipmentdate) VALUES (?,?,?)
5945 foreach(@$results) {
5946 $sth->execute($_->{invoicenumber}, $_->{booksellerid}, $_->{datereceived});
5949 # Add the column in aqorders, fill it with correct value
5950 # and then drop booksellerinvoicenumber column
5951 $dbh->do("
5952 ALTER TABLE aqorders
5953 ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5954 ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5957 $dbh->do("
5958 UPDATE aqorders, aqinvoices
5959 SET aqorders.invoiceid = aqinvoices.invoiceid
5960 WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5963 $dbh->do("
5964 ALTER TABLE aqorders
5965 DROP COLUMN booksellerinvoicenumber
5968 print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5969 SetVersion ($DBversion);
5972 $DBversion = "3.09.00.052";
5973 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5974 $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');");
5975 $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');");
5976 $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');");
5977 print "Upgrade to $DBversion done (Add systempreferences to decrease loan length on high demand items decreaseLoanHighHolds, decreaseLoanHighHoldsValue and decreaseLoanHighHoldsDuration) \n";
5978 SetVersion ($DBversion);
5981 $DBversion = "3.09.00.053";
5982 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5983 $dbh->do(
5984 q|CREATE TABLE `import_auths` (
5985 import_record_id int(11) NOT NULL,
5986 matched_authid int(11) default NULL,
5987 control_number varchar(25) default NULL,
5988 authorized_heading varchar(128) default NULL,
5989 original_source varchar(25) default NULL,
5990 CONSTRAINT import_auths_ibfk_1 FOREIGN KEY (import_record_id)
5991 REFERENCES import_records (import_record_id) ON DELETE CASCADE ON UPDATE CASCADE,
5992 KEY matched_authid (matched_authid)
5993 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
5995 $dbh->do("ALTER TABLE import_batches
5996 CHANGE COLUMN num_biblios num_records int(11) NOT NULL default 0,
5997 ADD COLUMN record_type enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio'");
5998 $dbh->do("UPDATE import_batches SET record_type='auth' WHERE import_batch_id IN
5999 (SELECT import_batch_id FROM import_records WHERE record_type='auth')");
6001 print "Upgrade to $DBversion done (Added support for staging authorities)\n";
6002 SetVersion ($DBversion);
6005 $DBversion = "3.09.00.054";
6006 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6007 $dbh->do("ALTER TABLE aqorders CHANGE COLUMN gst gstrate DECIMAL(6,4) DEFAULT NULL");
6008 print "Upgrade to $DBversion done (Change column name in aqorders gst --> gstrate)\n";
6009 SetVersion($DBversion);
6012 $DBversion = "3.09.00.055";
6013 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6014 $dbh->do("ALTER TABLE aqorders ADD discount float(6,4) DEFAULT NULL AFTER gstrate");
6015 print "Upgrade to $DBversion done (Add discount field in aqorders table)\n";
6016 SetVersion($DBversion);
6019 $DBversion ="3.09.00.056";
6020 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6021 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('AuthDisplayHierarchy','0','Display authority hierarchies','','YesNo')");
6022 print "Upgrade to $DBversion done (Add system preference AuthDisplayHierarchy)\n";
6023 SetVersion($DBversion);
6026 $DBversion = "3.09.00.057";
6027 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6028 $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL AFTER basketgroupid;");
6029 $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL AFTER deliveryplace;");
6030 print "Upgrade to $DBversion done (Bug 5356: Added billingplace, deliveryplace to the aqbasket table)\n";
6031 SetVersion($DBversion);
6034 $DBversion ="3.09.00.058";
6035 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6036 $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');");
6037 $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');");
6038 print "Upgrade to $DBversion done (Add Did You Mean? configuration)\n";
6039 SetVersion($DBversion);
6042 $DBversion ="3.09.00.059";
6043 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6044 $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');");
6045 print "Upgrade to $DBversion done (Add system preference BlockReturnOfWithdrawnItems)\n";
6046 SetVersion($DBversion);
6049 $DBversion = "3.09.00.060";
6050 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6051 $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')");
6052 print "Upgrade to $DBversion done (Added HoldsToPullStartDate syspref)\n";
6053 SetVersion($DBversion);
6056 $DBversion = "3.09.00.061";
6057 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6058 $dbh->do("UPDATE systempreferences set value=0 WHERE variable='OPACItemsResultsDisplay' AND value='statuses'");
6059 $dbh->do("UPDATE systempreferences set value=1 WHERE variable='OPACItemsResultsDisplay' AND value='itemdetails'");
6060 $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'");
6061 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";
6062 SetVersion ($DBversion);
6065 $DBversion = "3.09.00.062";
6066 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6067 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='NoZebra'");
6068 $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='QueryRemoveStopwords'");
6069 print "Upgrade to $DBversion done (Disable obsolete NoZebra and QueryRemoveStopwords sysprefs)\n";
6070 SetVersion ($DBversion);
6073 $DBversion = "3.09.00.063";
6074 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6075 my $gst_booksellers = $dbh->selectcol_arrayref("SELECT DISTINCT(gstrate) FROM aqbooksellers");
6076 my $gist_syspref = C4::Context->preference("gist");
6077 # remove the undef values and construct and array with the syspref and the supplier values
6078 my @gstrates = map { defined $_ ? $_ : () } @$gst_booksellers;
6079 push @gstrates, split ('\|', $gist_syspref);
6080 # we want to compare integer (or float)
6081 $_ = $_ + 0 for @gstrates;
6082 use List::MoreUtils qw/uniq/;
6083 # remove duplicate values
6084 @gstrates = uniq sort @gstrates;
6085 my $new_syspref_value = join '|', @gstrates;
6086 # update the syspref with the new values
6087 my $sth = $dbh->prepare("UPDATE systempreferences set value=? WHERE variable='gist'");
6088 $sth->execute( $new_syspref_value );
6090 print "Upgrade to $DBversion done (Bug 8832, Set the syspref gist with the existing values)\n";
6091 SetVersion ($DBversion);
6094 $DBversion = "3.09.00.064";
6095 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6096 $dbh->do('ALTER TABLE items ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6097 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the items table)\n";
6098 SetVersion ($DBversion);
6101 $DBversion = "3.09.00.065";
6102 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6103 $dbh->do('ALTER TABLE deleteditems ADD coded_location_qualifier varchar(10) default NULL AFTER itemcallnumber');
6104 print "Upgrade to $DBversion done (Bug 6428: Added coded_location_qualifier to the deleteditems table)\n";
6105 SetVersion ($DBversion);
6108 $DBversion = "3.09.00.066";
6109 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6110 $dbh->do("DELETE FROM systempreferences WHERE variable='DidYouMeanFromAuthorities'");
6111 print "Upgrade to $DBversion done (Bug 9107: remove DidYouMeanFromAuthorities syspref)\n";
6112 SetVersion ($DBversion);
6115 $DBversion = "3.09.00.067";
6116 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6117 $dbh->do("ALTER TABLE statistics CHANGE COLUMN ccode ccode varchar(10) NULL");
6118 print "Upgrade to $DBversion done (Bug 9064: statistics.ccode potentially wrongly defined)\n";
6119 SetVersion ($DBversion);
6122 $DBversion = "3.10.00.00";
6123 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6124 print "Upgrade to $DBversion done (release tag)\n";
6125 SetVersion ($DBversion);
6128 $DBversion = "3.11.00.001";
6129 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6130 $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')");
6131 print "Upgrade to $DBversion done (Bug 2832 - Add alphabet syspref)\n";
6134 $DBversion = "3.11.00.002";
6135 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6136 $dbh->do(q{
6137 DELETE from aqorders_items where ordernumber NOT IN (SELECT ordernumber FROM aqorders);
6139 $dbh->do(q{
6140 ALTER TABLE aqorders_items
6141 ADD CONSTRAINT aqorders_items_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber)
6142 ON DELETE CASCADE ON UPDATE CASCADE;
6144 print "Upgrade to $DBversion done (Bug 9030: Add constraint on aqorders_items.ordernumber)\n";
6145 SetVersion ($DBversion);
6148 $DBversion = "3.11.00.003";
6149 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6150 $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')");
6151 print "Upgrade to $DBversion done (Bug 7189: Add system preference RefundLostItemFeeOnReturn)\n";
6152 SetVersion($DBversion);
6155 $DBversion = "3.11.00.004";
6156 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6157 $dbh->do(qq{
6158 ALTER TABLE subscription ADD COLUMN closed INT(1) NOT NULL DEFAULT 0 AFTER enddate;
6161 print "Upgrade to $DBversion done (Bug 8782: Add field subscription.closed)\n";
6162 SetVersion($DBversion);
6165 $DBversion = "3.11.00.005";
6166 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6167 $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;});
6169 $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;});
6171 $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;});
6173 print "Upgrade to $DBversion done (Bug 7919: Display of values depending on the connexion library)\n";
6174 SetVersion($DBversion);
6177 $DBversion = "3.11.00.006";
6178 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6179 $dbh->do(q{
6180 UPDATE virtualshelves SET sortfield="copyrightdate" where sortfield="year";
6182 print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n";
6183 SetVersion($DBversion);
6186 $DBversion = "3.11.00.007";
6187 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6188 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ar', 'language', 'de', 'Arabisch')");
6189 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hy', 'language', 'de', 'Armenisch')");
6190 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'bg', 'language', 'de', 'Bulgarisch')");
6191 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'zh', 'language', 'de', 'Chinesisch')");
6192 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'cs', 'language', 'de', 'Tschechisch')");
6193 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'da', 'language', 'de', 'Dänisch')");
6194 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nl', 'language', 'de', 'Niederländisch')");
6195 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'en', 'language', 'de', 'Englisch')");
6196 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fi', 'language', 'de', 'Finnisch')");
6197 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fr', 'language', 'de', 'Französisch')");
6198 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'fr', 'Laotien')");
6199 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'lo', 'language', 'de', 'Laotisch')");
6200 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'el', 'language', 'de', 'Griechisch (Nach 1453)')");
6201 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'he', 'language', 'de', 'Hebräisch')");
6202 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hi', 'language', 'de', 'Hindi')");
6203 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'hu', 'language', 'de', 'Ungarisch')");
6204 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'id', 'language', 'de', 'Indonesisch')");
6205 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'it', 'language', 'de', 'Italienisch')");
6206 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ja', 'language', 'de', 'Japanisch')");
6207 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ko', 'language', 'de', 'Koreanisch')");
6208 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'la', 'language', 'de', 'Latein')");
6209 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'fr', 'Galicien')");
6210 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'gl', 'language', 'de', 'Galizisch')");
6211 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nb', 'language', 'de', 'Norwegisch bokm&#229;l')");
6212 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'nn', 'language', 'de', 'Norwegisch nynorsk')");
6213 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'fa', 'language', 'de', 'Persisch')");
6214 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pl', 'language', 'de', 'Polnisch')");
6215 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'pt', 'language', 'de', 'Portugiesisch')");
6216 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ro', 'language', 'de', 'Rumänisch')");
6217 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ru', 'language', 'de', 'Russisch')");
6218 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'fr', 'Serbe')");
6219 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sr', 'language', 'de', 'Serbisch')");
6220 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'es', 'language', 'de', 'Spanisch')");
6221 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'sv', 'language', 'de', 'Schwedisch')");
6222 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'fr', 'Tétoum')");
6223 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tet', 'language', 'de', 'Tetum')");
6224 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'th', 'language', 'de', 'Thailändisch')");
6225 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'tr', 'language', 'de', 'Türkisch')");
6226 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'uk', 'language', 'de', 'Ukrainisch')");
6227 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'fr', 'Ourdou')");
6228 $dbh->do("INSERT INTO language_descriptions (subtag, type, lang, description) VALUES( 'ur', 'language', 'de', 'Urdu')");
6229 print "Upgrade to $DBversion done (Bug 9056: add German and a couple of French translations to language_descriptions)\n";
6230 SetVersion ($DBversion);
6233 $DBversion = "3.11.00.008";
6234 if (CheckVersion($DBversion)) {
6235 $dbh->do("
6236 CREATE TABLE IF NOT EXISTS `borrower_modifications` (
6237 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6238 `verification_token` varchar(255) NOT NULL DEFAULT '',
6239 `borrowernumber` int(11) NOT NULL DEFAULT '0',
6240 `cardnumber` varchar(16) DEFAULT NULL,
6241 `surname` mediumtext,
6242 `firstname` text,
6243 `title` mediumtext,
6244 `othernames` mediumtext,
6245 `initials` text,
6246 `streetnumber` varchar(10) DEFAULT NULL,
6247 `streettype` varchar(50) DEFAULT NULL,
6248 `address` mediumtext,
6249 `address2` text,
6250 `city` mediumtext,
6251 `state` text,
6252 `zipcode` varchar(25) DEFAULT NULL,
6253 `country` text,
6254 `email` mediumtext,
6255 `phone` text,
6256 `mobile` varchar(50) DEFAULT NULL,
6257 `fax` mediumtext,
6258 `emailpro` text,
6259 `phonepro` text,
6260 `B_streetnumber` varchar(10) DEFAULT NULL,
6261 `B_streettype` varchar(50) DEFAULT NULL,
6262 `B_address` varchar(100) DEFAULT NULL,
6263 `B_address2` text,
6264 `B_city` mediumtext,
6265 `B_state` text,
6266 `B_zipcode` varchar(25) DEFAULT NULL,
6267 `B_country` text,
6268 `B_email` text,
6269 `B_phone` mediumtext,
6270 `dateofbirth` date DEFAULT NULL,
6271 `branchcode` varchar(10) DEFAULT NULL,
6272 `categorycode` varchar(10) DEFAULT NULL,
6273 `dateenrolled` date DEFAULT NULL,
6274 `dateexpiry` date DEFAULT NULL,
6275 `gonenoaddress` tinyint(1) DEFAULT NULL,
6276 `lost` tinyint(1) DEFAULT NULL,
6277 `debarred` date DEFAULT NULL,
6278 `debarredcomment` varchar(255) DEFAULT NULL,
6279 `contactname` mediumtext,
6280 `contactfirstname` text,
6281 `contacttitle` text,
6282 `guarantorid` int(11) DEFAULT NULL,
6283 `borrowernotes` mediumtext,
6284 `relationship` varchar(100) DEFAULT NULL,
6285 `ethnicity` varchar(50) DEFAULT NULL,
6286 `ethnotes` varchar(255) DEFAULT NULL,
6287 `sex` varchar(1) DEFAULT NULL,
6288 `password` varchar(30) DEFAULT NULL,
6289 `flags` int(11) DEFAULT NULL,
6290 `userid` varchar(75) DEFAULT NULL,
6291 `opacnote` mediumtext,
6292 `contactnote` varchar(255) DEFAULT NULL,
6293 `sort1` varchar(80) DEFAULT NULL,
6294 `sort2` varchar(80) DEFAULT NULL,
6295 `altcontactfirstname` varchar(255) DEFAULT NULL,
6296 `altcontactsurname` varchar(255) DEFAULT NULL,
6297 `altcontactaddress1` varchar(255) DEFAULT NULL,
6298 `altcontactaddress2` varchar(255) DEFAULT NULL,
6299 `altcontactaddress3` varchar(255) DEFAULT NULL,
6300 `altcontactstate` text,
6301 `altcontactzipcode` varchar(50) DEFAULT NULL,
6302 `altcontactcountry` text,
6303 `altcontactphone` varchar(50) DEFAULT NULL,
6304 `smsalertnumber` varchar(50) DEFAULT NULL,
6305 `privacy` int(11) DEFAULT NULL,
6306 PRIMARY KEY (`verification_token`,`borrowernumber`),
6307 KEY `verification_token` (`verification_token`),
6308 KEY `borrowernumber` (`borrowernumber`)
6309 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6312 $dbh->do("
6313 INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES
6314 ('PatronSelfRegistration', '0', NULL, 'If enabled, patrons will be able to register themselves via the OPAC.', 'YesNo'),
6315 ('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'),
6316 ('PatronSelfRegistrationDefaultCategory', '', '', 'A patron registered via the OPAC will receive a borrower category code set in this system preference.', 'free'),
6317 ('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'),
6318 ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'),
6319 ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free');
6322 $dbh->do("
6323 INSERT INTO letter ( `module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content` )
6324 VALUES ( 'members', 'OPAC_REG_VERIFY', '', 'Opac Self-Registration Verification Email', '1', 'Verify Your Account', 'Hello!
6326 Your library account has been created. Please verify your email address by clicking this link to complete the signup process:
6328 http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>>
6330 If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
6331 )");
6333 print "Upgrade to $DBversion done (Bug 7067: Add Patron Self Registration)\n";
6334 SetVersion ($DBversion);
6337 $DBversion = "3.11.00.009";
6338 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6339 $dbh->do("
6340 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
6341 ('SeparateHoldings', '0', 'Separate current branch holdings from other holdings', NULL, 'YesNo'),
6342 ('SeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings', 'homebranch|holdingbranch', 'Choice'),
6343 ('OpacSeparateHoldings', '0', 'Separate current branch holdings from other holdings (OPAC)', NULL, 'YesNo'),
6344 ('OpacSeparateHoldingsBranch', 'homebranch', 'Branch used to separate holdings (OPAC)', 'homebranch|holdingbranch', 'Choice')
6347 print "Upgrade to $DBversion done (Bug 7674: Add systempreferences SeparateHoldings, SeparateHoldingsBranch, OpacSeparateHoldings and OpacSeparateHoldingsBranch) \n";
6348 SetVersion ($DBversion);
6351 $DBversion = "3.11.00.010";
6352 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6353 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('RenewalSendNotice', '0', '', NULL, 'YesNo')");
6354 $dbh->do(q{
6355 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
6356 ('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>>.');
6358 print "Upgrade to $DBversion done (Bug 9151 - Renewal notice according to patron alert preferences)\n";
6359 SetVersion($DBversion);
6362 $DBversion = "3.11.00.011";
6363 if ( CheckVersion($DBversion) ) {
6364 $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');");
6365 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','Media file extensions','','free');");
6366 print "Upgrade to $DBversion done (Bug 8377: Add HTML5MediaEnabled and HTML5MediaExtensions sysprefs)\n";
6367 SetVersion ($DBversion);
6370 $DBversion = "3.11.00.012";
6371 if ( CheckVersion($DBversion) ) {
6372 $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')");
6373 print "Upgrade to $DBversion done (Bug 9206: Only allow place holds in records that the patron don't have in his possession)\n";
6374 SetVersion($DBversion);
6377 $DBversion = "3.11.00.013";
6378 if ( CheckVersion($DBversion) ) {
6379 $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')");
6380 print "Upgrade to $DBversion done (Bug 9162 - Add a system preference to set which notes fields appears on title notes/description separator)\n";
6381 SetVersion($DBversion);
6384 $DBversion = "3.11.00.014";
6385 if ( CheckVersion($DBversion) ) {
6386 $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' )");
6387 $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SCOUserJS', '', 'Define custom javascript for inclusion in the SCO module', 'free' )");
6388 print "Upgrade to $DBversion done (Bug 9009: Add SCOUserCSS and SCOUserJS sysprefs)\n";
6391 $DBversion = "3.11.00.015";
6392 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6393 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RentalsInNoissuesCharge', '1', 'Rental charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6394 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ManInvInNoissuesCharge', '1', 'MANUAL_INV charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
6395 print "Upgrade to $DBversion done (Add sysprefs RentalsInNoissuesCharge and ManInvInNoissuesCharge.)\n";
6396 SetVersion($DBversion);
6399 $DBversion = "3.11.00.016";
6400 if ( CheckVersion($DBversion) ) {
6401 $dbh->do(q{
6402 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";
6404 $dbh->do(q{
6405 UPDATE userflags SET flagdesc="Edit Authorities" where flagdesc="Allow to edit authorities";
6407 $dbh->do(q{
6408 UPDATE userflags SET flagdesc="Allow access to the reports module" where flagdesc="Allow to access to the reports module";
6410 $dbh->do(q{
6411 UPDATE userflags SET flagdesc="Set library management parameters (deprecated)" where flagdesc="Set library management parameters";
6413 $dbh->do(q{
6414 UPDATE userflags SET flagdesc="Manage serial subscriptions" where flagdesc="Allow to manage serials subscriptions";
6416 $dbh->do(q{
6417 UPDATE userflags SET flagdesc="Manage patrons fines and fees" where flagdesc="Update borrower charges";
6419 $dbh->do(q{
6420 UPDATE userflags SET flagdesc="Check out and check in items" where flagdesc="Circulate books";
6422 $dbh->do(q{
6423 UPDATE userflags SET flagdesc="Manage Koha system settings (Administration panel)" where flagdesc="Set Koha system parameters";
6425 $dbh->do(q{
6426 UPDATE userflags SET flagdesc="Add or modify patrons" where flagdesc="Add or modify borrowers";
6428 $dbh->do(q{
6429 UPDATE userflags SET flagdesc="Use all tools (expand for granular tools permissions)" where flagdesc="Use tools (export, import, barcodes)";
6431 $dbh->do(q{
6432 UPDATE userflags SET flagdesc="Allow staff members to modify permissions for other staff members" where flagdesc="Set user permissions";
6434 $dbh->do(q{
6435 UPDATE permissions SET description="Perform batch modification of patrons" where description="Perform batch modifivation of patrons";
6438 print "Upgrade to $DBversion done (Bug 9382 (updated with bug 9745) - refresh permission descriptions to make more sense)\n";
6439 SetVersion ($DBversion);
6442 $DBversion ="3.11.00.017";
6443 if ( CheckVersion($DBversion) ) {
6444 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReviews','0','Display book review snippets from IDreamBooks.com','','YesNo');");
6445 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksReadometer','0','Display Readometer from IDreamBooks.com','','YesNo');");
6446 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo');");
6447 print "Upgrade to $DBversion done (Add IDreamBooks enhanced content)\n";
6448 SetVersion($DBversion);
6451 $DBversion = "3.11.00.018";
6452 if ( CheckVersion($DBversion) ) {
6453 $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')");
6454 $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')");
6455 print "Upgrade to $DBversion done (Bug 9395: Problem with callnumber and standard number search in OPAC and Staff Client)\n";
6456 SetVersion ($DBversion);
6459 $DBversion = "3.11.00.019";
6460 if ( CheckVersion($DBversion) ) {
6461 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorityField100', 'afrey50 ba0', NULL, NULL, 'Textarea')");
6462 print "Upgrade to $DBversion done (Bug 9145 - Add syspref UNIMARCAuthorityField100)\n";
6463 SetVersion ($DBversion);
6466 $DBversion = "3.11.00.020";
6467 if ( CheckVersion($DBversion) ) {
6468 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')");
6469 print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n";
6470 SetVersion($DBversion);
6473 $DBversion ="3.11.00.021";
6474 if ( CheckVersion($DBversion) ) {
6475 $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');");
6476 print "Upgrade to $DBversion done (Bug 5888 - Subject search pop-up for the OPAC)\n";
6477 SetVersion($DBversion);
6480 $DBversion = "3.11.00.022";
6481 if ( CheckVersion($DBversion) ) {
6482 $dbh->do(
6483 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('Persona',0,'Use Mozilla Persona for login','','YesNo')"
6485 print "Upgrade to $DBversion done (Bug 9587 - Allow login via Persona)\n";
6486 SetVersion($DBversion);
6489 $DBversion = "3.11.00.023";
6490 if ( CheckVersion($DBversion) ) {
6491 $dbh->do("UPDATE z3950servers SET host = 'lx2.loc.gov', port = 210, db = 'LCDB', syntax = 'USMARC', encoding = 'utf8' WHERE name = 'LIBRARY OF CONGRESS'");
6492 print "Upgrade to $DBversion done (Bug 9520 - Update default LOC Z39.50 target)\n";
6493 SetVersion($DBversion);
6496 $DBversion = "3.11.00.024";
6497 if ( CheckVersion($DBversion) ) {
6498 $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');");
6499 print "Upgrade to $DBversion done (Bug 5079: Add OpacItemLocation syspref)\n";
6500 SetVersion ($DBversion);
6503 $DBversion = "3.11.00.025";
6504 if ( CheckVersion($DBversion) ) {
6505 $dbh->do(
6506 "CREATE TABLE linktracker (
6507 id int(11) NOT NULL AUTO_INCREMENT,
6508 biblionumber int(11) DEFAULT NULL,
6509 itemnumber int(11) DEFAULT NULL,
6510 borrowernumber int(11) DEFAULT NULL,
6511 url text,
6512 timeclicked datetime DEFAULT NULL,
6513 PRIMARY KEY (id),
6514 KEY bibidx (biblionumber),
6515 KEY itemidx (itemnumber),
6516 KEY borridx (borrowernumber),
6517 KEY dateidx (timeclicked)
6518 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
6520 $dbh->do( "
6521 INSERT INTO systempreferences (variable,value,explanation,options,type)
6522 VALUES('TrackClicks','0','Track links clicked',NULL,'Integer')" );
6523 print
6524 "Upgrade to $DBversion done (Adds feature Bug 8917, the ability to track links clicked)\n";
6525 SetVersion($DBversion);
6528 $DBversion = "3.11.00.026";
6529 if ( CheckVersion($DBversion) ) {
6530 $dbh->do(qq{
6531 ALTER TABLE import_records ADD INDEX batch_id_record_type ( import_batch_id, record_type );
6533 print "Upgrade to $DBversion done (Bug 9207: Add new index batch_id_record_type to import_records)\n";
6534 SetVersion($DBversion);
6537 $DBversion = "3.11.00.027";
6538 if ( CheckVersion($DBversion) ) {
6539 $dbh->do(q{
6540 INSERT INTO permissions ( module_bit, code, description )
6541 VALUES ( '1', 'overdues_report', 'Execute overdue items report' )
6543 # add new permission for users with all report permissions and circulation remaining permission
6544 $dbh->do(q{
6545 INSERT INTO user_permissions (borrowernumber, module_bit, code)
6546 SELECT user_permissions.borrowernumber, 1, 'overdues_report'
6547 FROM user_permissions
6548 LEFT JOIN borrowers USING(borrowernumber)
6549 WHERE borrowers.flags & (1 << 16)
6550 AND user_permissions.code = 'circulate_remaining_permissions'
6552 print "Upgrade to $DBversion done ( Add circ permission overdues_report )\n";
6553 SetVersion($DBversion);
6556 $DBversion = "3.11.00.028";
6557 if ( CheckVersion($DBversion) ) {
6558 $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' );");
6559 print "Upgrade to $DBversion done (Bug 9756 - Patron self registration missing the system preference PatronSelfRegistrationAdditionalInstructions)\n";
6560 SetVersion($DBversion);
6563 $DBversion = "3.11.00.029";
6564 if (CheckVersion($DBversion)) {
6565 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo')");
6566 print "Upgrade to $DBversion done (Bug 9239: Make it possible for Koha to use QueryParser)\n";
6567 SetVersion ($DBversion);
6570 $DBversion = "3.11.00.030";
6571 if ( CheckVersion($DBversion) ) {
6572 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');");
6573 print "Upgrade to $DBversion done (Add system preference FinesIncludeGracePeriod)\n";
6574 SetVersion($DBversion);
6577 $DBversion = "3.11.00.100";
6578 if ( CheckVersion($DBversion) ) {
6579 print "Upgrade to $DBversion done (3.12-alpha release)\n";
6580 SetVersion ($DBversion);
6583 $DBversion = "3.11.00.101";
6584 if ( CheckVersion($DBversion) ) {
6585 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short')");
6586 print "Upgrade to $DBversion done (Bug 9341: Problem with UNIMARC authors facets)\n";
6587 SetVersion ($DBversion);
6590 $DBversion = "3.11.00.102";
6591 if ( CheckVersion($DBversion) ) {
6592 $dbh->do(q{
6593 DELETE FROM systempreferences WHERE variable='NoZebra'
6595 $dbh->do(q{
6596 DELETE FROM systempreferences WHERE variable='QueryRemoveStopwords'
6598 print "Upgrade to $DBversion done (Remove deprecated NoZebra and QueryRemoveStopwords sysprefs)\n";
6599 SetVersion($DBversion);
6602 $DBversion = "3.11.00.103";
6603 if ( CheckVersion($DBversion) ) {
6604 $dbh->do("DELETE FROM systempreferences WHERE variable = 'insecure';");
6605 print "Upgrade to $DBversion done (Bug 9827 - Remove 'insecure' system preference)\n";
6606 SetVersion($DBversion);
6609 $DBversion = "3.11.00.104";
6610 if ( CheckVersion($DBversion) ) {
6611 print "Upgrade to $DBversion done (3.12-alpha2 release)\n";
6612 SetVersion ($DBversion);
6615 $DBversion = "3.11.00.105";
6616 if ( CheckVersion($DBversion) ) {
6617 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
6618 $sth = $dbh->prepare(
6619 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '029'"
6621 $sth->execute;
6622 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6624 for my $frameworkcode ( keys %$frameworkcodes ) {
6625 $dbh->do( "
6626 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6627 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6628 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6629 ('029', 'a', 'OCLC library identifier', 'OCLC library identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6630 ('029', 'b', 'System control number', 'System control number', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6631 ('029', 'c', 'OAI set name', 'OAI set name', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL),
6632 ('029', 't', 'Content type identifier', 'Content type identifier', 0, 0, '', 0, '', '', '', 0, -6, '$frameworkcode', '', '', NULL)
6633 " );
6636 for my $tag ( '863', '864', '865' ) {
6637 $sth = $dbh->prepare(
6638 "SELECT frameworkcode FROM marc_tag_structure WHERE tagfield = '$tag'"
6640 $sth->execute;
6641 my $frameworkcodes = $sth->fetchall_hashref('frameworkcode');
6643 for my $frameworkcode ( keys %$frameworkcodes ) {
6644 $dbh->do( "
6645 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian,
6646 libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode,
6647 value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
6648 ('$tag', '6', 'Linkage', 'Linkage', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6649 ('$tag', '8', 'Field link and sequence number', 'Field link and sequence number', 0, 0, '', 8, '', '', '', NULL, 5, '$frameworkcode', '', '', NULL),
6650 ('$tag', 'a', 'First level of enumeration', 'First level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6651 ('$tag', 'b', 'Second level of enumeration', 'Second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6652 ('$tag', 'c', 'Third level of enumeration', 'Third level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6653 ('$tag', 'd', 'Fourth level of enumeration', 'Fourth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6654 ('$tag', 'e', 'Fifth level of enumeration', 'Fifth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6655 ('$tag', 'f', 'Sixth level of enumeration', 'Sixth level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6656 ('$tag', 'g', 'Alternative numbering scheme, first level of enumeration', 'Alternative numbering scheme, first level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6657 ('$tag', 'h', 'Alternative numbering scheme, second level of enumeration', 'Alternative numbering scheme, second level of enumeration', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6658 ('$tag', 'i', 'First level of chronology', 'First level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6659 ('$tag', 'j', 'Second level of chronology', 'Second level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6660 ('$tag', 'k', 'Third level of chronology', 'Third level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6661 ('$tag', 'l', 'Fourth level of chronology', 'Fourth level of chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6662 ('$tag', 'm', 'Alternative numbering scheme, chronology', 'Alternative numbering scheme, chronology', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6663 ('$tag', 'n', 'Converted Gregorian year', 'Converted Gregorian year', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6664 ('$tag', 'o', 'Type of unit', 'Type of unit', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6665 ('$tag', 'p', 'Piece designation', 'Piece designation', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6666 ('$tag', 'q', 'Piece physical condition', 'Piece physical condition', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6667 ('$tag', 's', 'Copyright article-fee code', 'Copyright article-fee code', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6668 ('$tag', 't', 'Copy number', 'Copy number', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6669 ('$tag', 'v', 'Issuing date', 'Issuing date', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6670 ('$tag', 'w', 'Break indicator', 'Break indicator', 0, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6671 ('$tag', 'x', 'Nonpublic note', 'Nonpublic note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL),
6672 ('$tag', 'z', 'Public note', 'Public note', 1, 0, '', 8, '', '', '', 0, 5, '$frameworkcode', '', '', NULL)
6673 " );
6677 print "Upgrade to $DBversion done (Bug 9353: Missing subfields on MARC21 frameworks)\n";
6678 SetVersion($DBversion);
6682 $DBversion = "3.11.00.106";
6683 if ( CheckVersion($DBversion) ) {
6684 $dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('19', 'plugins', 'Koha plugins', '0')");
6685 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
6686 ('19', 'manage', 'Manage plugins ( install / uninstall )'),
6687 ('19', 'tool', 'Use tool plugins'),
6688 ('19', 'report', 'Use report plugins'),
6689 ('19', 'configure', 'Configure plugins')
6691 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','0','Enable or disable the ability to use Koha Plugins.','','YesNo')");
6693 $dbh->do("
6694 CREATE TABLE IF NOT EXISTS plugin_data (
6695 plugin_class varchar(255) NOT NULL,
6696 plugin_key varchar(255) NOT NULL,
6697 plugin_value text,
6698 PRIMARY KEY (plugin_class,plugin_key)
6699 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6702 print "Upgrade to $DBversion done (Bug 7804: Added plugin system.)\n";
6703 SetVersion($DBversion);
6706 $DBversion = "3.11.00.107";
6707 if ( CheckVersion($DBversion) ) {
6708 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice')");
6709 print "Upgrade to $DBversion done (Bug 9014: Add syspref TimeFormat)\n";
6710 SetVersion ($DBversion);
6713 $DBversion = "3.11.00.108";
6714 if ( CheckVersion($DBversion) ) {
6715 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
6716 $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');");
6717 $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;");
6718 print "Upgrade to $DBversion done (Bug 7241: Fix on circulation logs)\n";
6719 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";
6720 SetVersion($DBversion);
6723 $DBversion = "3.11.00.109";
6724 if ( CheckVersion($DBversion) ) {
6725 $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');");
6726 print "Upgrade to $DBversion done (Bug 9403: Add DisplayIconsXSLT)\n";
6727 SetVersion ($DBversion);
6730 $DBversion = "3.11.00.110";
6731 if ( CheckVersion($DBversion) ) {
6732 $dbh->do("ALTER TABLE pending_offline_operations CHANGE barcode barcode VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
6733 $dbh->do("ALTER TABLE pending_offline_operations ADD amount DECIMAL( 28, 6 ) NULL DEFAULT NULL");
6734 print "Upgrade to $DBversion done (Bug 8220 - Allow koc uploads to go to process queue)\n";
6735 SetVersion ($DBversion);
6738 $DBversion = "3.11.00.111";
6739 if ( CheckVersion($DBversion) ) {
6740 my $sth = $dbh->prepare("
6741 SELECT module, code, branchcode, content
6742 FROM letter
6743 WHERE content LIKE '%<fine>%'
6745 $sth->execute;
6746 my $sth_update = $dbh->prepare("UPDATE letter SET content = ? WHERE module = ? AND code = ? AND branchcode = ?");
6747 while(my $row = $sth->fetchrow_hashref){
6748 $row->{content} =~ s/<fine>\w+<\/fine>/<<items.fine>>/;
6749 $sth_update->execute($row->{content}, $row->{module}, $row->{code}, $row->{branchcode});
6751 print "Upgrade to $DBversion done (use new <<items.fine>> syntax in notices)\n";
6752 SetVersion($DBversion);
6755 $DBversion = "3.11.00.112";
6756 if ( CheckVersion($DBversion) ) {
6757 $dbh->do(qq{
6758 ALTER TABLE issuingrules ADD COLUMN renewalperiod int(4) DEFAULT NULL AFTER renewalsallowed
6760 $dbh->do(qq{
6761 UPDATE issuingrules SET renewalperiod = issuelength
6763 print "Upgrade to $DBversion done (Bug 8365: Add colum issuingrules.renewalperiod)\n";
6764 SetVersion ($DBversion);
6767 $DBversion = "3.11.00.113";
6768 if ( CheckVersion($DBversion) ) {
6769 $dbh->do(q{
6770 ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6771 ADD INDEX ( show_in_pulldown )
6773 print "Upgrade to $DBversion done (Bug 9257 - Add groups to normal search pulldown)\n";
6774 SetVersion ($DBversion);
6777 $DBversion = "3.11.00.115";
6778 if ( CheckVersion($DBversion) ) {
6779 $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')");
6780 $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')");
6781 print "Upgrade to $DBversion done (Bug 7740: Add syspref HighlightOwnItemsOnOPAC)\n";
6782 SetVersion ($DBversion);
6785 $DBversion = "3.11.00.116";
6786 if ( CheckVersion($DBversion) ) {
6787 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN serialid;});
6788 $dbh->do(q{ALTER TABLE aqorders DROP COLUMN subscription;});
6789 $dbh->do(q{ALTER TABLE aqorders ADD COLUMN subscriptionid INT(11) DEFAULT NULL;});
6790 $dbh->do(q{ALTER TABLE aqorders ADD CONSTRAINT aqorders_subscriptionid FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE;});
6791 $dbh->do(q{ALTER TABLE subscription ADD COLUMN reneweddate DATE DEFAULT NULL;});
6792 print "Upgrade to $DBversion done (Bug 5343: table aqorders: DROP serialid and subscription fields and ADD subscriptionid, table subscription: ADD reneweddate)\n";
6793 SetVersion ($DBversion);
6796 $DBversion = "3.11.00.200";
6797 if ( CheckVersion($DBversion) ) {
6798 print "Upgrade to $DBversion done (3.12-beta1 release)\n";
6799 SetVersion ($DBversion);
6802 $DBversion = "3.11.00.201";
6803 if ( CheckVersion($DBversion) ) {
6804 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'BIBSYS' AND host LIKE 'z3950.bibsys.no'");
6805 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'NORBOK' AND host LIKE 'z3950.nb.no'");
6806 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'SAMBOK' AND host LIKE 'z3950.nb.no'");
6807 $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'DEICHMAN' AND host like 'z3950.deich.folkebibl.no'");
6808 print "Upgrade to $DBversion done (Bug 9498 - Update encoding for Norwegian sample Z39.50 servers)\n";
6809 SetVersion($DBversion);
6812 $DBversion = "3.11.00.202";
6813 if ( CheckVersion($DBversion) ) {
6814 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ca', 'language', 'Catalan','2013-01-12' )");
6815 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ca','cat')");
6816 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'es', 'Catalán')");
6817 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'en', 'Catalan')");
6818 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'fr', 'Catalan')");
6819 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'ca', 'Català')");
6820 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'de', 'Katalanisch')");
6821 print "Upgrade to $DBversion done (Bug 9381: Add Catalan laguage)\n";
6822 SetVersion ($DBversion);
6825 $DBversion = "3.11.00.203";
6826 if ( CheckVersion($DBversion) ) {
6827 $dbh->do(q{ALTER TABLE suggestions CHANGE COLUMN title title VARCHAR(255) DEFAULT NULL;});
6828 print "Upgrade to $DBversion done (Bug 2046 - increasing title column length for suggestions)\n";
6829 SetVersion ($DBversion);
6832 $DBversion = "3.11.00.300";
6833 if ( CheckVersion($DBversion) ) {
6834 print "Upgrade to $DBversion done (3.12-beta3 release)\n";
6835 SetVersion ($DBversion);
6838 $DBversion = "3.11.00.301";
6839 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6840 #issues
6841 $dbh->do(q{
6842 ALTER TABLE `issues`
6843 ADD KEY `itemnumber_idx` (`itemnumber`),
6844 ADD KEY `branchcode_idx` (`branchcode`),
6845 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6847 $dbh->do(q{
6848 ALTER TABLE `old_issues`
6849 ADD KEY `branchcode_idx` (`branchcode`),
6850 ADD KEY `issuingbranch_idx` (`issuingbranch`)
6852 #items
6853 $dbh->do(q{
6854 ALTER TABLE `items` ADD KEY `itype_idx` (`itype`)
6856 $dbh->do(q{
6857 ALTER TABLE `deleteditems` ADD KEY `itype_idx` (`itype`)
6859 # biblioitems
6860 $dbh->do(q{
6861 ALTER TABLE `biblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6863 $dbh->do(q{
6864 ALTER TABLE `deletedbiblioitems` ADD KEY `itemtype_idx` (`itemtype`)
6866 # statistics
6867 $dbh->do(q{
6868 ALTER TABLE `statistics`
6869 ADD KEY `branch_idx` (`branch`),
6870 ADD KEY `proccode_idx` (`proccode`),
6871 ADD KEY `type_idx` (`type`),
6872 ADD KEY `usercode_idx` (`usercode`),
6873 ADD KEY `itemnumber_idx` (`itemnumber`),
6874 ADD KEY `itemtype_idx` (`itemtype`),
6875 ADD KEY `borrowernumber_idx` (`borrowernumber`),
6876 ADD KEY `associatedborrower_idx` (`associatedborrower`),
6877 ADD KEY `ccode_idx` (`ccode`)
6880 print "Upgrade to $DBversion done (Bug 9681: Add some database indexes)\n";
6881 SetVersion($DBversion);
6884 $DBversion = "3.12.00.000";
6885 if ( CheckVersion($DBversion) ) {
6886 print "Upgrade to $DBversion done (3.12.0 release)\n";
6887 SetVersion ($DBversion);
6890 $DBversion = '3.13.00.000';
6891 if ( CheckVersion($DBversion) ) {
6892 print "Upgrade to $DBversion done (start the journey to Koha Pi)\n";
6893 SetVersion ($DBversion);
6896 $DBversion = "3.13.00.001";
6897 if ( CheckVersion($DBversion) ) {
6898 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
6899 $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
6900 $dbh->do("
6901 CREATE TABLE `courses` (
6902 `course_id` int(11) NOT NULL AUTO_INCREMENT,
6903 `department` varchar(20) DEFAULT NULL,
6904 `course_number` varchar(255) DEFAULT NULL,
6905 `section` varchar(255) DEFAULT NULL,
6906 `course_name` varchar(255) DEFAULT NULL,
6907 `term` varchar(20) DEFAULT NULL,
6908 `staff_note` mediumtext,
6909 `public_note` mediumtext,
6910 `students_count` varchar(20) DEFAULT NULL,
6911 `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
6912 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6913 PRIMARY KEY (`course_id`)
6914 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6917 $dbh->do("
6918 CREATE TABLE `course_instructors` (
6919 `course_id` int(11) NOT NULL,
6920 `borrowernumber` int(11) NOT NULL,
6921 PRIMARY KEY (`course_id`,`borrowernumber`),
6922 KEY `borrowernumber` (`borrowernumber`)
6923 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6926 $dbh->do("
6927 ALTER TABLE `course_instructors`
6928 ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
6929 ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6932 $dbh->do("
6933 CREATE TABLE `course_items` (
6934 `ci_id` int(11) NOT NULL AUTO_INCREMENT,
6935 `itemnumber` int(11) NOT NULL,
6936 `itype` varchar(10) DEFAULT NULL,
6937 `ccode` varchar(10) DEFAULT NULL,
6938 `holdingbranch` varchar(10) DEFAULT NULL,
6939 `location` varchar(80) DEFAULT NULL,
6940 `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
6941 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6942 PRIMARY KEY (`ci_id`),
6943 UNIQUE KEY `itemnumber` (`itemnumber`),
6944 KEY `holdingbranch` (`holdingbranch`)
6945 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6948 $dbh->do("
6949 ALTER TABLE `course_items`
6950 ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
6951 ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
6954 $dbh->do("
6955 CREATE TABLE `course_reserves` (
6956 `cr_id` int(11) NOT NULL AUTO_INCREMENT,
6957 `course_id` int(11) NOT NULL,
6958 `ci_id` int(11) NOT NULL,
6959 `staff_note` mediumtext,
6960 `public_note` mediumtext,
6961 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
6962 PRIMARY KEY (`cr_id`),
6963 UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
6964 KEY `course_id` (`course_id`)
6965 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6968 $dbh->do("
6969 ALTER TABLE `course_reserves`
6970 ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
6973 $dbh->do("
6974 INSERT INTO permissions (module_bit, code, description) VALUES
6975 (18, 'manage_courses', 'Add, edit and delete courses'),
6976 (18, 'add_reserves', 'Add course reserves'),
6977 (18, 'delete_reserves', 'Remove course reserves')
6982 print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
6983 SetVersion($DBversion);
6986 $DBversion = "3.13.00.002";
6987 if ( CheckVersion($DBversion) ) {
6988 $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6989 print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6990 SetVersion ($DBversion);
6993 $DBversion = '3.13.00.003';
6994 if ( CheckVersion($DBversion) ) {
6995 $dbh->do("ALTER TABLE serial DROP itemnumber");
6996 print "Upgrade to $DBversion done (Bug 7718 - Remove itemnumber column from serials table)\n";
6997 SetVersion($DBversion);
7000 $DBversion = "3.13.00.004";
7001 if(CheckVersion($DBversion)) {
7002 $dbh->do(
7003 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo')"
7005 print "Upgrade to $DBversion done (Bug 9722: Allow users to add notes when placing a hold in OPAC)\n";
7006 SetVersion($DBversion);
7009 $DBversion = "3.13.00.005";
7010 if(CheckVersion($DBversion)) {
7011 my $intra= C4::Context->preference("intranetstylesheet");
7012 #if this pref is not blank or starting with http, https or / [root], then
7013 #add an additional / to the front
7014 if($intra && $intra !~ /^(\/|https?)/) {
7015 $dbh->do("UPDATE systempreferences SET value=? WHERE variable=?",
7016 undef,('/'.$intra,"intranetstylesheet"));
7017 print "WARNING: Your system preference intranetstylesheet has been prefixed with a slash to make it an absolute path.\n";
7019 print "Upgrade to $DBversion done (Bug 10052: Make intranetstylesheet and intranetcolorstylesheet behave exactly like their opac counterparts)\n";
7020 SetVersion ($DBversion);
7023 $DBversion = "3.13.00.006";
7024 if ( CheckVersion($DBversion) ) {
7025 $dbh->do(q{
7026 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
7027 VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo')
7029 print "Upgrade to $DBversion done (Bug 10120: Fines on item return controlled by a systempreference)\n";
7030 SetVersion($DBversion);
7033 $DBversion = "3.13.00.007";
7034 if ( CheckVersion($DBversion) ) {
7035 $dbh->do("UPDATE systempreferences SET variable='OpacHoldNotes' WHERE variable='OpacShowHoldNotes'");
7036 print "Upgrade to $DBversion done (Bug 10343: Rename OpacShowHoldNotes to OpacHoldNotes)\n";
7037 SetVersion($DBversion);
7040 $DBversion = "3.13.00.008";
7041 if ( CheckVersion($DBversion) ) {
7042 $dbh->do("
7043 CREATE TABLE IF NOT EXISTS borrower_files (
7044 file_id int(11) NOT NULL AUTO_INCREMENT,
7045 borrowernumber int(11) NOT NULL,
7046 file_name varchar(255) NOT NULL,
7047 file_type varchar(255) NOT NULL,
7048 file_description varchar(255) DEFAULT NULL,
7049 file_content longblob NOT NULL,
7050 date_uploaded timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7051 PRIMARY KEY (file_id),
7052 KEY borrowernumber (borrowernumber),
7053 CONSTRAINT borrower_files_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7054 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7056 print "Upgrade to $DBversion done (Bug 10443: make sure borrower_files table exists)\n";
7057 SetVersion($DBversion);
7060 $DBversion = "3.13.00.009";
7061 if ( CheckVersion($DBversion) ) {
7062 $dbh->do("ALTER TABLE aqorders DROP COLUMN biblioitemnumber");
7063 print "Upgrade to $DBversion done (Bug 9987 - Drop column aqorders.biblioitemnumber)\n";
7064 SetVersion($DBversion);
7067 $DBversion = "3.13.00.010";
7068 if ( CheckVersion($DBversion) ) {
7069 $dbh->do(
7071 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
7074 print
7075 "Upgrade to $DBversion done (Bug 10366 - Add system preference to enabling warning librarian when invoice is duplicated)\n";
7076 SetVersion($DBversion);
7079 $DBversion = "3.13.00.011";
7080 if ( CheckVersion($DBversion) ) {
7081 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it'");
7082 print "Upgrade to $DBversion done (Bug 9519: Wrong language code for Italian in the advanced search language limitations)\n";
7083 SetVersion($DBversion);
7086 $DBversion = "3.13.00.012";
7087 if ( CheckVersion($DBversion) ) {
7088 $dbh->do("ALTER TABLE issuingrules MODIFY COLUMN overduefinescap decimal(28,6) DEFAULT NULL;");
7089 print "Upgrade to $DBversion done (Bug 10490: Correct datatype for overduefinescap in issuingrules)\n";
7090 SetVersion($DBversion);
7093 $DBversion ="3.13.00.013";
7094 if ( CheckVersion($DBversion) ) {
7095 $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');");
7096 print "Upgrade to $DBversion done (Bug 9576: add AllowTooManyOverride syspref to enable or disable issue limit confirmation)\n";
7097 SetVersion($DBversion);
7100 $DBversion = "3.13.00.014";
7101 if ( CheckVersion($DBversion) ) {
7102 $dbh->do("ALTER TABLE courses MODIFY COLUMN department varchar(80) DEFAULT NULL;");
7103 $dbh->do("ALTER TABLE courses MODIFY COLUMN term varchar(80) DEFAULT NULL;");
7104 print "Upgrade to $DBversion done (Bug 10604: correct width of courses.department and courses.term)\n";
7105 SetVersion($DBversion);
7108 $DBversion = "3.13.00.015";
7109 if ( CheckVersion($DBversion) ) {
7110 $dbh->do(
7111 "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')"
7113 print "Upgrade to $DBversion done (Bug 7494: Add itemBarcodeFallbackSearch syspref)\n";
7114 SetVersion($DBversion);
7117 $DBversion = "3.13.00.016";
7118 if ( CheckVersion($DBversion) ) {
7119 $dbh->do(q{
7120 ALTER TABLE items CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7123 $dbh->do(q{
7124 ALTER TABLE deleteditems CHANGE wthdrawn withdrawn TINYINT( 1 ) NOT NULL DEFAULT '0'
7127 $dbh->do(q{
7128 UPDATE saved_sql SET savedsql = REPLACE(savedsql, 'wthdrawn', 'withdrawn')
7131 $dbh->do(q{
7132 UPDATE marc_subfield_structure SET kohafield = 'items.withdrawn' WHERE kohafield = 'items.wthdrawn'
7135 print "Upgrade to $DBversion done (Bug 10550 - Fix database typo wthdrawn)\n";
7136 SetVersion($DBversion);
7139 $DBversion = "3.13.00.017";
7140 if ( CheckVersion($DBversion) ) {
7141 $dbh->do(
7142 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientKey','','Client key for OverDrive integration','30','Free')"
7144 $dbh->do(
7145 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveClientSecret','','Client key for OverDrive integration','30','YesNo')"
7147 $dbh->do(
7148 "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer')"
7150 print "Upgrade to $DBversion done (Bug 10320 - Show results from library's OverDrive collection in OPAC search)\n";
7151 SetVersion($DBversion);
7154 $DBversion = "3.13.00.018";
7155 if ( CheckVersion($DBversion) ) {
7156 $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7157 $dbh->do(qq{
7158 CREATE TABLE aqorders_transfers (
7159 ordernumber_from int(11) NULL,
7160 ordernumber_to int(11) NULL,
7161 timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7162 UNIQUE KEY ordernumber_from (ordernumber_from),
7163 UNIQUE KEY ordernumber_to (ordernumber_to),
7164 CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7165 CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7166 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7168 print "Upgrade to $DBversion done (Bug 5349: Add aqorders_transfers table)\n";
7169 SetVersion($DBversion);
7172 $DBversion = "3.13.00.019";
7173 if ( CheckVersion($DBversion) ) {
7174 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255) AFTER summary;");
7175 $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL AFTER checkinmsg;");
7176 print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
7177 SetVersion($DBversion);
7180 $DBversion = "3.13.00.020";
7181 if ( CheckVersion($DBversion) ) {
7182 $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')");
7183 $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')");
7184 print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7185 SetVersion($DBversion);
7188 $DBversion ="3.13.00.021";
7189 if ( CheckVersion($DBversion) ) {
7190 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('ConfirmFutureHolds','0','Number of days for confirming future holds','','Integer');");
7191 print "Upgrade to $DBversion done (Bug 9761: Add ConfirmFutureHolds pref)\n";
7192 SetVersion($DBversion);
7195 $DBversion = "3.13.00.022";
7196 if ( CheckVersion($DBversion) ) {
7197 $dbh->do("DELETE from auth_tag_structure WHERE tagfield IN ('68a','68b')");
7198 $dbh->do("DELETE from auth_subfield_structure WHERE tagfield IN ('68a','68b')");
7199 print "Upgrade to $DBversion done (Bug 10687 - Delete erroneous tags 68a and 68b on default MARC21 auth framework)\n";
7200 SetVersion($DBversion);
7203 $DBversion = "3.13.00.023";
7204 if ( CheckVersion($DBversion) ) {
7205 $dbh->do("ALTER TABLE borrowers CHANGE password password VARCHAR(60);");
7206 print "Upgrade to $DBversion done (Bug 9611 upgrading password storage system)\n";
7207 SetVersion($DBversion);
7210 $DBversion = "3.13.00.024";
7211 if ( CheckVersion($DBversion) ) {
7212 $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;});
7213 print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n";
7216 $DBversion = "3.13.00.025";
7217 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7218 $dbh->do("ALTER TABLE oai_sets_mappings ADD COLUMN operator varchar(8) NOT NULL default 'equal' AFTER marcsubfield;");
7219 print "Upgrade to $DBversion done (Bug 9295: OAI notequal: add operator column to OAI mappings table)\n";
7220 SetVersion ($DBversion);
7223 $DBversion = "3.13.00.026";
7224 if ( CheckVersion($DBversion) ) {
7225 $dbh->do(q|
7226 ALTER TABLE auth_subfield_structure ADD COLUMN defaultvalue TEXT DEFAULT NULL AFTER frameworkcode
7228 print "Upgrade to $DBversion done (Bug 10602: Add the column auth_subfield_structure.defaultvalue)\n";
7229 SetVersion($DBversion);
7232 $DBversion = "3.13.00.027";
7233 if ( CheckVersion($DBversion) ) {
7234 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo')");
7235 print "Upgrade to $DBversion done (Bug 10240: Add syspref AllowOfflineCirculation)\n";
7236 SetVersion ($DBversion);
7239 $DBversion = "3.13.00.028";
7240 if ( CheckVersion($DBversion) ) {
7241 $dbh->do(q{
7242 ALTER TABLE export_format ADD type VARCHAR(255) DEFAULT 'marc' AFTER encoding
7244 $dbh->do(q{
7245 ALTER TABLE export_format CHANGE marcfields content mediumtext NOT NULL
7247 print "Upgrade to $DBversion done (Bug 10853: Add new field export_format.type and rename export_format.marcfields with export_format.content)\n";
7248 SetVersion($DBversion);
7251 $DBversion = "3.13.00.029";
7252 if ( CheckVersion($DBversion) ) {
7253 $dbh->do(q{
7254 INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type )
7255 VALUES ( "issues to claim", "Default CSV export for serial issue claims",
7256 "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate",
7257 ",", "sql" )
7259 print "Upgrade to $DBversion done (Bug 10854: Add the default CSV profile for claiming issues)\n";
7260 SetVersion($DBversion);
7263 $DBversion = "3.13.00.030";
7264 if ( CheckVersion($DBversion) ) {
7265 $dbh->do(qq{
7266 DELETE FROM patronimage WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowers.cardnumber = patronimage.cardnumber)
7269 $dbh->do(qq{
7270 ALTER TABLE patronimage ADD borrowernumber INT( 11 ) NULL FIRST
7273 $dbh->{AutoCommit} = 0;
7274 $dbh->{RaiseError} = 1;
7276 eval {
7277 $dbh->do(qq{
7278 UPDATE patronimage LEFT JOIN borrowers USING ( cardnumber ) SET patronimage.borrowernumber = borrowers.borrowernumber
7280 $dbh->commit();
7283 if ($@) {
7284 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber) failed! Transaction aborted because $@\n";
7285 eval { $dbh->rollback };
7287 else {
7288 $dbh->do(qq{
7289 ALTER TABLE patronimage DROP FOREIGN KEY patronimage_fk1
7291 $dbh->do(qq{
7292 ALTER TABLE patronimage DROP PRIMARY KEY, ADD PRIMARY KEY( borrowernumber )
7294 $dbh->do(qq{
7295 ALTER TABLE patronimage DROP cardnumber
7297 $dbh->do(qq{
7298 ALTER TABLE patronimage ADD FOREIGN KEY ( borrowernumber ) REFERENCES borrowers ( borrowernumber ) ON DELETE CASCADE ON UPDATE CASCADE
7301 print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber)\n";
7302 SetVersion($DBversion);
7305 $dbh->{AutoCommit} = 1;
7306 $dbh->{RaiseError} = 0;
7309 $DBversion = "3.13.00.031";
7310 if ( CheckVersion($DBversion) ) {
7312 $dbh->do(q{
7313 CREATE TABLE IF NOT EXISTS `patron_lists` (
7314 patron_list_id int(11) NOT NULL AUTO_INCREMENT,
7315 name varchar(255) CHARACTER SET utf8 NOT NULL,
7316 owner int(11) NOT NULL,
7317 PRIMARY KEY (patron_list_id),
7318 KEY owner (owner)
7319 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7322 $dbh->do(q{
7323 ALTER TABLE `patron_lists`
7324 ADD CONSTRAINT patron_lists_ibfk_1 FOREIGN KEY (`owner`) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7327 $dbh->do(q{
7328 CREATE TABLE patron_list_patrons (
7329 patron_list_patron_id int(11) NOT NULL AUTO_INCREMENT,
7330 patron_list_id int(11) NOT NULL,
7331 borrowernumber int(11) NOT NULL,
7332 PRIMARY KEY (patron_list_patron_id),
7333 KEY patron_list_id (patron_list_id),
7334 KEY borrowernumber (borrowernumber)
7335 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7338 $dbh->do(q{
7339 ALTER TABLE `patron_list_patrons`
7340 ADD CONSTRAINT patron_list_patrons_ibfk_1 FOREIGN KEY (patron_list_id) REFERENCES patron_lists (patron_list_id) ON DELETE CASCADE ON UPDATE CASCADE,
7341 ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE;
7344 $dbh->do(q{
7345 INSERT INTO permissions (module_bit, code, description) VALUES
7346 (13, 'manage_patron_lists', 'Add, edit and delete patron lists and their contents')
7349 print "Upgrade to $DBversion done (Bug 10565 - Add a 'Patron List' feature for storing and manipulating collections of patrons)\n";
7350 SetVersion($DBversion);
7353 $DBversion = "3.13.00.032";
7354 if ( CheckVersion($DBversion) ) {
7355 $dbh->do("ALTER TABLE aqorders ADD COLUMN orderstatus varchar(16) DEFAULT 'new' AFTER parent_ordernumber");
7356 $dbh->do("UPDATE aqorders SET orderstatus='ordered' WHERE basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)");
7357 $dbh->do(q{
7358 UPDATE aqorders SET orderstatus='partial'
7359 WHERE quantity > quantityreceived
7360 AND quantityreceived > 0
7361 AND ordernumber IN (
7362 SELECT parent_ordernumber
7363 FROM (
7364 SELECT DISTINCT(parent_ordernumber)
7365 FROM aqorders
7366 WHERE ordernumber != parent_ordernumber
7367 ) AS aq
7369 AND basketno IN (SELECT basketno FROM aqbasket WHERE closedate IS NOT NULL)
7371 $dbh->do("UPDATE aqorders SET orderstatus='complete' WHERE quantity=quantityreceived");
7372 $dbh->do("UPDATE aqorders SET orderstatus='cancelled' WHERE datecancellationprinted IS NOT NULL");
7373 print "Upgrade to $DBversion done (Bug 5336: Add the new column aqorders.orderstatus)\n";
7374 SetVersion($DBversion);
7377 $DBversion = "3.13.00.033";
7378 if ( CheckVersion($DBversion) ) {
7379 $dbh->do(qq|
7380 DROP TABLE IF EXISTS subscription_frequencies
7382 $dbh->do(qq|
7383 CREATE TABLE subscription_frequencies (
7384 id INTEGER NOT NULL AUTO_INCREMENT,
7385 description TEXT NOT NULL,
7386 displayorder INT DEFAULT NULL,
7387 unit ENUM('day','week','month','year') DEFAULT NULL,
7388 unitsperissue INTEGER NOT NULL DEFAULT '1',
7389 issuesperunit INTEGER NOT NULL DEFAULT '1',
7390 PRIMARY KEY (id)
7391 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7394 $dbh->do(qq|
7395 DROP TABLE IF EXISTS subscription_numberpatterns
7397 $dbh->do(qq|
7398 CREATE TABLE subscription_numberpatterns (
7399 id INTEGER NOT NULL AUTO_INCREMENT,
7400 label VARCHAR(255) NOT NULL,
7401 displayorder INTEGER DEFAULT NULL,
7402 description TEXT NOT NULL,
7403 numberingmethod VARCHAR(255) NOT NULL,
7404 label1 VARCHAR(255) DEFAULT NULL,
7405 add1 INTEGER DEFAULT NULL,
7406 every1 INTEGER DEFAULT NULL,
7407 whenmorethan1 INTEGER DEFAULT NULL,
7408 setto1 INTEGER DEFAULT NULL,
7409 numbering1 VARCHAR(255) DEFAULT NULL,
7410 label2 VARCHAR(255) DEFAULT NULL,
7411 add2 INTEGER DEFAULT NULL,
7412 every2 INTEGER DEFAULT NULL,
7413 whenmorethan2 INTEGER DEFAULT NULL,
7414 setto2 INTEGER DEFAULT NULL,
7415 numbering2 VARCHAR(255) DEFAULT NULL,
7416 label3 VARCHAR(255) DEFAULT NULL,
7417 add3 INTEGER DEFAULT NULL,
7418 every3 INTEGER DEFAULT NULL,
7419 whenmorethan3 INTEGER DEFAULT NULL,
7420 setto3 INTEGER DEFAULT NULL,
7421 numbering3 VARCHAR(255) DEFAULT NULL,
7422 PRIMARY KEY (id)
7423 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
7426 $dbh->do(qq|
7427 INSERT INTO subscription_frequencies (description, unit, unitsperissue, issuesperunit, displayorder)
7428 VALUES
7429 ('2/day', 'day', 1, 2, 1),
7430 ('1/day', 'day', 1, 1, 2),
7431 ('3/week', 'week', 1, 3, 3),
7432 ('1/week', 'week', 1, 1, 4),
7433 ('1/2 weeks', 'week', 2, 1, 5),
7434 ('1/3 weeks', 'week', 3, 1, 6),
7435 ('1/month', 'month', 1, 1, 7),
7436 ('1/2 months', 'month', 2, 1, 8),
7437 ('1/3 months', 'month', 3, 1, 9),
7438 ('2/year', 'month', 6, 1, 10),
7439 ('1/year', 'year', 1, 1, 11),
7440 ('1/2 year', 'year', 2, 1, 12),
7441 ('Irregular', NULL, 1, 1, 13)
7444 # Used to link existing subscription to newly created frequencies
7445 my $frequencies_mapping = { # keys are old frequency numbers, values are the new ones
7446 1 => 2, # daily (n/week)
7447 2 => 4, # 1/week
7448 3 => 5, # 1/2 weeks
7449 4 => 6, # 1/3 weeks
7450 5 => 7, # 1/month
7451 6 => 8, # 1/2 months (6/year)
7452 7 => 9, # 1/3 months (1/quarter)
7453 8 => 9, # 1/quarter (seasonal)
7454 9 => 10, # 2/year
7455 10 => 11, # 1/year
7456 11 => 12, # 1/2 years
7457 12 => 1, # 2/day
7458 16 => 13, # Without periodicity
7459 32 => 13, # Irregular
7460 48 => 13 # Unknown
7463 $dbh->do(qq|
7464 INSERT INTO subscription_numberpatterns
7465 (label, displayorder, description, numberingmethod,
7466 label1, add1, every1, whenmorethan1, setto1, numbering1,
7467 label2, add2, every2, whenmorethan2, setto2, numbering2,
7468 label3, add3, every3, whenmorethan3, setto3, numbering3)
7469 VALUES
7470 ('Number', 1, 'Simple Numbering method', 'No.{X}',
7471 'Number', 1, 1, 99999, 1, NULL,
7472 NULL, NULL, NULL, NULL, NULL, NULL,
7473 NULL, NULL, NULL, NULL, NULL, NULL),
7475 ('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
7476 'Volume', 1, 48, 99999, 1, NULL,
7477 'Number', 1, 4, 12, 1, NULL,
7478 'Issue', 1, 1, 4, 1, NULL),
7480 ('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
7481 'Volume', 1, 12, 99999, 1, NULL,
7482 'Number', 1, 1, 12, 1, NULL,
7483 NULL, NULL, NULL, NULL, NULL, NULL),
7485 ('Seasonal', 4, 'Season Year', '{X} {Y}',
7486 'Season', 1, 1, 3, 0, 'season',
7487 'Year', 1, 4, 99999, 1, NULL,
7488 NULL, NULL, NULL, NULL, NULL, NULL)
7491 $dbh->do(qq|
7492 ALTER TABLE subscription
7493 MODIFY COLUMN numberpattern INTEGER DEFAULT NULL,
7494 MODIFY COLUMN periodicity INTEGER DEFAULT NULL
7497 # Update existing subscriptions
7499 my $query = qq|
7500 SELECT subscriptionid, periodicity, numberingmethod,
7501 add1, every1, whenmorethan1, setto1,
7502 add2, every2, whenmorethan2, setto2,
7503 add3, every3, whenmorethan3, setto3
7504 FROM subscription
7505 ORDER BY subscriptionid
7507 my $sth = $dbh->prepare($query);
7508 $sth->execute;
7509 my $insert_numberpatterns_sth = $dbh->prepare(qq|
7510 INSERT INTO subscription_numberpatterns
7511 (label, displayorder, description, numberingmethod,
7512 label1, add1, every1, whenmorethan1, setto1, numbering1,
7513 label2, add2, every2, whenmorethan2, setto2, numbering2,
7514 label3, add3, every3, whenmorethan3, setto3, numbering3)
7515 VALUES
7516 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
7518 my $check_numberpatterns_sth = $dbh->prepare(qq|
7519 SELECT * FROM subscription_numberpatterns
7520 WHERE (add1 = ? OR (add1 IS NULL AND ? IS NULL)) AND (add2 = ? OR (add2 IS NULL AND ? IS NULL))
7521 AND (add3 = ? OR (add3 IS NULL AND ? IS NULL)) AND (every1 = ? OR (every1 IS NULL AND ? IS NULL))
7522 AND (every2 = ? OR (every2 IS NULL AND ? IS NULL)) AND (every3 = ? OR (every3 IS NULL AND ? IS NULL))
7523 AND (whenmorethan1 = ? OR (whenmorethan1 IS NULL AND ? IS NULL)) AND (whenmorethan2 = ? OR (whenmorethan2 IS NULL AND ? IS NULL))
7524 AND (whenmorethan3 = ? OR (whenmorethan3 IS NULL AND ? IS NULL)) AND (setto1 = ? OR (setto1 IS NULL AND ? IS NULL))
7525 AND (setto2 = ? OR (setto2 IS NULL AND ? IS NULL)) AND (setto3 = ? OR (setto3 IS NULL AND ? IS NULL))
7526 AND (numberingmethod = ? OR (numberingmethod IS NULL AND ? IS NULL))
7527 LIMIT 1
7529 my $update_subscription_sth = $dbh->prepare(qq|
7530 UPDATE subscription
7531 SET numberpattern = ?,
7532 periodicity = ?
7533 WHERE subscriptionid = ?
7536 my $i = 1;
7537 while(my $sub = $sth->fetchrow_hashref) {
7538 $check_numberpatterns_sth->execute(
7539 $sub->{add1}, $sub->{add1}, $sub->{add2}, $sub->{add2}, $sub->{add3}, $sub->{add3},
7540 $sub->{every1}, $sub->{every1}, $sub->{every2}, $sub->{every2}, $sub->{every3}, $sub->{every3},
7541 $sub->{whenmorethan1}, $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan2},
7542 $sub->{whenmorethan3}, $sub->{whenmorethan3}, $sub->{setto1}, $sub->{setto1}, $sub->{setto2},
7543 $sub->{setto2}, $sub->{setto3}, $sub->{setto3}, $sub->{numberingmethod}, $sub->{numberingmethod}
7545 my $p = $check_numberpatterns_sth->fetchrow_hashref;
7546 if (defined $p) {
7547 # Pattern already exists, link to it
7548 $update_subscription_sth->execute($p->{id},
7549 $frequencies_mapping->{$sub->{periodicity}},
7550 $sub->{subscriptionid});
7551 } else {
7552 # Create a new numbering pattern for this subscription
7553 my $ok = $insert_numberpatterns_sth->execute(
7554 "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
7555 "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
7556 "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
7557 "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
7559 if($ok) {
7560 my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
7561 # Link to subscription_numberpatterns and subscription_frequencies
7562 $update_subscription_sth->execute($id,
7563 $frequencies_mapping->{$sub->{periodicity}},
7564 $sub->{subscriptionid});
7566 $i++;
7570 # Remove now useless columns
7571 $dbh->do(qq|
7572 ALTER TABLE subscription
7573 DROP COLUMN numberingmethod,
7574 DROP COLUMN add1,
7575 DROP COLUMN every1,
7576 DROP COLUMN whenmorethan1,
7577 DROP COLUMN setto1,
7578 DROP COLUMN add2,
7579 DROP COLUMN every2,
7580 DROP COLUMN whenmorethan2,
7581 DROP COLUMN setto2,
7582 DROP COLUMN add3,
7583 DROP COLUMN every3,
7584 DROP COLUMN whenmorethan3,
7585 DROP COLUMN setto3,
7586 DROP COLUMN dow,
7587 DROP COLUMN issuesatonce,
7588 DROP COLUMN hemisphere,
7589 ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
7590 ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
7591 ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
7592 ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
7593 ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
7596 # Set firstacquidate if not already set (firstacquidate is now mandatory)
7597 my $get_first_planneddate_sth = $dbh->prepare(qq|
7598 SELECT planneddate
7599 FROM serial
7600 WHERE subscriptionid = ?
7601 ORDER BY serialid
7602 LIMIT 1
7604 my $update_firstacquidate_sth = $dbh->prepare(qq|
7605 UPDATE subscription
7606 SET firstacquidate = ?
7607 WHERE subscriptionid = ?
7609 my $get_subscriptions_sth = $dbh->prepare(qq|
7610 SELECT subscriptionid, startdate
7611 FROM subscription
7612 WHERE firstacquidate IS NULL
7613 OR firstacquidate = '0000-00-00'
7615 $get_subscriptions_sth->execute;
7616 while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) {
7617 # Try to get the planned date of the first serial
7618 $get_first_planneddate_sth->execute($subscriptionid);
7619 my ($first_planneddate) = $get_first_planneddate_sth->fetchrow;
7620 if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) {
7621 $update_firstacquidate_sth->execute($first_planneddate, $subscriptionid);
7622 } else {
7623 # Defaults to subscription start date
7624 $update_firstacquidate_sth->execute($startdate, $subscriptionid);
7628 print "Upgrade to $DBversion done (Bug 7688: add subscription_frequencies and subscription_numberpatterns tables)\n";
7629 SetVersion($DBversion);
7632 $DBversion = "3.13.00.034";
7633 if ( CheckVersion($DBversion) ) {
7634 $dbh->do("
7635 ALTER TABLE `import_batches`
7636 CHANGE `item_action` `item_action`
7637 ENUM( 'always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore', 'replace' )
7638 NOT NULL DEFAULT 'always_add'
7640 print "Upgrade to $DBversion done (Bug 7131 - way to overlay items in in marc import)\n";
7641 SetVersion($DBversion);
7644 $DBversion ="3.13.00.035";
7645 if ( CheckVersion($DBversion) ) {
7646 $dbh->do(q{
7647 CREATE TABLE borrower_debarments (
7648 borrower_debarment_id int(11) NOT NULL AUTO_INCREMENT,
7649 borrowernumber int(11) NOT NULL,
7650 expiration date DEFAULT NULL,
7651 `type` enum('SUSPENSION','OVERDUES','MANUAL') NOT NULL DEFAULT 'MANUAL',
7652 `comment` text,
7653 manager_id int(11) DEFAULT NULL,
7654 created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
7655 updated timestamp NULL DEFAULT NULL,
7656 PRIMARY KEY (borrower_debarment_id),
7657 KEY borrowernumber (borrowernumber) ,
7658 CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
7659 ON DELETE CASCADE ON UPDATE CASCADE
7660 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7663 # debarments with end date
7664 $dbh->do(q{
7665 INSERT INTO borrower_debarments ( borrowernumber, expiration, comment ) SELECT borrowernumber, debarred, debarredcomment FROM borrowers WHERE debarred IS NOT NULL AND debarred <> '9999-12-31'
7667 # debarments with no end date
7668 $dbh->do(q{
7669 INSERT INTO borrower_debarments ( borrowernumber, comment ) SELECT borrowernumber, debarredcomment FROM borrowers WHERE debarred = '9999-12-31'
7672 $dbh->do(q{
7673 INSERT IGNORE INTO systempreferences (variable,value,explanation,type) VALUES
7674 ('AutoRemoveOverduesRestrictions','0','Defines whether an OVERDUES debarment should be lifted automatically if all overdue items are returned by the patron.','YesNo')
7677 print "Upgrade to $DBversion done (Bug 2720 - Overdues which debar automatically should undebar automatically when returned)\n";
7678 SetVersion($DBversion);
7681 $DBversion = "3.13.00.036";
7682 if ( CheckVersion($DBversion) ) {
7683 $dbh->do(qq{
7684 INSERT INTO systempreferences (variable, value, explanation, options, type)
7685 VALUES ('StaffDetailItemSelection', '1', 'Enable item selection in record detail page', NULL, 'YesNo')
7687 print "Upgrade to $DBversion done (Add system preference StaffDetailItemSelection)\n";
7688 SetVersion($DBversion);
7691 $DBversion = "3.13.00.037";
7692 if ( CheckVersion($DBversion) ) {
7693 #add phone if it is not there already (explains the ignore option)
7694 $dbh->do("
7695 INSERT IGNORE INTO message_transport_types (message_transport_type) values ('phone');
7697 print "Upgrade to $DBversion done (Bug 10572: Add phone to message_transport_types table for new installs)\n";
7698 SetVersion($DBversion);
7701 $DBversion = "3.13.00.038";
7702 if ( CheckVersion($DBversion) ) {
7703 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES(15, 'superserials', 'Manage subscriptions from any branch (only applies when IndependentBranches is used)')");
7704 print "Upgrade to $DBversion done (Bug 8435: Add superserials permission)\n";
7705 SetVersion($DBversion);
7708 $DBversion = "3.13.00.039";
7709 if ( CheckVersion($DBversion) ) {
7710 $dbh->do("
7711 ALTER TABLE aqbasket ADD branch varchar(10) default NULL
7713 $dbh->do("
7714 ALTER TABLE aqbasket
7715 ADD CONSTRAINT aqbasket_ibfk_4 FOREIGN KEY (branch)
7716 REFERENCES branches (branchcode)
7717 ON UPDATE CASCADE ON DELETE SET NULL
7719 $dbh->do("
7720 DROP TABLE IF EXISTS aqbasketusers
7722 $dbh->do("
7723 CREATE TABLE aqbasketusers (
7724 basketno int(11) NOT NULL,
7725 borrowernumber int(11) NOT NULL,
7726 PRIMARY KEY (basketno,borrowernumber),
7727 CONSTRAINT aqbasketusers_ibfk_1 FOREIGN KEY (basketno) REFERENCES aqbasket (basketno) ON DELETE CASCADE ON UPDATE CASCADE,
7728 CONSTRAINT aqbasketusers_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
7729 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7731 $dbh->do("
7732 INSERT INTO permissions (module_bit, code, description)
7733 VALUES (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them')
7736 print "Upgrade to $DBversion done (Add branch and users list to baskets. "
7737 . "New permission order_manage_all)\n";
7738 SetVersion($DBversion);
7741 $DBversion = "3.13.00.040";
7742 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
7743 $dbh->do("CREATE TABLE IF NOT EXISTS marc_modification_templates (
7744 template_id int(11) NOT NULL auto_increment,
7745 name text NOT NULL,
7746 PRIMARY KEY (template_id)
7747 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
7750 $dbh->do("
7751 CREATE TABLE IF NOT EXISTS marc_modification_template_actions (
7752 mmta_id int(11) NOT NULL auto_increment,
7753 template_id int(11) NOT NULL,
7754 ordering int(3) NOT NULL,
7755 action enum('delete_field','update_field','move_field','copy_field') NOT NULL,
7756 field_number smallint(6) NOT NULL default '0',
7757 from_field varchar(3) NOT NULL,
7758 from_subfield varchar(1) NULL,
7759 field_value varchar(100) default NULL,
7760 to_field varchar(3) default NULL,
7761 to_subfield varchar(1) default NULL,
7762 to_regex_search text,
7763 to_regex_replace text,
7764 to_regex_modifiers varchar(8) default '',
7765 conditional enum('if','unless') default NULL,
7766 conditional_field varchar(3) default NULL,
7767 conditional_subfield varchar(1) default NULL,
7768 conditional_comparison enum('exists','not_exists','equals','not_equals') default NULL,
7769 conditional_value text,
7770 conditional_regex tinyint(1) NOT NULL default '0',
7771 description text,
7772 PRIMARY KEY (mmta_id),
7773 CONSTRAINT `mmta_ibfk_1` FOREIGN KEY (`template_id`) REFERENCES `marc_modification_templates` (`template_id`) ON DELETE CASCADE ON UPDATE CASCADE
7774 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7777 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'marc_modification_templates', 'Manage marc modification templates')");
7779 print "Upgrade to $DBversion done ( Bug 8015: Added tables for MARC Modification Framework )\n";
7780 SetVersion($DBversion);
7783 $DBversion = "3.13.00.041";
7784 if(CheckVersion($DBversion)) {
7785 $dbh->do(q{
7786 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');
7788 print "Upgrade to $DBversion done (Bug 10986: Added AcqItemSetSubfieldsWhenReceived syspref)\n";
7789 SetVersion($DBversion);
7792 $DBversion = "3.13.00.042";
7793 if(CheckVersion($DBversion)) {
7794 print "Upgrade to $DBversion done (Koha 3.14 beta)\n";
7795 SetVersion($DBversion);
7798 $DBversion = "3.13.00.043";
7799 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7800 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('SearchEngine','Zebra','Solr|Zebra','Search Engine','Choice')");
7801 print "Upgrade to $DBversion done (Bug 11196: Add system preference SearchEngine if missing )\n";
7802 SetVersion($DBversion);
7805 $DBversion = "3.14.00.000";
7806 if ( CheckVersion($DBversion) ) {
7807 print "Upgrade to $DBversion done (3.14.0 release)\n";
7808 SetVersion ($DBversion);
7811 $DBversion = '3.15.00.000';
7812 if ( CheckVersion($DBversion) ) {
7813 print "Upgrade to $DBversion done (the road goes ever on)\n";
7814 SetVersion ($DBversion);
7817 $DBversion = "3.15.00.001";
7818 if ( CheckVersion($DBversion) ) {
7819 $dbh->do("UPDATE systempreferences SET value='clear' where variable = 'CircAutoPrintQuickSlip' and value = '0'");
7820 $dbh->do("UPDATE systempreferences SET value='qslip' where variable = 'CircAutoPrintQuickSlip' and value = '1'");
7821 $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'");
7822 print "Upgrade to $DBversion done (Bug 11040: Add option to print full slip when checking out a null barcode)\n";
7823 SetVersion($DBversion);
7826 $DBversion = "3.15.00.002";
7827 if(CheckVersion($DBversion)) {
7828 $dbh->do("ALTER TABLE deleteditems MODIFY materials text;");
7829 print "Upgrade to $DBversion done (Bug 11275: alter deleteditems.materials from varchar(10) to text)\n";
7830 SetVersion($DBversion);
7833 $DBversion = "3.15.00.003";
7834 if ( CheckVersion($DBversion) ) {
7835 $dbh->do(q{
7836 UPDATE accountlines
7837 SET description = ''
7838 WHERE description IN (
7839 ' New Card',
7840 ' Fine',
7841 ' Sundry',
7842 'Writeoff',
7843 ' Account Management fee',
7844 'Payment,thanks', 'Payment,thanks - ',
7845 ' Lost Item'
7848 print "Upgrade to $DBversion done (Bug 2546: Update fine descriptions)\n";
7849 SetVersion($DBversion);
7852 $DBversion = "3.15.00.004";
7853 if ( CheckVersion($DBversion) ) {
7854 if ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
7855 $dbh->do(qq{
7856 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
7857 kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link,
7858 defaultvalue) VALUES
7859 ('015', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7860 ('020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7861 ('024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7862 ('027', 'q', 'Qualifying information', 'Qualifying information', 1, 0, '', 0, '', '', '', 0, 0, '', '', '', NULL),
7863 ('800', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7864 ('810', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7865 ('811', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL),
7866 ('830', '7', 'Control subfield', 'Control subfield', 0, 0, '', 8, '', '', '', NULL, -6, '', '', '', NULL);
7868 $dbh->do(qq{
7869 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
7870 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
7871 ('', '020', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', ''),
7872 ('', '024', 'q', 'Qualifying information', 'Qualifying information', 1, 0, 0, NULL, NULL, NULL, 0, 0, '', '', '');
7875 print "Upgrade to $DBversion done (Bug 10970 - Update MARC21 frameworks to Update Nr. 17 - DB update)\n";
7876 SetVersion($DBversion);
7879 $DBversion = "3.15.00.005";
7880 if ( CheckVersion($DBversion) ) {
7881 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo');");
7882 print "Upgrade to $DBversion done (Bug 8230: Add AcquisitionDetails system preference)\n";
7883 SetVersion ($DBversion);
7886 $DBversion = "3.15.00.006";
7887 if(CheckVersion($DBversion)) {
7888 $dbh->do(q{
7889 ALTER TABLE `borrowers`
7890 ADD KEY `surname_idx` (`surname`(255)),
7891 ADD KEY `firstname_idx` (`firstname`(255)),
7892 ADD KEY `othernames_idx` (`othernames`(255))
7894 print "Upgrade to $DBversion done (Bug 11249 - Add DB indexes on borrower names)\n";
7895 SetVersion($DBversion);
7898 $DBversion = "3.15.00.007";
7899 if ( CheckVersion($DBversion) ) {
7900 $dbh->do("ALTER TABLE items ADD itemlost_on DATETIME NULL AFTER itemlost");
7901 $dbh->do("ALTER TABLE items ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7902 $dbh->do("ALTER TABLE deleteditems ADD itemlost_on DATETIME NULL AFTER itemlost");
7903 $dbh->do("ALTER TABLE deleteditems ADD withdrawn_on DATETIME NULL AFTER withdrawn");
7904 print "Upgrade to $DBversion done (Bug 9673 - Track when items are marked as lost or withdrawn)\n";
7905 SetVersion ($DBversion);
7908 $DBversion = "3.15.00.008";
7909 if ( CheckVersion($DBversion) ) {
7910 $dbh->do(q{
7911 ALTER TABLE collections_tracking CHANGE ctId collections_tracking_id integer(11) NOT NULL auto_increment;
7913 print "Upgrade to $DBversion done (Bug 11384) - change name of collections_tracker.ctId column)\n";
7914 SetVersion ($DBversion);
7917 $DBversion = "3.15.00.009";
7918 if ( CheckVersion($DBversion) ) {
7919 $dbh->do(q{
7920 ALTER TABLE suggestions MODIFY suggesteddate DATE NOT NULL
7922 print "Upgrade to $DBversion done (Bug 11391) - drop default value on suggestions.suggesteddate column)\n";
7923 SetVersion ($DBversion);
7926 $DBversion = "3.15.00.010";
7927 if(CheckVersion($DBversion)) {
7928 $dbh->do("ALTER TABLE deleteditems DROP COLUMN marc");
7929 print "Upgrade to $DBversion done (Bug 6331: remove obsolete column in deleteditems.marc)\n";
7930 SetVersion ($DBversion);
7933 $DBversion = "3.15.00.011";
7934 if(CheckVersion($DBversion)) {
7935 $dbh->do("UPDATE marc_subfield_structure SET maxlength=9999 WHERE maxlength IS NULL OR maxlength=0;");
7936 print "Upgrade to $DBversion done (Bug 8018: set 9999 as default max length for subfields)\n";
7937 SetVersion ($DBversion);
7940 $DBversion = "3.15.00.012";
7941 if ( CheckVersion($DBversion) ) {
7942 $dbh->do(q{
7943 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'force_checkout', 'Force checkout if a limitation exists')
7945 $dbh->do(q{
7946 INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_restrictions', 'Manage restrictions for accounts')
7948 $dbh->do(q{
7949 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7950 SELECT user_permissions.borrowernumber, 1, 'force_checkout'
7951 FROM user_permissions
7952 LEFT JOIN borrowers USING(borrowernumber)
7953 WHERE borrowers.flags & (1 << 1)
7955 $dbh->do(q{
7956 INSERT INTO user_permissions (borrowernumber, module_bit, code)
7957 SELECT user_permissions.borrowernumber, 1, 'manage_restrictions'
7958 FROM user_permissions
7959 LEFT JOIN borrowers USING(borrowernumber)
7960 WHERE borrowers.flags & (1 << 1)
7963 print "Upgrade to $DBversion done (Bug 10863 - Add permissions force_checkout and manage_restrictions)\n";
7964 SetVersion($DBversion);
7967 $DBversion = "3.15.00.013";
7968 if(CheckVersion($DBversion)) {
7969 $dbh->do(q{
7970 UPDATE systempreferences
7971 SET explanation = 'Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")'
7972 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7975 $dbh->do(q{
7976 UPDATE systempreferences
7977 SET value = ''
7978 WHERE variable = "AcqItemSetSubfieldsWhenReceived"
7979 AND value = "0"
7981 print "Upgrade to $DBversion done (Bug 11237: Update explanation and default value for AcqItemSetSubfieldsWhenReceived syspref)\n";
7982 SetVersion($DBversion);
7985 $DBversion = "3.15.00.014";
7986 if (CheckVersion($DBversion)) {
7987 $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');");
7988 print "Upgrade to $DBversion done (Bug 11415: add system preference for automatic self checkout receipt printing)\n";
7989 SetVersion($DBversion);
7992 $DBversion = "3.15.00.015";
7993 if (CheckVersion($DBversion)) {
7994 $dbh->do("INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
7995 ('OpacSuggestionManagedBy',1,'','Show the name of the staff member who managed a suggestion in OPAC','YesNo');");
7996 print "Upgrade to $DBversion done (Bug 10907: Add OpacSuggestionManagedBy system preference)\n";
7997 SetVersion($DBversion);
8000 $DBversion = "3.15.00.016";
8001 if (CheckVersion($DBversion)) {
8002 $dbh->do("ALTER TABLE biblioitems CHANGE url url TEXT NULL DEFAULT NULL");
8003 $dbh->do("ALTER TABLE deletedbiblioitems CHANGE url url TEXT NULL DEFAULT NULL");
8004 print "Upgrade to $DBversion done (Bug 11268 - Biblioitems URL field is too small for some URLs)\n";
8005 SetVersion($DBversion);
8008 $DBversion = "3.15.00.017";
8009 if(CheckVersion($DBversion)) {
8010 $dbh->do(q{
8011 UPDATE systempreferences
8012 SET explanation = 'Define the contents of UNIMARC authority control field 100 position 08-35'
8013 WHERE variable = "UNIMARCAuthorityField100"
8015 $dbh->do(q{
8016 UPDATE systempreferences
8017 SET explanation = 'Define the contents of MARC21 authority control field 008 position 06-39'
8018 WHERE variable = "MARCAuthorityControlField008"
8020 $dbh->do(q{
8021 UPDATE systempreferences
8022 SET explanation = 'Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html'
8023 WHERE variable = "MARCOrgCode"
8025 print "Upgrade to $DBversion done (Bug 11611 - fix possible confusion between UNIMARC and MARC21 in some sysprefs)\n";
8026 SetVersion($DBversion);
8029 $DBversion = "3.15.00.018";
8030 if ( CheckVersion($DBversion) ) {
8031 $dbh->{AutoCommit} = 0;
8032 $dbh->{RaiseError} = 1;
8034 eval {
8035 $dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|);
8037 unless ( $@ ) {
8038 my $av_added = $dbh->do(q|
8039 INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
8040 SELECT 'ROADTYPE', roadtypeid, road_type, road_type
8041 FROM roadtype;
8044 my $rt_deleted = $dbh->do(q|
8045 DELETE FROM roadtype
8048 if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
8049 $dbh->do(q|
8050 DROP TABLE roadtype;
8052 $dbh->commit;
8053 print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
8054 SetVersion($DBversion);
8055 } else {
8056 print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
8057 $dbh->rollback;
8060 $dbh->{AutoCommit} = 1;
8061 $dbh->{RaiseError} = 0;
8064 $DBversion = "3.15.00.019";
8065 if ( CheckVersion($DBversion) ) {
8066 $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')");
8067 print "Upgrade to $DBversion done (Bug 11256: Add system preference OpacMaxItemsToDisplay)\n";
8068 SetVersion($DBversion);
8071 $DBversion = "3.15.00.020";
8072 if ( CheckVersion($DBversion) ) {
8073 $dbh->do(q|
8074 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')
8076 print "Upgrade to $DBversion done (Bug 11343: Add system preference MaxItemsForBatch )\n";
8077 SetVersion($DBversion);
8080 $DBversion = "3.15.00.021";
8081 if(CheckVersion($DBversion)) {
8082 $dbh->do(q{
8083 ALTER TABLE `action_logs`
8084 DROP KEY timestamp,
8085 ADD KEY `timestamp_idx` (`timestamp`),
8086 ADD KEY `user_idx` (`user`),
8087 ADD KEY `module_idx` (`module`(255)),
8088 ADD KEY `action_idx` (`action`(255)),
8089 ADD KEY `object_idx` (`object`),
8090 ADD KEY `info_idx` (`info`(255))
8092 print "Upgrade to $DBversion done (Bug 3445: Add indexes to action_logs table)\n";
8093 SetVersion($DBversion);
8096 $DBversion = "3.15.00.022";
8097 if (CheckVersion($DBversion)) {
8098 $dbh->do(q|
8099 DELETE FROM systempreferences WHERE variable= "memberofinstitution"
8101 print "Upgrade to $DBversion done (Bug 11751: Remove memberofinstitytion system preference)\n";
8102 SetVersion($DBversion);
8105 $DBversion = "3.15.00.023";
8106 if ( CheckVersion($DBversion) ) {
8107 $dbh->do("
8108 INSERT INTO systempreferences (variable,value,options,explanation,type)
8109 VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free');
8111 print "Upgrade to $DBversion done (Bug 10861: Add CardnumberLength syspref)\n";
8112 SetVersion ($DBversion);
8115 $DBversion = "3.15.00.024";
8116 if ( CheckVersion($DBversion) ) {
8117 $dbh->do(q{
8118 DELETE FROM systempreferences WHERE variable = 'NoZebraIndexes'
8120 print "Upgrade to $DBversion done (Bug 10012 - remove last vestiges of NoZebra)\n";
8121 SetVersion($DBversion);
8124 $DBversion = "3.15.00.025";
8125 if ( CheckVersion($DBversion) ) {
8126 $dbh->do(q{
8127 DROP TABLE aqorderdelivery;
8129 print "Upgrade to $DBversion done (Bug 11928 - remove unused table)\n";
8130 SetVersion($DBversion);
8133 $DBversion = "3.15.00.026";
8134 if ( CheckVersion($DBversion) ) {
8135 $dbh->do(q{
8136 UPDATE language_descriptions SET description = 'Հայերեն' WHERE subtag = 'hy' AND lang = 'hy';
8138 print "Upgrade to $DBversion done (Bug 11973 - Fix Armenian language description)\n";
8139 SetVersion($DBversion);
8142 $DBversion = "3.15.00.027";
8143 if (CheckVersion($DBversion)) {
8144 $dbh->do(q{
8145 ALTER TABLE opac_news ADD branchcode varchar(10) DEFAULT NULL
8146 AFTER idnew,
8147 ADD CONSTRAINT opac_news_branchcode_ibfk
8148 FOREIGN KEY (branchcode)
8149 REFERENCES branches (branchcode)
8150 ON DELETE CASCADE ON UPDATE CASCADE;
8152 print "Upgrade to $DBversion done (Bug 7567: Add branchcode to opac_news)\n";
8153 SetVersion($DBversion);
8156 $DBversion = "3.15.00.028";
8157 if(CheckVersion($DBversion)) {
8158 $dbh->do(q{
8159 ALTER TABLE issuingrules ADD norenewalbefore int(4) default NULL AFTER renewalperiod
8161 print "Upgrade to $DBversion done (Bug 7413: Allow OPAC renewal x days before due date)\n";
8162 SetVersion($DBversion);
8165 $DBversion = "3.15.00.029";
8166 if ( CheckVersion($DBversion) ) {
8167 $dbh->do(q{
8168 UPDATE borrower_debarments SET expiration = NULL WHERE expiration = '9999-12-31'
8170 print "Upgrade to $DBversion done (Bug 11846 - correct borrower_debarments with expiration 9999-12-31)\n";
8171 SetVersion($DBversion);
8174 $DBversion = "3.15.00.030";
8175 if(CheckVersion($DBversion)) {
8176 $dbh->do(q|
8177 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')
8179 print "Upgrade to $DBversion done (Bug 12052: Add OPACMySummaryNote syspref)\n";
8180 SetVersion($DBversion);
8183 $DBversion = "3.15.00.031";
8184 if ( CheckVersion($DBversion) ) {
8185 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'writeoff', 'Write off fines and fees')");
8186 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ('10', 'remaining_permissions', 'Remaining permissions for managing fines and fees')");
8187 print "Upgrade to $DBversion done (Bug 9448 - Add separate permission for writing off fees)\n";
8188 SetVersion ($DBversion);
8191 $DBversion = "3.15.00.032";
8192 if ( CheckVersion($DBversion) ) {
8193 $dbh->do("ALTER TABLE aqorders CHANGE notes order_internalnote MEDIUMTEXT;");
8194 $dbh->do("ALTER TABLE aqorders ADD COLUMN order_vendornote MEDIUMTEXT AFTER order_internalnote;");
8195 print "Upgrade to $DBversion done (Bug 9416 - In each order, add a new note made for the vendor)\n";
8196 SetVersion ($DBversion);
8199 $DBversion = "3.15.00.033";
8200 if ( CheckVersion($DBversion) ) {
8201 $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')");
8202 print "Upgrade to $DBversion done (Bug 10951: Add NoLoginInstructions pref)\n";
8203 SetVersion($DBversion);
8206 $DBversion = "3.15.00.034";
8207 if ( CheckVersion($DBversion) ) {
8208 $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')");
8209 print "Upgrade to $DBversion done (Bug 10986: system preferences to limit languages in advanced search )\n";
8210 SetVersion ($DBversion);
8213 $DBversion = "3.15.00.035";
8214 if ( CheckVersion($DBversion) ) {
8215 #insert a notice for sharing a list and accepting a share
8216 $dbh->do("
8217 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8218 VALUES ( 'members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
8220 One of our patrons, <<borrowers.firstname>> <<borrowers.surname>>, invites you to share a list <<listname>> in our library catalog.
8222 To access this shared list, please click on the following URL or copy-and-paste it into your browser address bar.
8224 <<shareurl>>
8226 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.
8228 Thank you.
8230 Your library.'
8231 )");
8232 $dbh->do("
8233 INSERT INTO letter (module, code, branchcode, name, is_html, title, content)
8234 VALUES ( 'members', 'SHARE_ACCEPT', '', 'Notification about an accepted share', '0', 'Share on list <<listname>> accepted', 'Dear patron,
8236 We want to inform you that <<borrowers.firstname>> <<borrowers.surname>> accepted your invitation to share your list <<listname>> in our library catalog.
8238 Thank you.
8240 Your library.'
8241 )");
8242 print "Upgrade to $DBversion done (Bug 9032: Share a list)\n";
8243 SetVersion($DBversion);
8246 $DBversion = "3.15.00.036";
8247 if ( CheckVersion($DBversion) ) {
8248 $dbh->do(q{
8249 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
8250 VALUES('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo')
8253 print "Upgrade to $DBversion done (Bug 10859 - Add system preference AllowMultipleIssuesOnABiblio)\n";
8254 SetVersion($DBversion);
8257 $DBversion = "3.15.00.037";
8258 if(CheckVersion($DBversion)) {
8259 $dbh->do(q{
8260 ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) DEFAULT NULL AFTER checkinmsgtype
8262 $dbh->do(q{
8263 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
8264 ('SIP_MEDIA_TYPE', '000', 'Other'),
8265 ('SIP_MEDIA_TYPE', '001', 'Book'),
8266 ('SIP_MEDIA_TYPE', '002', 'Magazine'),
8267 ('SIP_MEDIA_TYPE', '003', 'Bound journal'),
8268 ('SIP_MEDIA_TYPE', '004', 'Audio tape'),
8269 ('SIP_MEDIA_TYPE', '005', 'Video tape'),
8270 ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'),
8271 ('SIP_MEDIA_TYPE', '007', 'Diskette'),
8272 ('SIP_MEDIA_TYPE', '008', 'Book with diskette'),
8273 ('SIP_MEDIA_TYPE', '009', 'Book with CD'),
8274 ('SIP_MEDIA_TYPE', '010', 'Book with audio tape')
8276 print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n";
8277 SetVersion($DBversion);
8280 $DBversion = '3.15.00.038';
8281 if ( CheckVersion($DBversion) ) {
8282 $dbh->do(q{
8283 INSERT INTO systempreferences (
8284 variable,
8285 value,
8286 options,
8287 explanation,
8288 type
8290 VALUES (
8291 'DisplayLibraryFacets', 'holding', 'home|holding|both', 'Defines which library facets to display.', 'Choice'
8294 print "Upgrade to $DBversion done (Bug 11334 - Add facet for home library)\n";
8295 SetVersion ($DBversion);
8298 $DBversion = "3.15.00.039";
8299 if ( CheckVersion($DBversion) ) {
8301 $dbh->do( q{
8302 ALTER TABLE letter ADD COLUMN message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email' AFTER content
8303 } );
8305 $dbh->do( q{
8306 ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type);
8307 } );
8309 $dbh->do( q{
8310 ALTER TABLE letter DROP PRIMARY KEY, ADD PRIMARY KEY (`module`,`code`,`branchcode`, message_transport_type);
8311 } );
8313 $dbh->do( q{
8314 CREATE TABLE overduerules_transport_types(
8315 id INT(11) NOT NULL AUTO_INCREMENT,
8316 branchcode varchar(10) NOT NULL DEFAULT '',
8317 categorycode VARCHAR(10) NOT NULL DEFAULT '',
8318 letternumber INT(1) NOT NULL DEFAULT 1,
8319 message_transport_type VARCHAR(20) NOT NULL DEFAULT 'email',
8320 PRIMARY KEY (id),
8321 CONSTRAINT overduerules_fk FOREIGN KEY (branchcode, categorycode) REFERENCES overduerules (branchcode, categorycode) ON DELETE CASCADE ON UPDATE CASCADE,
8322 CONSTRAINT mtt_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types (message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE
8323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8324 } );
8326 my $sth = $dbh->prepare( q{
8327 SELECT * FROM overduerules;
8328 } );
8330 $sth->execute;
8331 my $sth_insert_mtt = $dbh->prepare( q{
8332 INSERT INTO overduerules_transport_types (branchcode, categorycode, letternumber, message_transport_type) VALUES ( ?, ?, ?, ? )
8333 } );
8334 while ( my $row = $sth->fetchrow_hashref ) {
8335 my $branchcode = $row->{branchcode};
8336 my $categorycode = $row->{categorycode};
8337 for my $letternumber ( 1 .. 3 ) {
8338 next unless $row->{"letter$letternumber"};
8339 $sth_insert_mtt->execute(
8340 $branchcode, $categorycode, $letternumber, 'email'
8345 print "Upgrade done (Bug 9016: Adds multi transport types management for notices)\n";
8346 SetVersion($DBversion);
8349 $DBversion = "3.15.00.040";
8350 if ( CheckVersion($DBversion) ) {
8351 $dbh->do(q|
8352 UPDATE message_transports SET letter_code='HOLD' WHERE letter_code='HOLD_PHONE' OR letter_code='HOLD_PRINT'
8354 $dbh->do(q|
8355 UPDATE letter SET code='HOLD', message_transport_type='print' WHERE code='HOLD_PRINT'
8357 $dbh->do(q|
8358 UPDATE letter SET code='HOLD', message_transport_type='phone' WHERE code='HOLD_PHONE'
8360 print "Upgrade to $DBversion done (Bug 10845: Multi transport types for holds)\n";
8361 SetVersion($DBversion);
8364 $DBversion = "3.15.00.041";
8365 if ( CheckVersion($DBversion) ) {
8366 my ( $name ) = $dbh->selectrow_array(q|
8367 SELECT name FROM letter WHERE code="HOLD"
8369 $dbh->do(q|
8370 UPDATE letter
8371 SET code="HOLD",
8372 message_transport_type="phone",
8373 name= ?
8374 WHERE code="HOLD_PHONE"
8375 |, {}, $name);
8377 ( $name ) = $dbh->selectrow_array(q|
8378 SELECT name FROM letter WHERE code="PREDUE"
8380 $dbh->do(q|
8381 UPDATE letter
8382 SET code="PREDUE",
8383 message_transport_type="phone",
8384 name= ?
8385 WHERE code="PREDUE_PHONE"
8386 |, {}, $name);
8388 ( $name ) = $dbh->selectrow_array(q|
8389 SELECT name FROM letter WHERE code="OVERDUE"
8391 $dbh->do(q|
8392 UPDATE letter
8393 SET code="OVERDUE",
8394 message_transport_type="phone",
8395 name= ?
8396 WHERE code="OVERDUE_PHONE"
8397 |, {}, $name);
8399 print "Upgrade to $DBversion done (Bug 11867: Update letters *_PHONE)\n";
8400 SetVersion($DBversion);
8403 $DBversion = "3.15.00.042";
8404 if ( CheckVersion($DBversion) ) {
8405 $dbh->do(q{
8406 INSERT INTO systempreferences
8407 (variable,value,explanation,options,type)
8408 VALUES
8409 ('SpecifyReturnDate',0,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo')
8411 print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n";
8412 SetVersion($DBversion);
8415 $DBversion = "3.15.00.043";
8416 if ( CheckVersion($DBversion) ) {
8417 $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')");
8418 print "Upgrade to $DBversion done (Bug 7180: Added MarcFieldsToOrder syspref)\n";
8419 SetVersion ($DBversion);
8422 $DBversion = "3.15.00.044";
8423 if ( CheckVersion($DBversion) ) {
8424 $dbh->do("ALTER TABLE currency ADD isocode VARCHAR(5) default NULL AFTER symbol;");
8425 print "Upgrade to $DBversion done (Added isocode to the currency table)\n";
8426 SetVersion($DBversion);
8429 $DBversion = "3.15.00.045";
8430 if ( CheckVersion($DBversion) ) {
8431 $dbh->do("
8432 INSERT INTO systempreferences (variable,value,explanation,options,type)
8433 VALUES (
8434 'BlockExpiredPatronOpacActions',
8435 '0',
8436 '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',
8437 NULL,
8438 'YesNo'
8441 $dbh->do("ALTER TABLE `categories` ADD COLUMN `BlockExpiredPatronOpacActions` TINYINT(1) DEFAULT -1 NOT NULL AFTER category_type");
8442 print "Upgraded to $DBversion done (Bug 6739 - expired patrons not blocked from opac actions)\n";
8443 SetVersion ($DBversion);
8446 $DBversion = "3.15.00.046";
8447 if ( CheckVersion($DBversion) ) {
8448 $dbh->do(q|
8449 ALTER TABLE search_history ADD COLUMN type VARCHAR(16) NOT NULL DEFAULT 'biblio' AFTER query_cgi
8451 print "Upgrade to $DBversion done (Bug 10807 - Add db field search_history.type)\n";
8452 SetVersion($DBversion);
8455 $DBversion = "3.15.00.047";
8456 if ( CheckVersion($DBversion) ) {
8457 $dbh->do(q|
8458 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableSearchHistory','0','','Enable or disable search history','YesNo')
8460 print "Upgrade to $DBversion done (Bug 10862: Add EnableSearchHistory syspref)\n";
8461 SetVersion($DBversion);
8464 $DBversion = "3.15.00.048";
8465 if ( CheckVersion($DBversion) ) {
8466 $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')");
8467 $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')");
8468 print "Upgrade to $DBversion done (Bug 10195: Records hidden with OpacSuppression can still be accessed)\n";
8469 SetVersion($DBversion);
8472 $DBversion = "3.15.00.049";
8473 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8474 $dbh->do("ALTER TABLE biblioitems DROP INDEX isbn");
8475 $dbh->do("ALTER TABLE biblioitems DROP INDEX issn");
8476 $dbh->do("ALTER TABLE biblioitems
8477 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8478 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8480 $dbh->do("ALTER TABLE biblioitems
8481 ADD INDEX isbn ( isbn ( 255 ) ),
8482 ADD INDEX issn ( issn ( 255 ) )
8485 $dbh->do("ALTER TABLE deletedbiblioitems DROP INDEX isbn");
8486 $dbh->do("ALTER TABLE deletedbiblioitems
8487 CHANGE isbn isbn MEDIUMTEXT NULL DEFAULT NULL,
8488 CHANGE issn issn MEDIUMTEXT NULL DEFAULT NULL
8490 $dbh->do("ALTER TABLE deletedbiblioitems
8491 ADD INDEX isbn ( isbn ( 255 ) )
8494 print "Upgrade to $DBversion done (Bug 5377 - Biblioitems isbn and issn fields too small for multiple ISBN and ISSN)\n";
8495 SetVersion($DBversion);
8498 $DBversion = "3.15.00.050";
8499 if ( CheckVersion($DBversion) ) {
8500 $dbh->do("
8501 INSERT INTO systempreferences (
8502 variable,
8503 value,
8504 explanation,
8505 type
8506 ) VALUES (
8507 'AggressiveMatchOnISBN',
8508 '0',
8509 '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',
8510 'YesNo'
8514 print "Upgrade to $DBversion done (Bug 10500 - Improve isbn matching when importing records)\n";
8515 SetVersion($DBversion);
8518 $DBversion = "3.15.00.051";
8519 if ( CheckVersion($DBversion) ) {
8520 print "Upgrade to $DBversion done (Koha 3.16 beta)\n";
8521 SetVersion($DBversion);
8524 $DBversion = "3.15.00.052";
8525 if ( CheckVersion($DBversion) ) {
8526 print "Upgrade to $DBversion done (Koha 3.16 RC)\n";
8527 SetVersion($DBversion);
8530 $DBversion = "3.16.00.000";
8531 if ( CheckVersion($DBversion) ) {
8532 print "Upgrade to $DBversion done (3.16.0 release)\n";
8533 SetVersion ($DBversion);
8536 $DBversion = '3.17.00.000';
8537 if ( CheckVersion($DBversion) ) {
8538 print "Upgrade to $DBversion done (there is no time to rest on our laurels)\n";
8539 SetVersion ($DBversion);
8542 $DBversion = '3.17.00.001';
8543 if ( CheckVersion($DBversion) ) {
8544 $dbh->do("UPDATE systempreferences SET variable = 'AuthoritySeparator' WHERE variable = 'authoritysep'");
8545 print "Upgrade to $DBversion done (Bug 10330 - Rename system preference authoritysep to AuthoritySeparator)\n";
8546 SetVersion ($DBversion);
8549 $DBversion = "3.17.00.002";
8550 if (CheckVersion($DBversion)) {
8551 $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')");
8552 $dbh->do("
8553 CREATE TABLE IF NOT EXISTS `misc_files` (
8554 `file_id` int(11) NOT NULL AUTO_INCREMENT,
8555 `table_tag` varchar(255) NOT NULL,
8556 `record_id` int(11) NOT NULL,
8557 `file_name` varchar(255) NOT NULL,
8558 `file_type` varchar(255) NOT NULL,
8559 `file_description` varchar(255) DEFAULT NULL,
8560 `file_content` longblob NOT NULL, -- file content
8561 `date_uploaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
8562 PRIMARY KEY (`file_id`),
8563 KEY `table_tag` (`table_tag`),
8564 KEY `record_id` (`record_id`)
8565 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8567 print "Upgrade to $DBversion done (Bug 3050 - Add an option to upload scanned invoices)\n";
8568 SetVersion($DBversion);
8571 $DBversion = "3.17.00.003";
8572 if (CheckVersion($DBversion)) {
8573 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = '0|1|force' WHERE variable = 'OPACItemHolds'");
8574 print "Upgrade to $DBversion done (Bug 7825 - Changed OPACItemHolds syspref to Choice)\n";
8575 SetVersion($DBversion);
8578 $DBversion = "3.17.00.004";
8579 if (CheckVersion($DBversion)) {
8580 $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER category_type");
8581 print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
8582 SetVersion($DBversion);
8585 $DBversion = "3.17.00.005";
8586 if (CheckVersion($DBversion)) {
8587 $dbh->do(q|
8588 ALTER TABLE issuingrules
8589 ADD maxsuspensiondays INT(11) DEFAULT NULL AFTER finedays;
8591 print "Upgrade to $DBversion done (Bug 12230: Add new issuing rule maxsuspensiondays)\n";
8592 SetVersion($DBversion);
8595 $DBversion = "3.17.00.006";
8596 if ( CheckVersion($DBversion) ) {
8597 $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')");
8598 $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')");
8599 print "Upgrade to $DBversion done (Bug 7720 - Ambiguity in OPAC Details location.)\n";
8600 SetVersion($DBversion);
8603 $DBversion = "3.17.00.007";
8604 if (CheckVersion($DBversion)) {
8605 $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');");
8606 print "Upgrade to $DBversion done (Bug 11629 - Add ability to update not for loan status on checkin)\n";
8607 SetVersion($DBversion);
8610 $DBversion = "3.17.00.008";
8611 if ( CheckVersion($DBversion) ) {
8612 $dbh->do(q|
8613 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('OPACAcquisitionDetails','0', '','Show the acquisition details at the OPAC','YesNo')
8615 print "Upgrade to $DBversion done (Bug 11169 - Add OPACAcquisitionDetails syspref)\n";
8616 SetVersion($DBversion);
8619 $DBversion = "3.17.00.009";
8620 if ( CheckVersion($DBversion) ) {
8621 $dbh->do(q{
8622 DELETE FROM systempreferences WHERE variable = 'UseTablesortForCirc'
8625 print "Upgrade to $DBversion done (Bug 11703 - Remove UseTablesortForCirc syspref)\n";
8626 SetVersion($DBversion);
8629 $DBversion = "3.17.00.010";
8630 if ( CheckVersion($DBversion) ) {
8631 $dbh->do("DELETE FROM systempreferences WHERE variable='opacsmallimage'");
8632 print "Upgrade to $DBversion done (Bug 11347 - PROG/CCSR deprecation: Remove opacsmallimage system preference)\n";
8633 SetVersion($DBversion);
8636 $DBversion = "3.17.00.011";
8637 if ( CheckVersion($DBversion) ) {
8638 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'hr', 'language', 'Croatian','2014-07-24' )");
8639 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'hr','hrv')");
8640 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'hr', 'Hrvatski')");
8641 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'en', 'Croatian')");
8642 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'fr', 'Croate')");
8643 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'hr', 'language', 'de', 'Kroatisch')");
8644 print "Upgrade to $DBversion done (Bug 12649: Add Croatian language)\n";
8645 SetVersion ($DBversion);
8648 $DBversion = "3.17.00.012";
8649 if ( CheckVersion($DBversion) ) {
8650 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowFiltersPulldownMobile'");
8651 print "Upgrade to $DBversion done ( Bug 12512 - PROG/CCSR deprecation: Remove OpacShowFiltersPulldownMobile system preference )\n";
8652 SetVersion ($DBversion);
8655 $DBversion = "3.17.00.013";
8656 if ( CheckVersion($DBversion) ) {
8657 $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')");
8658 print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n";
8659 SetVersion ($DBversion);
8662 $DBversion = '3.17.00.014';
8663 if ( CheckVersion($DBversion) ) {
8664 $dbh->do("
8665 INSERT INTO systempreferences (variable,value,explanation,type) VALUES
8666 ('OverdueNoticeCalendar',0,'Take calendar into consideration when working out sending overdue notices','YesNo')
8668 print "Upgrade to $DBversion done (Bug 12529 - Adding a syspref to allow the overdue notices to consider the calendar when generating notices)\n";
8669 SetVersion($DBversion);
8672 $DBversion = "3.17.00.015";
8673 if ( CheckVersion($DBversion) ) {
8674 $dbh->do(q{
8675 CREATE TABLE IF NOT EXISTS columns_settings (
8676 module varchar(255) NOT NULL,
8677 page varchar(255) NOT NULL,
8678 tablename varchar(255) NOT NULL,
8679 columnname varchar(255) NOT NULL,
8680 cannot_be_toggled int(1) NOT NULL DEFAULT 0,
8681 is_hidden int(1) NOT NULL DEFAULT 0,
8682 PRIMARY KEY(module, page, tablename, columnname)
8683 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
8685 print "Upgrade to $DBversion done (Bug 10212 - Create new table columns_settings)\n";
8686 SetVersion ($DBversion);
8689 $DBversion = "3.17.00.016";
8690 if ( CheckVersion($DBversion) ) {
8691 $dbh->do("CREATE TABLE aqcontacts (
8692 id int(11) NOT NULL auto_increment,
8693 name varchar(100) default NULL,
8694 position varchar(100) default NULL,
8695 phone varchar(100) default NULL,
8696 altphone varchar(100) default NULL,
8697 fax varchar(100) default NULL,
8698 email varchar(100) default NULL,
8699 notes mediumtext,
8700 claimacquisition BOOLEAN NOT NULL DEFAULT 0,
8701 claimissues BOOLEAN NOT NULL DEFAULT 0,
8702 acqprimary BOOLEAN NOT NULL DEFAULT 0,
8703 serialsprimary BOOLEAN NOT NULL DEFAULT 0,
8704 booksellerid int(11) not NULL,
8705 PRIMARY KEY (id),
8706 CONSTRAINT booksellerid_aqcontacts_fk FOREIGN KEY (booksellerid)
8707 REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE
8708 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
8709 $dbh->do("INSERT INTO aqcontacts (name, position, phone, altphone, fax,
8710 email, notes, booksellerid, claimacquisition, claimissues, acqprimary, serialsprimary)
8711 SELECT contact, contpos, contphone, contaltphone, contfax, contemail,
8712 contnotes, id, 1, 1, 1, 1 FROM aqbooksellers;");
8713 $dbh->do("ALTER TABLE aqbooksellers DROP COLUMN contact,
8714 DROP COLUMN contpos, DROP COLUMN contphone,
8715 DROP COLUMN contaltphone, DROP COLUMN contfax,
8716 DROP COLUMN contemail, DROP COLUMN contnotes;");
8717 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contact>>', '<<aqcontacts.name>>')");
8718 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contpos>>', '<<aqcontacts.position>>')");
8719 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contphone>>', '<<aqcontacts.phone>>')");
8720 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contaltphone>>', '<<aqcontacts.altphone>>')");
8721 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contfax>>', '<<aqcontacts.contfax>>')");
8722 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contemail>>', '<<aqcontacts.contemail>>')");
8723 $dbh->do("UPDATE letter SET content = replace(content, '<<aqbooksellers.contnotes>>', '<<aqcontacts.contnotes>>')");
8724 print "Upgrade to $DBversion done (Bug 10402: Move bookseller contacts to separate table)\n";
8725 SetVersion($DBversion);
8728 $DBversion = "3.17.00.017";
8729 if ( CheckVersion($DBversion) ) {
8730 # Correct invalid recordtypes (should be very exceptional)
8731 $dbh->do(q{
8732 UPDATE z3950servers set recordtype='biblio' WHERE recordtype NOT IN ('authority','biblio')
8734 # Correct invalid server types (should also be very exceptional)
8735 $dbh->do(q{
8736 UPDATE z3950servers set type='zed' WHERE type <> 'zed'
8738 # Adjust table
8739 $dbh->do(q{
8740 ALTER TABLE z3950servers
8741 DROP COLUMN icon,
8742 DROP COLUMN description,
8743 DROP COLUMN position,
8744 MODIFY COLUMN id int NOT NULL AUTO_INCREMENT FIRST,
8745 MODIFY COLUMN recordtype enum('authority','biblio') NOT NULL DEFAULT 'biblio',
8746 CHANGE COLUMN name servername mediumtext NOT NULL,
8747 CHANGE COLUMN type servertype enum('zed','sru') NOT NULL DEFAULT 'zed',
8748 ADD COLUMN sru_options varchar(255) default NULL,
8749 ADD COLUMN sru_fields mediumtext default NULL,
8750 ADD COLUMN add_xslt mediumtext default NULL
8752 print "Upgrade to $DBversion done (Bug 6536: Z3950 improvements)\n";
8753 SetVersion ($DBversion);
8756 $DBversion = "3.17.00.018";
8757 if ( CheckVersion($DBversion) ) {
8758 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('HoldsInNoissuesCharge', '0', 'Hold charges block checkouts (added to noissuescharge).',NULL,'YesNo');");
8759 print "Upgrade to $DBversion done (Bug 12205: Add HoldsInNoissuesCharge systempreference)\n";
8760 SetVersion($DBversion);
8763 $DBversion = "3.17.00.019";
8764 if ( CheckVersion($DBversion) ) {
8765 $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')"
8767 print "Upgrade to $DBversion done (Bug 6149: Operator highlighted in search results)\n";
8768 SetVersion($DBversion);
8771 $DBversion = "3.17.00.020";
8772 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) {
8773 $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')");
8774 print "Upgrade to $DBversion done (Bug 8735 - Expire holds waiting only on days the library is open)\n";
8775 SetVersion ($DBversion);
8778 $DBversion = "3.17.00.021";
8779 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
8780 my $pref = C4::Context->preference('HomeOrHoldingBranch');
8781 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
8782 VALUES ('StaffSearchResultsDisplayBranch', ?,'homebranch|holdingbranch','Controls the display of the home or holding branch for staff search results','choice')", undef, $pref);
8783 print "Upgrade to $DBversion done (Bug 12582 - Control of branch displayed in search results linked to HomeOrHoldingBranch)\n";
8784 SetVersion ($DBversion);
8787 $DBversion = '3.17.00.022';
8788 if ( CheckVersion($DBversion) ) {
8789 my @temp= $dbh->selectrow_array(qq|
8790 SELECT count(*)
8791 FROM marc_subfield_structure
8792 WHERE kohafield='permanent_location' OR kohafield='items.permanent_location'
8794 print "Upgrade to $DBversion done (Bug 7817: Check for permanent_location)\n";
8795 if( $temp[0] ) {
8796 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";
8798 SetVersion($DBversion);
8801 $DBversion = "3.17.00.023";
8802 if ( CheckVersion($DBversion) ) {
8803 $dbh->do(q{
8804 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')
8806 print "Upgrade to $DBversion done (Bug 11169 - Add AcqItemSetSubfieldsWhenReceiptIsCancelled syspref)\n";
8807 SetVersion($DBversion);
8810 $DBversion = "3.17.00.024";
8811 if(CheckVersion($DBversion)) {
8812 $dbh->do(q{
8813 ALTER TABLE issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8815 $dbh->do(q{
8816 ALTER TABLE old_issues ADD auto_renew BOOLEAN default FALSE AFTER renewals
8818 $dbh->do(q{
8819 ALTER TABLE issuingrules ADD auto_renew BOOLEAN default FALSE AFTER norenewalbefore
8821 print "Upgrade to $DBversion done (Bug 11577: [ENH] Automatic renewal feature)\n";
8822 SetVersion($DBversion);
8825 $DBversion = '3.17.00.025';
8826 if ( CheckVersion($DBversion) ) {
8827 $dbh->do(qq{
8828 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')
8830 print "Upgrade to $DBversion done (Bug 12728: Checked syspref StatisticsFields)\n";
8833 $DBversion = "3.17.00.026";
8834 if ( CheckVersion($DBversion) ) {
8835 if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
8836 $dbh->do("UPDATE marc_subfield_structure SET liblibrarian = 'Encoded bitrate', libopac = 'Encoded bitrate' WHERE tagfield = '347' AND tagsubfield = 'f'");
8837 $dbh->do("UPDATE marc_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','610','611','710','711','810','811') AND tagsubfield = 'c'");
8838 $dbh->do("UPDATE auth_subfield_structure SET repeatable = 1 WHERE tagfield IN ('110','111','410','411','510','511','710','711') AND tagsubfield = 'c'");
8839 print "Upgrade to $DBversion done (Bug 12435 - Update MARC21 frameworks to Update No. 18 (April 2014))\n";
8841 SetVersion($DBversion);
8844 $DBversion = "3.17.00.027";
8845 if ( CheckVersion($DBversion) ) {
8846 $dbh->do(q{
8847 DELETE FROM systempreferences WHERE variable = 'SearchEngine'
8849 print "Upgrade to $DBversion done (Bug 12538 - Remove SearchEngine syspref)\n";
8850 SetVersion($DBversion);
8853 $DBversion = "3.17.00.028";
8854 if ( CheckVersion($DBversion) ) {
8855 $dbh->do(q{
8856 INSERT INTO systempreferences (variable,value) VALUES('OpacCustomSearch','');
8858 print "Upgrade to $DBversion done (Bug 12296 - search box replaceable with a system preference)\n";
8859 SetVersion($DBversion);
8862 $DBversion = "3.17.00.029";
8863 if ( CheckVersion($DBversion) ) {
8864 $dbh->do("ALTER TABLE `items` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8865 $dbh->do("ALTER TABLE `deleteditems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8866 $dbh->do("ALTER TABLE `biblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8867 $dbh->do("ALTER TABLE `deletedbiblioitems` CHANGE `cn_sort` `cn_sort` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
8868 print "Upgrade to $DBversion done (Bug 12424 - ddc sorting of call numbers truncates long Cutter parts)\n";
8869 SetVersion ($DBversion);
8872 $DBversion = "3.17.00.030";
8873 if ( CheckVersion($DBversion) ) {
8874 $dbh->do(
8876 INSERT INTO systempreferences (variable, value, options, explanation, type )
8877 VALUES
8878 ('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'YesNo'),
8879 ('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8880 ('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
8881 ('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
8882 ('UsageStatsLibraryType', 'public', 'public|university', 'The library type to be shown on the Hea Koha community website', 'Choice'),
8883 ('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
8884 ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo')
8886 print "Upgrade to $DBversion done (Bug 11926: Add UsageStats systempreferences (HEA))\n";
8887 SetVersion ($DBversion);
8890 $DBversion = "3.17.00.031";
8891 if ( CheckVersion($DBversion) ) {
8892 $dbh->do("ALTER TABLE saved_sql CHANGE report_name report_name VARCHAR( 255 ) NOT NULL DEFAULT '' ");
8893 print "Upgrade to $DBversion done (Bug 2969: Report Name should be mandatory for saved reports)\n";
8894 SetVersion ($DBversion);
8897 $DBversion = "3.17.00.032";
8898 if ( CheckVersion($DBversion) ) {
8899 $dbh->do(
8900 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReplytoDefault', '', NULL, 'The default email address to be set as replyto.', 'Free')"
8902 $dbh->do(
8903 "INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReturnpathDefault', '', NULL, 'The default email address to be set as return-path', 'Free')"
8905 $dbh->do("ALTER TABLE branches ADD branchreplyto mediumtext AFTER branchemail");
8906 $dbh->do("ALTER TABLE branches ADD branchreturnpath mediumtext AFTER branchreplyto");
8907 print "Upgrade to $DBversion done (Bug 9530: Adding replyto and returnpath addresses.)\n";
8908 SetVersion($DBversion);
8911 $DBversion = "3.17.00.033";
8912 if ( CheckVersion($DBversion) ) {
8913 $dbh->do(q{
8914 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
8915 VALUES('FacetMaxCount', '20','Specify the max facet count for each category',NULL,'Integer')
8917 print "Upgrade to $DBversion done (Bug 13088 - Allow the user to specify a max amount of facets to show)\n";
8918 SetVersion($DBversion);
8921 $DBversion = "3.17.00.034";
8922 if ( CheckVersion($DBversion) ) {
8923 $dbh->do(q|
8924 ALTER TABLE aqorders DROP COLUMN cancelledby;
8927 print "Upgrade to $DBversion done (Bug 11007 - DROP column aqorders.cancelledby)\n";
8928 SetVersion($DBversion);
8931 $DBversion = "3.17.00.035";
8932 if ( CheckVersion($DBversion) ) {
8933 $dbh->do(q|
8934 ALTER TABLE serial ADD COLUMN claims_count INT(11) DEFAULT 0 after claimdate
8936 $dbh->do(q|
8937 UPDATE serial
8938 SET claims_count = 1
8939 WHERE claimdate IS NOT NULL
8941 print "Upgrade to $DBversion done (Bug 5342: Add claims_count field in serial table)\n";
8942 SetVersion($DBversion);
8945 $DBversion = "3.17.00.036";
8946 if ( CheckVersion($DBversion) ) {
8947 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacShowLibrariesPulldownMobile'");
8948 print "Upgrade to $DBversion done ( Bug 12513 - PROG/CCSR deprecation: Remove OpacShowLibrariesPulldownMobile system preference )\n";
8949 SetVersion ($DBversion);
8952 $DBversion = "3.17.00.037";
8953 if ( CheckVersion($DBversion) ) {
8954 $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlockMobile'");
8955 print "Upgrade to $DBversion done ( Bug 12246 - PROG/CCSR deprecation: Remove OpacMainUserBlockMobile system preference )\n";
8956 SetVersion ($DBversion);
8959 $DBversion = "3.17.00.038";
8960 if ( CheckVersion($DBversion) ) {
8961 $dbh->do("DELETE FROM systempreferences WHERE variable='OPACMobileUserCSS'");
8962 print "Upgrade to $DBversion done ( Bug 12245 - PROG/CCSR deprecation: Remove OPACMobileUserCSS system preference )\n";
8963 SetVersion ($DBversion);
8966 $DBversion = "3.17.00.039";
8967 if ( CheckVersion($DBversion) ) {
8968 $dbh->do("INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
8969 ('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes')");
8970 print "Upgrade to $DBversion done (Bug 12539 - PROG/CCSR deprecation: Remove hardcoded theme from C4/Templates.pm)\n";
8971 SetVersion ($DBversion);
8974 $DBversion = "3.17.00.040";
8975 if ( CheckVersion($DBversion) ) {
8976 my $opac_theme = C4::Context->preference( 'opacthemes' );
8977 if ( !defined $opac_theme || $opac_theme eq 'prog' || $opac_theme eq 'ccsr' ) {
8978 $dbh->do("UPDATE systempreferences SET value='bootstrap' WHERE variable='opacthemes'");
8980 print "Upgrade to $DBversion done (Bug 12223: 'prog' and 'ccsr' themes removed)\n";
8981 SetVersion($DBversion);
8984 $DBversion = "3.17.00.041";
8985 if ( CheckVersion($DBversion) ) {
8986 print "Upgrade to $DBversion done (Bug 11346: Deprecate the 'prog' and 'CCSR' themes)\n";
8987 SetVersion($DBversion);
8990 $DBversion = "3.17.00.042";
8991 if ( CheckVersion($DBversion) ) {
8992 $dbh->do("DELETE FROM systempreferences WHERE variable='yuipath'");
8993 print "Upgrade to $DBversion done (Bug 12494: Remove yuipath system preference)\n";
8994 SetVersion ($DBversion);
8997 $DBversion = "3.17.00.043";
8998 if ( CheckVersion($DBversion) ) {
8999 $dbh->do("
9000 ALTER TABLE aqorders
9001 ADD COLUMN cancellationreason TEXT DEFAULT NULL AFTER datecancellationprinted
9003 print "Upgrade to $DBversion done (Bug 7162: Add aqorders.cancellationreason)\n";
9004 SetVersion ($DBversion);
9007 $DBversion = "3.17.00.044";
9008 if ( CheckVersion($DBversion) ) {
9009 $dbh->do(q{
9010 INSERT IGNORE INTO systempreferences
9011 (variable,value,explanation,options,type)
9012 VALUES('OnSiteCheckouts','0','Enable/Disable the on-site checkouts feature','','YesNo');
9014 $dbh->do(q{
9015 INSERT IGNORE INTO systempreferences
9016 (variable,value,explanation,options,type)
9017 VALUES('OnSiteCheckoutsForce','0','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','','YesNo');
9019 $dbh->do(q{
9020 ALTER TABLE issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9022 $dbh->do(q{
9023 ALTER TABLE old_issues ADD COLUMN onsite_checkout INT(1) NOT NULL DEFAULT 0 AFTER issuedate;
9025 print "Upgrade to $DBversion done (Bug 10860: Add new system preference OnSiteCheckouts + fields [old_]issues.onsite_checkout)\n";
9026 SetVersion($DBversion);
9029 $DBversion = "3.17.00.045";
9030 if ( CheckVersion($DBversion) ) {
9031 $dbh->do(q{
9032 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9033 ('LocalHoldsPriority', '0', NULL, 'Enables the LocalHoldsPriority feature', 'YesNo'),
9034 ('LocalHoldsPriorityItemControl', 'holdingbranch', 'holdingbranch|homebranch', 'decides if the feature operates using the item''s home or holding library.', 'Choice'),
9035 ('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')
9037 print "Upgrade to $DBversion done (Bug 11126 - Make the holds system optionally give precedence to local holds)\n";
9038 SetVersion($DBversion);
9041 $DBversion = "3.17.00.046";
9042 if ( CheckVersion($DBversion) ) {
9043 $dbh->do(q{
9044 CREATE TABLE IF NOT EXISTS items_search_fields (
9045 name VARCHAR(255) NOT NULL,
9046 label VARCHAR(255) NOT NULL,
9047 tagfield CHAR(3) NOT NULL,
9048 tagsubfield CHAR(1) NULL DEFAULT NULL,
9049 authorised_values_category VARCHAR(16) NULL DEFAULT NULL,
9050 PRIMARY KEY(name),
9051 CONSTRAINT items_search_fields_authorised_values_category
9052 FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
9053 ON DELETE SET NULL ON UPDATE CASCADE
9054 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
9056 print "Upgrade to $DBversion done (Bug 11425: Add items_search_fields table)\n";
9057 SetVersion($DBversion);
9060 $DBversion = "3.17.00.047";
9061 if ( CheckVersion($DBversion) ) {
9062 $dbh->do(q{
9063 ALTER TABLE collections
9064 CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL,
9065 ADD INDEX ( colBranchcode ),
9066 ADD CONSTRAINT collections_ibfk_1 FOREIGN KEY (colBranchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
9068 print "Upgrade to $DBversion done (Bug 8836 - Resurrect Rotating Collections)\n";
9069 SetVersion($DBversion);
9072 $DBversion = "3.17.00.048";
9073 if ( CheckVersion($DBversion) ) {
9074 $dbh->do(q|
9075 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')
9077 print "Upgrade to $DBversion done (Bug 12448 - Add RentalFeesCheckoutConfirmation syspref)\n";
9078 SetVersion($DBversion);
9081 $DBversion = "3.17.00.049";
9082 if ( CheckVersion($DBversion) ) {
9083 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'am', 'language', 'Amharic','2014-10-29')");
9084 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'am','amh')");
9085 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'am', 'አማርኛ')");
9086 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'am', 'language', 'en', 'Amharic')");
9088 $dbh->do("UPDATE language_descriptions SET description = 'لعربية' WHERE subtag = 'ar' AND type = 'language' AND lang = 'ar'");
9090 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'az', 'language', 'Azerbaijani','2014-10-30')");
9091 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'az','aze')");
9092 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'az', 'Azərbaycan dili')");
9093 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'az', 'language', 'en', 'Azerbaijani')");
9095 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'be', 'language', 'Byelorussian','2014-10-30')");
9096 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'be','bel')");
9097 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'be', 'Беларуская мова')");
9098 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'be', 'language', 'en', 'Byelorussian')");
9100 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'bn', 'language', 'Bengali','2014-10-30')");
9101 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'bn','ben')");
9102 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'bn', 'বাংলা')");
9103 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'bn', 'language', 'en', 'Bengali')");
9105 $dbh->do("UPDATE language_descriptions SET description = 'Български' WHERE subtag = 'bg' AND type = 'language' AND lang = 'bg'");
9106 $dbh->do("UPDATE language_descriptions SET description = 'Ceština' WHERE subtag = 'cs' AND type = 'language' AND lang = 'cs'");
9107 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικά' WHERE subtag = 'el' AND type = 'language' AND lang = 'el'");
9108 $dbh->do("UPDATE language_descriptions SET description = 'Español' WHERE subtag = 'es' AND type = 'language' AND lang = 'es'");
9110 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'eu', 'language', 'Basque','2014-10-30')");
9111 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'eu','eus')");
9112 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'eu', 'Euskera')");
9113 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'eu', 'language', 'en', 'Basque')");
9115 $dbh->do("UPDATE language_descriptions SET description = 'فارسى' WHERE subtag = 'fa' AND type = 'language' AND lang = 'fa'");
9116 $dbh->do("UPDATE language_descriptions SET description = 'Suomi' WHERE subtag = 'fi' AND type = 'language' AND lang = 'fi'");
9118 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'fo', 'language', 'Faroese','2014-10-30')");
9119 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'fo','fao')");
9120 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'fo', 'Føroyskt')");
9121 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'fo', 'language', 'en', 'Faroese')");
9123 $dbh->do("UPDATE language_descriptions SET description = 'Français' WHERE subtag = 'fr' AND type = 'language' AND lang = 'fr'");
9124 $dbh->do("UPDATE language_descriptions SET description = 'עִבְרִית' WHERE subtag = 'he' AND type = 'language' AND lang = 'he'");
9125 $dbh->do("UPDATE language_descriptions SET description = 'हिन्दी' WHERE subtag = 'hi' AND type = 'language' AND lang = 'hi'");
9127 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'is', 'language', 'Icelandic','2014-10-30')");
9128 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'is','ice')");
9129 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'is', 'Íslenska')");
9130 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'is', 'language', 'en', 'Icelandic')");
9132 $dbh->do("UPDATE language_descriptions SET description = '日本語' WHERE subtag = 'ja' AND type = 'language' AND lang = 'ja'");
9134 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Kannada','2014-10-30')");
9135 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka','kan')");
9136 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ಕನ್ನಡ')");
9137 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Kannada')");
9139 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'km', 'language', 'Khmer','2014-10-30')");
9140 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'km','khm')");
9141 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'km', 'language', 'km', 'ភាសាខ្មែរ')");
9142 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'km', 'language', 'en', 'Khmer')");
9144 $dbh->do("UPDATE language_descriptions SET description = '한국어' WHERE subtag = 'ko' AND type = 'language' AND lang = 'ko'");
9146 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ku', 'language', 'Kurdish','2014-05-13')");
9147 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ku','kur')");
9148 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'ku', 'کوردی')");
9149 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'en', 'Kurdish')");
9150 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'fr', 'Kurde')");
9151 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'de', 'Kurdisch')");
9152 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ku', 'language', 'es', 'Kurdo')");
9154 $dbh->do("UPDATE language_descriptions SET description = 'ພາສາລາວ' WHERE subtag = 'lo' AND type = 'language' AND lang = 'lo'");
9156 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mi', 'language', 'Maori','2014-10-30')");
9157 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mi','mri')");
9158 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'mi', 'Te Reo Māori')");
9159 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mi', 'language', 'en', 'Maori')");
9161 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mn', 'language', 'Mongolian','2014-10-30')");
9162 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mn','mon')");
9163 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'mn', 'Mонгол')");
9164 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mn', 'language', 'en', 'Mongolian')");
9166 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'mr', 'language', 'Marathi','2014-10-30')");
9167 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'mr','mar')");
9168 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'mr', 'मराठी')");
9169 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'mr', 'language', 'en', 'Marathi')");
9171 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ms', 'language', 'Malay','2014-10-30')");
9172 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ms','may')");
9173 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'ms', 'Bahasa melayu')");
9174 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ms', 'language', 'en', 'Malay')");
9176 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'nb'");
9177 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'en'");
9178 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'fr'");
9179 $dbh->do("UPDATE language_descriptions SET description = 'Norwegisch bokmål' WHERE subtag = 'nb' AND type = 'language' AND lang = 'de'");
9181 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ne', 'language', 'Nepali','2014-10-30')");
9182 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ne','nep')");
9183 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)VALUES ( 'ne', 'language', 'ne', 'नेपाली')");
9184 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ne', 'language', 'en', 'Nepali')");
9186 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'pbr', 'language', 'Pangwa','2014-10-30')");
9187 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'pbr','pbr')");
9188 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'pbr', 'Ekipangwa')");
9189 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'pbr', 'language', 'en', 'Pangwa')");
9191 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'prs', 'language', 'Dari','2014-10-30')");
9192 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'prs','prs')");
9193 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'prs', 'درى')");
9194 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'prs', 'language', 'en', 'Dari')");
9196 $dbh->do("UPDATE language_descriptions SET description = 'Português' WHERE subtag = 'pt' AND type = 'language' AND lang = 'pt'");
9197 $dbh->do("UPDATE language_descriptions SET description = 'Român' WHERE subtag = 'ro' AND type = 'language' AND lang = 'ro'");
9198 $dbh->do("UPDATE language_descriptions SET description = 'Русский' WHERE subtag = 'ru' AND type = 'language' AND lang = 'ru'");
9200 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'rw', 'language', 'Kinyarwanda','2014-10-30')");
9201 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'rw','kin')");
9202 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'rw', 'Ikinyarwanda')");
9203 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'rw', 'language', 'en', 'Kinyarwanda')");
9205 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sd', 'language', 'Sindhi','2014-10-30')");
9206 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sd','snd')");
9207 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'sd', 'سنڌي')");
9208 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sd', 'language', 'en', 'Sindhi')");
9210 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sk', 'language', 'Slovak','2014-10-30')");
9211 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sk','slk')");
9212 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'sk', 'Slovenčina')");
9213 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sk', 'language', 'en', 'Slovak')");
9215 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sl', 'language', 'Slovene','2014-10-30')");
9216 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sl','slv')");
9217 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'sl', 'Slovenščina')");
9218 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sl', 'language', 'en', 'Slovene')");
9220 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sq', 'language', 'Albanian','2014-10-30')");
9221 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sq','sqi')");
9222 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'sq', 'Shqip')");
9223 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sq', 'language', 'en', 'Albanian')");
9225 $dbh->do("UPDATE language_descriptions SET description = 'Cрпски' WHERE subtag = 'sr' AND type = 'language' AND lang = 'sr'");
9227 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'sw', 'language', 'Swahili','2014-10-30')");
9228 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'sw','swa')");
9229 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'sw', 'Kiswahili')");
9230 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'sw', 'language', 'en', 'Swahili')");
9232 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ta', 'language', 'Tamil','2014-10-30')");
9233 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ta','tam')");
9234 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'ta', 'தமிழ்')");
9235 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ta', 'language', 'en', 'Tamil')");
9237 $dbh->do("UPDATE language_descriptions SET description = 'Tetun' WHERE subtag = 'tet' AND type = 'language' AND lang = 'tet'");
9238 $dbh->do("UPDATE language_descriptions SET description = 'ภาษาไทย' WHERE subtag = 'th' AND type = 'language' AND lang = 'th'");
9240 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'tl', 'language', 'Tagalog','2014-10-30')");
9241 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'tl','tgl')");
9242 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'tl', 'Tagalog')");
9243 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'tl', 'language', 'en', 'Tagalog')");
9245 $dbh->do("UPDATE language_descriptions SET description = 'Türkçe' WHERE subtag = 'tr' AND type = 'language' AND lang = 'tr'");
9246 $dbh->do("UPDATE language_descriptions SET description = 'Українська' WHERE subtag = 'uk' AND type = 'language' AND lang = 'uk'");
9247 $dbh->do("UPDATE language_descriptions SET description = 'اردو' WHERE subtag = 'ur' AND type = 'language' AND lang = 'ur'");
9249 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'vi', 'language', 'Vietnamese','2014-10-30')");
9250 $dbh->do("INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'vi','vie')");
9251 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'vi', '㗂越')");
9252 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'vi', 'language', 'en', 'Vietnamese')");
9254 $dbh->do("UPDATE language_descriptions SET description = '中文' WHERE subtag = 'zh' AND type = 'language' AND lang = 'zh'");
9255 $dbh->do("UPDATE language_descriptions SET description = '' WHERE subtag = 'Arab,script' AND type = 'Arab' AND lang = 'العربية'");
9257 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Armn', 'script', 'Armenian','2014-10-30')");
9258 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Armn', 'script', 'Armn', 'Հայոց այբուբեն')");
9259 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Armn', 'script', 'en', 'Armenian')");
9261 $dbh->do("UPDATE language_descriptions SET description = 'Кирилица' WHERE subtag = 'Cyrl' AND type = 'script' AND lang = 'Cyrl'");
9263 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Ethi', 'script', 'Ethiopic','2014-10-30')");
9264 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Ethi', 'script', 'Ethi', 'ግዕዝ')");
9265 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Ethi', 'script', 'en', 'Ethiopic')");
9267 $dbh->do("UPDATE language_descriptions SET description = 'Ελληνικό αλφάβητο' WHERE subtag = 'Grek' AND type = 'script' AND lang = 'Grek'");
9268 $dbh->do("UPDATE language_descriptions SET description = '简体字' WHERE subtag = 'Hans' AND type = 'script' AND lang = 'Hans'");
9269 $dbh->do("UPDATE language_descriptions SET description = '繁體字' WHERE subtag = 'Hant' AND type = 'script' AND lang = 'Hant'");
9270 $dbh->do("UPDATE language_descriptions SET description = 'אָלֶף־בֵּית עִבְרִי' WHERE subtag = 'Hebr' AND type = 'script' AND lang = 'Hebr'");
9272 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Jpan', 'script', 'Japanese','2014-10-30')");
9273 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Jpan', 'script', 'Jpan', '漢字')");
9274 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Jpan', 'script', 'en', 'Japanese')");
9276 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Knda', 'script', 'Kannada','2014-10-30')");
9277 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Knda', 'script', 'Knda', 'ಕನ್ನಡ ಲಿಪಿ')");
9278 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Knda', 'script', 'en', 'Kannada')");
9280 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'Kore', 'script', 'Korean','2014-10-30')");
9281 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'Kore', 'script', 'Kore', '한글')");
9282 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES( 'Kore', 'script', 'en', 'Korean')");
9284 $dbh->do("UPDATE language_descriptions SET description = 'ອັກສອນລາວ' WHERE subtag = 'Laoo' AND type = 'script' AND lang = 'Laoo'");
9286 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AL', 'region', 'Albania','2014-10-30')");
9287 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'en', 'Albania')");
9288 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AL', 'region', 'sq', 'Shqipërisë')");
9290 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'AZ', 'region', 'Azerbaijan','2014-10-30')");
9291 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'en', 'Azerbaijan')");
9292 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'AZ', 'region', 'az', 'Azərbaycan')");
9294 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BE', 'region', 'Belgium','2014-10-30')");
9295 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'en', 'Belgium')");
9296 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BE', 'region', 'nl', 'België')");
9298 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BR', 'region', 'Brazil','2014-10-30')");
9299 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'en', 'Brazil')");
9300 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BR', 'region', 'pt', 'Brasil')");
9302 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'BY', 'region', 'Belarus','2014-10-30')");
9303 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'en', 'Belarus')");
9304 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'BY', 'region', 'be', 'Беларусь')");
9306 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CA', 'region', 'fr', 'Canada')");
9308 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CH', 'region', 'Switzerland','2014-10-30')");
9309 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'en', 'Switzerland')");
9310 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CH', 'region', 'de', 'Schweiz')");
9312 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CN', 'region', 'China','2014-10-30')");
9313 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'en', 'China')");
9314 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CN', 'region', 'zh', '中国')");
9316 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'CZ', 'region', 'Czech Republic','2014-10-30')");
9317 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'en', 'Czech Republic')");
9318 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'CZ', 'region', 'cs', 'Česká republika')");
9320 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'DE', 'region', 'Germany','2014-10-30')");
9321 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'en', 'Germany')");
9322 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DE', 'region', 'de', 'Deutschland')");
9324 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'DK', 'region', 'en', 'Denmark')");
9326 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ES', 'region', 'Spain','2014-10-30')");
9327 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'en', 'Spain')");
9328 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ES', 'region', 'es', 'España')");
9330 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FI', 'region', 'Finland','2014-10-30')");
9331 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'en', 'Finland')");
9332 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FI', 'region', 'fi', 'Suomi')");
9334 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'FO', 'region', 'Faroe Islands','2014-10-30')");
9335 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'en', 'Faroe Islands')");
9336 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'FO', 'region', 'fo', 'Føroyar')");
9338 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'GR', 'region', 'Greece','2014-10-30')");
9339 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'en', 'Greece')");
9340 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'GR', 'region', 'el', 'Ελλάδα')");
9342 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HR', 'region', 'Croatia','2014-10-30')");
9343 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'en', 'Croatia')");
9344 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HR', 'region', 'hr', 'Hrvatska')");
9346 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'HU', 'region', 'Hungary','2014-10-30')");
9347 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'en', 'Hungary')");
9348 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'HU', 'region', 'hu', 'Magyarország')");
9350 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ID', 'region', 'Indonesia','2014-10-30')");
9351 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'en', 'Indonesia')");
9352 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ID', 'region', 'id', 'Indonesia')");
9354 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IS', 'region', 'Iceland','2014-10-30')");
9355 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'en', 'Iceland')");
9356 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IS', 'region', 'is', 'Ísland')");
9358 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'IT', 'region', 'Italy','2014-10-30')");
9359 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'en', 'Italy')");
9360 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'IT', 'region', 'it', 'Italia')");
9362 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'JP', 'region', 'Japan','2014-10-30')");
9363 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'en', 'Japan')");
9364 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'JP', 'region', 'ja', '日本')");
9366 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KE', 'region', 'Kenya','2014-10-30')");
9367 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'en', 'Kenya')");
9368 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KE', 'region', 'rw', 'Kenya')");
9370 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KH', 'region', 'Cambodia','2014-10-30')");
9371 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'en', 'Cambodia')");
9372 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KH', 'region', 'km', 'កម្ពុជា')");
9374 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'KP', 'region', 'North Korea','2014-10-30')");
9375 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'en', 'North Korea')");
9376 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'KP', 'region', 'ko', '조선민주주의인민공화국')");
9378 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'LK', 'region', 'Sri Lanka','2014-10-30')");
9379 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'en', 'Sri Lanka')");
9380 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'LK', 'region', 'ta', 'இலங்கை')");
9382 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'MY', 'region', 'Malaysia','2014-10-30')");
9383 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'en', 'Malaysia')");
9384 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'MY', 'region', 'ms', 'Malaysia')");
9386 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NE', 'region', 'Niger','2014-10-30')");
9387 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'en', 'Niger')");
9388 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NE', 'region', 'ne', 'Niger')");
9390 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NL', 'region', 'Netherlands','2014-10-30')");
9391 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'en', 'Netherlands')");
9392 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NL', 'region', 'nl', 'Nederland')");
9394 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'NO', 'region', 'Norway','2014-10-30')");
9395 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'en', 'Norway')");
9396 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'ne', 'Noreg')");
9397 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'NO', 'region', 'nn', 'Noreg')");
9399 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PH', 'region', 'Philippines','2014-10-30')");
9400 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'en', 'Philippines')");
9401 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PH', 'region', 'tl', 'Pilipinas')");
9403 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PK', 'region', 'Pakistan','2014-10-30')");
9404 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'en', 'Pakistan')");
9405 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PK', 'region', 'sd', 'پاكستان')");
9407 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PL', 'region', 'Poland','2014-10-30')");
9408 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'en', 'Poland')");
9409 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PL', 'region', 'pl', 'Polska')");
9411 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'PT', 'region', 'Portugal','2014-10-30')");
9412 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'en', 'Portugal')");
9413 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'PT', 'region', 'pt', 'Portugal')");
9415 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RO', 'region', 'Romania','2014-10-30')");
9416 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'en', 'Romania')");
9417 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RO', 'region', 'ro', 'România')");
9419 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RU', 'region', 'Russia','2014-10-30')");
9420 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'en', 'Russia')");
9421 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RU', 'region', 'ru', 'Россия')");
9423 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'RW', 'region', 'Rwanda','2014-10-30')");
9424 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'en', 'Rwanda')");
9425 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'RW', 'region', 'rw', 'Rwanda')");
9427 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SE', 'region', 'Sweden','2014-10-30')");
9428 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'en', 'Sweden')");
9429 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SE', 'region', 'sv', 'Sverige')");
9431 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SI', 'region', 'Slovenia','2014-10-30')");
9432 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'en', 'Slovenia')");
9433 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SI', 'region', 'sl', 'Slovenija')");
9435 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'SK', 'region', 'Slovakia','2014-10-30')");
9436 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'en', 'Slovakia')");
9437 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'SK', 'region', 'sk', 'Slovensko')");
9439 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TH', 'region', 'Thailand','2014-10-30')");
9440 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'en', 'Thailand')");
9441 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TH', 'region', 'th', 'ประเทศไทย')");
9443 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TR', 'region', 'Turkey','2014-10-30')");
9444 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'en', 'Turkey')");
9445 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TR', 'region', 'tr', 'Türkiye')");
9447 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'TW', 'region', 'Taiwan','2014-10-30')");
9448 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'en', 'Taiwan')");
9449 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'TW', 'region', 'zh', '台灣')");
9451 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'UA', 'region', 'Ukraine','2014-10-30')");
9452 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'en', 'Ukraine')");
9453 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'UA', 'region', 'uk', 'Україна')");
9455 $dbh->do("INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'VN', 'region', 'Vietnam','2014-10-30')");
9456 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'en', 'Vietnam')");
9457 $dbh->do("INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'VN', 'region', 'vi', 'Việt Nam')");
9459 print "Upgrade to $DBversion done (Bug 12250: Update descriptions for languages, scripts and regions)\n";
9460 SetVersion($DBversion);
9463 $DBversion = "3.17.00.050";
9464 if ( CheckVersion($DBversion) ) {
9465 $dbh->do(q|
9466 INSERT INTO permissions (module_bit, code, description) VALUES
9467 (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)')
9469 print "Upgrade to $DBversion done (Bug 12403: Add permission tools_records_batchdelitem)\n";
9470 SetVersion($DBversion);
9473 $DBversion = "3.17.00.051";
9474 if ( CheckVersion($DBversion) ) {
9475 $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('GoogleIndicTransliteration','0','','GoogleIndicTransliteration on the OPAC.','YesNo')");
9476 print "Upgrade to $DBversion done (Bug 13211: Added system preferences GoogleIndicTransliteration on the OPAC)\n";
9477 SetVersion($DBversion);
9480 $DBversion = "3.17.00.052";
9481 if ( CheckVersion($DBversion) ) {
9482 $dbh->do(q{
9483 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');
9486 $dbh->do(q{
9487 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');
9489 print "Upgrade to $DBversion done (Bug 9043: Add system preference OpacAdvSearchOptions and OpacAdvSearchMoreOptions)\n";
9490 SetVersion ($DBversion);
9493 $DBversion = "3.17.00.053";
9494 if ( CheckVersion($DBversion) ) {
9495 $dbh->do(q{
9496 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)');
9499 $dbh->do(q{
9500 INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
9503 $dbh->do(q{
9504 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)');
9507 # The delete_all_items permission should be added to users having the edit_items permission.
9508 $dbh->do(q{
9509 INSERT INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, module_bit, "delete_all_items" FROM user_permissions WHERE code="edit_items";
9512 # Add 2 new prefs
9513 $dbh->do(q{
9514 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');
9517 $dbh->do(q{
9518 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');
9521 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";
9522 SetVersion($DBversion);
9525 $DBversion = "3.17.00.054";
9526 if (CheckVersion($DBversion)) {
9527 $dbh->do(q{
9528 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
9529 ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo')
9531 print "Upgrade to $DBversion done (Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds)\n";
9532 SetVersion($DBversion);
9535 $DBversion = "3.17.00.055";
9536 if ( CheckVersion($DBversion) ) {
9537 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEnable', '0', NULL, 'Enable communication with the Norwegian national patron database.', 'YesNo')");
9538 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEndpoint', '', NULL, 'Which NL endpoint to use.', 'Free')");
9539 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBUsername', '', NULL, 'Username for communication with the Norwegian national patron database.', 'Free')");
9540 $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBPassword', '', NULL, 'Password for communication with the Norwegian national patron database.', 'Free')");
9541 $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')");
9542 $dbh->do("
9543 CREATE TABLE borrower_sync (
9544 borrowersyncid int(11) NOT NULL AUTO_INCREMENT,
9545 borrowernumber int(11) NOT NULL,
9546 synctype varchar(32) NOT NULL,
9547 sync tinyint(1) NOT NULL DEFAULT '0',
9548 syncstatus varchar(10) DEFAULT NULL,
9549 lastsync varchar(50) DEFAULT NULL,
9550 hashed_pin varchar(64) DEFAULT NULL,
9551 PRIMARY KEY (borrowersyncid),
9552 KEY borrowernumber (borrowernumber),
9553 CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9554 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
9556 print "Upgrade to $DBversion done (Bug 11401 - Add support for Norwegian national library card)\n";
9557 SetVersion($DBversion);
9560 $DBversion = "3.17.00.056";
9561 if ( CheckVersion($DBversion) ) {
9562 $dbh->do(q{
9563 UPDATE systempreferences SET value = 'pubdate,itemtype,language,sorting,location' WHERE variable='OpacAdvSearchOptions'
9566 $dbh->do(q{
9567 UPDATE systempreferences SET value = 'pubdate,itemtype,language,subtype,sorting,location' WHERE variable='OpacAdvSearchMoreOptions'
9570 print "Upgrade to $DBversion done (Bug 9043 - Update the values for OpacAdvSearchOptions and OpacAdvSearchOptions)\n";
9571 SetVersion($DBversion);
9574 $DBversion = "3.17.00.057";
9575 if ( CheckVersion($DBversion) ) {
9576 print "Upgrade to $DBversion done (Koha 3.18 beta)\n";
9577 SetVersion ($DBversion);
9580 $DBversion = "3.17.00.058";
9581 if( CheckVersion($DBversion) ){
9582 $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')");
9583 $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')");
9584 $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')");
9585 print "Upgrade to $DBversion done (Bug 8337: System preferences for longoverdue cron)\n";
9586 SetVersion($DBversion);
9589 $DBversion = "3.17.00.059";
9590 if ( CheckVersion($DBversion) ) {
9591 $dbh->do(q{
9592 UPDATE permissions SET description = "Add and delete budgets (but can't modifiy budgets)" WHERE description = "Add and delete budgets (but cant modify budgets)";
9594 print "Upgrade to $DBversion done (Bug 10749: Fix typo in budget_add_del permission description)\n";
9595 SetVersion ($DBversion);
9598 $DBversion = "3.17.00.060";
9599 if ( CheckVersion($DBversion) ) {
9600 my $count_l = $dbh->selectcol_arrayref(q|
9601 SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
9603 my $count_mq = $dbh->selectcol_arrayref(q|
9604 SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
9606 my $count_ott = $dbh->selectcol_arrayref(q|
9607 SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
9609 my $count_mt = $dbh->selectcol_arrayref(q|
9610 SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
9612 my $count_bmtp = $dbh->selectcol_arrayref(q|
9613 SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
9616 my $deleted = 0;
9617 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 ) {
9618 $deleted = $dbh->do(q|
9619 DELETE FROM message_transport_types where message_transport_type='feed'
9621 $deleted = $deleted ne '0E0' ? 1 : 0;
9624 print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
9625 SetVersion($DBversion);
9628 $DBversion = "3.18.00.000";
9629 if ( CheckVersion($DBversion) ) {
9630 print "Upgrade to $DBversion done (3.18.0 release)\n";
9631 SetVersion($DBversion);
9634 $DBversion = "3.19.00.000";
9635 if ( CheckVersion($DBversion) ) {
9636 print "Upgrade to $DBversion done (there's life after 3.18)\n";
9637 SetVersion ($DBversion);
9640 $DBversion = "3.19.00.001";
9641 if ( CheckVersion($DBversion) ) {
9642 $dbh->do("
9643 UPDATE systempreferences
9644 SET options = 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription'
9645 WHERE variable = 'UsageStatsLibraryType'
9647 if ( C4::Context->preference("UsageStatsLibraryType") eq "university" ) {
9648 C4::Context->set_preference("UsageStatsLibraryType", "academic")
9650 print "Upgrade to $DBversion done (Bug 13436: Add more options to UsageStatsLibraryType)\n";
9651 SetVersion ($DBversion);
9654 $DBversion = "3.19.00.002";
9655 if ( CheckVersion($DBversion) ) {
9656 $dbh->do(q|
9657 UPDATE suggestions SET branchcode="" WHERE branchcode="__ANY__"
9659 print "upgrade to $DBversion done (Bug 10753: replace __ANY__ with empty string in suggestions.branchcode)\n";
9660 SetVersion ($DBversion);
9663 $DBversion = "3.19.00.003";
9664 if ( CheckVersion($DBversion) ) {
9665 my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1");
9667 if ( $count ) {
9668 print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n";
9669 print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n";
9670 print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)";
9671 } else {
9672 $dbh->do(q{
9673 ALTER TABLE borrowers
9674 DROP INDEX userid ,
9675 ADD UNIQUE userid (userid)
9677 print "Upgrade to $DBversion done (Bug 1861: Unique patrons logins not (totally) enforced)\n";
9679 SetVersion ($DBversion);
9682 $DBversion = "3.19.00.004";
9683 if ( CheckVersion($DBversion) ) {
9684 my $pref_value = C4::Context->preference('OpacExportOptions');
9685 $pref_value =~ s/\|/,/g; # multiple is separated by ,
9686 $dbh->do(q{
9687 UPDATE systempreferences
9688 SET value = ?,
9689 type = 'multiple'
9690 WHERE variable = 'OpacExportOptions'
9691 }, {}, $pref_value );
9692 print "Upgrade to $DBversion done (Bug 13346: OpacExportOptions is now multiple)\n";
9693 SetVersion ($DBversion);
9696 $DBversion = "3.19.00.005";
9697 if(CheckVersion($DBversion)) {
9698 $dbh->do(q{
9699 ALTER TABLE authorised_values MODIFY COLUMN category VARCHAR(32) NOT NULL DEFAULT ''
9702 $dbh->do(q{
9703 ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
9706 print "Upgrade to $DBversion done (Bug 13379: Modify authorised_values.category to varchar(32))\n";
9707 SetVersion($DBversion);
9710 $DBversion = "3.19.00.006";
9711 if ( CheckVersion($DBversion) ) {
9712 $dbh->do(q|SET foreign_key_checks = 0|);
9713 my $sth = $dbh->table_info( '','','','TABLE' );
9714 my ( $cat, $schema, $name, $type, $remarks );
9715 while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
9716 my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
9717 $table_sth->execute;
9718 my @table = $table_sth->fetchrow_array;
9719 unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
9720 if ( $name eq 'marc_subfield_structure' ) {
9721 $dbh->do(q|
9722 ALTER TABLE marc_subfield_structure
9723 MODIFY COLUMN tagfield varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9724 MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '',
9725 MODIFY COLUMN liblibrarian varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9726 MODIFY COLUMN libopac varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9727 MODIFY COLUMN kohafield varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
9728 MODIFY COLUMN authorised_value varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9729 MODIFY COLUMN authtypecode varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9730 MODIFY COLUMN value_builder varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL,
9731 MODIFY COLUMN frameworkcode varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9732 MODIFY COLUMN seealso varchar(1100) COLLATE utf8_unicode_ci DEFAULT NULL,
9733 MODIFY COLUMN link varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL
9736 else {
9737 $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9741 $dbh->do(q|SET foreign_key_checks = 1|);;
9743 print "Upgrade to $DBversion done (Bug 11944: Convert DB tables to utf8_unicode_ci)\n";
9744 SetVersion($DBversion);
9747 $DBversion = "3.19.00.007";
9748 if ( CheckVersion($DBversion) ) {
9749 my $orphan_budgets = $dbh->selectall_arrayref(q|
9750 SELECT budget_id, budget_name, budget_code
9751 FROM aqbudgets
9752 WHERE budget_parent_id IS NOT NULL
9753 AND budget_parent_id NOT IN (
9754 SELECT DISTINCT budget_id FROM aqbudgets
9756 |, { Slice => {} } );
9758 if ( @$orphan_budgets ) {
9759 for my $b ( @$orphan_budgets ) {
9760 print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n";
9762 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n";
9763 } else {
9764 print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n";
9766 SetVersion($DBversion);
9769 $DBversion = "3.19.00.008";
9770 if ( CheckVersion($DBversion) ) {
9771 my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
9772 SELECT COUNT(*)
9773 FROM aqorders o
9774 WHERE NOT EXISTS (
9775 SELECT NULL
9776 FROM aqbudgets b
9777 WHERE b.budget_id = o.budget_id
9781 if ( $number_of_orders_not_linked->[0] > 0 ) {
9782 $dbh->do(q|
9783 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)
9785 my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
9786 $dbh->do(qq|
9787 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 );
9789 my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
9790 $dbh->do(qq|
9791 UPDATE aqorders o
9792 SET budget_id = $budget_id
9793 WHERE NOT EXISTS (
9794 SELECT NULL
9795 FROM aqbudgets b
9796 WHERE b.budget_id = o.budget_id
9801 $dbh->do(q|
9802 ALTER TABLE aqorders
9803 ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
9806 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";
9807 SetVersion($DBversion);
9810 $DBversion = "3.19.00.009";
9811 if ( CheckVersion($DBversion) ) {
9812 $dbh->do(q|
9813 UPDATE suggestions s SET s.budgetid = NULL
9814 WHERE NOT EXISTS (
9815 SELECT NULL
9816 FROM aqbudgets b
9817 WHERE b.budget_id = s.budgetid
9821 $dbh->do(q|
9822 ALTER TABLE suggestions
9823 ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9826 print "Upgrade to $DBversion done (Bug 13007: Add new foreign key suggestions.budgetid)\n";
9827 SetVersion($DBversion);
9830 $DBversion = "3.19.00.010";
9831 if ( CheckVersion($DBversion) ) {
9832 $dbh->do(q|
9833 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
9834 VALUES('SessionRestrictionByIP','1','Check for Change in Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')
9836 print "Upgrade to $DBversion done (Bug 5511: SessionRestrictionByIP)\n";
9837 SetVersion ($DBversion);
9840 $DBversion = "3.19.00.011";
9841 if ( CheckVersion($DBversion) ) {
9842 $dbh->do(q|
9843 INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
9844 (20, 'lists', 'Lists', 0)
9846 $dbh->do(q|
9847 INSERT INTO permissions (module_bit, code, description) VALUES
9848 (20, 'delete_public_lists', 'Delete public lists')
9850 print "Upgrade to $DBversion done (Bug 13417: Add permission to delete public lists)\n";
9851 SetVersion ($DBversion);
9854 $DBversion = "3.19.00.012";
9855 if(CheckVersion($DBversion)) {
9856 $dbh->do(q{
9857 ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext
9860 $dbh->do(q{
9861 ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext
9864 print "Upgrade to $DBversion done (Bug 13523 Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n";
9865 SetVersion ($DBversion);
9868 $DBversion = "3.19.00.013";
9869 if ( CheckVersion($DBversion) ) {
9870 $dbh->do(q|
9871 INSERT INTO permissions (module_bit, code, description) VALUES
9872 (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)')
9874 print "Upgrade to $DBversion done (Bug 11395: Add permission tools_records_batchmod)\n";
9875 SetVersion($DBversion);
9878 $DBversion = "3.19.00.014";
9879 if ( CheckVersion($DBversion) ) {
9880 $dbh->do(q|
9881 CREATE TABLE aqorder_users (
9882 ordernumber int(11) NOT NULL,
9883 borrowernumber int(11) NOT NULL,
9884 PRIMARY KEY (ordernumber, borrowernumber),
9885 CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9886 CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9887 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9890 $dbh->do(q|
9891 INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
9892 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')
9894 print "Upgrade to $DBversion done (Bug 12648: Add letter ACQ_NOTIF_ON_RECEIV )\n";
9895 SetVersion ($DBversion);
9898 $DBversion = "3.19.00.015";
9899 if ( CheckVersion($DBversion) ) {
9900 $dbh->do(q|
9901 ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id);
9903 print "Upgrade to $DBversion done (Bug 11430: Add primary key for search_history)\n";
9904 SetVersion($DBversion);
9907 $DBversion = "3.19.00.016";
9908 if(CheckVersion($DBversion)) {
9909 my @order_cancellation_reason = $dbh->selectrow_array("SELECT count(*) FROM authorised_values WHERE category='ORDER_CANCELLATION_REASON'");
9910 if ($order_cancellation_reason[0] == 0) {
9911 $dbh->do(q{
9912 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9913 ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'),
9914 ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'),
9915 ('ORDER_CANCELLATION_REASON', 2, 'Restocking')
9918 my $already_existing_reasons = $dbh->selectcol_arrayref(q{
9919 SELECT DISTINCT( cancellationreason )
9920 FROM aqorders;
9921 }, { Slice => {} });
9923 my $update_orders_sth = $dbh->prepare(q{
9924 UPDATE aqorders
9925 SET cancellationreason = ?
9926 WHERE cancellationreason = ?
9929 my $insert_av_sth = $dbh->prepare(q{
9930 INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9931 ('ORDER_CANCELLATION_REASON', ?, ?)
9933 my $i = 3;
9934 for my $reason ( @$already_existing_reasons ) {
9935 next unless $reason;
9936 $insert_av_sth->execute( $i, $reason );
9937 $update_orders_sth->execute( $i, $reason );
9938 $i++;
9940 print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n";
9942 else {
9943 print "Upgrade to $DBversion done (Bug 13380: ORDER_CANCELLATION_REASON authorised value already existed from earlier update!)\n";
9946 SetVersion($DBversion);
9949 $DBversion = '3.19.00.017';
9950 if ( CheckVersion($DBversion) ) {
9951 # First create the column
9952 $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL");
9953 # Now update the column
9954 if (C4::Context->preference("AllowOnShelfHolds")){
9955 # Pref is on, set allow for all rules
9956 $dbh->do("UPDATE issuingrules SET onshelfholds=1");
9957 } else {
9958 # If the preference is not set, leave off
9959 $dbh->do("UPDATE issuingrules SET onshelfholds=0");
9961 # Remove from the systempreferences table
9962 $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'");
9964 # First create the column
9965 $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL");
9966 # Now update the column
9967 my $opacitemholds = C4::Context->preference("OPACItemHolds") || '';
9968 if (lc ($opacitemholds) eq 'force') {
9969 $opacitemholds = 'F';
9971 else {
9972 $opacitemholds = $opacitemholds ? 'Y' : 'N';
9974 # Set allow for all rules
9975 $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'");
9977 # Remove from the systempreferences table
9978 $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'");
9980 print "Upgrade to $DBversion done (Bug 5786: Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n";
9981 SetVersion ($DBversion);
9985 $DBversion = "3.19.00.018";
9986 if ( CheckVersion($DBversion) ) {
9987 $dbh->do(q|
9988 UPDATE systempreferences set variable="OpacAdditionalStylesheet" WHERE variable="opaccolorstylesheet"
9990 print "Upgrade to $DBversion done (Bug 10328: Rename opaccolorstylesheet to OpacAdditionalStylesheet\n";
9991 SetVersion ($DBversion);
9994 $DBversion = "3.19.00.019";
9995 if ( CheckVersion($DBversion) ) {
9996 $dbh->do(q{
9997 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
9998 VALUES('Coce','0', 'If on, enables cover retrieval from the configured Coce server', NULL, 'YesNo')
10000 $dbh->do(q{
10001 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
10002 VALUES('CoceHost', NULL, 'Coce server URL', NULL,'Free')
10004 $dbh->do(q{
10005 INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
10006 VALUES('CoceProviders', NULL, 'Coce providers', 'aws,gb,ol', 'multiple')
10008 print "Upgrade to $DBversion done (Bug 9580: Cover image from Coce, a remote image URL cache)\n";
10009 SetVersion($DBversion);
10012 $DBversion = "3.19.00.020";
10013 if ( CheckVersion($DBversion) ) {
10014 $dbh->do(q|
10015 ALTER TABLE aqorders DROP COLUMN supplierreference;
10018 print "Upgrade to $DBversion done (Bug 11008: DROP column aqorders.supplierreference)\n";
10019 SetVersion($DBversion);
10022 $DBversion = "3.19.00.021";
10023 if ( CheckVersion($DBversion) ) {
10024 $dbh->do(q|
10025 ALTER TABLE issues DROP COLUMN issuingbranch
10027 $dbh->do(q|
10028 ALTER TABLE old_issues DROP COLUMN issuingbranch
10030 print "Upgrade to $DBversion done (Bug 2806: Remove issuingbranch columns)\n";
10031 SetVersion ($DBversion);
10034 $DBversion = '3.19.00.022';
10035 if ( CheckVersion($DBversion) ) {
10036 $dbh->do(q{
10037 ALTER TABLE suggestions DROP COLUMN mailoverseeing;
10039 print "Upgrade to $DBversion done (Bug 13006: Drop column suggestion.mailoverseeing)\n";
10040 SetVersion($DBversion);
10043 $DBversion = "3.19.00.023";
10044 if ( CheckVersion($DBversion) ) {
10045 $dbh->do(q|
10046 DELETE FROM systempreferences where variable = 'AddPatronLists'
10048 print "Upgrade to $DBversion done (Bug 13497: Remove the AddPatronLists system preferences)\n";
10049 SetVersion ($DBversion);
10052 $DBversion = "3.19.00.024";
10053 if ( CheckVersion($DBversion) ) {
10054 $dbh->do(qq|DROP table patroncards;|);
10055 print "Upgrade to $DBversion done (Bug 13539: Remove table patroncards from database as it's no longer in use)\n";
10056 SetVersion ($DBversion);
10059 $DBversion = "3.19.00.025";
10060 if ( CheckVersion($DBversion) ) {
10061 $dbh->do(q|
10062 INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
10063 ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo')
10065 print "Upgrade to $DBversion done (Bug 13528: Add the SearchWithISBNVariations syspref)\n";
10066 SetVersion ($DBversion);
10069 $DBversion = "3.19.00.026";
10070 if( CheckVersion($DBversion) ) {
10071 if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
10072 $dbh->do(q{
10073 INSERT IGNORE INTO auth_tag_structure (authtypecode, tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value) VALUES
10074 ('', '388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL);
10077 $dbh->do(q{
10078 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10079 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10080 ('', '388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10081 ('', '388', '2', 'Source of term', 'Source of term', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10082 ('', '388', '3', 'Materials specified', 'Materials specified', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10083 ('', '388', '6', 'Linkage', 'Linkage', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10084 ('', '388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10085 ('', '388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', '');
10088 $dbh->do(q{
10089 UPDATE IGNORE auth_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND tagfield IN
10090 ('100','110','111','130','400','410','411','430','500','510','511','530','700','710','730');
10093 $dbh->do(q{
10094 INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10095 mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10096 ('', '150', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10097 ('', '151', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10098 ('', '450', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10099 ('', '451', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10100 ('', '550', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10101 ('', '551', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10102 ('', '750', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10103 ('', '751', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10104 ('', '748', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10105 ('', '755', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10106 ('', '780', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10107 ('', '781', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10108 ('', '782', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10109 ('', '785', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10110 ('', '710', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10111 ('', '730', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10112 ('', '748', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10113 ('', '750', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10114 ('', '751', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10115 ('', '755', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10116 ('', '762', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10117 ('', '780', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10118 ('', '781', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10119 ('', '782', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10120 ('', '785', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10121 ('', '788', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', '');
10124 $dbh->do(q{
10125 UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship information', libopac = 'Relationship information'
10126 WHERE tagsubfield = 'i' AND tagfield IN ('700','710','730','750','751','762');
10129 $dbh->do(q{
10130 UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship code', libopac = 'Relationship code'
10131 WHERE tagsubfield = '4' AND tagfield IN ('700','710');
10134 $dbh->do(q{
10135 INSERT IGNORE INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) VALUES
10136 ('370', 'ASSOCIATED PLACE', 'ASSOCIATED PLACE', 1, 0, NULL, ''),
10137 ('388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL, '');
10140 $dbh->do(q{
10141 INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
10142 kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
10143 ('370', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10144 ('370', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10145 ('370', '6', 'Linkage', 'Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10146 ('370', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10147 ('370', 'c', 'Associated country', 'Associated country', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10148 ('370', 'f', 'Other associated place', 'Other associated place', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10149 ('370', 'g', 'Place of origin of work', 'Place of origin of work', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10150 ('370', 's', 'Start period', 'Start period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10151 ('370', 't', 'End period', 'End period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10152 ('370', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10153 ('370', 'v', 'Source of information', 'Source of information', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10154 ('377', 'l', 'Language term', 'Language term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10155 ('382', 's', 'Total number of performers', 'Total number of performers', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10156 ('388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10157 ('388', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10158 ('388', '3', ' Materials specified', ' Materials specified', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10159 ('388', '6', ' Linkage', ' Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10160 ('388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10161 ('388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10162 ('650', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL),
10163 ('651', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL);
10166 $dbh->do(q{
10167 UPDATE IGNORE marc_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND
10168 tagfield IN ('100','110','111','130','240','243','246','247','600','610','611','630','700','710','711','730','800','810','811','830');
10172 print "Upgrade to $DBversion done (Bug 13322: Update MARC21 frameworks to Update No. 19 - October 2014)\n";
10173 SetVersion($DBversion);
10176 $DBversion = '3.19.00.027';
10177 if ( CheckVersion($DBversion) ) {
10178 $dbh->do("ALTER TABLE items ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10179 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10180 print "Upgrade to $DBversion done (Bug 4222: Nonpublic note not appearing in the staff client) <b>Please check each of your frameworks to ensure your non-public item notes are mapped to items.itemnotes_nonpublic. After doing so please have your administrator run misc/batchRebuildItemsTables.pl </b>)\n";
10181 SetVersion($DBversion);
10184 $DBversion = "3.19.00.028";
10185 if( CheckVersion($DBversion) ) {
10186 eval {
10187 local $dbh->{PrintError} = 0;
10188 $dbh->do(q{
10189 ALTER TABLE issues DROP PRIMARY KEY
10193 $dbh->do(q{
10194 ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10197 $dbh->do(q{
10198 ALTER TABLE old_issues CHANGE issue_id issue_id INT( 11 ) NOT NULL
10201 $dbh->do(q{
10202 ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10205 $dbh->do(q{
10206 UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
10209 my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max();
10210 if ($max_issue_id) {
10211 $max_issue_id++;
10212 $dbh->do(qq{
10213 ALTER TABLE issues AUTO_INCREMENT = $max_issue_id
10217 print "Upgrade to $DBversion done (Bug 13790: Add unique id issue_id to issues and oldissues tables)\n";
10218 SetVersion($DBversion);
10221 $DBversion = "3.19.00.029";
10222 if ( CheckVersion($DBversion) ) {
10223 $dbh->do(q|
10224 ALTER TABLE sessions CHANGE COLUMN a_session a_session MEDIUMTEXT
10226 print "Upgrade to $DBversion done (Bug 13606: Upgrade sessions.a_session to MEDIUMTEXT)\n";
10227 SetVersion($DBversion);
10230 $DBversion = "3.19.00.030";
10231 if ( CheckVersion($DBversion) ) {
10232 $dbh->do(q|
10233 UPDATE language_subtag_registry SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10235 $dbh->do(q|
10236 UPDATE language_rfc4646_to_iso639 SET rfc4646_subtag = 'kn' WHERE rfc4646_subtag = 'ka' AND iso639_2_code = 'kan';
10238 $dbh->do(q|
10239 UPDATE language_descriptions SET subtag = 'kn', lang = 'kn' WHERE subtag = 'ka' AND lang = 'ka' AND description = 'ಕನ್ನಡ';
10241 $dbh->do(q|
10242 UPDATE language_descriptions SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10244 $dbh->do(q|
10245 INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Georgian','2015-04-20');
10247 $dbh->do(q|
10248 DELETE FROM language_subtag_registry
10249 WHERE NOT id IN
10250 (SELECT id FROM
10251 (SELECT MIN(id) as id,subtag,type,description,added
10252 FROM language_subtag_registry
10253 GROUP BY subtag,type,description,added)
10254 AS subtable);
10256 $dbh->do(q|
10257 INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka', 'geo');
10259 $dbh->do(q|
10260 DELETE FROM language_rfc4646_to_iso639
10261 WHERE NOT id IN
10262 (SELECT id FROM
10263 (SELECT MIN(id) as id,rfc4646_subtag,iso639_2_code
10264 FROM language_rfc4646_to_iso639
10265 GROUP BY rfc4646_subtag,iso639_2_code)
10266 AS subtable);
10268 $dbh->do(q|
10269 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ქართული');
10271 $dbh->do(q|
10272 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Georgian');
10274 $dbh->do(q|
10275 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'fr', 'Géorgien');
10277 $dbh->do(q|
10278 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'de', 'Georgisch');
10280 $dbh->do(q|
10281 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'es', 'Georgiano');
10283 $dbh->do(q|
10284 DELETE FROM language_descriptions
10285 WHERE NOT id IN
10286 (SELECT id FROM
10287 (SELECT MIN(id) as id,subtag,type,lang,description
10288 FROM language_descriptions GROUP BY subtag,type,lang,description)
10289 AS subtable);
10291 print "Upgrade to $DBversion done (Bug 14030: Add Georgian language and fix Kannada language code)\n";
10292 SetVersion($DBversion);
10295 $DBversion = "3.19.00.031";
10296 if ( CheckVersion($DBversion) ) {
10297 $dbh->do(q{
10298 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10299 VALUES('IdRef','0','Disable/enable the IdRef webservice from the OPAC detail page.',NULL,'YesNo')
10301 print "Upgrade to $DBversion done (Bug 8992: Add system preference IdRef))\n";
10302 SetVersion($DBversion);
10305 $DBversion = "3.19.00.032";
10306 if ( CheckVersion($DBversion) ) {
10307 $dbh->do(q|
10308 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10309 VALUES('AddressFormat','us','Choose format to display postal addresses','','Choice')
10311 print "Upgrade to $DBversion done (Bug 4041: Address Format as a I18N/L10N system preference\n";
10312 SetVersion ($DBversion);
10315 $DBversion = "3.19.00.033";
10316 if ( CheckVersion($DBversion) ) {
10317 $dbh->do(q|
10318 ALTER TABLE auth_header
10319 CHANGE COLUMN datemodified modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP
10321 $dbh->do(q|
10322 ALTER TABLE auth_header
10323 CHANGE COLUMN modification_time modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
10325 print "Upgrade to $DBversion done (Bug 11165: Update auth_header.datemodified when updated)\n";
10326 SetVersion ($DBversion);
10329 $DBversion = "3.19.00.034";
10330 if ( CheckVersion($DBversion) ) {
10331 $dbh->do(q|
10332 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10333 VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free')
10335 print "Upgrade to $DBversion done (Bug 13984: CardnumberLength syspref missing on some setups\n";
10336 SetVersion ($DBversion);
10339 $DBversion = "3.19.00.035";
10340 if ( CheckVersion($DBversion) ) {
10341 $dbh->do(q|
10342 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('useDischarge','','Allows librarians to discharge borrowers and borrowers to request a discharge','','YesNo')
10344 $dbh->do(q|
10345 INSERT IGNORE INTO letter (module, code, name, title, content) VALUES('members', 'DISCHARGE', 'Discharge', 'Discharge for <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Discharge</h1>\r\n\r\nThe library <<borrowers.branchcode>> certifies that the following borrower :\r\n\r\n <<borrowers.firstname>> <<borrowers.surname>>\r\n Cardnumber : <<borrowers.cardnumber>>\r\n\r\nreturned all his documents.')
10348 $dbh->do(q|
10349 ALTER TABLE borrower_debarments CHANGE type type ENUM('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL'
10352 $dbh->do(q|
10353 CREATE TABLE discharges (
10354 borrower int(11) DEFAULT NULL,
10355 needed timestamp NULL DEFAULT NULL,
10356 validated timestamp NULL DEFAULT NULL,
10357 KEY borrower_discharges_ibfk1 (borrower),
10358 CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
10359 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10362 print "Upgrade to $DBversion done (Bug 8007: Add System Preferences useDischarge, the discharge notice and the new table discharges)\n";
10363 SetVersion($DBversion);
10366 $DBversion = "3.19.00.036";
10367 if ( CheckVersion($DBversion) ) {
10368 $dbh->do(q|
10369 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10370 VALUES ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo')
10372 print "Upgrade to $DBversion done (Bug 13889: Add cron jobs information to system log)\n";
10373 SetVersion ($DBversion);
10376 $DBversion = "3.19.00.037";
10377 if ( CheckVersion($DBversion) ) {
10378 $dbh->do(q|
10379 ALTER TABLE marc_subfield_structure
10380 MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT ''
10382 print "Upgrade to $DBversion done (Bug 13810: Change collate for tagsubfield (utf8_bin))\n";
10383 SetVersion ($DBversion);
10386 $DBversion = "3.19.00.038";
10387 if ( CheckVersion($DBversion) ) {
10388 $dbh->do(q|
10389 ALTER TABLE virtualshelves
10390 ADD COLUMN created_on DATETIME NOT NULL AFTER lastmodified
10392 # Set created_on = lastmodified
10393 # I would say it's better than 0000-00-00
10394 # Set modified to the existing value (do not get the current ts!)
10395 $dbh->do(q|
10396 UPDATE virtualshelves
10397 SET created_on = lastmodified, lastmodified = lastmodified
10399 print "Upgrade to $DBversion done (Bug 13421: Add DB field virtualshelves.created_on)\n";
10400 SetVersion ($DBversion);
10403 $DBversion = "3.19.00.039";
10404 if ( CheckVersion($DBversion) ) {
10405 print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
10406 SetVersion ($DBversion);
10409 $DBversion = "3.19.00.040";
10410 if ( CheckVersion($DBversion) ) {
10411 $dbh->do(q|
10412 ALTER TABLE aqorders DROP COLUMN totalamount
10414 print "Upgrade to $DBversion done (Bug 11006: Drop column aqorders.totalamount)\n";
10415 SetVersion ($DBversion);
10418 $DBversion = "3.19.00.041";
10419 if ( CheckVersion($DBversion) ) {
10420 $dbh->do(q|
10421 ALTER IGNORE TABLE suggestions ADD KEY status (STATUS)
10423 $dbh->do(q|
10424 ALTER IGNORE TABLE suggestions ADD KEY biblionumber (biblionumber)
10426 $dbh->do(q|
10427 ALTER IGNORE TABLE suggestions ADD KEY branchcode (branchcode)
10429 print "Upgrade to $DBversion done (Bug 14132: suggestions table is missing indexes)\n";
10430 SetVersion ($DBversion);
10433 $DBversion = "3.19.00.042";
10434 if ( CheckVersion($DBversion) ) {
10435 $dbh->do(q{
10436 DELETE ass.*
10437 FROM auth_subfield_structure AS ass
10438 LEFT JOIN auth_types USING(authtypecode)
10439 WHERE auth_types.authtypecode IS NULL
10442 $dbh->do(q{
10443 ALTER IGNORE TABLE auth_subfield_structure
10444 ADD CONSTRAINT auth_subfield_structure_ibfk_1
10445 FOREIGN KEY (authtypecode) REFERENCES auth_types(authtypecode)
10446 ON DELETE CASCADE ON UPDATE CASCADE
10449 print "Upgrade to $DBversion done (Bug 8480: Add foreign key on auth_subfield_structure.authtypecode)\n";
10450 SetVersion($DBversion);
10453 $DBversion = "3.19.00.043";
10454 if ( CheckVersion($DBversion) ) {
10455 $dbh->do(q|
10456 INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
10457 ('REPORT_GROUP', 'SER', 'Serials')
10460 print "Upgrade to $DBversion done (Bug 5338: Add Serial to the report groups if does not exist)\n";
10461 SetVersion ($DBversion);
10464 $DBversion = "3.20.00.000";
10465 if ( CheckVersion($DBversion) ) {
10466 print "Upgrade to $DBversion done (Koha 3.20)\n";
10467 SetVersion ($DBversion);
10470 $DBversion = "3.21.00.000";
10471 if ( CheckVersion($DBversion) ) {
10472 print "Upgrade to $DBversion done (El tiempo vuela, un nuevo ciclo comienza.)\n";
10473 SetVersion ($DBversion);
10476 $DBversion = "3.21.00.001";
10477 if ( CheckVersion($DBversion) ) {
10478 $dbh->do(q|
10479 UPDATE systempreferences SET variable='IntranetUserJS' where variable='intranetuserjs'
10481 print "Upgrade to $DBversion done (Bug 12160: Rename intranetuserjs to IntranetUserJS)\n";
10482 SetVersion ($DBversion);
10485 $DBversion = "3.21.00.002";
10486 if ( CheckVersion($DBversion) ) {
10487 $dbh->do(q|
10488 UPDATE systempreferences SET variable='OPACUserJS' where variable='opacuserjs'
10490 print "Upgrade to $DBversion done (Bug 12160: Rename opacuserjs to OPACUserJS)\n";
10491 SetVersion ($DBversion);
10494 $DBversion = "3.21.00.003";
10495 if ( CheckVersion($DBversion) ) {
10496 $dbh->do(q|
10497 INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added)
10498 VALUES ( 'IN', 'region', 'India','2015-05-28');
10500 $dbh->do(q|
10501 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10502 VALUES ( 'IN', 'region', 'en', 'India');
10504 $dbh->do(q|
10505 INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10506 VALUES ( 'IN', 'region', 'bn', 'ভারত');
10508 print "Upgrade to $DBversion done (Bug 14285: Add new region India)\n";
10509 SetVersion ($DBversion);
10512 $DBversion = '3.21.00.004';
10513 if ( CheckVersion($DBversion) ) {
10514 my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
10515 if (defined($OPACBaseURL) && substr($OPACBaseURL,0,4) ne "http") {
10516 my $explanation = q{Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.};
10517 $OPACBaseURL = 'http://' . $OPACBaseURL;
10518 my $sth_OPACBaseURL = $dbh->prepare( q{
10519 UPDATE systempreferences SET value=?,explanation=?
10520 WHERE variable='OPACBaseURL'; } );
10521 $sth_OPACBaseURL->execute($OPACBaseURL,$explanation);
10523 if (defined($OPACBaseURL)) {
10524 $dbh->do( q{ UPDATE letter
10525 SET content=replace(content,
10526 'http://<<OPACBaseURL>>',
10527 '<<OPACBaseURL>>')
10528 WHERE content LIKE "%http://<<OPACBaseURL>>%"; } );
10531 print "Upgrade to $DBversion done (Bug 5010: Fix OPACBaseURL to include protocol)\n";
10532 SetVersion($DBversion);
10535 $DBversion = "3.21.00.005";
10536 if ( CheckVersion($DBversion) ) {
10537 $dbh->do(q|
10538 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10539 VALUES ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo')
10541 print "Upgrade to $DBversion done (Bug 14024: Add reports to action logs)\n";
10542 SetVersion ($DBversion);
10545 $DBversion = "3.21.00.006";
10546 if ( CheckVersion($DBversion) ) {
10547 # Remove the borrow permission flag (bit 7)
10548 $dbh->do(q|
10549 UPDATE borrowers
10550 SET flags = flags - ( flags & (1<<7) )
10551 WHERE flags IS NOT NULL
10552 AND flags > 0
10554 $dbh->do(q|
10555 DELETE FROM userflags WHERE bit=7;
10557 print "Upgrade to $DBversion done (Bug 7976: Remove the 'borrow' permission)\n";
10558 SetVersion($DBversion);
10561 $DBversion = "3.21.00.007";
10562 if ( CheckVersion($DBversion) ) {
10563 $dbh->do(q|
10564 ALTER IGNORE TABLE aqbasket
10565 ADD KEY authorisedby (authorisedby)
10567 $dbh->do(q|
10568 ALTER IGNORE TABLE aqbooksellers
10569 ADD KEY name (name(255))
10571 $dbh->do(q|
10572 ALTER IGNORE TABLE aqbudgets
10573 ADD KEY budget_parent_id (budget_parent_id),
10574 ADD KEY budget_code (budget_code),
10575 ADD KEY budget_branchcode (budget_branchcode),
10576 ADD KEY budget_period_id (budget_period_id),
10577 ADD KEY budget_owner_id (budget_owner_id)
10579 $dbh->do(q|
10580 ALTER IGNORE TABLE aqbudgets_planning
10581 ADD KEY budget_period_id (budget_period_id)
10583 $dbh->do(q|
10584 ALTER IGNORE TABLE aqorders
10585 ADD KEY parent_ordernumber (parent_ordernumber),
10586 ADD KEY orderstatus (orderstatus)
10588 print "Upgrade to $DBversion done (Bug 14053: Acquisition db tables are missing indexes)\n";
10589 SetVersion ($DBversion);
10592 $DBversion = "3.21.00.008";
10593 if ( CheckVersion($DBversion) ) {
10594 $dbh->do(q{
10595 DELETE IGNORE FROM systempreferences
10596 WHERE variable = 'HomeOrHoldingBranchReturn';
10598 print "Upgrade to $DBversion done (Bug 7981: Transfer message on return. HomeOrHoldingBranchReturn syspref removed in favour of circulation rules.)\n";
10599 SetVersion($DBversion);
10602 $DBversion = "3.21.00.009";
10603 if ( CheckVersion($DBversion) ) {
10604 $dbh->do(q|
10605 UPDATE aqorders SET orderstatus='cancelled'
10606 WHERE (datecancellationprinted IS NOT NULL OR
10607 datecancellationprinted<>'0000-00-00');
10609 print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n";
10610 SetVersion($DBversion);
10613 $DBversion = "3.21.00.010";
10614 if ( CheckVersion($DBversion) ) {
10615 $dbh->do(q|
10616 ALTER TABLE message_queue
10617 DROP message_id
10619 $dbh->do(q|
10620 ALTER TABLE message_queue
10621 ADD message_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10623 print "Upgrade to $DBversion done (Bug 7793: redefine the field message_id as PRIMARY KEY of message_queue)\n";
10624 SetVersion ($DBversion);
10627 $DBversion = "3.21.00.011";
10628 if ( CheckVersion($DBversion) ) {
10629 $dbh->do(q{
10630 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10631 VALUES ('OpacLangSelectorMode','footer','top|both|footer','Select the location to display the language selector','Choice')
10633 print "Upgrade to $DBversion done (Bug 14252: Make the OPAC language switcher available in the masthead navbar, footer, or both)\n";
10634 SetVersion ($DBversion);
10637 $DBversion = "3.21.00.012";
10638 if ( CheckVersion($DBversion) ) {
10639 $dbh->do(q|
10640 INSERT INTO letter (module, code, name, title, content, message_transport_type)
10641 VALUES
10642 ('suggestions','TO_PROCESS','Notify fund owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.autho r>>.\n\nThank you,\n\n<<branches.branchname>>', 'email')
10644 print "Upgrade to $DBversion done (Bug 13014: Add the TO_PROCESS letter code)\n";
10645 SetVersion($DBversion);
10648 $DBversion = "3.21.00.013";
10649 if ( CheckVersion($DBversion) ) {
10650 my $msg;
10651 if ( C4::Context->preference('OPACPrivacy') ) {
10652 if ( my $anonymous_patron = C4::Context->preference('AnonymousPatron') ) {
10653 my $anonymous_patron_exists = $dbh->selectcol_arrayref(q|
10654 SELECT COUNT(*)
10655 FROM borrowers
10656 WHERE borrowernumber=?
10657 |, {}, $anonymous_patron);
10658 unless ( $anonymous_patron_exists->[0] ) {
10659 $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not linked to an existing patron";
10662 else {
10663 $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not";
10666 else {
10667 my $patrons_have_required_anonymity = $dbh->selectcol_arrayref(q|
10668 SELECT COUNT(*)
10669 FROM borrowers
10670 WHERE privacy = 2
10671 |, {} );
10672 if ( $patrons_have_required_anonymity->[0] ) {
10673 $msg = "Configuration WARNING: OPACPrivacy is not set but $patrons_have_required_anonymity->[0] patrons have required anonymity (perhaps in a previous configuration). You should fix that asap.";
10677 $msg //= "Privacy is correctly set";
10678 print "Upgrade to $DBversion done (Bug 9942: $msg)\n";
10679 SetVersion ($DBversion);
10682 $DBversion = "3.21.00.014";
10683 if ( CheckVersion($DBversion) ) {
10684 $dbh->do(q{
10685 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10686 VALUES ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent) or might be deleted (transient)','transient|persistent','Choice')
10688 $dbh->do(q|
10689 ALTER TABLE oai_sets_biblios DROP FOREIGN KEY oai_sets_biblios_ibfk_1
10691 print "Upgrade to $DBversion done (Bug 3206: OAI repository deleted record support)\n";
10692 SetVersion ($DBversion);
10695 $DBversion = "3.21.00.015";
10696 if ( CheckVersion($DBversion) ) {
10697 $dbh->do(q{
10698 UPDATE systempreferences SET value='0' WHERE variable='CalendarFirstDayOfWeek' AND value='Sunday';
10700 $dbh->do(q{
10701 UPDATE systempreferences SET value='1' WHERE variable='CalendarFirstDayOfWeek' AND value='Monday';
10703 $dbh->do(q{
10704 UPDATE systempreferences SET options='0|1|2|3|4|5|6' WHERE variable='CalendarFirstDayOfWeek';
10707 print "Upgrade to $DBversion done (Bug 12137: Extend functionality of CalendarFirstDayOfWeek to be any day)\n";
10708 SetVersion($DBversion);
10711 $DBversion = "3.21.00.016";
10712 if ( CheckVersion($DBversion) ) {
10713 my $rs = $schema->resultset('Systempreference');
10714 $rs->find_or_create(
10716 variable => 'DumpTemplateVarsIntranet',
10717 value => 0,
10718 explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',
10719 type => 'YesNo',
10722 $rs->find_or_create(
10724 variable => 'DumpTemplateVarsOpac',
10725 value => 0,
10726 explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',
10727 type => 'YesNo',
10730 print "Upgrade to $DBversion done (Bug 13948: Add ability to dump template toolkit variables to html comment)\n";
10731 SetVersion($DBversion);
10734 $DBversion = "3.21.00.017";
10735 if ( CheckVersion($DBversion) ) {
10736 $dbh->do("
10737 CREATE TABLE uploaded_files (
10738 id int(11) NOT NULL AUTO_INCREMENT,
10739 hashvalue CHAR(40) NOT NULL,
10740 filename TEXT NOT NULL,
10741 dir TEXT NOT NULL,
10742 filesize int(11),
10743 dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10744 categorycode tinytext,
10745 owner int(11),
10746 PRIMARY KEY (id)
10747 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
10750 print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
10751 print "This plugin comes with a new config variable (upload_path) and a new table (uploaded_files)\n";
10752 print "To use it, set 'upload_path' config variable and 'OPACBaseURL' system preference and link this plugin to a subfield (856\$u for instance)\n";
10753 SetVersion($DBversion);
10756 $DBversion = "3.21.00.018";
10757 if ( CheckVersion($DBversion) ) {
10758 $dbh->do(q{
10759 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10760 VALUES
10761 ('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: \"127.0.0,127.0.2\")','Free'),
10762 ('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
10763 ('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free')
10765 print "Upgrade to $DBversion done (Bug 13485: Add a page to display links to restricted sites)\n";
10766 SetVersion ($DBversion);
10769 $DBversion = "3.21.00.019";
10770 if ( CheckVersion($DBversion) ) {
10771 $dbh->do(q{
10772 ALTER TABLE reserves DROP constrainttype
10774 $dbh->do(q{
10775 ALTER TABLE old_reserves DROP constrainttype
10777 $dbh->do(q{
10778 DROP TABLE IF EXISTS reserveconstraints
10780 print "Upgrade to $DBversion done (Bug 9809: Get rid of reserveconstraints)\n";
10781 SetVersion ($DBversion);
10784 $DBversion = "3.21.00.020";
10785 if ( CheckVersion($DBversion) ) {
10786 $dbh->do(q{
10787 INSERT IGNORE INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`)
10788 VALUES ('FeeOnChangePatronCategory','1','','If set, when a patron changes to a category with enrolment fee, a fee is charged','YesNo')
10790 print "Upgrade to $DBversion done (Bug 13697: Option to don't charge a fee, if the patron changes to a category with enrolment fee)\n";
10791 SetVersion($DBversion);
10794 $DBversion = "3.21.00.021";
10795 if ( CheckVersion($DBversion) ) {
10796 $dbh->do(q{
10797 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10798 VALUES ('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo')
10800 print "Upgrade to $DBversion done (Bug 11584: Add wysiwyg editor to system preferences dealing with HTML)\n";
10801 SetVersion($DBversion);
10804 $DBversion = "3.21.00.022";
10805 if ( CheckVersion($DBversion) ) {
10806 $dbh->do(q{
10807 DELETE cr.*
10808 FROM course_reserves AS cr
10809 LEFT JOIN course_items USING(ci_id)
10810 WHERE course_items.ci_id IS NULL
10813 my ($print_error) = $dbh->{PrintError};
10814 $dbh->{RaiseError} = 0;
10815 $dbh->{PrintError} = 0;
10816 $dbh->do(q{ALTER TABLE course_reserves DROP FOREIGN KEY course_reserves_ibfk_2});
10817 $dbh->do(q{ALTER TABLE course_reserves DROP INDEX course_reserves_ibfk_2});
10818 $dbh->{PrintError} = $print_error;
10820 $dbh->do(q{
10821 ALTER IGNORE TABLE course_reserves
10822 ADD CONSTRAINT course_reserves_ibfk_2
10823 FOREIGN KEY (ci_id) REFERENCES course_items (ci_id)
10824 ON DELETE CASCADE ON UPDATE CASCADE
10826 print "Upgrade to $DBversion done (Bug 14205: Deleting an Item/Record does not remove link to course reserve)\n";
10827 SetVersion($DBversion);
10830 $DBversion = "3.21.00.023";
10831 if ( CheckVersion($DBversion) ) {
10832 $dbh->do(q{
10833 UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00'
10835 $dbh->do(q{
10836 UPDATE borrowers SET dateexpiry=NULL where dateexpiry='0000-00-00'
10838 $dbh->do(q{
10839 UPDATE borrowers SET dateofbirth=NULL where dateofbirth='0000-00-00'
10841 $dbh->do(q{
10842 UPDATE borrowers SET dateenrolled=NULL where dateenrolled='0000-00-00'
10844 print "Upgrade to $DBversion done (Bug 14717: Prevent 0000-00-00 dates in patron data)\n";
10845 SetVersion($DBversion);
10848 $DBversion = "3.21.00.024";
10849 if ( CheckVersion($DBversion) ) {
10850 $dbh->do(q{
10851 ALTER TABLE marc_modification_template_actions
10852 MODIFY COLUMN action
10853 ENUM('delete_field','update_field','move_field','copy_field','copy_and_replace_field')
10854 NOT NULL
10856 print "Upgrade to $DBversion done (Bug 14098: Regression in Marc Modification Templates)\n";
10857 SetVersion($DBversion);
10860 $DBversion = "3.21.00.025";
10861 if ( CheckVersion($DBversion) ) {
10862 $dbh->do(q{
10863 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10864 VALUES ('RisExportAdditionalFields', '', NULL , 'Define additional RIS tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea')
10866 $dbh->do(q{
10867 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10868 VALUES ('BibtexExportAdditionalFields', '', NULL , 'Define additional BibTex tags to export from MARC records in YAML format as an associative array with either a marc tag/subfield combination as the value, or a list of tag/subfield combinations.', 'textarea')
10870 print "Upgrade to $DBversion done (Bug 12357: Enhancements to RIS and BibTeX exporting)\n";
10871 SetVersion($DBversion);
10874 $DBversion = "3.21.00.026";
10875 if ( CheckVersion($DBversion) ) {
10876 $dbh->do(q{
10877 UPDATE matchpoints
10878 SET search_index='issn'
10879 WHERE matcher_id IN (SELECT matcher_id FROM marc_matchers WHERE code = 'ISSN')
10881 print "Upgrade to $DBversion done (Bug 14472: Wrong ISSN search index in record matching rules)\n";
10882 SetVersion($DBversion);
10885 $DBversion = "3.21.00.027";
10886 if ( CheckVersion($DBversion) ) {
10887 $dbh->do(q|
10888 INSERT IGNORE INTO permissions (module_bit, code, description)
10889 VALUES (1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID')
10892 my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
10894 $dbh->do(q|
10895 UPDATE borrowers
10896 SET flags=0
10897 WHERE userid=?
10898 |, undef, $AutoSelfCheckID);
10900 $dbh->do(q|
10901 DELETE FROM user_permissions
10902 WHERE borrowernumber=(SELECT borrowernumber FROM borrowers WHERE userid=?)
10903 |, undef, $AutoSelfCheckID);
10905 $dbh->do(q|
10906 INSERT INTO user_permissions(borrowernumber, module_bit, code)
10907 SELECT borrowernumber, 1, 'self_checkout' FROM borrowers WHERE userid=?
10908 |, undef, $AutoSelfCheckID);
10909 print "Upgrade to $DBversion done (Bug 14298: AutoSelfCheckID user should only be able to access SCO)\n";
10910 SetVersion($DBversion);
10913 $DBversion = "3.21.00.028";
10914 if ( CheckVersion($DBversion) ) {
10915 $dbh->do(q{
10916 ALTER TABLE uploaded_files
10917 ADD COLUMN public tinyint,
10918 ADD COLUMN permanent tinyint
10920 $dbh->do(q{
10921 UPDATE uploaded_files SET public=1, permanent=1
10923 $dbh->do(q{
10924 ALTER TABLE uploaded_files
10925 CHANGE COLUMN categorycode uploadcategorycode tinytext
10927 print "Upgrade to $DBversion done (Bug 14321: Merge UploadedFile and UploadedFiles into Koha::Upload)\n";
10928 SetVersion($DBversion);
10931 $DBversion = "3.21.00.029";
10932 if ( CheckVersion($DBversion) ) {
10933 $dbh->do(q{
10934 ALTER IGNORE TABLE discharges
10935 ADD COLUMN discharge_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10937 print "Upgrade to $DBversion done (Bug 14368: Add discharges history)\n";
10938 SetVersion($DBversion);
10941 $DBversion = "3.21.00.030";
10942 if ( CheckVersion($DBversion) ) {
10943 $dbh->do(q{
10944 UPDATE marc_subfield_structure
10945 SET value_builder='marc21_leader.pl'
10946 WHERE value_builder='marc21_leader_book.pl'
10948 $dbh->do(q{
10949 UPDATE marc_subfield_structure
10950 SET value_builder='marc21_leader.pl'
10951 WHERE value_builder='marc21_leader_computerfile.pl'
10953 $dbh->do(q{
10954 UPDATE marc_subfield_structure
10955 SET value_builder='marc21_leader.pl'
10956 WHERE value_builder='marc21_leader_video.pl'
10958 print "Upgrade to $DBversion done (Bug 14201: Remove unused code or template from some MARC21 leader plugins )\n";
10959 SetVersion($DBversion);
10962 $DBversion = "3.21.00.031";
10963 if ( CheckVersion($DBversion) ) {
10964 $dbh->do(q{
10965 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10966 VALUES
10967 ('SMSSendPassword', '', '', 'Password used to send SMS messages', 'free'),
10968 ('SMSSendUsername', '', '', 'Username/Login used to send SMS messages', 'free')
10970 print "Upgrade to $DBversion done (Bug 14820: SMSSendUsername and SMSSendPassword are not listed in the system preferences)\n";
10971 SetVersion($DBversion);
10974 $DBversion = "3.21.00.032";
10975 if ( CheckVersion($DBversion) ) {
10976 $dbh->do(q{
10977 CREATE TABLE additional_fields (
10978 id int(11) NOT NULL AUTO_INCREMENT,
10979 tablename varchar(255) NOT NULL DEFAULT '',
10980 name varchar(255) NOT NULL DEFAULT '',
10981 authorised_value_category varchar(16) NOT NULL DEFAULT '',
10982 marcfield varchar(16) NOT NULL DEFAULT '',
10983 searchable tinyint(1) NOT NULL DEFAULT '0',
10984 PRIMARY KEY (id),
10985 UNIQUE KEY fields_uniq (tablename,name)
10986 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
10988 $dbh->do(q{
10989 CREATE TABLE additional_field_values (
10990 id int(11) NOT NULL AUTO_INCREMENT,
10991 field_id int(11) NOT NULL,
10992 record_id int(11) NOT NULL,
10993 value varchar(255) NOT NULL DEFAULT '',
10994 PRIMARY KEY (id),
10995 UNIQUE KEY field_record (field_id,record_id),
10996 CONSTRAINT afv_fk FOREIGN KEY (field_id) REFERENCES additional_fields (id) ON DELETE CASCADE ON UPDATE CASCADE
10997 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
10999 print "Upgrade to $DBversion done (Bug 10855: Additional fields for subscriptions)\n";
11000 SetVersion($DBversion);
11003 $DBversion = "3.21.00.033";
11004 if ( CheckVersion($DBversion) ) {
11006 my $done = 0;
11007 my $count_ethnicity = $dbh->selectrow_arrayref(q|
11008 SELECT COUNT(*) FROM ethnicity
11010 my $count_borrower_modifications = $dbh->selectrow_arrayref(q|
11011 SELECT COUNT(*)
11012 FROM borrower_modifications
11013 WHERE ethnicity IS NOT NULL
11014 OR ethnotes IS NOT NULL
11016 my $count_borrowers = $dbh->selectrow_arrayref(q|
11017 SELECT COUNT(*)
11018 FROM borrowers
11019 WHERE ethnicity IS NOT NULL
11020 OR ethnotes IS NOT NULL
11022 # We don't care about the ethnicity of the deleted borrowers, right?
11023 if ( $count_ethnicity->[0] == 0
11024 and $count_borrower_modifications->[0] == 0
11025 and $count_borrowers->[0] == 0
11027 $dbh->do(q|
11028 DROP TABLE ethnicity
11030 $dbh->do(q|
11031 ALTER TABLE borrower_modifications
11032 DROP COLUMN ethnicity,
11033 DROP COLUMN ethnotes
11035 $dbh->do(q|
11036 ALTER TABLE borrowers
11037 DROP COLUMN ethnicity,
11038 DROP COLUMN ethnotes
11040 $dbh->do(q|
11041 ALTER TABLE deletedborrowers
11042 DROP COLUMN ethnicity,
11043 DROP COLUMN ethnotes
11045 $done = 1;
11047 if ( $done ) {
11048 print "Upgrade to $DBversion done (Bug 10020: Drop table ethnicity and columns ethnicity and ethnotes)\n";
11050 else {
11051 print "Upgrade to $DBversion done (Bug 10020: This database contains data related to 'ethnicity'. No change will be done on the DB structure but note that the Koha codebase does not use it)\n";
11054 SetVersion ($DBversion);
11057 $DBversion = "3.21.00.034";
11058 if ( CheckVersion($DBversion) ) {
11059 $dbh->do(q{
11060 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11061 VALUES('MembershipExpiryDaysNotice',NULL,'Send an account expiration notice that a patron''s card is about to expire after',NULL,'Integer')
11063 $dbh->do(q{
11064 INSERT IGNORE INTO letter (module, code, branchcode, name, title, content, message_transport_type)
11065 VALUES('members','MEMBERSHIP_EXPIRY','','Account expiration','Account expiration','Dear <<borrowers.title>> <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nYour library card will expire soon, on:\r\n\r\n<<borrowers.dateexpiry>>\r\n\r\nThank you,\r\n\r\nLibrarian\r\n\r\n<<branches.branchname>>', 'email')
11067 print "Upgrade to $DBversion done (Bug 6810: Send membership expiry reminder notices)\n";
11068 SetVersion($DBversion);
11071 $DBversion = "3.21.00.035";
11072 if ( CheckVersion($DBversion) ) {
11073 $dbh->do(q|
11074 ALTER TABLE branch_borrower_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11076 $dbh->do(q|
11077 UPDATE branch_borrower_circ_rules SET maxonsiteissueqty = maxissueqty;
11079 $dbh->do(q|
11080 ALTER TABLE default_borrower_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11082 $dbh->do(q|
11083 UPDATE default_borrower_circ_rules SET maxonsiteissueqty = maxissueqty;
11085 $dbh->do(q|
11086 ALTER TABLE default_branch_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11088 $dbh->do(q|
11089 UPDATE default_branch_circ_rules SET maxonsiteissueqty = maxissueqty;
11091 $dbh->do(q|
11092 ALTER TABLE default_circ_rules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11094 $dbh->do(q|
11095 UPDATE default_circ_rules SET maxonsiteissueqty = maxissueqty;
11097 $dbh->do(q|
11098 ALTER TABLE issuingrules ADD COLUMN maxonsiteissueqty int(4) DEFAULT NULL AFTER maxissueqty;
11100 $dbh->do(q|
11101 UPDATE issuingrules SET maxonsiteissueqty = maxissueqty;
11103 $dbh->do(q|
11104 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11105 VALUES ('ConsiderOnSiteCheckoutsAsNormalCheckouts','1',NULL,'Consider on-site checkouts as normal checkouts','YesNo');
11108 print "Upgrade to $DBversion done (Bug 14045: Add DB fields maxonsiteissueqty and pref ConsiderOnSiteCheckoutsAsNormalCheckouts)\n";
11109 SetVersion ($DBversion);
11112 $DBversion = "3.21.00.036";
11113 if ( CheckVersion($DBversion) ) {
11114 $dbh->do(q{
11115 ALTER TABLE authorised_values_branches
11116 DROP FOREIGN KEY authorised_values_branches_ibfk_1,
11117 DROP FOREIGN KEY authorised_values_branches_ibfk_2
11119 $dbh->do(q{
11120 ALTER TABLE authorised_values_branches
11121 MODIFY av_id INT( 11 ) NOT NULL,
11122 MODIFY branchcode VARCHAR( 10 ) NOT NULL,
11123 ADD FOREIGN KEY (`av_id`) REFERENCES `authorised_values` (`id`) ON DELETE CASCADE,
11124 ADD FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
11126 print "Upgrade to $DBversion done (Bug 10363: There is no package for authorised values)\n";
11127 SetVersion($DBversion);
11130 $DBversion = "3.21.00.037";
11131 if ( CheckVersion($DBversion) ) {
11132 $dbh->do(q{
11133 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11134 VALUES ('OverduesBlockRenewing','allow','If any of a patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|block','Choice')
11136 $dbh->do(q{
11137 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11138 VALUES ('RestrictionBlockRenewing','0','If patron is restricted, should renewal be allowed or blocked',NULL,'YesNo')
11140 print "Upgrade to $DBversion done (Bug 8236: Prevent renewing if overdue or restriction)\n";
11141 SetVersion($DBversion);
11144 $DBversion = "3.21.00.038";
11145 if ( CheckVersion($DBversion) ) {
11146 $dbh->do(q|
11147 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11148 VALUES ('BatchCheckouts','0','','Enable or disable batch checkouts','YesNo')
11150 $dbh->do(q|
11151 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11152 VALUES ('BatchCheckoutsValidCategories','',NULL,'Patron categories allowed to checkout in a batch','Free')
11154 print "Upgrade to $DBversion done (Bug 11759: Add the batch checkout feature)\n";
11155 SetVersion($DBversion);
11158 $DBversion = "3.21.00.039";
11159 if ( CheckVersion($DBversion) ) {
11160 $dbh->do(q|
11161 ALTER TABLE creator_layouts ADD COLUMN oblique_title INT(1) NULL DEFAULT 1 AFTER guidebox
11163 print "Upgrade to $DBversion done (Bug 12194: Add column oblique_title to layouts)\n";
11164 SetVersion($DBversion);
11167 $DBversion = "3.21.00.040";
11168 if ( CheckVersion($DBversion) ) {
11169 $dbh->do(q{
11170 ALTER TABLE itemtypes
11171 ADD hideinopac TINYINT(1) NOT NULL DEFAULT 0
11172 AFTER sip_media_type,
11173 ADD searchcategory VARCHAR(80) DEFAULT NULL
11174 AFTER hideinopac;
11176 print "Upgrade to $DBversion done (Bug 10937: Option to hide and group itemtypes from advanced search)\n";
11177 SetVersion($DBversion);
11180 $DBversion = "3.21.00.041";
11181 if ( CheckVersion($DBversion) ) {
11182 $dbh->do(q|
11183 ALTER TABLE issuingrules
11184 ADD chargeperiod_charge_at BOOLEAN NOT NULL DEFAULT '0' AFTER chargeperiod
11186 print "Upgrade to $DBversion done (Bug 13590: Add ability to charge fines at start of charge period)\n";
11187 SetVersion($DBversion);
11190 $DBversion = "3.21.00.042";
11191 if ( CheckVersion($DBversion) ) {
11192 $dbh->do(q|
11193 ALTER TABLE items_search_fields
11194 MODIFY COLUMN authorised_values_category VARCHAR(32) DEFAULT NULL
11196 print "Upgrade to $DBversion done (Bug 15069: items_search_fields.authorised_values_category is still a varchar(32))\n";
11197 SetVersion($DBversion);
11200 $DBversion = "3.21.00.043";
11201 if ( CheckVersion($DBversion) ) {
11202 $dbh->do(q|
11203 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11204 VALUES ('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo')
11206 print "Upgrade to $DBversion done (Bug 11559: Professional cataloger's interface)\n";
11207 SetVersion($DBversion);
11210 $DBversion = "3.21.00.044";
11211 if ( CheckVersion($DBversion) ) {
11212 $dbh->do(q|
11213 CREATE TABLE localization (
11214 localization_id int(11) NOT NULL AUTO_INCREMENT,
11215 entity varchar(16) COLLATE utf8_unicode_ci NOT NULL,
11216 code varchar(64) COLLATE utf8_unicode_ci NOT NULL,
11217 lang varchar(25) COLLATE utf8_unicode_ci NOT NULL,
11218 translation text COLLATE utf8_unicode_ci,
11219 PRIMARY KEY (localization_id),
11220 UNIQUE KEY entity_code_lang (entity,code,lang)
11221 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
11223 print "Upgrade to $DBversion done (Bug 14100: Generic solution for language overlay)\n";
11224 SetVersion($DBversion);
11227 $DBversion = "3.21.00.045";
11228 if ( CheckVersion($DBversion) ) {
11229 $dbh->do(q|
11230 ALTER TABLE opac_news
11231 ADD borrowernumber int(11) default NULL
11232 AFTER number
11234 $dbh->do(q|
11235 ALTER TABLE opac_news
11236 ADD CONSTRAINT borrowernumber_fk
11237 FOREIGN KEY (borrowernumber)
11238 REFERENCES borrowers (borrowernumber)
11239 ON DELETE SET NULL ON UPDATE CASCADE
11241 print "Upgrade to $DBversion done (Bug 14246: (newsauthor) Add borrowernumber to koha_news)\n";
11242 SetVersion($DBversion);
11245 $DBversion = "3.21.00.046";
11246 if ( CheckVersion($DBversion) ) {
11247 $dbh->do(q{
11248 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11249 VALUES ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice')
11251 print "Upgrade to $DBversion done (Bug 14247: (newsauthor) System preference for news author display)\n";
11252 SetVersion($DBversion);
11255 $DBversion = "3.21.00.047";
11256 if(CheckVersion($DBversion)) {
11257 $dbh->do(q{
11258 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11259 VALUES ('IndependentBranchesPatronModifications','0','Show only modification request for the logged in branch','','YesNo')
11261 print "Upgrade to $DBversion done (Bug 10904: Limit patron update request management by branch)\n";
11262 SetVersion($DBversion);
11265 $DBversion = '3.21.00.048';
11266 if ( CheckVersion($DBversion) ) {
11267 my $create_table_issues = @{ $dbh->selectall_arrayref(q|SHOW CREATE TABLE issues|) }[0]->[1];
11268 if ($create_table_issues !~ m|UNIQUE KEY.*itemnumber| ) {
11269 $dbh->do(q|ALTER TABLE issues ADD CONSTRAINT UNIQUE KEY (itemnumber)|);
11271 print "Upgrade to $DBversion done (Bug 14978: Make sure issues.itemnumber is a unique key)\n";
11272 SetVersion($DBversion);
11275 $DBversion = "3.21.00.049";
11276 if ( CheckVersion($DBversion) ) {
11277 $dbh->do(q{UPDATE systempreferences SET variable = 'AudioAlerts' WHERE variable = 'soundon'});
11279 $dbh->do(q{
11280 CREATE TABLE audio_alerts (
11281 id int(11) NOT NULL AUTO_INCREMENT,
11282 precedence smallint(5) unsigned NOT NULL,
11283 selector varchar(255) NOT NULL,
11284 sound varchar(255) NOT NULL,
11285 PRIMARY KEY (id),
11286 KEY precedence (precedence)
11287 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
11290 $dbh->do(q{
11291 INSERT IGNORE INTO audio_alerts VALUES
11292 (1, 1, '.audio-alert-action', 'opening.ogg'),
11293 (2, 2, '.audio-alert-warning', 'critical.ogg'),
11294 (3, 3, '.audio-alert-success', 'beep.ogg');
11297 print "Upgrade to $DBversion done (Bug 11431: Add additional sound options for warnings)\n";
11298 SetVersion($DBversion);
11301 $DBversion = "3.21.00.050";
11302 if(CheckVersion($DBversion)) {
11303 $dbh->do(q{
11304 INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
11305 VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
11307 <item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
11308 ', 'print' )
11310 print "Upgrade to $DBversion done (Bug 12933: Add ability to print overdue slip from staff intranet)\n";
11311 SetVersion($DBversion);
11314 $DBversion = "3.21.00.051";
11315 if ( CheckVersion($DBversion) ) {
11316 $dbh->do(q{
11317 ALTER TABLE virtualshelves
11318 CHANGE COLUMN sortfield sortfield VARCHAR(16) DEFAULT 'title'
11320 $dbh->do(q{
11321 UPDATE virtualshelves
11322 SET sortfield='title'
11323 WHERE sortfield IS NULL;
11325 print "Upgrade to $DBversion done (Bug 14544: Move the list related code to Koha::Virtualshelves)\n";
11326 SetVersion($DBversion);
11329 $DBversion = "3.21.00.052";
11330 if ( CheckVersion($DBversion) ) {
11331 $dbh->do(q{
11332 ALTER TABLE serial
11333 ADD COLUMN publisheddatetext VARCHAR(100) DEFAULT NULL AFTER publisheddate
11335 print "Upgrade to $DBversion done (Bug 8296: Add descriptive (text) published date field for serials)\n";
11336 SetVersion($DBversion);
11339 $DBversion = "3.21.00.053";
11340 if ( CheckVersion($DBversion) ) {
11341 my $query = q{ SELECT * FROM itemtypes ORDER BY description };
11342 my $sth = C4::Context->dbh->prepare($query);
11343 $sth->execute;
11344 my $suggestion_formats = $sth->fetchall_arrayref( {} );
11346 foreach my $format (@$suggestion_formats) {
11347 $dbh->do(
11349 INSERT IGNORE INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl)
11350 VALUES (?, ?, ?, ?, ?)
11351 |, {},
11352 'SUGGEST_FORMAT', $format->{itemtype}, $format->{description}, $format->{description},
11353 $format->{imageurl}
11356 print "Upgrade to $DBversion done (Bug 9468: create new SUGGEST_FORMAT authorised_value list)\n";
11357 SetVersion($DBversion);
11360 $DBversion = "3.21.00.054";
11361 if(CheckVersion($DBversion)) {
11362 $dbh->do(q{
11363 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
11364 VALUES('MergeReportFields','','Displayed fields for deleted MARC records after merge',NULL,'Free')
11366 print "Upgrade to $DBversion done (Bug 8064: Merge several biblio records)\n";
11367 SetVersion($DBversion);
11370 $DBversion = "3.21.00.055";
11371 if ( CheckVersion($DBversion) ) {
11372 print "Upgrade to $DBversion done (Koha 3.22 beta)\n";
11373 SetVersion($DBversion);
11376 $DBversion = "3.21.00.056";
11377 if(CheckVersion($DBversion)) {
11378 $dbh->do(q{
11379 UPDATE systempreferences
11381 options='metric|us|iso|dmydot',
11382 explanation='Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, DMY separated by dots dd.mm.yyyy)'
11383 WHERE variable='dateformat'
11385 print "Upgrade to $DBversion done (Bug 12072: New dateformat dd.mm.yyyy)\n";
11386 SetVersion($DBversion);
11389 $DBversion = "3.22.00.000";
11390 if ( CheckVersion($DBversion) ) {
11391 print "Upgrade to $DBversion done (Koha 3.22)\n";
11392 SetVersion($DBversion);
11395 $DBversion = "3.22.01.000";
11396 if ( CheckVersion($DBversion) ) {
11397 print "Upgrade to $DBversion done (Koha 3.22.1)\n";
11398 SetVersion($DBversion);
11401 $DBversion = "3.22.01.001";
11402 if ( CheckVersion($DBversion) ) {
11403 $dbh->do(q{
11404 INSERT IGNORE INTO systempreferences
11405 (`variable`, `value`, `explanation`, `options`, `type`)
11406 VALUES
11407 ('MaxSearchResultsItemsPerRecordStatusCheck', '20', 'Max number of items per record for which to check transit and hold status', '', 'Integer')
11410 print "Upgrade to $DBversion done (Bug 13022 - Hardcoded limit causes records with more than 20 items to show inaccurate statuses)\n";
11411 SetVersion($DBversion);
11414 $DBversion = "3.22.02.000";
11415 if ( CheckVersion($DBversion) ) {
11416 print "Upgrade to $DBversion done (Koha 3.22.2)\n";
11417 SetVersion($DBversion);
11420 $DBversion = "3.22.02.001";
11421 if ( CheckVersion($DBversion) ) {
11422 $dbh->do(q{
11423 DELETE FROM uploaded_files
11424 WHERE COALESCE(permanent,0)=0 AND dir='koha_upload'
11427 my $tmp = File::Spec->tmpdir . '/koha_upload';
11428 remove_tree( $tmp ) if -d $tmp;
11430 print "Upgrade to $DBversion done (Bug 14893 - Separate temporary storage per instance in Upload.pm)\n";
11431 SetVersion($DBversion);
11434 $DBversion = "3.22.02.002";
11435 if ( CheckVersion($DBversion) ) {
11436 $dbh->do(q{
11437 UPDATE permissions SET description = 'Manage circulation rules' WHERE description = 'manage circulation rules'
11439 $dbh->do(q{
11440 UPDATE permissions SET description = 'Manage staged MARC records, including completing and reversing imports' WHERE description = 'Managed staged MARC records, including completing and reversing imports'
11442 print "Upgrade to $DBversion done (Bug 11569 - Typo in userpermissions.sql)\n";
11443 SetVersion($DBversion);
11446 $DBversion = "3.22.03.000";
11447 if ( CheckVersion($DBversion) ) {
11448 print "Upgrade to $DBversion done (Koha 3.22.3)\n";
11449 SetVersion($DBversion);
11452 $DBversion = "3.22.03.001";
11453 if ( CheckVersion($DBversion) ) {
11454 $dbh->do(q{
11455 UPDATE `authorised_values` SET `lib`='Non-fiction' WHERE `lib`='Non Fiction';
11458 print "Upgrade to $DBversion done (Bug 15411 - Change Non Fiction to Non-fiction in authorised_values)\n";
11459 SetVersion($DBversion);
11462 $DBversion = "3.22.03.002";
11463 if ( CheckVersion($DBversion) ) {
11464 $dbh->do(q{ ALTER TABLE tags_all MODIFY COLUMN borrowernumber INT(11) });
11465 $dbh->do(q{ ALTER TABLE tags_all drop FOREIGN KEY tags_borrowers_fk_1 });
11466 $dbh->do(q{ ALTER TABLE tags_all ADD CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE });
11467 $dbh->do(q{ ALTER TABLE tags_approval DROP FOREIGN KEY tags_approval_borrowers_fk_1 });
11468 $dbh->do(q{ ALTER TABLE tags_approval ADD CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE });
11470 print "Upgrade to $DBversion done (Bug 13534 - Deleting staff patron will delete tags approved by this patron)\n";
11471 SetVersion($DBversion);
11474 $DBversion = "3.22.03.003";
11475 if ( CheckVersion($DBversion) ) {
11476 $dbh->do(q{
11477 ALTER TABLE deletedborrowers MODIFY COLUMN userid VARCHAR(75) DEFAULT NULL;
11479 $dbh->do(q{
11480 ALTER TABLE deletedborrowers MODIFY COLUMN password VARCHAR(60) DEFAULT NULL;
11482 print "Upgrade to $DBversion done (Bug 15517 - Tables borrowers and deletedborrowers differ again)\n";
11483 SetVersion($DBversion);
11486 $DBversion = "3.22.04.000";
11487 if ( CheckVersion($DBversion) ) {
11488 print "Upgrade to $DBversion done (Koha 3.22.4)\n";
11489 SetVersion($DBversion);
11492 $DBversion = "3.22.04.001";
11493 if ( CheckVersion($DBversion) ) {
11494 $dbh->do(q{
11495 INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ShowAllCheckins', '0', '', 'Show all checkins', 'YesNo');
11497 print "Upgrade to $DBversion done (Bug 15736 - Add a preference to control whether all items should be shown in checked-in items list)\n";
11498 SetVersion($DBversion);
11501 $DBversion = "3.22.04.002";
11502 if ( CheckVersion($DBversion) ) {
11503 $dbh->do(q{
11504 DROP TABLE IF EXISTS nozebra;
11506 print "Upgrade to $DBversion done (Bug 15526 - Drop nozebra database table)\n";
11507 SetVersion($DBversion);
11510 $DBversion = "3.22.04.003";
11511 if ( CheckVersion($DBversion) ) {
11512 $dbh->do(q{
11513 UPDATE systempreferences SET value="0" where type="YesNo" and value="";
11516 print "Upgrade to $DBversion done (Bug 15446 - Fix systempreferences rows where type=YesNo and value='')\n";
11517 SetVersion($DBversion);
11520 $DBversion = "3.22.05.000";
11521 if ( CheckVersion($DBversion) ) {
11522 print "Upgrade to $DBversion done (Koha 3.22.5)\n";
11523 SetVersion($DBversion);
11526 $DBversion = "3.22.06.000";
11527 if ( CheckVersion($DBversion) ) {
11528 print "Upgrade to $DBversion done (Koha 3.22.6)\n";
11529 SetVersion($DBversion);
11532 $DBversion = "3.22.06.001";
11533 if ( CheckVersion($DBversion) ) {
11534 my $letters = $dbh->selectall_arrayref(q|
11535 SELECT code, name
11536 FROM letter
11537 WHERE message_transport_type="email"
11538 |, { Slice => {} });
11540 for my $letter ( @$letters ) {
11541 $dbh->do(q|
11542 UPDATE letter
11543 SET name = ?
11544 WHERE code = ?
11545 AND message_transport_type <> "email"
11546 |, undef, $letter->{name}, $letter->{code});
11549 print "Upgrade to $DBversion done (Bug 16217 - Notice' names may have diverged)\n";
11550 SetVersion($DBversion);
11553 $DBversion = "3.22.06.002";
11554 if ( CheckVersion($DBversion) ) {
11556 my ($count_imageurl) = $dbh->selectrow_array(q|
11557 SELECT COUNT(*)
11558 FROM authorised_values
11559 WHERE imageurl IS NOT NULL
11560 AND imageurl <> ""
11563 unless ($count_imageurl) {
11564 if ( C4::Context->preference('AuthorisedValueImages')
11565 or C4::Context->preference('StaffAuthorisedValueImages') )
11567 $dbh->do(q|
11568 UPDATE systempreferences
11569 SET value = 0
11570 WHERE variable = "AuthorisedValueImages"
11571 or variable = "StaffAuthorisedValueImages"
11573 warn "The system preferences AuthorisedValueImages and StaffAuthorisedValueImages have been turned off\n";
11574 warn "authorised_values.imageurl is not populated, that means you are not using this feature\n";
11577 else {
11578 warn "At least one authorised value has an icon defined (imageurl)\n";
11579 warn "The system preference AuthorisedValueImages or StaffAuthorisedValueImages could be turned off if you are not aware of this feature\n";
11582 print "Upgrade to $DBversion done (Bug 16041 - StaffAuthorisedValueImages & AuthorisedValueImages preferences - impact on search performance)\n";
11583 SetVersion($DBversion);
11586 $DBversion = "3.22.06.003";
11587 if ( CheckVersion($DBversion) ) {
11588 my ( $cnt ) = $dbh->selectrow_array( q|
11589 SELECT COUNT(*) FROM items it
11590 LEFT JOIN biblio bi ON bi.biblionumber=it.biblionumber
11591 LEFT JOIN biblioitems bii USING (biblioitemnumber)
11592 WHERE bi.biblionumber IS NULL
11594 if( $cnt ) {
11595 print "WARNING: You have corrupted data in your items table!! The table contains $cnt references to biblio records that do not exist.\nPlease correct your data IMMEDIATELY after this upgrade and manually add the foreign key constraint for biblionumber in the items table.\n";
11596 } else {
11597 # now add FK
11598 $dbh->do( q|
11599 ALTER TABLE items
11600 ADD FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
11602 print "Upgrade to $DBversion done (Bug 16170 - Add FK for biblionumber in items)\n";
11604 SetVersion($DBversion);
11607 $DBversion = "3.22.06.004";
11608 if ( CheckVersion($DBversion) ) {
11609 $dbh->do(q{
11610 UPDATE letter SET branchcode='' WHERE branchcode IS NULL;
11612 $dbh->do(q{
11613 ALTER TABLE letter MODIFY COLUMN branchcode varchar(10) NOT NULL DEFAULT ''
11615 $dbh->do(q{
11616 ALTER TABLE permissions MODIFY COLUMN code varchar(64) NOT NULL DEFAULT '';
11618 print "Upgrade to $DBversion done (Bug 16402: Fix DB structure to work on MySQL 5.7)\n";
11619 SetVersion($DBversion);
11622 $DBversion = "3.22.06.005";
11623 if ( CheckVersion($DBversion) ) {
11624 $dbh->do(q{
11625 ALTER TABLE creator_layouts MODIFY layout_name char(25) NOT NULL DEFAULT 'DEFAULT';
11627 print "Upgrade to $DBversion done (Bug 15086 - Creators layout and template sql has warnings)\n";
11628 SetVersion($DBversion);
11631 $DBversion = "3.22.07.000";
11632 if ( CheckVersion($DBversion) ) {
11633 print "Upgrade to $DBversion done (Koha 3.22.7)\n";
11634 SetVersion($DBversion);
11637 $DBversion = "3.22.07.001";
11638 if ( CheckVersion($DBversion) ) {
11639 $dbh->do(q{
11640 UPDATE accountlines
11641 SET accounttype='HE', description=itemnumber
11642 WHERE (description REGEXP '^Hold waiting too long [0-9]+')
11643 AND accounttype='F';
11645 print "Upgrade to $DBversion done (Bug 16200 - 'Hold waiting too long' fee has a translation problem)\n";
11646 SetVersion($DBversion);
11649 $DBversion = "3.22.08.000";
11650 if ( CheckVersion($DBversion) ) {
11651 print "Upgrade to $DBversion done (Koha 3.22.8)\n";
11652 SetVersion($DBversion);
11655 $DBversion = "3.22.08.001";
11656 if ( CheckVersion($DBversion) ) {
11657 $dbh->do(q{
11658 ALTER TABLE borrowers
11659 ADD COLUMN updated_on timestamp NULL DEFAULT CURRENT_TIMESTAMP
11660 ON UPDATE CURRENT_TIMESTAMP
11661 AFTER privacy;
11663 $dbh->do(q{
11664 ALTER TABLE deletedborrowers
11665 ADD COLUMN updated_on timestamp NULL DEFAULT CURRENT_TIMESTAMP
11666 ON UPDATE CURRENT_TIMESTAMP
11667 AFTER privacy;
11669 print "Upgrade to $DBversion done (Bug 10459 - borrowers should have a timestamp)\n";
11670 SetVersion($DBversion);
11673 $DBversion = "3.22.09.000";
11674 if ( CheckVersion($DBversion) ) {
11675 print "Upgrade to $DBversion done (Koha 3.22.9)\n";
11676 SetVersion($DBversion);
11679 $DBversion = "3.22.09.001";
11680 if ( CheckVersion($DBversion) ) {
11681 print "Upgrade to $DBversion done. (Bug 15006: Distinguish SIP2 client timeout from login timeout.)\nWarning to Koha System Administrators: If you're using SIP2 Server, and encounter 'instability' after upgrade, you may have to tweak your SIP2 config file, and use 'client_timeout' new parameter.";
11682 SetVersion($DBversion);
11685 $DBversion = '3.22.09.002';
11686 if ( CheckVersion($DBversion) ) {
11687 $dbh->do(q{
11688 ALTER TABLE virtualshelves MODIFY COLUMN created_on DATETIME not NULL;
11691 print "Upgrade to $DBversion done (Bug 16573 - Web installer fails to load structure and sample data on MySQL 5.7)\n";
11692 SetVersion($DBversion);
11695 $DBversion = '3.22.09.003';
11696 if ( CheckVersion($DBversion) ) {
11697 $dbh->do(q{
11698 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11699 SELECT 'MaxItemsToProcessForBatchMod', value, NULL, 'Process up to a given number of items in a single item modification batch.', 'Integer' FROM systempreferences WHERE variable='MaxItemsForBatch';
11701 $dbh->do(q{
11702 INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type )
11703 SELECT 'MaxItemsToDisplayForBatchDel', value, NULL, 'Display up to a given number of items in a single item deletionbatch.', 'Integer' FROM systempreferences WHERE variable='MaxItemsForBatch';
11705 $dbh->do(q{
11706 DELETE FROM systempreferences WHERE variable="MaxItemsForBatch";
11709 print "Upgrade to $DBversion done (Bug 11490 - MaxItemsForBatch should be split into two new prefs)\n";
11710 SetVersion($DBversion);
11713 $DBversion = '3.22.09.004';
11714 if ( CheckVersion($DBversion) ) {
11715 $dbh->do(q{
11716 INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES
11717 ('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice');
11720 print "Upgrade to $DBversion done (Bug 7441 - Search results showing wrong branch)\n";
11721 SetVersion($DBversion);
11724 $DBversion = "3.22.10.000";
11725 if ( CheckVersion($DBversion) ) {
11726 print "Upgrade to $DBversion done (Koha 3.22.10)\n";
11727 SetVersion($DBversion);
11730 $DBversion = "3.22.10.001";
11731 if ( CheckVersion($DBversion) ) {
11732 $dbh->do(q{
11733 UPDATE language_descriptions SET description = 'Română' WHERE subtag = 'ro' AND type = 'language' AND lang = 'ro';
11736 print "Upgrade to $DBversion done (Bug 17187 - Advanced search language limit typo for Romanian).\n";
11737 SetVersion($DBversion);
11740 $DBversion = "3.22.11.000";
11741 if ( CheckVersion($DBversion) ) {
11742 print "Upgrade to $DBversion done (Koha 3.22.11)\n";
11743 SetVersion($DBversion);
11746 $DBversion = "3.22.11.001";
11747 if ( CheckVersion($DBversion) ) {
11748 $dbh->do(q{
11749 UPDATE systempreferences SET type="Choice" WHERE variable="UsageStatsLibraryType";
11751 $dbh->do(q{
11752 UPDATE systempreferences SET value="Canada" WHERE variable="UsageStatsCountry" AND value="CANADA";
11754 $dbh->do(q{
11755 UPDATE systempreferences SET value="Czech Republic" WHERE variable="UsageStatsCountry" AND value="CZ";
11757 $dbh->do(q{
11758 UPDATE systempreferences SET value="United Kingdom" WHERE variable="UsageStatsCountry" AND (value="England" OR value="UK");
11760 $dbh->do(q{
11761 UPDATE systempreferences SET value="Spain" WHERE variable="UsageStatsCountry" AND value="España";
11763 $dbh->do(q{
11764 UPDATE systempreferences SET value="Greece" WHERE variable="UsageStatsCountry" AND value="GR";
11766 $dbh->do(q{
11767 UPDATE systempreferences SET value="Ireland" WHERE variable="UsageStatsCountry" AND value="Irelanbd";
11769 $dbh->do(q{
11770 UPDATE systempreferences SET value="Mexico" WHERE variable="UsageStatsCountry" AND value="México";
11772 $dbh->do(q{
11773 UPDATE systempreferences SET value="Peru" WHERE variable="UsageStatsCountry" AND value="Perú";
11775 $dbh->do(q{
11776 UPDATE systempreferences SET value="Dominican Rep." WHERE variable="UsageStatsCountry" AND value="República Dominicana";
11778 $dbh->do(q{
11779 UPDATE systempreferences SET value="Trinidad & Tob." WHERE variable="UsageStatsCountry" AND value="Trinidad";
11781 $dbh->do(q{
11782 UPDATE systempreferences SET value="Turkey" WHERE variable="UsageStatsCountry" AND value="Türkiye";
11784 $dbh->do(q{
11785 UPDATE systempreferences SET value="USA" WHERE variable="UsageStatsCountry" AND (value="United States" OR value="United States of America" OR value="US");
11787 $dbh->do(q{
11788 UPDATE systempreferences SET value="Zimbabwe" WHERE variable="UsageStatsCountry" AND value="Zimbabbwe";
11791 print "Upgrade to $DBversion done (Bug 14707 - Change UsageStatsCountry from free text to a dropdown list)\n";
11792 SetVersion($DBversion);
11795 $DBversion = "3.22.11.002";
11796 if ( CheckVersion($DBversion) ) {
11797 $dbh->do(q{
11798 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'YYYY', '<<YYYY>>') where defaultvalue like "%YYYY%" and defaultvalue not like "%<<YYYY>>%";
11800 $dbh->do(q{
11801 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'MM', '<<MM>>') where defaultvalue like "%MM%" and defaultvalue not like "%<<MM>>%";
11803 $dbh->do(q{
11804 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'DD', '<<DD>>') where defaultvalue like "%DD%" and defaultvalue not like "%<<DD>>%";
11806 $dbh->do(q{
11807 update marc_subfield_structure set defaultvalue=REPLACE(defaultvalue, 'user', '<<USER>>') where defaultvalue like "%user%" and defaultvalue not like "%<<USER>>%";
11809 print "Upgrade to $DBversion done (Bug 7045 - Default-value substitution inconsistent)\n";
11810 SetVersion($DBversion);
11813 $DBversion = "3.22.11.003";
11814 if ( CheckVersion($DBversion) ) {
11815 $dbh->do(q{
11816 UPDATE marc_subfield_structure SET authorised_value="WITHDRAWN" WHERE authorised_value="WTHDRAWN";
11819 print "Upgrade to $DBversion done (Bug 17357 - WTHDRAWN is still used in installer files)\n";
11820 SetVersion($DBversion);
11823 $DBversion = "3.22.12.000";
11824 if ( CheckVersion($DBversion) ) {
11825 print "Upgrade to $DBversion done (Koha 3.22.12)\n";
11826 SetVersion($DBversion);
11829 $DBversion = '3.22.12.001';
11830 if ( CheckVersion($DBversion) ) {
11831 $dbh->do(q{
11832 UPDATE language_descriptions SET description = 'Čeština' WHERE subtag = 'cs' AND type = 'language' AND lang = 'cs'
11835 print "Upgrade to $DBversion done (Bug 17518: Displayed language name for Czech is wrong)\n";
11836 SetVersion($DBversion);
11839 $DBversion = '3.22.12.002';
11840 if ( CheckVersion($DBversion) ) {
11842 my $sth = $dbh->prepare(q{
11843 SELECT s.itemnumber, i.itype, b.itemtype
11844 FROM
11845 ( SELECT DISTINCT itemnumber
11846 FROM statistics
11847 WHERE ( type = "return" OR type = "localuse" ) AND
11848 itemtype IS NULL
11850 LEFT JOIN
11851 ( SELECT itemnumber,biblionumber, itype
11852 FROM items
11853 UNION
11854 SELECT itemnumber,biblionumber, itype
11855 FROM deleteditems
11857 ON (s.itemnumber=i.itemnumber)
11858 LEFT JOIN
11859 ( SELECT biblionumber, itemtype
11860 FROM biblioitems
11861 UNION
11862 SELECT biblionumber, itemtype
11863 FROM deletedbiblioitems
11865 ON (i.biblionumber=b.biblionumber);
11867 $sth->execute();
11869 my $update_sth = $dbh->prepare(q{
11870 UPDATE statistics
11871 SET itemtype=?
11872 WHERE itemnumber=? AND itemtype IS NULL
11874 my $ilevel_itypes = C4::Context->preference('item-level_itypes');
11876 while ( my ($itemnumber,$item_itype,$biblio_itype) = $sth->fetchrow_array ) {
11878 my $effective_itemtype = $ilevel_itypes
11879 ? $item_itype // $biblio_itype
11880 : $biblio_itype;
11881 warn "item-level_itypes set but no itype defined for item ($itemnumber)"
11882 if $ilevel_itypes and !defined $item_itype;
11883 $update_sth->execute( $effective_itemtype, $itemnumber );
11886 print "Upgrade to $DBversion done (Bug 14598: itemtype is not set on statistics by C4::Circulation::AddReturn)\n";
11887 SetVersion($DBversion);
11890 $DBversion = '3.22.12.003';
11891 if( CheckVersion( $DBversion ) ) {
11892 $dbh->do(q|
11893 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
11894 VALUES ('ReplytoDefault', '', NULL, 'The default email address to be set as replyto.', 'Free');
11897 $dbh->do(q|
11898 INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
11899 VALUES ('ReturnpathDefault', '', NULL, 'The default email address to be set as return-path', 'Free');
11902 SetVersion( $DBversion );
11903 print "Upgrade to $DBversion done (Bug 17391 - ReturnpathDefault and ReplyToDefault missing from syspref.sql)\n";
11906 $DBversion = "3.22.13.000";
11907 if ( CheckVersion($DBversion) ) {
11908 print "Upgrade to $DBversion done (Koha 3.22.13)\n";
11909 SetVersion($DBversion);
11912 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
11913 # SEE bug 13068
11914 # if there is anything in the atomicupdate, read and execute it.
11916 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
11917 opendir( my $dirh, $update_dir );
11918 foreach my $file ( sort readdir $dirh ) {
11919 next if $file !~ /\.(sql|perl)$/; #skip other files
11920 print "DEV atomic update: $file\n";
11921 if ( $file =~ /\.sql$/ ) {
11922 my $installer = C4::Installer->new();
11923 my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
11924 } elsif ( $file =~ /\.perl$/ ) {
11925 do $update_dir . $file;
11929 =head1 FUNCTIONS
11931 =head2 TableExists($table)
11933 =cut
11935 sub TableExists {
11936 my $table = shift;
11937 eval {
11938 local $dbh->{PrintError} = 0;
11939 local $dbh->{RaiseError} = 1;
11940 $dbh->do(qq{SELECT * FROM $table WHERE 1 = 0 });
11942 return 1 unless $@;
11943 return 0;
11946 =head2 DropAllForeignKeys($table)
11948 Drop all foreign keys of the table $table
11950 =cut
11952 sub DropAllForeignKeys {
11953 my ($table) = @_;
11954 # get the table description
11955 my $sth = $dbh->prepare("SHOW CREATE TABLE $table");
11956 $sth->execute;
11957 my $vsc_structure = $sth->fetchrow;
11958 # split on CONSTRAINT keyword
11959 my @fks = split /CONSTRAINT /,$vsc_structure;
11960 # parse each entry
11961 foreach (@fks) {
11962 # isolate what is before FOREIGN KEY, if there is something, it's a foreign key to drop
11963 $_ = /(.*) FOREIGN KEY.*/;
11964 my $id = $1;
11965 if ($id) {
11966 # we have found 1 foreign, drop it
11967 $dbh->do("ALTER TABLE $table DROP FOREIGN KEY $id");
11968 $id="";
11974 =head2 TransformToNum
11976 Transform the Koha version from a 4 parts string
11977 to a number, with just 1 .
11979 =cut
11981 sub TransformToNum {
11982 my $version = shift;
11983 # remove the 3 last . to have a Perl number
11984 $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
11985 # three X's at the end indicate that you are testing patch with dbrev
11986 # change it into 999
11987 # prevents error on a < comparison between strings (should be: lt)
11988 $version =~ s/XXX$/999/;
11989 return $version;
11992 =head2 SetVersion
11994 set the DBversion in the systempreferences
11996 =cut
11998 sub SetVersion {
11999 return if $_[0]=~ /XXX$/;
12000 #you are testing a patch with a db revision; do not change version
12001 my $kohaversion = TransformToNum($_[0]);
12002 if (C4::Context->preference('Version')) {
12003 my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
12004 $finish->execute($kohaversion);
12005 } else {
12006 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')");
12007 $finish->execute($kohaversion);
12009 C4::Context::clear_syspref_cache(); # invalidate cached preferences
12012 =head2 CheckVersion
12014 Check whether a given update should be run when passed the proposed version
12015 number. The update will always be run if the proposed version is greater
12016 than the current database version and less than or equal to the version in
12017 kohaversion.pl. The update is also run if the version contains XXX, though
12018 this behavior will be changed following the adoption of non-linear updates
12019 as implemented in bug 7167.
12021 =cut
12023 sub CheckVersion {
12024 my ($proposed_version) = @_;
12025 my $version_number = TransformToNum($proposed_version);
12027 # The following line should be deleted when bug 7167 is pushed
12028 return 1 if ( $proposed_version =~ m/XXX/ );
12030 if ( C4::Context->preference("Version") < $version_number
12031 && $version_number <= TransformToNum( $Koha::VERSION ) )
12033 return 1;
12035 else {
12036 return 0;
12040 exit;