Bug 7886 - C4/ShelfBrowser slow SQL performance
[koha.git] / installer / data / mysql / updatedatabase.pl
blobfae635182386c8088ee0b700a4abdc4257c7cf1f
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 under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 C4::Dates;
41 use MARC::Record;
42 use MARC::File::XML ( BinaryEncoding => 'utf8' );
44 # FIXME - The user might be installing a new database, so can't rely
45 # on /etc/koha.conf anyway.
47 my $debug = 0;
49 my (
50 $sth, $sti,
51 $query,
52 %existingtables, # tables already in database
53 %types,
54 $table,
55 $column,
56 $type, $null, $key, $default, $extra,
57 $prefitem, # preference item in systempreferences table
60 my $silent;
61 GetOptions(
62 's' =>\$silent
64 my $dbh = C4::Context->dbh;
65 $|=1; # flushes output
68 # Record the version we are coming from
70 my $original_version = C4::Context->preference("Version");
72 # Deal with virtualshelves
73 my $DBversion = "3.00.00.001";
74 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
75 # update virtualshelves table to
77 $dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
78 $dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
79 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
80 $dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
81 # drop all foreign keys : otherwise, we can't drop itemnumber field.
82 DropAllForeignKeys('virtualshelfcontents');
83 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
84 # create the new foreign keys (on biblionumber)
85 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
86 # re-create the foreign key on virtualshelf
87 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
88 $dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
89 print "Upgrade to $DBversion done (virtualshelves)\n";
90 SetVersion ($DBversion);
94 $DBversion = "3.00.00.002";
95 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
96 $dbh->do("DROP TABLE sessions");
97 $dbh->do("CREATE TABLE `sessions` (
98 `id` varchar(32) NOT NULL,
99 `a_session` text NOT NULL,
100 UNIQUE KEY `id` (`id`)
101 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
102 print "Upgrade to $DBversion done (sessions uses CGI::session, new table structure for sessions)\n";
103 SetVersion ($DBversion);
107 $DBversion = "3.00.00.003";
108 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
109 if (C4::Context->preference("opaclanguages") eq "fr") {
110 $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')");
111 } else {
112 $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')");
114 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
115 SetVersion ($DBversion);
119 $DBversion = "3.00.00.004";
120 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
121 $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')");
122 print "Upgrade to $DBversion done (adding DebugLevel systempref, in 'Admin' tab)\n";
123 SetVersion ($DBversion);
126 $DBversion = "3.00.00.005";
127 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
128 $dbh->do("CREATE TABLE `tags` (
129 `entry` varchar(255) NOT NULL default '',
130 `weight` bigint(20) NOT NULL default 0,
131 PRIMARY KEY (`entry`)
132 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
134 $dbh->do("CREATE TABLE `nozebra` (
135 `server` varchar(20) NOT NULL,
136 `indexname` varchar(40) NOT NULL,
137 `value` varchar(250) NOT NULL,
138 `biblionumbers` longtext NOT NULL,
139 KEY `indexname` (`server`,`indexname`),
140 KEY `value` (`server`,`value`))
141 ENGINE=InnoDB DEFAULT CHARSET=utf8;
143 print "Upgrade to $DBversion done (adding tags and nozebra tables )\n";
144 SetVersion ($DBversion);
147 $DBversion = "3.00.00.006";
148 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
149 $dbh->do("UPDATE issues SET issuedate=timestamp WHERE issuedate='0000-00-00'");
150 print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n";
151 SetVersion ($DBversion);
154 $DBversion = "3.00.00.007";
155 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
156 $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')");
157 print "Upgrade to $DBversion done (set SessionStorage variable)\n";
158 SetVersion ($DBversion);
161 $DBversion = "3.00.00.008";
162 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
163 $dbh->do("ALTER TABLE `biblio` ADD `datecreated` DATE NOT NULL AFTER `timestamp` ;");
164 $dbh->do("UPDATE biblio SET datecreated=timestamp");
165 print "Upgrade to $DBversion done (biblio creation date)\n";
166 SetVersion ($DBversion);
169 $DBversion = "3.00.00.009";
170 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
172 # Create backups of call number columns
173 # in case default migration needs to be customized
175 # UPGRADE NOTE: temp_upg_biblioitems_call_num should be dropped
176 # after call numbers have been transformed to the new structure
178 # Not bothering to do the same with deletedbiblioitems -- assume
179 # default is good enough.
180 $dbh->do("CREATE TABLE `temp_upg_biblioitems_call_num` AS
181 SELECT `biblioitemnumber`, `biblionumber`,
182 `classification`, `dewey`, `subclass`,
183 `lcsort`, `ccode`
184 FROM `biblioitems`");
186 # biblioitems changes
187 $dbh->do("ALTER TABLE `biblioitems` CHANGE COLUMN `volumeddesc` `volumedesc` TEXT,
188 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
189 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
190 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
191 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
192 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
193 ADD `totalissues` INT(10) AFTER `cn_sort`");
195 # default mapping of call number columns:
196 # cn_class = concatentation of classification + dewey,
197 # trimmed to fit -- assumes that most users do not
198 # populate both classification and dewey in a single record
199 # cn_item = subclass
200 # cn_source = left null
201 # cn_sort = lcsort
203 # After upgrade, cn_sort will have to be set based on whatever
204 # default call number scheme user sets as a preference. Misc
205 # script will be added at some point to do that.
207 $dbh->do("UPDATE `biblioitems`
208 SET cn_class = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
209 cn_item = subclass,
210 `cn_sort` = `lcsort`
213 # Now drop the old call number columns
214 $dbh->do("ALTER TABLE `biblioitems` DROP COLUMN `classification`,
215 DROP COLUMN `dewey`,
216 DROP COLUMN `subclass`,
217 DROP COLUMN `lcsort`,
218 DROP COLUMN `ccode`");
220 # deletedbiblio changes
221 $dbh->do("ALTER TABLE `deletedbiblio` ALTER COLUMN `frameworkcode` SET DEFAULT '',
222 DROP COLUMN `marc`,
223 ADD `datecreated` DATE NOT NULL AFTER `timestamp`");
224 $dbh->do("UPDATE deletedbiblio SET datecreated = timestamp");
226 # deletedbiblioitems changes
227 $dbh->do("ALTER TABLE `deletedbiblioitems`
228 MODIFY `publicationyear` TEXT,
229 CHANGE `volumeddesc` `volumedesc` TEXT,
230 MODIFY `collectiontitle` MEDIUMTEXT DEFAULT NULL AFTER `volumedesc`,
231 MODIFY `collectionissn` TEXT DEFAULT NULL AFTER `collectiontitle`,
232 MODIFY `collectionvolume` MEDIUMTEXT DEFAULT NULL AFTER `collectionissn`,
233 MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
234 MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
235 MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
236 MODIFY `marc` LONGBLOB,
237 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
238 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
239 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
240 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
241 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
242 ADD `totalissues` INT(10) AFTER `cn_sort`,
243 ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
244 ADD KEY `isbn` (`isbn`),
245 ADD KEY `publishercode` (`publishercode`)
248 $dbh->do("UPDATE `deletedbiblioitems`
249 SET `cn_class` = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
250 `cn_item` = `subclass`,
251 `cn_sort` = `lcsort`
253 $dbh->do("ALTER TABLE `deletedbiblioitems`
254 DROP COLUMN `classification`,
255 DROP COLUMN `dewey`,
256 DROP COLUMN `subclass`,
257 DROP COLUMN `lcsort`,
258 DROP COLUMN `ccode`
261 # deleteditems changes
262 $dbh->do("ALTER TABLE `deleteditems`
263 MODIFY `barcode` VARCHAR(20) DEFAULT NULL,
264 MODIFY `price` DECIMAL(8,2) DEFAULT NULL,
265 MODIFY `replacementprice` DECIMAL(8,2) DEFAULT NULL,
266 DROP `bulk`,
267 MODIFY `itemcallnumber` VARCHAR(30) DEFAULT NULL AFTER `wthdrawn`,
268 MODIFY `holdingbranch` VARCHAR(10) DEFAULT NULL,
269 DROP `interim`,
270 MODIFY `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER `paidfor`,
271 DROP `cutterextra`,
272 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
273 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
274 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
275 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
276 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`,
277 MODIFY `marc` LONGBLOB AFTER `uri`,
278 DROP KEY `barcode`,
279 DROP KEY `itembarcodeidx`,
280 DROP KEY `itembinoidx`,
281 DROP KEY `itembibnoidx`,
282 ADD UNIQUE KEY `delitembarcodeidx` (`barcode`),
283 ADD KEY `delitembinoidx` (`biblioitemnumber`),
284 ADD KEY `delitembibnoidx` (`biblionumber`),
285 ADD KEY `delhomebranch` (`homebranch`),
286 ADD KEY `delholdingbranch` (`holdingbranch`)");
287 $dbh->do("UPDATE deleteditems SET `ccode` = `itype`");
288 $dbh->do("ALTER TABLE deleteditems DROP `itype`");
289 $dbh->do("UPDATE `deleteditems` SET `cn_sort` = `itemcallnumber`");
291 # items changes
292 $dbh->do("ALTER TABLE `items` ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
293 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
294 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
295 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
296 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`
298 $dbh->do("ALTER TABLE `items`
299 DROP KEY `itembarcodeidx`,
300 ADD UNIQUE KEY `itembarcodeidx` (`barcode`)");
302 # map items.itype to items.ccode and
303 # set cn_sort to itemcallnumber -- as with biblioitems.cn_sort,
304 # will have to be subsequently updated per user's default
305 # classification scheme
306 $dbh->do("UPDATE `items` SET `cn_sort` = `itemcallnumber`,
307 `ccode` = `itype`");
309 $dbh->do("ALTER TABLE `items` DROP `cutterextra`,
310 DROP `itype`");
312 print "Upgrade to $DBversion done (major changes to biblio, biblioitems, items, and deleted* versions of same\n";
313 SetVersion ($DBversion);
316 $DBversion = "3.00.00.010";
317 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
318 $dbh->do("CREATE INDEX `userid` ON borrowers (`userid`) ");
319 print "Upgrade to $DBversion done (userid index added)\n";
320 SetVersion ($DBversion);
323 $DBversion = "3.00.00.011";
324 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
325 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
326 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
327 $dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
328 $dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
329 $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
330 print "Upgrade to $DBversion done (added branchcategory type)\n";
331 SetVersion ($DBversion);
334 $DBversion = "3.00.00.012";
335 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
336 $dbh->do("CREATE TABLE `class_sort_rules` (
337 `class_sort_rule` varchar(10) NOT NULL default '',
338 `description` mediumtext,
339 `sort_routine` varchar(30) NOT NULL default '',
340 PRIMARY KEY (`class_sort_rule`),
341 UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
342 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
343 $dbh->do("CREATE TABLE `class_sources` (
344 `cn_source` varchar(10) NOT NULL default '',
345 `description` mediumtext,
346 `used` tinyint(4) NOT NULL default 0,
347 `class_sort_rule` varchar(10) NOT NULL default '',
348 PRIMARY KEY (`cn_source`),
349 UNIQUE KEY `cn_source_idx` (`cn_source`),
350 KEY `used_idx` (`used`),
351 CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`)
352 REFERENCES `class_sort_rules` (`class_sort_rule`)
353 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
354 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type)
355 VALUES('DefaultClassificationSource','ddc',
356 'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'free')");
357 $dbh->do("INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
358 ('dewey', 'Default filing rules for DDC', 'Dewey'),
359 ('lcc', 'Default filing rules for LCC', 'LCC'),
360 ('generic', 'Generic call number filing rules', 'Generic')");
361 $dbh->do("INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
362 ('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
363 ('lcc', 'Library of Congress Classification', 1, 'lcc'),
364 ('udc', 'Universal Decimal Classification', 0, 'generic'),
365 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
366 ('z', 'Other/Generic Classification Scheme', 0, 'generic')");
367 print "Upgrade to $DBversion done (classification sources added)\n";
368 SetVersion ($DBversion);
371 $DBversion = "3.00.00.013";
372 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
373 $dbh->do("CREATE TABLE `import_batches` (
374 `import_batch_id` int(11) NOT NULL auto_increment,
375 `template_id` int(11) default NULL,
376 `branchcode` varchar(10) default NULL,
377 `num_biblios` int(11) NOT NULL default 0,
378 `num_items` int(11) NOT NULL default 0,
379 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
380 `overlay_action` enum('replace', 'create_new', 'use_template') NOT NULL default 'create_new',
381 `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
382 `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
383 `file_name` varchar(100),
384 `comments` mediumtext,
385 PRIMARY KEY (`import_batch_id`),
386 KEY `branchcode` (`branchcode`)
387 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
388 $dbh->do("CREATE TABLE `import_records` (
389 `import_record_id` int(11) NOT NULL auto_increment,
390 `import_batch_id` int(11) NOT NULL,
391 `branchcode` varchar(10) default NULL,
392 `record_sequence` int(11) NOT NULL default 0,
393 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
394 `import_date` DATE default NULL,
395 `marc` longblob NOT NULL,
396 `marcxml` longtext NOT NULL,
397 `marcxml_old` longtext NOT NULL,
398 `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
399 `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
400 `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted') NOT NULL default 'staged',
401 `import_error` mediumtext,
402 `encoding` varchar(40) NOT NULL default '',
403 `z3950random` varchar(40) default NULL,
404 PRIMARY KEY (`import_record_id`),
405 CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
406 REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
407 KEY `branchcode` (`branchcode`),
408 KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
409 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
410 $dbh->do("CREATE TABLE `import_record_matches` (
411 `import_record_id` int(11) NOT NULL,
412 `candidate_match_id` int(11) NOT NULL,
413 `score` int(11) NOT NULL default 0,
414 CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
415 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
416 KEY `record_score` (`import_record_id`, `score`)
417 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
418 $dbh->do("CREATE TABLE `import_biblios` (
419 `import_record_id` int(11) NOT NULL,
420 `matched_biblionumber` int(11) default NULL,
421 `control_number` varchar(25) default NULL,
422 `original_source` varchar(25) default NULL,
423 `title` varchar(128) default NULL,
424 `author` varchar(80) default NULL,
425 `isbn` varchar(14) default NULL,
426 `issn` varchar(9) default NULL,
427 `has_items` tinyint(1) NOT NULL default 0,
428 CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
429 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
430 KEY `matched_biblionumber` (`matched_biblionumber`),
431 KEY `title` (`title`),
432 KEY `isbn` (`isbn`)
433 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
434 $dbh->do("CREATE TABLE `import_items` (
435 `import_items_id` int(11) NOT NULL auto_increment,
436 `import_record_id` int(11) NOT NULL,
437 `itemnumber` int(11) default NULL,
438 `branchcode` varchar(10) default NULL,
439 `status` enum('error', 'staged', 'imported', 'reverted') NOT NULL default 'staged',
440 `marcxml` longtext NOT NULL,
441 `import_error` mediumtext,
442 PRIMARY KEY (`import_items_id`),
443 CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
444 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
445 KEY `itemnumber` (`itemnumber`),
446 KEY `branchcode` (`branchcode`)
447 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
449 $dbh->do("INSERT INTO `import_batches`
450 (`overlay_action`, `import_status`, `batch_type`, `file_name`)
451 SELECT distinct 'create_new', 'staged', 'z3950', `file`
452 FROM `marc_breeding`");
454 $dbh->do("INSERT INTO `import_records`
455 (`import_batch_id`, `import_record_id`, `record_sequence`, `marc`, `record_type`, `status`,
456 `encoding`, `z3950random`, `marcxml`, `marcxml_old`)
457 SELECT `import_batch_id`, `id`, 1, `marc`, 'biblio', 'staged', `encoding`, `z3950random`, '', ''
458 FROM `marc_breeding`
459 JOIN `import_batches` ON (`file_name` = `file`)");
461 $dbh->do("INSERT INTO `import_biblios`
462 (`import_record_id`, `title`, `author`, `isbn`)
463 SELECT `import_record_id`, `title`, `author`, `isbn`
464 FROM `marc_breeding`
465 JOIN `import_records` ON (`import_record_id` = `id`)");
467 $dbh->do("UPDATE `import_batches`
468 SET `num_biblios` = (
469 SELECT COUNT(*)
470 FROM `import_records`
471 WHERE `import_batch_id` = `import_batches`.`import_batch_id`
472 )");
474 $dbh->do("DROP TABLE `marc_breeding`");
476 print "Upgrade to $DBversion done (import_batches et al. added)\n";
477 SetVersion ($DBversion);
480 $DBversion = "3.00.00.014";
481 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
482 $dbh->do("ALTER TABLE subscription ADD lastbranch VARCHAR(4)");
483 print "Upgrade to $DBversion done (userid index added)\n";
484 SetVersion ($DBversion);
487 $DBversion = "3.00.00.015";
488 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
489 $dbh->do("CREATE TABLE `saved_sql` (
490 `id` int(11) NOT NULL auto_increment,
491 `borrowernumber` int(11) default NULL,
492 `date_created` datetime default NULL,
493 `last_modified` datetime default NULL,
494 `savedsql` text,
495 `last_run` datetime default NULL,
496 `report_name` varchar(255) default NULL,
497 `type` varchar(255) default NULL,
498 `notes` text,
499 PRIMARY KEY (`id`),
500 KEY boridx (`borrowernumber`)
501 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
502 $dbh->do("CREATE TABLE `saved_reports` (
503 `id` int(11) NOT NULL auto_increment,
504 `report_id` int(11) default NULL,
505 `report` longtext,
506 `date_run` datetime default NULL,
507 PRIMARY KEY (`id`)
508 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
509 print "Upgrade to $DBversion done (saved_sql and saved_reports added)\n";
510 SetVersion ($DBversion);
513 $DBversion = "3.00.00.016";
514 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
515 $dbh->do(" CREATE TABLE reports_dictionary (
516 id int(11) NOT NULL auto_increment,
517 name varchar(255) default NULL,
518 description text,
519 date_created datetime default NULL,
520 date_modified datetime default NULL,
521 saved_sql text,
522 area int(11) default NULL,
523 PRIMARY KEY (id)
524 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
525 print "Upgrade to $DBversion done (reports_dictionary) added)\n";
526 SetVersion ($DBversion);
529 $DBversion = "3.00.00.017";
530 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
531 $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
532 $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)");
533 $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
534 $dbh->do("UPDATE action_logs SET action_id = if (\@a, \@a:=\@a+1, \@a:=1)");
535 $dbh->do("ALTER TABLE action_logs MODIFY action_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY");
536 print "Upgrade to $DBversion done (added column to action_logs)\n";
537 SetVersion ($DBversion);
540 $DBversion = "3.00.00.018";
541 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
542 $dbh->do("ALTER TABLE `zebraqueue`
543 ADD `done` INT NOT NULL DEFAULT '0',
544 ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
546 print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
547 SetVersion ($DBversion);
550 $DBversion = "3.00.00.019";
551 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
552 $dbh->do("ALTER TABLE biblio MODIFY biblionumber INT(11) NOT NULL AUTO_INCREMENT");
553 $dbh->do("ALTER TABLE biblioitems MODIFY biblioitemnumber INT(11) NOT NULL AUTO_INCREMENT");
554 $dbh->do("ALTER TABLE items MODIFY itemnumber INT(11) NOT NULL AUTO_INCREMENT");
555 print "Upgrade to $DBversion done (made bib/item PKs auto_increment)\n";
556 SetVersion ($DBversion);
559 $DBversion = "3.00.00.020";
560 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
561 $dbh->do("ALTER TABLE deleteditems
562 DROP KEY `delitembarcodeidx`,
563 ADD KEY `delitembarcodeidx` (`barcode`)");
564 print "Upgrade to $DBversion done (dropped uniqueness of key on deleteditems.barcode)\n";
565 SetVersion ($DBversion);
568 $DBversion = "3.00.00.021";
569 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
570 $dbh->do("ALTER TABLE items CHANGE homebranch homebranch VARCHAR(10)");
571 $dbh->do("ALTER TABLE deleteditems CHANGE homebranch homebranch VARCHAR(10)");
572 $dbh->do("ALTER TABLE statistics CHANGE branch branch VARCHAR(10)");
573 $dbh->do("ALTER TABLE subscription CHANGE lastbranch lastbranch VARCHAR(10)");
574 print "Upgrade to $DBversion done (extended missed branchcode columns to 10 chars)\n";
575 SetVersion ($DBversion);
578 $DBversion = "3.00.00.022";
579 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
580 $dbh->do("ALTER TABLE items
581 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
582 $dbh->do("ALTER TABLE deleteditems
583 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
584 print "Upgrade to $DBversion done (adding damaged column to items table)\n";
585 SetVersion ($DBversion);
588 $DBversion = "3.00.00.023";
589 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
590 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
591 VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
592 print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
593 SetVersion ($DBversion);
595 $DBversion = "3.00.00.024";
596 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
597 $dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
598 print "Upgrade to $DBversion done (changing itemtype to (10))\n";
599 SetVersion ($DBversion);
602 $DBversion = "3.00.00.025";
603 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
604 $dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
605 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
606 if(C4::Context->preference('item-level_itypes')){
607 $dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
609 print "Upgrade to $DBversion done (reintroduce items.itype - fill from itemtype)\n ";
610 SetVersion ($DBversion);
613 $DBversion = "3.00.00.026";
614 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
615 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
616 VALUES ('HomeOrHoldingBranch','homebranch','homebranch|holdingbranch','With independent branches turned on this decides whether to check the items holdingbranch or homebranch at circulatilon','choice')");
617 print "Upgrade to $DBversion done (adding new system preference for choosing whether homebranch or holdingbranch is checked in circulation)\n";
618 SetVersion ($DBversion);
621 $DBversion = "3.00.00.027";
622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
623 $dbh->do("CREATE TABLE `marc_matchers` (
624 `matcher_id` int(11) NOT NULL auto_increment,
625 `code` varchar(10) NOT NULL default '',
626 `description` varchar(255) NOT NULL default '',
627 `record_type` varchar(10) NOT NULL default 'biblio',
628 `threshold` int(11) NOT NULL default 0,
629 PRIMARY KEY (`matcher_id`),
630 KEY `code` (`code`),
631 KEY `record_type` (`record_type`)
632 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
633 $dbh->do("CREATE TABLE `matchpoints` (
634 `matcher_id` int(11) NOT NULL,
635 `matchpoint_id` int(11) NOT NULL auto_increment,
636 `search_index` varchar(30) NOT NULL default '',
637 `score` int(11) NOT NULL default 0,
638 PRIMARY KEY (`matchpoint_id`),
639 CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
640 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
641 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
642 $dbh->do("CREATE TABLE `matchpoint_components` (
643 `matchpoint_id` int(11) NOT NULL,
644 `matchpoint_component_id` int(11) NOT NULL auto_increment,
645 sequence int(11) NOT NULL default 0,
646 tag varchar(3) NOT NULL default '',
647 subfields varchar(40) NOT NULL default '',
648 offset int(4) NOT NULL default 0,
649 length int(4) NOT NULL default 0,
650 PRIMARY KEY (`matchpoint_component_id`),
651 KEY `by_sequence` (`matchpoint_id`, `sequence`),
652 CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
653 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
654 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
655 $dbh->do("CREATE TABLE `matchpoint_component_norms` (
656 `matchpoint_component_id` int(11) NOT NULL,
657 `sequence` int(11) NOT NULL default 0,
658 `norm_routine` varchar(50) NOT NULL default '',
659 KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
660 CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
661 REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
662 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
663 $dbh->do("CREATE TABLE `matcher_matchpoints` (
664 `matcher_id` int(11) NOT NULL,
665 `matchpoint_id` int(11) NOT NULL,
666 CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
667 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
668 CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
669 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
670 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
671 $dbh->do("CREATE TABLE `matchchecks` (
672 `matcher_id` int(11) NOT NULL,
673 `matchcheck_id` int(11) NOT NULL auto_increment,
674 `source_matchpoint_id` int(11) NOT NULL,
675 `target_matchpoint_id` int(11) NOT NULL,
676 PRIMARY KEY (`matchcheck_id`),
677 CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
678 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
679 CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
680 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
681 CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
682 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
683 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
684 print "Upgrade to $DBversion done (added C4::Matcher serialization tables)\n ";
685 SetVersion ($DBversion);
688 $DBversion = "3.00.00.028";
689 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
690 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
691 VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
692 print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
693 SetVersion ($DBversion);
697 $DBversion = "3.00.00.029";
698 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
699 $dbh->do("ALTER TABLE `import_batches` ADD `matcher_id` int(11) NULL AFTER `import_batch_id`");
700 print "Upgrade to $DBversion done (adding matcher_id to import_batches)\n";
701 SetVersion ($DBversion);
704 $DBversion = "3.00.00.030";
705 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
706 $dbh->do("
707 CREATE TABLE services_throttle (
708 service_type varchar(10) NOT NULL default '',
709 service_count varchar(45) default NULL,
710 PRIMARY KEY (service_type)
711 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
713 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
714 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')");
715 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
716 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')");
717 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
718 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')");
719 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
720 VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free')");
721 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
722 VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo')");
723 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
724 VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo')");
725 print "Upgrade to $DBversion done (adding services throttle table and sysprefs for xISBN)\n";
726 SetVersion ($DBversion);
729 $DBversion = "3.00.00.031";
730 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
732 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryStemming',1,'If ON, enables query stemming',NULL,'YesNo')");
733 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryFuzzy',1,'If ON, enables fuzzy option for searches',NULL,'YesNo')");
734 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryWeightFields',1,'If ON, enables field weighting',NULL,'YesNo')");
735 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo')");
736 $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')");
737 $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')");
738 $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')");
739 $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')");
740 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice')");
741 $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')");
742 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortOrder',NULL,'Specify the default sort order','asc|dsc|za|az','Choice')");
743 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
744 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
745 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
746 $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')");
747 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
748 $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')");
749 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice')");
750 $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')");
751 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
752 $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')");
753 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
754 $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')");
755 $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')");
756 $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')");
757 $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')");
758 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
760 print "Upgrade to $DBversion done (adding additional system preference)\n";
761 SetVersion ($DBversion);
764 $DBversion = "3.00.00.032";
765 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
766 $dbh->do("UPDATE `marc_subfield_structure` SET `kohafield` = 'items.wthdrawn' WHERE `kohafield` = 'items.withdrawn'");
767 print "Upgrade to $DBversion done (fixed MARC framework references to items.withdrawn)\n";
768 SetVersion ($DBversion);
771 $DBversion = "3.00.00.033";
772 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
773 $dbh->do("INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0)");
774 print "Upgrade to $DBversion done (Adding permissions flag for staff member access modification. )\n";
775 SetVersion ($DBversion);
778 $DBversion = "3.00.00.034";
779 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
780 $dbh->do("ALTER TABLE `virtualshelves` ADD COLUMN `sortfield` VARCHAR(16) ");
781 print "Upgrade to $DBversion done (Adding sortfield for Virtual Shelves. )\n";
782 SetVersion ($DBversion);
785 $DBversion = "3.00.00.035";
786 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
787 $dbh->do("UPDATE marc_subfield_structure
788 SET authorised_value = 'cn_source'
789 WHERE kohafield IN ('items.cn_source', 'biblioitems.cn_source')
790 AND (authorised_value is NULL OR authorised_value = '')");
791 print "Upgrade to $DBversion done (MARC frameworks: make classification source a drop-down)\n";
792 SetVersion ($DBversion);
795 $DBversion = "3.00.00.036";
796 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
797 $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');");
798 print "Upgrade to $DBversion done (OPACItemsResultsDisplay systempreference added)\n";
799 SetVersion ($DBversion);
802 $DBversion = "3.00.00.037";
803 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
804 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactfirstname` varchar(255)");
805 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactsurname` varchar(255)");
806 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress1` varchar(255)");
807 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress2` varchar(255)");
808 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress3` varchar(255)");
809 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactzipcode` varchar(50)");
810 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactphone` varchar(50)");
811 print "Upgrade to $DBversion done (Adding Alternative Contact Person information to borrowers table)\n";
812 SetVersion ($DBversion);
815 $DBversion = "3.00.00.038";
816 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
817 $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'");
818 $dbh->do("DELETE FROM `systempreferences` WHERE variable='hideBiblioNumber'");
819 print "Upgrade to $DBversion done ('alter finesMode systempreference, remove superfluous syspref.')\n";
820 SetVersion ($DBversion);
823 $DBversion = "3.00.00.039";
824 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
825 $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')");
826 $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')");
827 $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')");
828 # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
829 print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
830 SetVersion ($DBversion);
833 $DBversion = "3.00.00.040";
834 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
835 $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')");
836 $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')");
837 print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
838 SetVersion ($DBversion);
842 $DBversion = "3.00.00.041";
843 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
844 # Strictly speaking it is not necessary to explicitly change
845 # NULL values to 0, because the ALTER TABLE statement will do that.
846 # However, setting them first avoids a warning.
847 $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL");
848 $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL");
849 $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL");
850 $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL");
851 $dbh->do("ALTER TABLE items
852 MODIFY notforloan tinyint(1) NOT NULL default 0,
853 MODIFY damaged tinyint(1) NOT NULL default 0,
854 MODIFY itemlost tinyint(1) NOT NULL default 0,
855 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
856 $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
857 $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
858 $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
859 $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
860 $dbh->do("ALTER TABLE deleteditems
861 MODIFY notforloan tinyint(1) NOT NULL default 0,
862 MODIFY damaged tinyint(1) NOT NULL default 0,
863 MODIFY itemlost tinyint(1) NOT NULL default 0,
864 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
865 print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
866 SetVersion ($DBversion);
869 $DBversion = "3.00.00.04";
870 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
871 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
872 print "Upgrade to $DBversion done (disallow NULL in aqbooksellers.name; part of fix for bug 1251)\n";
873 SetVersion ($DBversion);
876 $DBversion = "3.00.00.043";
877 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
878 $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");
879 print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
880 SetVersion ($DBversion);
883 $DBversion = "3.00.00.044";
884 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
885 $dbh->do("ALTER TABLE deletedborrowers
886 ADD `altcontactfirstname` varchar(255) default NULL,
887 ADD `altcontactsurname` varchar(255) default NULL,
888 ADD `altcontactaddress1` varchar(255) default NULL,
889 ADD `altcontactaddress2` varchar(255) default NULL,
890 ADD `altcontactaddress3` varchar(255) default NULL,
891 ADD `altcontactzipcode` varchar(50) default NULL,
892 ADD `altcontactphone` varchar(50) default NULL
894 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
895 ('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
896 ('language','en','Set the default language in the staff client.',NULL,'Languages'),
897 ('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
898 ('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
900 print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
901 SetVersion ($DBversion);
904 #-- http://www.w3.org/International/articles/language-tags/
906 #-- RFC4646
907 $DBversion = "3.00.00.045";
908 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
909 $dbh->do("
910 CREATE TABLE language_subtag_registry (
911 subtag varchar(25),
912 type varchar(25), -- language-script-region-variant-extension-privateuse
913 description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
914 added date,
915 KEY `subtag` (`subtag`)
916 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
918 #-- TODO: add suppress_scripts
919 #-- this maps three letter codes defined in iso639.2 back to their
920 #-- two letter equivilents in rfc4646 (LOC maintains iso639+)
921 $dbh->do("CREATE TABLE language_rfc4646_to_iso639 (
922 rfc4646_subtag varchar(25),
923 iso639_2_code varchar(25),
924 KEY `rfc4646_subtag` (`rfc4646_subtag`)
925 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
927 $dbh->do("CREATE TABLE language_descriptions (
928 subtag varchar(25),
929 type varchar(25),
930 lang varchar(25),
931 description varchar(255),
932 KEY `lang` (`lang`)
933 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
935 #-- bi-directional support, keyed by script subcode
936 $dbh->do("CREATE TABLE language_script_bidi (
937 rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
938 bidi varchar(3), -- rtl ltr
939 KEY `rfc4646_subtag` (`rfc4646_subtag`)
940 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
942 #-- BIDI Stuff, Arabic and Hebrew
943 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
944 VALUES( 'Arab', 'rtl')");
945 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
946 VALUES( 'Hebr', 'rtl')");
948 #-- TODO: need to map language subtags to script subtags for detection
949 #-- of bidi when script is not specified (like ar, he)
950 $dbh->do("CREATE TABLE language_script_mapping (
951 language_subtag varchar(25),
952 script_subtag varchar(25),
953 KEY `language_subtag` (`language_subtag`)
954 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
956 #-- Default mappings between script and language subcodes
957 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
958 VALUES( 'ar', 'Arab')");
959 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
960 VALUES( 'he', 'Hebr')");
962 print "Upgrade to $DBversion done (adding language subtag registry and basic BiDi support NOTE: You should import the subtag registry SQL)\n";
963 SetVersion ($DBversion);
966 $DBversion = "3.00.00.046";
967 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
968 $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
969 CHANGE `weeklength` `weeklength` int(11) default '0'");
970 $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
971 $dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
972 print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
973 SetVersion ($DBversion);
976 $DBversion = "3.00.00.047";
977 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
978 $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');");
979 print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
980 SetVersion ($DBversion);
983 $DBversion = "3.00.00.048";
984 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
985 $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
986 print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
987 SetVersion ($DBversion);
990 $DBversion = "3.00.00.049";
991 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
992 $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
993 print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
994 SetVersion ($DBversion);
997 $DBversion = "3.00.00.050";
998 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
999 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
1000 print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
1001 SetVersion ($DBversion);
1004 $DBversion = "3.00.00.051";
1005 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1006 $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
1007 print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
1008 SetVersion ($DBversion);
1011 $DBversion = "3.00.00.052";
1012 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1013 $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
1014 print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
1015 SetVersion ($DBversion);
1018 $DBversion = "3.00.00.053";
1019 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1020 $dbh->do("CREATE TABLE `printers_profile` (
1021 `prof_id` int(4) NOT NULL auto_increment,
1022 `printername` varchar(40) NOT NULL,
1023 `tmpl_id` int(4) NOT NULL,
1024 `paper_bin` varchar(20) NOT NULL,
1025 `offset_horz` float default NULL,
1026 `offset_vert` float default NULL,
1027 `creep_horz` float default NULL,
1028 `creep_vert` float default NULL,
1029 `unit` char(20) NOT NULL default 'POINT',
1030 PRIMARY KEY (`prof_id`),
1031 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1032 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1033 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1034 $dbh->do("CREATE TABLE `labels_profile` (
1035 `tmpl_id` int(4) NOT NULL,
1036 `prof_id` int(4) NOT NULL,
1037 UNIQUE KEY `tmpl_id` (`tmpl_id`),
1038 UNIQUE KEY `prof_id` (`prof_id`)
1039 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1040 print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
1041 SetVersion ($DBversion);
1044 $DBversion = "3.00.00.054";
1045 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1046 $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';");
1047 print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
1048 SetVersion ($DBversion);
1051 $DBversion = "3.00.00.055";
1052 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1053 $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
1054 print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
1055 SetVersion ($DBversion);
1057 $DBversion = "3.00.00.056";
1058 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1059 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
1060 $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) ");
1061 } else {
1062 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('952', 'h', 'Serial Enumeration / chronology','Serial Enumeration / chronology', 0, 0, 'items.enumchron', 10, '', '', '', 0, 0, '', '', '', NULL) ");
1064 $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
1065 print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
1066 SetVersion ($DBversion);
1069 $DBversion = "3.00.00.057";
1070 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1071 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
1072 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
1073 $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');");
1074 $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');");
1075 $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');");
1076 SetVersion ($DBversion);
1079 $DBversion = "3.00.00.058";
1080 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1081 $dbh->do("ALTER TABLE `opac_news`
1082 CHANGE `lang` `lang` VARCHAR( 25 )
1083 CHARACTER SET utf8
1084 COLLATE utf8_general_ci
1085 NOT NULL default ''");
1086 print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
1087 SetVersion ($DBversion);
1090 $DBversion = "3.00.00.059";
1091 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1093 $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
1094 `tmpl_id` int(4) NOT NULL auto_increment,
1095 `tmpl_code` char(100) default '',
1096 `tmpl_desc` char(100) default '',
1097 `page_width` float default '0',
1098 `page_height` float default '0',
1099 `label_width` float default '0',
1100 `label_height` float default '0',
1101 `topmargin` float default '0',
1102 `leftmargin` float default '0',
1103 `cols` int(2) default '0',
1104 `rows` int(2) default '0',
1105 `colgap` float default '0',
1106 `rowgap` float default '0',
1107 `active` int(1) default NULL,
1108 `units` char(20) default 'PX',
1109 `fontsize` int(4) NOT NULL default '3',
1110 PRIMARY KEY (`tmpl_id`)
1111 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1112 $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
1113 `prof_id` int(4) NOT NULL auto_increment,
1114 `printername` varchar(40) NOT NULL,
1115 `tmpl_id` int(4) NOT NULL,
1116 `paper_bin` varchar(20) NOT NULL,
1117 `offset_horz` float default NULL,
1118 `offset_vert` float default NULL,
1119 `creep_horz` float default NULL,
1120 `creep_vert` float default NULL,
1121 `unit` char(20) NOT NULL default 'POINT',
1122 PRIMARY KEY (`prof_id`),
1123 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1124 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1125 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1126 print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
1127 SetVersion ($DBversion);
1130 $DBversion = "3.00.00.060";
1131 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1132 $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
1133 `cardnumber` varchar(16) NOT NULL,
1134 `mimetype` varchar(15) NOT NULL,
1135 `imagefile` mediumblob NOT NULL,
1136 PRIMARY KEY (`cardnumber`),
1137 CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1138 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1139 print "Upgrade to $DBversion done ( Added patronimage table. )\n";
1140 SetVersion ($DBversion);
1143 $DBversion = "3.00.00.061";
1144 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1145 $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
1146 print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
1147 SetVersion ($DBversion);
1150 $DBversion = "3.00.00.062";
1151 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1152 $dbh->do("CREATE TABLE `old_issues` (
1153 `borrowernumber` int(11) default NULL,
1154 `itemnumber` int(11) default NULL,
1155 `date_due` date default NULL,
1156 `branchcode` varchar(10) default NULL,
1157 `issuingbranch` varchar(18) default NULL,
1158 `returndate` date default NULL,
1159 `lastreneweddate` date default NULL,
1160 `return` varchar(4) default NULL,
1161 `renewals` tinyint(4) default NULL,
1162 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1163 `issuedate` date default NULL,
1164 KEY `old_issuesborridx` (`borrowernumber`),
1165 KEY `old_issuesitemidx` (`itemnumber`),
1166 KEY `old_bordate` (`borrowernumber`,`timestamp`),
1167 CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1168 ON DELETE SET NULL ON UPDATE SET NULL,
1169 CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1170 ON DELETE SET NULL ON UPDATE SET NULL
1171 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1172 $dbh->do("CREATE TABLE `old_reserves` (
1173 `borrowernumber` int(11) default NULL,
1174 `reservedate` date default NULL,
1175 `biblionumber` int(11) default NULL,
1176 `constrainttype` varchar(1) default NULL,
1177 `branchcode` varchar(10) default NULL,
1178 `notificationdate` date default NULL,
1179 `reminderdate` date default NULL,
1180 `cancellationdate` date default NULL,
1181 `reservenotes` mediumtext,
1182 `priority` smallint(6) default NULL,
1183 `found` varchar(1) default NULL,
1184 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1185 `itemnumber` int(11) default NULL,
1186 `waitingdate` date default NULL,
1187 KEY `old_reserves_borrowernumber` (`borrowernumber`),
1188 KEY `old_reserves_biblionumber` (`biblionumber`),
1189 KEY `old_reserves_itemnumber` (`itemnumber`),
1190 KEY `old_reserves_branchcode` (`branchcode`),
1191 CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1192 ON DELETE SET NULL ON UPDATE SET NULL,
1193 CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1194 ON DELETE SET NULL ON UPDATE SET NULL,
1195 CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1196 ON DELETE SET NULL ON UPDATE SET NULL
1197 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1199 # move closed transactions to old_* tables
1200 $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
1201 $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
1202 $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1203 $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1205 print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
1206 SetVersion ($DBversion);
1209 $DBversion = "3.00.00.063";
1210 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1211 $dbh->do("ALTER TABLE deleteditems
1212 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
1213 ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
1214 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1215 $dbh->do("ALTER TABLE items
1216 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
1217 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1218 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";
1219 SetVersion ($DBversion);
1222 $DBversion = "3.00.00.064";
1223 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1224 $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');");
1225 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
1226 $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
1227 $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
1228 $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
1229 print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
1230 SetVersion ($DBversion);
1233 $DBversion = "3.00.00.065";
1234 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1235 $dbh->do("CREATE TABLE `patroncards` (
1236 `cardid` int(11) NOT NULL auto_increment,
1237 `batch_id` varchar(10) NOT NULL default '1',
1238 `borrowernumber` int(11) NOT NULL,
1239 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1240 PRIMARY KEY (`cardid`),
1241 KEY `patroncards_ibfk_1` (`borrowernumber`),
1242 CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1243 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1244 print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
1245 SetVersion ($DBversion);
1248 $DBversion = "3.00.00.066";
1249 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1250 $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
1251 DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
1253 print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
1254 SetVersion ($DBversion);
1257 $DBversion = "3.00.00.067";
1258 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1259 $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
1260 print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
1261 SetVersion ($DBversion);
1264 $DBversion = "3.00.00.068";
1265 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1266 $dbh->do("CREATE TABLE `permissions` (
1267 `module_bit` int(11) NOT NULL DEFAULT 0,
1268 `code` varchar(30) DEFAULT NULL,
1269 `description` varchar(255) DEFAULT NULL,
1270 PRIMARY KEY (`module_bit`, `code`),
1271 CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
1272 ON DELETE CASCADE ON UPDATE CASCADE
1273 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1274 $dbh->do("CREATE TABLE `user_permissions` (
1275 `borrowernumber` int(11) NOT NULL DEFAULT 0,
1276 `module_bit` int(11) NOT NULL DEFAULT 0,
1277 `code` varchar(30) DEFAULT NULL,
1278 CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1279 ON DELETE CASCADE ON UPDATE CASCADE,
1280 CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
1281 REFERENCES `permissions` (`module_bit`, `code`)
1282 ON DELETE CASCADE ON UPDATE CASCADE
1283 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1285 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
1286 (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
1287 (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
1288 (13, 'edit_calendar', 'Define days when the library is closed'),
1289 (13, 'moderate_comments', 'Moderate patron comments'),
1290 (13, 'edit_notices', 'Define notices'),
1291 (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
1292 (13, 'view_system_logs', 'Browse the system logs'),
1293 (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
1294 (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
1295 (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
1296 (13, 'export_catalog', 'Export bibliographic and holdings data'),
1297 (13, 'import_patrons', 'Import patron data'),
1298 (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
1299 (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
1300 (13, 'schedule_tasks', 'Schedule tasks to run')");
1302 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
1304 print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
1305 SetVersion ($DBversion);
1307 $DBversion = "3.00.00.069";
1308 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1309 $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
1310 print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
1311 SetVersion ($DBversion);
1314 $DBversion = "3.00.00.070";
1315 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1316 $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
1317 $sth->execute;
1318 my ($value) = $sth->fetchrow;
1319 $value =~ s/2.3.1/2.5.1/;
1320 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
1321 print "Update yuipath syspref to 2.5.1 if necessary\n";
1322 SetVersion ($DBversion);
1325 $DBversion = "3.00.00.071";
1326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1327 $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
1328 # fill the new field with the previous systempreference value, then drop the syspref
1329 my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
1330 $sth->execute;
1331 my ($serialsadditems) = $sth->fetchrow();
1332 $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
1333 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1334 print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
1335 SetVersion ($DBversion);
1338 $DBversion = "3.00.00.072";
1339 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1340 $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring mediumtext DEFAULT NULL AFTER printingtype");
1341 print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
1342 SetVersion ($DBversion);
1345 $DBversion = "3.00.00.073";
1346 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1347 $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
1348 $dbh->do(q#
1349 CREATE TABLE `tags_all` (
1350 `tag_id` int(11) NOT NULL auto_increment,
1351 `borrowernumber` int(11) NOT NULL,
1352 `biblionumber` int(11) NOT NULL,
1353 `term` varchar(255) NOT NULL,
1354 `language` int(4) default NULL,
1355 `date_created` datetime NOT NULL,
1356 PRIMARY KEY (`tag_id`),
1357 KEY `tags_borrowers_fk_1` (`borrowernumber`),
1358 KEY `tags_biblionumber_fk_1` (`biblionumber`),
1359 CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
1360 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1361 CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1362 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1363 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1365 $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
1366 $dbh->do(q#
1367 CREATE TABLE `tags_approval` (
1368 `term` varchar(255) NOT NULL,
1369 `approved` int(1) NOT NULL default '0',
1370 `date_approved` datetime default NULL,
1371 `approved_by` int(11) default NULL,
1372 `weight_total` int(9) NOT NULL default '1',
1373 PRIMARY KEY (`term`),
1374 KEY `tags_approval_borrowers_fk_1` (`approved_by`),
1375 CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
1376 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1377 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1379 $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
1380 $dbh->do(q#
1381 CREATE TABLE `tags_index` (
1382 `term` varchar(255) NOT NULL,
1383 `biblionumber` int(11) NOT NULL,
1384 `weight` int(9) NOT NULL default '1',
1385 PRIMARY KEY (`term`,`biblionumber`),
1386 KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
1387 CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
1388 REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
1389 CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1390 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1391 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1393 $dbh->do(q#
1394 INSERT INTO `systempreferences` VALUES
1395 ('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=',''),
1396 ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
1397 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
1398 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
1399 ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
1400 ('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.',''),
1401 ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
1402 ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
1403 ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
1404 ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
1405 ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
1407 print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
1408 SetVersion ($DBversion);
1411 $DBversion = "3.00.00.074";
1412 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1413 $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
1414 where imageurl not like 'http%'
1415 and imageurl is not NULL
1416 and imageurl != '') );
1417 print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
1418 SetVersion ($DBversion);
1421 $DBversion = "3.00.00.075";
1422 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1423 $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
1424 print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
1425 SetVersion ($DBversion);
1428 $DBversion = "3.00.00.076";
1429 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1430 $dbh->do("ALTER TABLE import_batches
1431 ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
1432 $dbh->do("ALTER TABLE import_batches
1433 ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
1434 NOT NULL default 'always_add' AFTER nomatch_action");
1435 $dbh->do("ALTER TABLE import_batches
1436 MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
1437 NOT NULL default 'create_new'");
1438 $dbh->do("ALTER TABLE import_records
1439 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
1440 'ignored') NOT NULL default 'staged'");
1441 $dbh->do("ALTER TABLE import_items
1442 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
1444 print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
1445 SetVersion ($DBversion);
1448 $DBversion = "3.00.00.077";
1449 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1450 # drop these tables only if they exist and none of them are empty
1451 # these tables are not defined in the packaged 2.2.9, but since it is believed
1452 # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
1453 # some care is taken.
1454 my ($print_error) = $dbh->{PrintError};
1455 $dbh->{PrintError} = 0;
1456 my ($raise_error) = $dbh->{RaiseError};
1457 $dbh->{RaiseError} = 1;
1459 my $count = 0;
1460 my $do_drop = 1;
1461 eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
1462 if ($count > 0) {
1463 $do_drop = 0;
1465 eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
1466 if ($count > 0) {
1467 $do_drop = 0;
1469 eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
1470 if ($count > 0) {
1471 $do_drop = 0;
1474 if ($do_drop) {
1475 $dbh->do("DROP TABLE IF EXISTS `categorytable`");
1476 $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
1477 $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
1480 $dbh->{PrintError} = $print_error;
1481 $dbh->{RaiseError} = $raise_error;
1482 print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
1483 SetVersion ($DBversion);
1486 $DBversion = "3.00.00.078";
1487 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1488 my ($print_error) = $dbh->{PrintError};
1489 $dbh->{PrintError} = 0;
1491 unless ($dbh->do("SELECT 1 FROM browser")) {
1492 $dbh->{PrintError} = $print_error;
1493 $dbh->do("CREATE TABLE `browser` (
1494 `level` int(11) NOT NULL,
1495 `classification` varchar(20) NOT NULL,
1496 `description` varchar(255) NOT NULL,
1497 `number` bigint(20) NOT NULL,
1498 `endnode` tinyint(4) NOT NULL
1499 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1501 $dbh->{PrintError} = $print_error;
1502 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1503 SetVersion ($DBversion);
1506 $DBversion = "3.00.00.079";
1507 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1508 my ($print_error) = $dbh->{PrintError};
1509 $dbh->{PrintError} = 0;
1511 $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
1512 ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
1513 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1514 SetVersion ($DBversion);
1517 $DBversion = "3.00.00.080";
1518 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1519 $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
1520 $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
1521 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
1522 print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
1523 SetVersion ($DBversion);
1526 $DBversion = "3.00.00.081";
1527 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1528 $dbh->do("CREATE TABLE `borrower_attribute_types` (
1529 `code` varchar(10) NOT NULL,
1530 `description` varchar(255) NOT NULL,
1531 `repeatable` tinyint(1) NOT NULL default 0,
1532 `unique_id` tinyint(1) NOT NULL default 0,
1533 `opac_display` tinyint(1) NOT NULL default 0,
1534 `password_allowed` tinyint(1) NOT NULL default 0,
1535 `staff_searchable` tinyint(1) NOT NULL default 0,
1536 `authorised_value_category` varchar(10) default NULL,
1537 PRIMARY KEY (`code`)
1538 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1539 $dbh->do("CREATE TABLE `borrower_attributes` (
1540 `borrowernumber` int(11) NOT NULL,
1541 `code` varchar(10) NOT NULL,
1542 `attribute` varchar(30) default NULL,
1543 `password` varchar(30) default NULL,
1544 KEY `borrowernumber` (`borrowernumber`),
1545 KEY `code_attribute` (`code`, `attribute`),
1546 CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1547 ON DELETE CASCADE ON UPDATE CASCADE,
1548 CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1549 ON DELETE CASCADE ON UPDATE CASCADE
1550 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1551 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
1552 print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
1553 SetVersion ($DBversion);
1556 $DBversion = "3.00.00.082";
1557 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1558 $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
1559 print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
1560 SetVersion ($DBversion);
1563 $DBversion = "3.00.00.083";
1564 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1565 $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
1566 print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
1567 SetVersion ($DBversion);
1569 $DBversion = "3.00.00.084";
1570 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1571 $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')");
1572 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
1573 print "Upgrade to $DBversion done (add new sysprefs)\n";
1574 SetVersion ($DBversion);
1577 $DBversion = "3.00.00.085";
1578 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1579 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1580 $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
1581 $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
1582 $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
1583 $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
1584 $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
1585 $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
1587 print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
1588 SetVersion ($DBversion);
1591 $DBversion = "3.00.00.086";
1592 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1593 $dbh->do(
1594 "CREATE TABLE `tmp_holdsqueue` (
1595 `biblionumber` int(11) default NULL,
1596 `itemnumber` int(11) default NULL,
1597 `barcode` varchar(20) default NULL,
1598 `surname` mediumtext NOT NULL,
1599 `firstname` text,
1600 `phone` text,
1601 `borrowernumber` int(11) NOT NULL,
1602 `cardnumber` varchar(16) default NULL,
1603 `reservedate` date default NULL,
1604 `title` mediumtext,
1605 `itemcallnumber` varchar(30) default NULL,
1606 `holdingbranch` varchar(10) default NULL,
1607 `pickbranch` varchar(10) default NULL,
1608 `notes` text
1609 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1611 $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')");
1612 $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')");
1614 print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
1615 SetVersion ($DBversion);
1618 $DBversion = "3.00.00.087";
1619 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1620 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
1621 $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')");
1622 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1623 SetVersion ($DBversion);
1626 $DBversion = "3.00.00.088";
1627 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1628 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
1629 $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')");
1630 $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')");
1631 $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')");
1632 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1633 SetVersion ($DBversion);
1636 $DBversion = "3.00.00.089";
1637 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1638 $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')");
1639 print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
1640 SetVersion ($DBversion);
1643 $DBversion = "3.00.00.090";
1644 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1645 $dbh->do("
1646 CREATE TABLE `branch_borrower_circ_rules` (
1647 `branchcode` VARCHAR(10) NOT NULL,
1648 `categorycode` VARCHAR(10) NOT NULL,
1649 `maxissueqty` int(4) default NULL,
1650 PRIMARY KEY (`categorycode`, `branchcode`),
1651 CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1652 ON DELETE CASCADE ON UPDATE CASCADE,
1653 CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1654 ON DELETE CASCADE ON UPDATE CASCADE
1655 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1657 $dbh->do("
1658 CREATE TABLE `default_borrower_circ_rules` (
1659 `categorycode` VARCHAR(10) NOT NULL,
1660 `maxissueqty` int(4) default NULL,
1661 PRIMARY KEY (`categorycode`),
1662 CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1663 ON DELETE CASCADE ON UPDATE CASCADE
1664 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1666 $dbh->do("
1667 CREATE TABLE `default_branch_circ_rules` (
1668 `branchcode` VARCHAR(10) NOT NULL,
1669 `maxissueqty` int(4) default NULL,
1670 PRIMARY KEY (`branchcode`),
1671 CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1672 ON DELETE CASCADE ON UPDATE CASCADE
1673 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1675 $dbh->do("
1676 CREATE TABLE `default_circ_rules` (
1677 `singleton` enum('singleton') NOT NULL default 'singleton',
1678 `maxissueqty` int(4) default NULL,
1679 PRIMARY KEY (`singleton`)
1680 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1682 print "Upgrade to $DBversion done (added several circ rules tables)\n";
1683 SetVersion ($DBversion);
1687 $DBversion = "3.00.00.091";
1688 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1689 $dbh->do(<<'END_SQL');
1690 ALTER TABLE borrowers
1691 ADD `smsalertnumber` varchar(50) default NULL
1692 END_SQL
1694 $dbh->do(<<'END_SQL');
1695 CREATE TABLE `message_attributes` (
1696 `message_attribute_id` int(11) NOT NULL auto_increment,
1697 `message_name` varchar(20) NOT NULL default '',
1698 `takes_days` tinyint(1) NOT NULL default '0',
1699 PRIMARY KEY (`message_attribute_id`),
1700 UNIQUE KEY `message_name` (`message_name`)
1701 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1702 END_SQL
1704 $dbh->do(<<'END_SQL');
1705 CREATE TABLE `message_transport_types` (
1706 `message_transport_type` varchar(20) NOT NULL,
1707 PRIMARY KEY (`message_transport_type`)
1708 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1709 END_SQL
1711 $dbh->do(<<'END_SQL');
1712 CREATE TABLE `message_transports` (
1713 `message_attribute_id` int(11) NOT NULL,
1714 `message_transport_type` varchar(20) NOT NULL,
1715 `is_digest` tinyint(1) NOT NULL default '0',
1716 `letter_module` varchar(20) NOT NULL default '',
1717 `letter_code` varchar(20) NOT NULL default '',
1718 PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
1719 KEY `message_transport_type` (`message_transport_type`),
1720 KEY `letter_module` (`letter_module`,`letter_code`),
1721 CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1722 CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
1723 CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
1724 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1725 END_SQL
1727 $dbh->do(<<'END_SQL');
1728 CREATE TABLE `borrower_message_preferences` (
1729 `borrower_message_preference_id` int(11) NOT NULL auto_increment,
1730 `borrowernumber` int(11) NOT NULL default '0',
1731 `message_attribute_id` int(11) default '0',
1732 `days_in_advance` int(11) default '0',
1733 `wants_digets` tinyint(1) NOT NULL default '0',
1734 PRIMARY KEY (`borrower_message_preference_id`),
1735 KEY `borrowernumber` (`borrowernumber`),
1736 KEY `message_attribute_id` (`message_attribute_id`),
1737 CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1738 CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
1739 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1740 END_SQL
1742 $dbh->do(<<'END_SQL');
1743 CREATE TABLE `borrower_message_transport_preferences` (
1744 `borrower_message_preference_id` int(11) NOT NULL default '0',
1745 `message_transport_type` varchar(20) NOT NULL default '0',
1746 PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1747 KEY `message_transport_type` (`message_transport_type`),
1748 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,
1749 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
1750 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1751 END_SQL
1753 $dbh->do(<<'END_SQL');
1754 CREATE TABLE `message_queue` (
1755 `message_id` int(11) NOT NULL auto_increment,
1756 `borrowernumber` int(11) NOT NULL,
1757 `subject` text,
1758 `content` text,
1759 `message_transport_type` varchar(20) NOT NULL,
1760 `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
1761 `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1762 KEY `message_id` (`message_id`),
1763 KEY `borrowernumber` (`borrowernumber`),
1764 KEY `message_transport_type` (`message_transport_type`),
1765 CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1766 CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
1767 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1768 END_SQL
1770 $dbh->do(<<'END_SQL');
1771 INSERT INTO `systempreferences`
1772 (variable,value,explanation,options,type)
1773 VALUES
1774 ('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
1775 END_SQL
1777 $dbh->do( <<'END_SQL');
1778 INSERT INTO `letter`
1779 (module, code, name, title, content)
1780 VALUES
1781 ('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>>'),
1782 ('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
1783 ('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>>'),
1784 ('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
1785 ('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.');
1786 END_SQL
1788 my @sql_scripts = (
1789 'installer/data/mysql/en/mandatory/message_transport_types.sql',
1790 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
1791 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
1794 my $installer = C4::Installer->new();
1795 foreach my $script ( @sql_scripts ) {
1796 my $full_path = $installer->get_file_path_from_name($script);
1797 my $error = $installer->load_sql($full_path);
1798 warn $error if $error;
1801 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";
1802 SetVersion ($DBversion);
1805 $DBversion = "3.00.00.092";
1806 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1807 $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')");
1808 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
1809 print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
1810 SetVersion ($DBversion);
1813 $DBversion = "3.00.00.093";
1814 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1815 $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1816 $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1817 print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
1818 SetVersion ($DBversion);
1821 $DBversion = "3.00.00.094";
1822 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1823 $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
1824 print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
1825 SetVersion ($DBversion);
1828 $DBversion = "3.00.00.095";
1829 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1830 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1831 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
1832 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
1834 print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
1835 SetVersion ($DBversion);
1838 $DBversion = "3.00.00.096";
1839 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1840 $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
1841 $sth->execute();
1842 if (my $row = $sth->fetchrow_hashref) {
1843 $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
1845 print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
1846 SetVersion ($DBversion);
1849 $DBversion = '3.00.00.097';
1850 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1852 $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
1853 $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
1854 $dbh->do('ALTER TABLE message_queue ADD content_type text');
1855 $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
1857 print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
1858 SetVersion($DBversion);
1861 $DBversion = '3.00.00.098';
1862 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1864 $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
1865 $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
1867 print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
1868 SetVersion($DBversion);
1871 $DBversion = '3.00.00.099';
1872 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1873 $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')");
1874 print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
1875 SetVersion($DBversion);
1878 $DBversion = '3.00.00.100';
1879 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1880 $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
1881 print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
1882 SetVersion($DBversion);
1885 $DBversion = '3.00.00.101';
1886 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1887 $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1888 $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1889 print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
1890 SetVersion($DBversion);
1893 $DBversion = '3.00.00.102';
1894 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1895 $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
1896 $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
1897 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
1898 # before setting constraint, delete any unvalid data
1899 $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
1900 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
1901 print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
1902 SetVersion($DBversion);
1905 $DBversion = "3.00.00.103";
1906 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1907 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1908 print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
1909 SetVersion ($DBversion);
1912 $DBversion = "3.00.00.104";
1913 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1914 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1915 print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
1916 SetVersion ($DBversion);
1919 $DBversion = '3.00.00.105';
1920 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
1922 # it is possible that this syspref is already defined since the feature was added some time ago.
1923 unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
1924 $dbh->do(<<'END_SQL');
1925 INSERT INTO `systempreferences`
1926 (variable,value,explanation,options,type)
1927 VALUES
1928 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
1929 END_SQL
1931 print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
1932 SetVersion($DBversion);
1935 $DBversion = "3.00.00.106";
1936 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1937 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1939 # db revision 105 didn't apply correctly, so we're rolling this into 106
1940 $dbh->do("INSERT INTO `systempreferences`
1941 (variable,value,explanation,options,type)
1942 VALUES
1943 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
1945 print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
1946 $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
1947 $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
1948 SetVersion ($DBversion);
1951 $DBversion = '3.00.00.107';
1952 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1953 $dbh->do(<<'END_SQL');
1954 UPDATE systempreferences
1955 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
1956 WHERE variable = 'OPACShelfBrowser'
1957 AND explanation NOT LIKE '%WARNING%'
1958 END_SQL
1959 $dbh->do(<<'END_SQL');
1960 UPDATE systempreferences
1961 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
1962 WHERE variable = 'CataloguingLog'
1963 AND explanation NOT LIKE '%WARNING%'
1964 END_SQL
1965 $dbh->do(<<'END_SQL');
1966 UPDATE systempreferences
1967 SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
1968 WHERE variable = 'NoZebra'
1969 AND explanation NOT LIKE '%WARNING%'
1970 END_SQL
1971 print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
1972 SetVersion ($DBversion);
1975 $DBversion = '3.01.00.000';
1976 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1977 print "Upgrade to $DBversion done (start of 3.1)\n";
1978 SetVersion ($DBversion);
1981 $DBversion = '3.01.00.001';
1982 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1983 $dbh->do("
1984 CREATE TABLE hold_fill_targets (
1985 `borrowernumber` int(11) NOT NULL,
1986 `biblionumber` int(11) NOT NULL,
1987 `itemnumber` int(11) NOT NULL,
1988 `source_branchcode` varchar(10) default NULL,
1989 `item_level_request` tinyint(4) NOT NULL default 0,
1990 PRIMARY KEY `itemnumber` (`itemnumber`),
1991 KEY `bib_branch` (`biblionumber`, `source_branchcode`),
1992 CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
1993 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1994 CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
1995 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1996 CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
1997 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1998 CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
1999 REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2000 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2002 $dbh->do("
2003 ALTER TABLE tmp_holdsqueue
2004 ADD item_level_request tinyint(4) NOT NULL default 0
2007 print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
2008 SetVersion($DBversion);
2011 $DBversion = '3.01.00.002';
2012 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2013 # use statistics where available
2014 $dbh->do("
2015 ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
2017 $dbh->do("
2018 UPDATE issues iss
2019 SET issuedate = (
2020 SELECT max(datetime)
2021 FROM statistics
2022 WHERE type = 'issue'
2023 AND itemnumber = iss.itemnumber
2024 AND borrowernumber = iss.borrowernumber
2026 WHERE issuedate IS NULL;
2028 $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
2030 # default to last renewal date
2031 $dbh->do("
2032 UPDATE issues
2033 SET issuedate = lastreneweddate
2034 WHERE issuedate IS NULL
2035 and lastreneweddate IS NOT NULL
2038 my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
2039 if ($num_bad_issuedates > 0) {
2040 print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
2041 "Please check the issues table in your database.";
2043 print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
2044 SetVersion($DBversion);
2047 $DBversion = "3.01.00.003";
2048 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2049 $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')");
2050 print "Upgrade to $DBversion done (add new syspref)\n";
2051 SetVersion ($DBversion);
2054 $DBversion = '3.01.00.004';
2055 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2056 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACDisplayRequestPriority','0','Show patrons the priority level on holds in the OPAC','','YesNo')");
2057 print "Upgrade to $DBversion done (added OPACDisplayRequestPriority system preference)\n";
2058 SetVersion ($DBversion);
2061 $DBversion = '3.01.00.005';
2062 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2063 $dbh->do("
2064 INSERT INTO `letter` (module, code, name, title, content)
2065 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>>')
2067 $dbh->do("INSERT INTO `message_attributes` (message_attribute_id, message_name, takes_days) values(4, 'Hold Filled', 0)");
2068 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'sms', 0, 'reserves', 'HOLD')");
2069 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'email', 0, 'reserves', 'HOLD')");
2070 print "Upgrade to $DBversion done (Add letter for holds notifications)\n";
2071 SetVersion ($DBversion);
2074 $DBversion = '3.01.00.006';
2075 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2076 $dbh->do("ALTER TABLE `biblioitems` ADD KEY issn (issn)");
2077 print "Upgrade to $DBversion done (add index on biblioitems.issn)\n";
2078 SetVersion ($DBversion);
2081 $DBversion = "3.01.00.007";
2082 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2083 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetmainUserblock'");
2084 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetuserjs'");
2085 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacheader'");
2086 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacMainUserBlock'");
2087 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacNav'");
2088 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacuserjs'");
2089 $dbh->do("UPDATE `systempreferences` SET options='30|10', type='Textarea' WHERE variable='OAI-PMH:Set'");
2090 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetstylesheet'");
2091 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetcolorstylesheet'");
2092 $dbh->do("UPDATE `systempreferences` SET options='10' WHERE variable='globalDueDate'");
2093 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='numSearchResults'");
2094 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='OPACnumSearchResults'");
2095 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='ReservesMaxPickupDelay'");
2096 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='TransfersMaxDaysWarning'");
2097 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='StaticHoldsQueueWeight'");
2098 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='holdCancelLength'");
2099 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='XISBNDailyLimit'");
2100 $dbh->do("UPDATE `systempreferences` SET type='Float' WHERE variable='gist'");
2101 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorUsername'");
2102 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorPassword'");
2103 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10' WHERE variable='ISBD'");
2104 $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'");
2105 print "Upgrade to $DBversion done (fix display of many sysprefs)\n";
2106 SetVersion ($DBversion);
2109 $DBversion = '3.01.00.008';
2110 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2112 $dbh->do("CREATE TABLE branch_transfer_limits (
2113 limitId int(8) NOT NULL auto_increment,
2114 toBranch varchar(4) NOT NULL,
2115 fromBranch varchar(4) NOT NULL,
2116 itemtype varchar(4) NOT NULL,
2117 PRIMARY KEY (limitId)
2118 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
2121 $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')");
2123 print "Upgrade to $DBversion done (added branch_transfer_limits table and UseBranchTransferLimits system preference)\n";
2124 SetVersion ($DBversion);
2127 $DBversion = "3.01.00.009";
2128 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2129 $dbh->do("ALTER TABLE permissions MODIFY `code` varchar(64) DEFAULT NULL");
2130 $dbh->do("ALTER TABLE user_permissions MODIFY `code` varchar(64) DEFAULT NULL");
2131 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'circulate_remaining_permissions', 'Remaining circulation permissions')");
2132 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'override_renewals', 'Override blocked renewals')");
2133 print "Upgrade to $DBversion done (added subpermissions for circulate permission)\n";
2136 $DBversion = '3.01.00.010';
2137 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2138 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `attribute` VARCHAR(64) DEFAULT NULL");
2139 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `password` VARCHAR(64) DEFAULT NULL");
2140 print "Upgrade to $DBversion done (bug 2687: increase length of borrower attribute fields)\n";
2141 SetVersion ($DBversion);
2144 $DBversion = '3.01.00.011';
2145 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2147 # Yes, the old value was ^M terminated.
2148 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);";
2150 my $intranetuserjs = C4::Context->preference('intranetuserjs');
2151 if ($intranetuserjs and $intranetuserjs eq $bad_value) {
2152 my $sql = <<'END_SQL';
2153 UPDATE systempreferences
2154 SET value = ''
2155 WHERE variable = 'intranetuserjs'
2156 END_SQL
2157 $dbh->do($sql);
2159 print "Upgrade to $DBversion done (removed bogus intranetuserjs syspref)\n";
2160 SetVersion($DBversion);
2163 $DBversion = "3.01.00.012";
2164 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2165 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo')");
2166 $dbh->do("
2167 CREATE TABLE `branch_item_rules` (
2168 `branchcode` varchar(10) NOT NULL,
2169 `itemtype` varchar(10) NOT NULL,
2170 `holdallowed` tinyint(1) default NULL,
2171 PRIMARY KEY (`itemtype`,`branchcode`),
2172 KEY `branch_item_rules_ibfk_2` (`branchcode`),
2173 CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
2174 CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2175 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2177 $dbh->do("
2178 CREATE TABLE `default_branch_item_rules` (
2179 `itemtype` varchar(10) NOT NULL,
2180 `holdallowed` tinyint(1) default NULL,
2181 PRIMARY KEY (`itemtype`),
2182 CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
2183 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2185 $dbh->do("
2186 ALTER TABLE default_branch_circ_rules
2187 ADD COLUMN holdallowed tinyint(1) NULL
2189 $dbh->do("
2190 ALTER TABLE default_circ_rules
2191 ADD COLUMN holdallowed tinyint(1) NULL
2193 print "Upgrade to $DBversion done (Add tables and system preferences for holds policies)\n";
2194 SetVersion ($DBversion);
2197 $DBversion = '3.01.00.013';
2198 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2199 $dbh->do("
2200 CREATE TABLE item_circulation_alert_preferences (
2201 id int(11) AUTO_INCREMENT,
2202 branchcode varchar(10) NOT NULL,
2203 categorycode varchar(10) NOT NULL,
2204 item_type varchar(10) NOT NULL,
2205 notification varchar(16) NOT NULL,
2206 PRIMARY KEY (id),
2207 KEY (branchcode, categorycode, item_type, notification)
2208 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2211 $dbh->do(q{ ALTER TABLE `message_queue` ADD metadata text DEFAULT NULL AFTER content; });
2212 $dbh->do(q{ ALTER TABLE `message_queue` ADD letter_code varchar(64) DEFAULT NULL AFTER metadata; });
2214 $dbh->do(q{
2215 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2216 ('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.');
2218 $dbh->do(q{
2219 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2220 ('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>>.');
2223 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (5, 'Item Check-in', 0);});
2224 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (6, 'Item Checkout', 0);});
2226 $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');});
2227 $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');});
2228 $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');});
2229 $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');});
2231 print "Upgrade to $DBversion done (data for Email Checkout Slips project)\n";
2232 SetVersion ($DBversion);
2235 $DBversion = "3.01.00.014";
2236 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2237 $dbh->do("ALTER TABLE `branch_transfer_limits` CHANGE `itemtype` `itemtype` VARCHAR( 4 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL");
2238 $dbh->do("ALTER TABLE `branch_transfer_limits` ADD `ccode` VARCHAR( 10 ) NULL ;");
2239 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2240 VALUES (
2241 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice'
2242 );");
2244 print "Upgrade to $DBversion done ( Updated table for Branch Transfer Limits)\n";
2245 SetVersion ($DBversion);
2248 $DBversion = '3.01.00.015';
2249 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2250 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsClientCode', '0', 'Client Code for using Syndetics Solutions content','','free')");
2252 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEnabled', '0', 'Turn on Syndetics Enhanced Content','','YesNo')");
2254 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImages', '0', 'Display Cover Images from Syndetics','','YesNo')");
2256 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsTOC', '0', 'Display Table of Content information from Syndetics','','YesNo')");
2258 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSummary', '0', 'Display Summary Information from Syndetics','','YesNo')");
2260 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEditions', '0', 'Display Editions from Syndetics','','YesNo')");
2262 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsExcerpt', '0', 'Display Excerpts and first chapters on OPAC from Syndetics','','YesNo')");
2264 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsReviews', '0', 'Display Reviews on OPAC from Syndetics','','YesNo')");
2266 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAuthorNotes', '0', 'Display Notes about the Author on OPAC from Syndetics','','YesNo')");
2268 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAwards', '0', 'Display Awards on OPAC from Syndetics','','YesNo')");
2270 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSeries', '0', 'Display Series information on OPAC from Syndetics','','YesNo')");
2272 $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')");
2274 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from Amazon Web Services','','YesNo')");
2276 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from Amazon Web Services','','YesNo')");
2278 $dbh->do("UPDATE systempreferences SET variable='AmazonEnabled' WHERE variable = 'AmazonContent'");
2280 $dbh->do("UPDATE systempreferences SET variable='OPACAmazonEnabled' WHERE variable = 'OPACAmazonContent'");
2282 print "Upgrade to $DBversion done (added Syndetics Enhanced Content system preferences)\n";
2283 SetVersion ($DBversion);
2286 $DBversion = "3.01.00.016";
2287 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2288 $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')");
2289 print "Upgrade to $DBversion done (Added Babeltheque syspref)\n";
2290 SetVersion ($DBversion);
2293 $DBversion = "3.01.00.017";
2294 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2295 $dbh->do("ALTER TABLE `subscription` ADD `staffdisplaycount` VARCHAR(10) NULL;");
2296 $dbh->do("ALTER TABLE `subscription` ADD `opacdisplaycount` VARCHAR(10) NULL;");
2297 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2298 VALUES (
2299 'StaffSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the Staff client', 'Integer'
2300 );");
2301 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2302 VALUES (
2303 'OPACSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the OPAC', 'Integer'
2304 );");
2306 print "Upgrade to $DBversion done ( Updated table for Serials Display)\n";
2307 SetVersion ($DBversion);
2310 $DBversion = "3.01.00.018";
2311 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2312 $dbh->do("ALTER TABLE deletedborrowers ADD `smsalertnumber` varchar(50) default NULL");
2313 print "Upgrade to $DBversion done (added deletedborrowers.smsalertnumber, missed in 3.00.00.091)\n";
2314 SetVersion ($DBversion);
2317 $DBversion = "3.01.00.019";
2318 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2319 $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')");
2320 print "Upgrade to $DBversion done (adding OPACShowCheckoutName systempref)\n";
2321 SetVersion ($DBversion);
2324 $DBversion = "3.01.00.020";
2325 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2326 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesID','','See:http://librarything.com/forlibraries/','','free')");
2327 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesEnabled','0','Enable or Disable Library Thing for Libraries Features','','YesNo')");
2328 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesTabbedView','0','Put LibraryThingForLibraries Content in Tabs.','','YesNo')");
2329 print "Upgrade to $DBversion done (adding LibraryThing for Libraries sysprefs)\n";
2330 SetVersion ($DBversion);
2333 $DBversion = "3.01.00.021";
2334 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2335 my $enable_reviews = C4::Context->preference('OPACAmazonEnabled') ? '1' : '0';
2336 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonReviews', '$enable_reviews', 'Display Amazon readers reviews on OPAC','','YesNo')");
2337 print "Upgrade to $DBversion done (adding OPACAmazonReviews syspref)\n";
2338 SetVersion ($DBversion);
2341 $DBversion = '3.01.00.022';
2342 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2343 $dbh->do("ALTER TABLE `labels_conf` MODIFY COLUMN `formatstring` mediumtext DEFAULT NULL");
2344 print "Upgrade to $DBversion done (bug 2945: increase size of labels_conf.formatstring)\n";
2345 SetVersion ($DBversion);
2348 $DBversion = '3.01.00.023';
2349 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2350 $dbh->do("ALTER TABLE biblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2351 $dbh->do("ALTER TABLE deletedbiblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2352 $dbh->do("ALTER TABLE import_biblios MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2353 $dbh->do("ALTER TABLE suggestions MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2354 print "Upgrade to $DBversion done (bug 2765: increase width of isbn column in several tables)\n";
2355 SetVersion ($DBversion);
2358 $DBversion = "3.01.00.024";
2359 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2360 $dbh->do("ALTER TABLE labels MODIFY COLUMN batch_id int(10) NOT NULL default 1;");
2361 print "Upgrade to $DBversion done (change labels.batch_id from varchar to int)\n";
2362 SetVersion ($DBversion);
2365 $DBversion = '3.01.00.025';
2366 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2367 $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')");
2369 print "Upgrade to $DBversion done (added ceilingDueDate system preference)\n";
2370 SetVersion ($DBversion);
2373 $DBversion = '3.01.00.026';
2374 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2375 $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')");
2377 print "Upgrade to $DBversion done (added numReturnedItemsToShow system preference)\n";
2378 SetVersion ($DBversion);
2381 $DBversion = '3.01.00.027';
2382 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2383 $dbh->do("ALTER TABLE zebraqueue CHANGE `biblio_auth_number` `biblio_auth_number` bigint(20) unsigned NOT NULL default 0");
2384 print "Upgrade to $DBversion done (Increased size of zebraqueue biblio_auth_number to address bug 3148.)\n";
2385 SetVersion ($DBversion);
2388 $DBversion = '3.01.00.028';
2389 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2390 my $enable_reviews = C4::Context->preference('AmazonEnabled') ? '1' : '0';
2391 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonReviews', '$enable_reviews', 'Display Amazon reviews on staff interface','','YesNo')");
2392 print "Upgrade to $DBversion done (added AmazonReviews)\n";
2393 SetVersion ($DBversion);
2396 $DBversion = '3.01.00.029';
2397 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2398 $dbh->do(q( UPDATE language_rfc4646_to_iso639
2399 SET iso639_2_code = 'spa'
2400 WHERE rfc4646_subtag = 'es'
2401 AND iso639_2_code = 'rus' )
2403 print "Upgrade to $DBversion done (fixed bug 2599: using Spanish search limit retrieves Russian results)\n";
2404 SetVersion ($DBversion);
2407 $DBversion = "3.01.00.030";
2408 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2409 $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')");
2410 print "Upgrade to $DBversion done (added AllowNotForLoanOverride system preference)\n";
2411 SetVersion ($DBversion);
2414 $DBversion = "3.01.00.031";
2415 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2416 $dbh->do("ALTER TABLE branch_transfer_limits
2417 MODIFY toBranch varchar(10) NOT NULL,
2418 MODIFY fromBranch varchar(10) NOT NULL,
2419 MODIFY itemtype varchar(10) NULL");
2420 print "Upgrade to $DBversion done (fix column widths in branch_transfer_limits)\n";
2421 SetVersion ($DBversion);
2424 $DBversion = "3.01.00.032";
2425 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2426 $dbh->do(<<ENDOFRENEWAL);
2427 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');
2428 ENDOFRENEWAL
2429 print "Upgrade to $DBversion done (Change the field)\n";
2430 SetVersion ($DBversion);
2433 $DBversion = "3.01.00.033";
2434 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2435 $dbh->do(q/
2436 ALTER TABLE borrower_message_preferences
2437 MODIFY borrowernumber int(11) default NULL,
2438 ADD categorycode varchar(10) default NULL AFTER borrowernumber,
2439 ADD KEY `categorycode` (`categorycode`),
2440 ADD CONSTRAINT `borrower_message_preferences_ibfk_3`
2441 FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
2442 ON DELETE CASCADE ON UPDATE CASCADE
2444 print "Upgrade to $DBversion done (DB changes to allow patron category defaults for messaging preferences)\n";
2445 SetVersion ($DBversion);
2448 $DBversion = "3.01.00.034";
2449 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2450 $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
2451 print "Upgrade to $DBversion done (Adding graceperiod column to subscription table)\n";
2452 SetVersion ($DBversion);
2455 $DBversion = '3.01.00.035';
2456 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2457 $dbh->do(q{ ALTER TABLE `subscription` ADD location varchar(80) NULL DEFAULT '' AFTER callnumber; });
2458 print "Upgrade to $DBversion done (Adding location to subscription table)\n";
2459 SetVersion ($DBversion);
2462 $DBversion = '3.01.00.036';
2463 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2464 $dbh->do("UPDATE systempreferences SET explanation = 'Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd'
2465 WHERE variable = 'IntranetBiblioDefaultView'
2466 AND explanation = 'IntranetBiblioDefaultView'");
2467 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = 'normal|marc|isbd|labeled_marc'
2468 WHERE variable = 'IntranetBiblioDefaultView'");
2469 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewISBD','1','Allow display of ISBD view of bibiographic records','','YesNo')");
2470 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo')");
2471 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo')");
2472 print "Upgrade to $DBversion done (new viewISBD, viewLabeledMARC, viewMARC sysprefs and tweak IntranetBiblioDefaultView)\n";
2473 SetVersion ($DBversion);
2476 $DBversion = '3.01.00.037';
2477 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2478 $dbh->do('ALTER TABLE authorised_values ADD KEY `lib` (`lib`)');
2479 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo')");
2480 SetVersion ($DBversion);
2481 print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
2484 $DBversion = "3.01.00.038";
2485 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2486 # update branches table
2488 $dbh->do("ALTER TABLE branches ADD `branchzip` varchar(25) default NULL AFTER `branchaddress3`");
2489 $dbh->do("ALTER TABLE branches ADD `branchcity` mediumtext AFTER `branchzip`");
2490 $dbh->do("ALTER TABLE branches ADD `branchcountry` text AFTER `branchcity`");
2491 $dbh->do("ALTER TABLE branches ADD `branchurl` mediumtext AFTER `branchemail`");
2492 $dbh->do("ALTER TABLE branches ADD `branchnotes` mediumtext AFTER `branchprinter`");
2493 print "Upgrade to $DBversion done (add ZIP, city, country, URL, and notes column to branches)\n";
2494 SetVersion ($DBversion);
2497 $DBversion = '3.01.00.039';
2498 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2499 $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')");
2500 $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')");
2501 SetVersion ($DBversion);
2502 print "Upgrade to $DBversion done (added SpineLabelFormat and SpineLabelAutoPrint sysprefs)\n";
2505 $DBversion = '3.01.00.040';
2506 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2507 $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')");
2508 $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')");
2509 SetVersion ($DBversion);
2510 print "Upgrade to $DBversion done (AllowHoldDateInFuture and OPACAllowHoldDateInFuture sysprefs)\n";
2513 $DBversion = '3.01.00.041';
2514 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2515 $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')");
2516 SetVersion ($DBversion);
2517 print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that if you use enhanced content from Amazon, this should be set right away.)\n";
2520 $DBversion = '3.01.00.042';
2521 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2522 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACFineNoRenewals','99999','Fine Limit above which user canmot renew books via OPAC','','Integer')");
2523 SetVersion ($DBversion);
2524 print "Upgrade to $DBversion done (added OPACFineNoRenewals syspref)\n";
2527 $DBversion = '3.01.00.043';
2528 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2529 $dbh->do('ALTER TABLE items ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2530 $dbh->do('UPDATE items SET permanent_location = location');
2531 $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 )', '')");
2532 $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')");
2533 $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')");
2534 SetVersion ($DBversion);
2535 print "Upgrade to $DBversion done (amended Item added NewItemsDefaultLocation, InProcessingToShelvingCart, ReturnToShelvingCart sysprefs)\n";
2538 $DBversion = '3.01.00.044';
2539 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2540 $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')");
2541 SetVersion ($DBversion);
2542 print "Upgrade to $DBversion done (added DisplayClearScreenButton system preference)\n";
2545 $DBversion = '3.01.00.045';
2546 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2547 $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')");
2548 SetVersion ($DBversion);
2549 print "Upgrade to $DBversion done (added a preference to hide the patrons name in the staff catalog)\n";
2552 $DBversion = "3.01.00.046";
2553 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2554 # update borrowers table
2556 $dbh->do("ALTER TABLE borrowers ADD `country` text AFTER zipcode");
2557 $dbh->do("ALTER TABLE borrowers ADD `B_country` text AFTER B_zipcode");
2558 $dbh->do("ALTER TABLE deletedborrowers ADD `country` text AFTER zipcode");
2559 $dbh->do("ALTER TABLE deletedborrowers ADD `B_country` text AFTER B_zipcode");
2560 print "Upgrade to $DBversion done (add country and B_country to borrowers)\n";
2561 SetVersion ($DBversion);
2564 $DBversion = '3.01.00.047';
2565 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2566 $dbh->do("ALTER TABLE items MODIFY itemcallnumber varchar(255);");
2567 $dbh->do("ALTER TABLE deleteditems MODIFY itemcallnumber varchar(255);");
2568 $dbh->do("ALTER TABLE tmp_holdsqueue MODIFY itemcallnumber varchar(255);");
2569 SetVersion ($DBversion);
2570 print " Upgrade to $DBversion done (bug 2761: change max length of itemcallnumber to 255 from 30)\n";
2573 $DBversion = '3.01.00.048';
2574 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2575 $dbh->do("UPDATE userflags SET flagdesc='View Catalog (Librarian Interface)' WHERE bit=2;");
2576 $dbh->do("UPDATE userflags SET flagdesc='Edit Catalog (Modify bibliographic/holdings data)' WHERE bit=9;");
2577 $dbh->do("UPDATE userflags SET flagdesc='Allow to edit authorities' WHERE bit=14;");
2578 $dbh->do("UPDATE userflags SET flagdesc='Allow to access to the reports module' WHERE bit=16;");
2579 $dbh->do("UPDATE userflags SET flagdesc='Allow to manage serials subscriptions' WHERE bit=15;");
2580 SetVersion ($DBversion);
2581 print " Upgrade to $DBversion done (bug 2611: fix spelling/capitalization in permission flag descriptions)\n";
2584 $DBversion = '3.01.00.049';
2585 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2586 $dbh->do("UPDATE permissions SET description = 'Perform inventory (stocktaking) of your catalog' WHERE code = 'inventory';");
2587 SetVersion ($DBversion);
2588 print "Upgrade to $DBversion done (bug 2611: changed catalogue to catalog per the standard)\n";
2591 $DBversion = '3.01.00.050';
2592 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2593 $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');");
2594 SetVersion ($DBversion);
2595 print "Upgrade to $DBversion done (bug 1934: Add OPACSearchForTitleIn syspref)\n";
2598 $DBversion = '3.01.00.051';
2599 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2600 $dbh->do("UPDATE systempreferences SET explanation='Fine limit above which user cannot renew books via OPAC' WHERE variable='OPACFineNoRenewals';");
2601 $dbh->do("UPDATE systempreferences SET explanation='If set to ON, a clear screen button will appear on the circulation page.' WHERE variable='DisplayClearScreenButton';");
2602 SetVersion ($DBversion);
2603 print "Upgrade to $DBversion done (fixed typos in new sysprefs)\n";
2606 $DBversion = '3.01.00.052';
2607 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2608 $dbh->do('ALTER TABLE deleteditems ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2609 SetVersion ($DBversion);
2610 print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
2613 $DBversion = '3.01.00.053';
2614 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2615 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
2616 system("perl $upgrade_script");
2617 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";
2618 SetVersion ($DBversion);
2621 $DBversion = '3.01.00.054';
2622 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2623 $dbh->do("ALTER TABLE borrowers ADD `B_address2` text AFTER B_address");
2624 $dbh->do("ALTER TABLE borrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2625 $dbh->do("ALTER TABLE deletedborrowers ADD `B_address2` text AFTER B_address");
2626 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2627 SetVersion ($DBversion);
2628 print "Upgrade to $DBversion done (bug 1600, bug 3454: add altcontactcountry and B_address2 to borrowers and deletedborrowers)\n";
2631 $DBversion = '3.01.00.055';
2632 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2633 $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'|);
2634 SetVersion ($DBversion);
2635 print "Upgrade to $DBversion done (changed OPACSearchForTitleIn per requests in bug 1934)\n";
2638 $DBversion = '3.01.00.056';
2639 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2640 $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');");
2641 SetVersion ($DBversion);
2642 print "Upgrade to $DBversion done (Bug 1172 : Add OPACPatronDetails syspref)\n";
2645 $DBversion = '3.01.00.057';
2646 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2647 $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');");
2648 SetVersion ($DBversion);
2649 print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
2652 $DBversion = '3.01.00.058';
2653 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2654 $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2655 $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2656 $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2657 SetVersion ($DBversion);
2658 print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
2661 $DBversion = '3.01.00.059';
2662 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2663 $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')");
2664 SetVersion ($DBversion);
2665 print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
2668 $DBversion = '3.01.00.060';
2669 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2670 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
2671 $dbh->do('DROP TABLE IF EXISTS messages');
2672 $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
2673 `borrowernumber` int(11) NOT NULL,
2674 `branchcode` varchar(4) default NULL,
2675 `message_type` varchar(1) NOT NULL,
2676 `message` text NOT NULL,
2677 `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2678 PRIMARY KEY (`message_id`)
2679 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
2681 print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
2682 SetVersion ($DBversion);
2685 $DBversion = '3.01.00.061';
2686 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2687 $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')");
2688 print "Upgrade to $DBversion done ( Added ShowPatronImageInWebBasedSelfCheck system preference )\n";
2689 SetVersion ($DBversion);
2692 $DBversion = "3.01.00.062";
2693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2694 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'manage_csv_profiles', 'Manage CSV export profiles')");
2695 $dbh->do(q/
2696 CREATE TABLE `export_format` (
2697 `export_format_id` int(11) NOT NULL auto_increment,
2698 `profile` varchar(255) NOT NULL,
2699 `description` mediumtext NOT NULL,
2700 `marcfields` mediumtext NOT NULL,
2701 PRIMARY KEY (`export_format_id`)
2702 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
2704 print "Upgrade to $DBversion done (added csv export profiles)\n";
2707 $DBversion = "3.01.00.063";
2708 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2709 $dbh->do("
2710 CREATE TABLE `fieldmapping` (
2711 `id` int(11) NOT NULL auto_increment,
2712 `field` varchar(255) NOT NULL,
2713 `frameworkcode` char(4) NOT NULL default '',
2714 `fieldcode` char(3) NOT NULL,
2715 `subfieldcode` char(1) NOT NULL,
2716 PRIMARY KEY (`id`)
2717 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2719 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";
2722 $DBversion = '3.01.00.065';
2723 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2724 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
2725 $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
2726 $sth->execute();
2728 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
2730 while(my $row = $sth->fetchrow_hashref){
2731 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
2734 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
2736 SetVersion ($DBversion);
2737 print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2740 $DBversion = '3.01.00.066';
2741 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2742 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2744 my $maxreserves = C4::Context->preference('maxreserves');
2745 $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2746 $sth->execute($maxreserves);
2748 $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2750 $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2752 SetVersion ($DBversion);
2753 print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2756 $DBversion = "3.01.00.067";
2757 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2758 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
2759 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
2760 print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
2761 SetVersion ($DBversion);
2764 $DBversion = "3.01.00.068";
2765 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2766 $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
2767 print "Upgrade to $DBversion done (Adding finedays in issuingrules table)\n";
2768 SetVersion ($DBversion);
2772 $DBversion = "3.01.00.069";
2773 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2774 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableOpacSearchHistory', '1', '', 'Enable or disable opac search history', 'YesNo')");
2776 my $create = <<SEARCHHIST;
2777 CREATE TABLE IF NOT EXISTS `search_history` (
2778 `userid` int(11) NOT NULL,
2779 `sessionid` varchar(32) NOT NULL,
2780 `query_desc` varchar(255) NOT NULL,
2781 `query_cgi` varchar(255) NOT NULL,
2782 `total` int(11) NOT NULL,
2783 `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2784 KEY `userid` (`userid`),
2785 KEY `sessionid` (`sessionid`)
2786 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
2787 SEARCHHIST
2788 $dbh->do($create);
2790 print "Upgrade to $DBversion done (added OPAC search history preference and table)\n";
2793 $DBversion = "3.01.00.070";
2794 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2795 $dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
2796 print "Upgrade to $DBversion done (Added a lib_opac field in authorised_values table)\n";
2799 $DBversion = "3.01.00.071";
2800 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2801 $dbh->do("ALTER TABLE `subscription` ADD `enddate` date default NULL");
2802 $dbh->do("ALTER TABLE subscriptionhistory CHANGE enddate histenddate DATE default NULL");
2803 print "Upgrade to $DBversion done ( Adding enddate to subscription)\n";
2806 # Acquisitions update
2808 $DBversion = "3.01.00.072";
2809 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2810 $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')");
2811 # create a new syspref for the 'Mr anonymous' patron
2812 $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,'')");
2813 # fill AnonymousPatron with AnonymousSuggestion value (copy)
2814 my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='AnonSuggestions'");
2815 $sth->execute;
2816 my ($value) = $sth->fetchrow() || 0;
2817 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='AnonymousPatron'");
2818 # set AnonymousSuggestion do YesNo
2819 # 1st, set the value (1/True if it had a borrowernumber)
2820 $dbh->do("UPDATE systempreferences SET value=1 WHERE variable='AnonSuggestions' AND value>0");
2821 # 2nd, change the type to Choice
2822 $dbh->do("UPDATE systempreferences SET type='YesNo' WHERE variable='AnonSuggestions'");
2823 # borrower reading record privacy : 0 : forever, 1 : laws, 2 : don't keep at all
2824 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
2825 print "Upgrade to $DBversion done (add new syspref and column in borrowers)\n";
2826 SetVersion ($DBversion);
2829 $DBversion = '3.01.00.073';
2830 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2831 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2832 $dbh->do(<<'END_SQL');
2833 CREATE TABLE IF NOT EXISTS `aqcontract` (
2834 `contractnumber` int(11) NOT NULL auto_increment,
2835 `contractstartdate` date default NULL,
2836 `contractenddate` date default NULL,
2837 `contractname` varchar(50) default NULL,
2838 `contractdescription` mediumtext,
2839 `booksellerid` int(11) not NULL,
2840 PRIMARY KEY (`contractnumber`),
2841 CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2842 REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2843 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2844 END_SQL
2845 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2846 print "Upgrade to $DBversion done (adding aqcontract table)\n";
2847 SetVersion ($DBversion);
2850 $DBversion = '3.01.00.074';
2851 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2852 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `basketname` varchar(50) default NULL AFTER `basketno`");
2853 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `note` mediumtext AFTER `basketname`");
2854 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `booksellernote` mediumtext AFTER `note`");
2855 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `contractnumber` int(11) AFTER `booksellernote`");
2856 $dbh->do("ALTER TABLE `aqbasket` ADD FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`)");
2857 print "Upgrade to $DBversion done (edit aqbasket table done)\n";
2858 SetVersion ($DBversion);
2861 $DBversion = '3.01.00.075';
2862 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2863 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `uncertainprice` tinyint(1)");
2865 print "Upgrade to $DBversion done (adding uncertainprices)\n";
2866 SetVersion ($DBversion);
2869 $DBversion = '3.01.00.076';
2870 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2871 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2872 $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` (
2873 `id` int(11) NOT NULL auto_increment,
2874 `name` varchar(50) default NULL,
2875 `closed` tinyint(1) default NULL,
2876 `booksellerid` int(11) NOT NULL,
2877 PRIMARY KEY (`id`),
2878 KEY `booksellerid` (`booksellerid`),
2879 CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2880 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
2881 $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
2882 $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
2883 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
2884 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2885 print "Upgrade to $DBversion done (adding basketgroups)\n";
2886 SetVersion ($DBversion);
2888 $DBversion = '3.01.00.077';
2889 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2891 $dbh->do("SET FOREIGN_KEY_CHECKS=0 ");
2892 # create a mapping table holding the info we need to match orders to budgets
2893 $dbh->do('DROP TABLE IF EXISTS fundmapping');
2894 $dbh->do(
2895 q|CREATE TABLE fundmapping AS
2896 SELECT aqorderbreakdown.ordernumber, branchcode, bookfundid, budgetdate, entrydate
2897 FROM aqorderbreakdown JOIN aqorders ON aqorderbreakdown.ordernumber = aqorders.ordernumber|);
2898 # match the new type of the corresponding field
2899 $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)');
2900 # System did not ensure budgetdate was valid historically
2901 $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate = '0000-00-00' OR budgetdate IS NULL|);
2902 # We save the map in fundmapping in case you need later processing
2903 $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|);
2904 # these can speed processing up
2905 $dbh->do(q|CREATE INDEX fundmaporder ON fundmapping (ordernumber)|);
2906 $dbh->do(q|CREATE INDEX fundmapid ON fundmapping (bookfundid)|);
2908 $dbh->do("DROP TABLE IF EXISTS `aqbudgetperiods` ");
2910 $dbh->do(qq|
2911 CREATE TABLE `aqbudgetperiods` (
2912 `budget_period_id` int(11) NOT NULL auto_increment,
2913 `budget_period_startdate` date NOT NULL,
2914 `budget_period_enddate` date NOT NULL,
2915 `budget_period_active` tinyint(1) default '0',
2916 `budget_period_description` mediumtext,
2917 `budget_period_locked` tinyint(1) default NULL,
2918 `sort1_authcat` varchar(10) default NULL,
2919 `sort2_authcat` varchar(10) default NULL,
2920 PRIMARY KEY (`budget_period_id`)
2921 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |);
2923 $dbh->do(<<ADDPERIODS);
2924 INSERT INTO aqbudgetperiods (budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_locked)
2925 SELECT DISTINCT startdate, enddate, NOW() BETWEEN startdate and enddate, concat(startdate," ",enddate),NOT NOW() BETWEEN startdate AND enddate from aqbudget
2926 ADDPERIODS
2927 # SORRY , NO AQBUDGET/AQBOOKFUND -> AQBUDGETS IMPORT JUST YET,
2928 # BUT A NEW CLEAN AQBUDGETS TABLE CREATE FOR NOW..
2929 # DROP TABLE IF EXISTS `aqbudget`;
2930 #CREATE TABLE `aqbudget` (
2931 # `bookfundid` varchar(10) NOT NULL default ',
2932 # `startdate` date NOT NULL default 0,
2933 # `enddate` date default NULL,
2934 # `budgetamount` decimal(13,2) default NULL,
2935 # `aqbudgetid` tinyint(4) NOT NULL auto_increment,
2936 # `branchcode` varchar(10) default NULL,
2937 DropAllForeignKeys('aqbudget');
2938 #$dbh->do("drop table aqbudget;");
2941 my $maxbudgetid = $dbh->selectcol_arrayref(<<IDsBUDGET);
2942 SELECT MAX(aqbudgetid) from aqbudget
2943 IDsBUDGET
2945 $$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
2947 $dbh->do(<<BUDGETAUTOINCREMENT);
2948 ALTER TABLE aqbudget AUTO_INCREMENT=$$maxbudgetid[0]
2949 BUDGETAUTOINCREMENT
2951 $dbh->do(<<BUDGETNAME);
2952 ALTER TABLE aqbudget RENAME `aqbudgets`
2953 BUDGETNAME
2955 $dbh->do(<<BUDGETS);
2956 ALTER TABLE `aqbudgets`
2957 CHANGE COLUMN aqbudgetid `budget_id` int(11) NOT NULL AUTO_INCREMENT,
2958 CHANGE COLUMN branchcode `budget_branchcode` varchar(10) default NULL,
2959 CHANGE COLUMN budgetamount `budget_amount` decimal(28,6) NOT NULL default '0.00',
2960 CHANGE COLUMN bookfundid `budget_code` varchar(30) default NULL,
2961 ADD COLUMN `budget_parent_id` int(11) default NULL,
2962 ADD COLUMN `budget_name` varchar(80) default NULL,
2963 ADD COLUMN `budget_encumb` decimal(28,6) default '0.00',
2964 ADD COLUMN `budget_expend` decimal(28,6) default '0.00',
2965 ADD COLUMN `budget_notes` mediumtext,
2966 ADD COLUMN `budget_description` mediumtext,
2967 ADD COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2968 ADD COLUMN `budget_amount_sublevel` decimal(28,6) AFTER `budget_amount`,
2969 ADD COLUMN `budget_period_id` int(11) default NULL,
2970 ADD COLUMN `sort1_authcat` varchar(80) default NULL,
2971 ADD COLUMN `sort2_authcat` varchar(80) default NULL,
2972 ADD COLUMN `budget_owner_id` int(11) default NULL,
2973 ADD COLUMN `budget_permission` int(1) default '0';
2974 BUDGETS
2976 $dbh->do(<<BUDGETCONSTRAINTS);
2977 ALTER TABLE `aqbudgets`
2978 ADD CONSTRAINT `aqbudgets_ifbk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
2979 BUDGETCONSTRAINTS
2980 # $dbh->do(<<BUDGETPKDROP);
2981 #ALTER TABLE `aqbudgets`
2982 # DROP PRIMARY KEY
2983 #BUDGETPKDROP
2984 # $dbh->do(<<BUDGETPKADD);
2985 #ALTER TABLE `aqbudgets`
2986 # ADD PRIMARY KEY budget_id
2987 #BUDGETPKADD
2990 my $query_period= $dbh->prepare(qq|SELECT budget_period_id from aqbudgetperiods where budget_period_startdate=? and budget_period_enddate=?|);
2991 my $query_bookfund= $dbh->prepare(qq|SELECT * from aqbookfund where bookfundid=?|);
2992 my $selectbudgets=$dbh->prepare(qq|SELECT * from aqbudgets|);
2993 my $updatebudgets=$dbh->prepare(qq|UPDATE aqbudgets SET budget_period_id= ? , budget_name=?, budget_branchcode=? where budget_id=?|);
2994 $selectbudgets->execute;
2995 while (my $databudget=$selectbudgets->fetchrow_hashref){
2996 $query_period->execute ($$databudget{startdate},$$databudget{enddate});
2997 my ($budgetperiodid)=$query_period->fetchrow;
2998 $query_bookfund->execute ($$databudget{budget_code});
2999 my $databf=$query_bookfund->fetchrow_hashref;
3000 my $branchcode=$$databudget{budget_branchcode}||$$databf{branchcode};
3001 $updatebudgets->execute($budgetperiodid,$$databf{bookfundname},$branchcode,$$databudget{budget_id});
3003 $dbh->do(<<BUDGETDROPDATES);
3004 ALTER TABLE `aqbudgets`
3005 DROP startdate,
3006 DROP enddate
3007 BUDGETDROPDATES
3010 $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
3011 $dbh->do("CREATE TABLE `aqbudgets_planning` (
3012 `plan_id` int(11) NOT NULL auto_increment,
3013 `budget_id` int(11) NOT NULL,
3014 `budget_period_id` int(11) NOT NULL,
3015 `estimated_amount` decimal(28,6) default NULL,
3016 `authcat` varchar(30) NOT NULL,
3017 `authvalue` varchar(30) NOT NULL,
3018 `display` tinyint(1) DEFAULT 1,
3019 PRIMARY KEY (`plan_id`),
3020 CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
3021 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
3023 $dbh->do("ALTER TABLE `aqorders`
3024 ADD COLUMN `budget_id` tinyint(4) NOT NULL,
3025 ADD COLUMN `budgetgroup_id` int(11) NOT NULL,
3026 ADD COLUMN `sort1_authcat` varchar(10) default NULL,
3027 ADD COLUMN `sort2_authcat` varchar(10) default NULL" );
3028 # We need to map the orders to the budgets
3029 # For Historic reasons this is more complex than it should be on occasions
3030 my $budg_arr = $dbh->selectall_arrayref(
3031 q|SELECT aqbudgets.budget_id, aqbudgets.budget_code, aqbudgetperiods.budget_period_startdate,
3032 aqbudgetperiods.budget_period_enddate
3033 FROM aqbudgets JOIN aqbudgetperiods ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id
3034 ORDER BY budget_code, budget_period_startdate|, { Slice => {} });
3035 # We arbitarily order on start date, this means if you have overlapping periods the order will be
3036 # linked to the latest matching budget YMMV
3037 my $b_sth = $dbh->prepare(
3038 'UPDATE fundmapping set aqbudgetid = ? where bookfundid =? AND budgetdate >= ? AND budgetdate <= ?');
3039 for my $b ( @{$budg_arr}) {
3040 $b_sth->execute($b->{budget_id}, $b->{budget_code}, $b->{budget_period_startdate}, $b->{budget_period_enddate});
3042 # move the budgetids to aqorders
3043 $dbh->do(q|UPDATE aqorders, fundmapping SET aqorders.budget_id = fundmapping.aqbudgetid
3044 WHERE aqorders.ordernumber = fundmapping.ordernumber AND fundmapping.aqbudgetid IS NOT NULL|);
3045 # NB fundmapping is left as an accontants trail also if you have budgetids that werent set
3046 # you can decide what to do with them
3048 $dbh->do(
3049 q|UPDATE aqorders, aqbudgets SET aqorders.budgetgroup_id = aqbudgets.budget_period_id
3050 WHERE aqorders.budget_id = aqbudgets.budget_id|);
3051 # cannot do until aqorderbreakdown removed
3052 # $dbh->do("DROP TABLE aqbookfund ");
3053 # $dbh->do("ALTER TABLE aqorders ADD FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON UPDATE CASCADE " ); ????
3054 $dbh->do("SET FOREIGN_KEY_CHECKS=1 ");
3056 print "Upgrade to $DBversion done (Adding new aqbudgetperiods, aqbudgets and aqbudget_planning tables )\n";
3057 SetVersion ($DBversion);
3062 $DBversion = '3.01.00.078';
3063 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3064 $dbh->do("ALTER TABLE aqbudgetperiods ADD COLUMN budget_period_total decimal(28,6)");
3065 print "Upgrade to $DBversion done (adds 'budget_period_total' column to aqbudgetperiods table)\n";
3066 SetVersion($DBversion);
3070 $DBversion = '3.01.00.079';
3071 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3072 $dbh->do("ALTER TABLE currency ADD COLUMN active tinyint(1)");
3074 print "Upgrade to $DBversion done (adds 'active' column to currencies table)\n";
3075 SetVersion($DBversion);
3078 $DBversion = '3.01.00.080';
3079 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3080 $dbh->do(<<BUDG_PERM );
3081 INSERT INTO permissions (module_bit, code, description) VALUES
3082 (11, 'vendors_manage', 'Manage vendors'),
3083 (11, 'contracts_manage', 'Manage contracts'),
3084 (11, 'period_manage', 'Manage periods'),
3085 (11, 'budget_manage', 'Manage budgets'),
3086 (11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
3087 (11, 'planning_manage', 'Manage budget plannings'),
3088 (11, 'order_manage', 'Manage orders & basket'),
3089 (11, 'group_manage', 'Manage orders & basketgroups'),
3090 (11, 'order_receive', 'Manage orders & basket'),
3091 (11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
3092 BUDG_PERM
3094 print "Upgrade to $DBversion done (adds permissions for the acquisitions module)\n";
3095 SetVersion($DBversion);
3099 $DBversion = '3.01.00.081';
3100 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3101 $dbh->do("ALTER TABLE aqbooksellers ADD COLUMN `gstrate` decimal(6,4) default NULL");
3102 if (my $gist=C4::Context->preference("gist")){
3103 my $sql=$dbh->prepare("UPDATE aqbooksellers set `gstrate`=? ");
3104 $sql->execute($gist) ;
3106 print "Upgrade to $DBversion done (added per-supplier gstrate setting)\n";
3107 SetVersion($DBversion);
3110 $DBversion = "3.01.00.082";
3111 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3112 if (C4::Context->preference("opaclanguages") eq "fr") {
3113 $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')#);
3114 } else {
3115 $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')");
3117 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
3118 SetVersion ($DBversion);
3121 $DBversion = "3.01.00.083";
3122 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3123 $dbh->do(qq|
3124 CREATE TABLE `aqorders_items` (
3125 `ordernumber` int(11) NOT NULL,
3126 `itemnumber` int(11) NOT NULL,
3127 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
3128 PRIMARY KEY (`itemnumber`),
3129 KEY `ordernumber` (`ordernumber`)
3130 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
3133 $dbh->do(qq| DROP TABLE aqorderbreakdown |);
3134 $dbh->do('DROP TABLE aqbookfund');
3135 print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
3136 SetVersion ($DBversion);
3139 $DBversion = "3.01.00.084";
3140 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3141 $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') #);
3143 print "Upgrade to $DBversion done (CurrencyFormat syspref added)\n";
3144 SetVersion ($DBversion);
3147 $DBversion = "3.01.00.085";
3148 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3149 $dbh->do("ALTER table aqorders drop column title");
3150 $dbh->do("ALTER TABLE `aqorders` CHANGE `budget_id` `budget_id` INT( 11 ) NOT NULL");
3151 print "Upgrade to $DBversion done update budget_id size that should not be a tinyint\n";
3152 SetVersion ($DBversion);
3155 $DBversion = "3.01.00.086";
3156 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3157 $dbh->do(<<SUGGESTIONS);
3158 ALTER table suggestions
3159 ADD budgetid INT(11),
3160 ADD branchcode VARCHAR(10) default NULL,
3161 ADD acceptedby INT(11) default NULL,
3162 ADD accepteddate date default NULL,
3163 ADD suggesteddate date default NULL,
3164 ADD manageddate date default NULL,
3165 ADD rejectedby INT(11) default NULL,
3166 ADD rejecteddate date default NULL,
3167 ADD collectiontitle text default NULL,
3168 ADD itemtype VARCHAR(30) default NULL
3170 SUGGESTIONS
3171 print "Upgrade to $DBversion done (Suggestions)\n";
3172 SetVersion ($DBversion);
3175 $DBversion = "3.01.00.087";
3176 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3177 $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;");
3178 print "Upgrade to $DBversion done (Drop column budget_amount_sublevel from aqbudgets)\n";
3179 SetVersion ($DBversion);
3182 $DBversion = "3.01.00.088";
3183 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3184 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo') #);
3186 print "Upgrade to $DBversion done (intranetbookbag syspref added)\n";
3187 SetVersion ($DBversion);
3190 $DBversion = "3.01.00.090";
3191 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3192 $dbh->do("
3193 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3194 (16, 'execute_reports', 'Execute SQL reports'),
3195 (16, 'create_reports', 'Create SQL Reports')
3198 print "Upgrade to $DBversion done (granular permissions for guided reports added)\n";
3199 SetVersion ($DBversion);
3202 $DBversion = "3.01.00.091";
3203 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3204 $dbh->do("
3205 UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions'
3206 WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1
3209 print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
3210 SetVersion ($DBversion);
3213 $DBversion = "3.01.00.092";
3214 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3215 if (C4::Context->preference("opaclanguages") =~ /fr/) {
3216 $dbh->do(qq{
3217 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');
3219 }else{
3220 $dbh->do(qq{
3221 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');
3224 print "Upgrade to $DBversion done (Added RoutingListAddReserves syspref)\n";
3225 SetVersion ($DBversion);
3228 $DBversion = "3.01.00.093";
3229 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3230 $dbh->do(qq{
3231 ALTER TABLE biblioitems ADD INDEX issn_idx (issn);
3233 print "Upgrade to $DBversion done (added index to ISSN)\n";
3234 SetVersion ($DBversion);
3237 $DBversion = "3.01.00.094";
3238 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3239 $dbh->do(qq{
3240 ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10) default NULL, ADD deliverycomment VARCHAR(255) default NULL;
3243 print "Upgrade to $DBversion done (adding deliveryplace deliverycomment to basketgroups)\n";
3244 SetVersion ($DBversion);
3247 $DBversion = "3.01.00.095";
3248 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3249 $dbh->do(qq{
3250 ALTER TABLE items ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number";
3252 $dbh->do(qq{
3253 ALTER TABLE items ADD UNIQUE INDEX itemsstocknumberidx (stocknumber);
3255 $dbh->do(qq{
3256 ALTER TABLE deleteditems ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number of deleted items";
3258 $dbh->do(qq{
3259 ALTER TABLE deleteditems ADD UNIQUE INDEX deleteditemsstocknumberidx (stocknumber);
3261 if (C4::Context->preference('marcflavour') eq 'UNIMARC'){
3262 $dbh->do(qq{
3263 INSERT IGNORE INTO marc_subfield_structure (frameworkcode,tagfield, tagsubfield, tab, repeatable, mandatory,kohafield)
3264 SELECT DISTINCT (frameworkcode),995,"j",10,0,0,"items.stocknumber" from biblio_framework ;
3266 #Previously, copynumber was used as stocknumber
3267 $dbh->do(qq{
3268 UPDATE items set stocknumber=copynumber;
3270 $dbh->do(qq{
3271 UPDATE items set copynumber=NULL;
3274 print "Upgrade to $DBversion done (stocknumber field added)\n";
3275 SetVersion ($DBversion);
3278 $DBversion = "3.01.00.096";
3279 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3280 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPdfTemplate','','Uploads a PDF template to use for printing baskets','NULL','Upload')");
3281 $dbh->do("UPDATE systempreferences SET variable='OrderPdfFormat' WHERE variable='pdfformat'");
3282 print "Upgrade to $DBversion done (PDF orders system preferences added and updated)\n";
3283 SetVersion ($DBversion);
3286 $DBversion = "3.01.00.097";
3287 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3288 $dbh->do(qq{
3289 ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10) NOT NULL AFTER deliverycomment;
3292 print "Upgrade to $DBversion done (Adding billingplace to aqbasketgroups)\n";
3293 SetVersion ($DBversion);
3296 $DBversion = "3.01.00.098";
3297 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3298 $dbh->do(qq{
3299 ALTER TABLE auth_subfield_structure MODIFY frameworkcode VARCHAR(10) NULL;
3302 print "Upgrade to $DBversion done (changing frameworkcode length in auth_subfield_structure)\n";
3303 SetVersion ($DBversion);
3306 $DBversion = "3.01.00.099";
3307 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3308 $dbh->do(qq{
3309 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3310 (9, 'edit_catalogue', 'Edit catalogue'),
3311 (9, 'fast_cataloging', 'Fast cataloging')
3314 print "Upgrade to $DBversion done (granular permissions for cataloging added)\n";
3315 SetVersion ($DBversion);
3318 $DBversion = "3.01.00.100";
3319 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3320 $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')");
3321 print "Upgrade to $DBversion done (added CAS authentication system preferences)\n";
3322 SetVersion ($DBversion);
3325 $DBversion = "3.01.00.101";
3326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3327 $dbh->do(
3328 "INSERT INTO systempreferences
3329 (variable, value, options, explanation, type)
3330 VALUES (
3331 'OverdueNoticeBcc', '', '',
3332 'Email address to Bcc outgoing notices sent by email',
3333 'free')
3335 print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
3336 SetVersion ($DBversion);
3338 $DBversion = "3.01.00.102";
3339 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3340 $dbh->do(
3341 "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
3343 print "Upgrade to $DBversion done (fixed spelling error in edit_catalogue permission)\n";
3344 SetVersion ($DBversion);
3347 $DBversion = "3.01.00.103";
3348 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3349 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
3350 print "Upgrade to $DBversion done (adding patron permissions for tags tool)\n";
3351 SetVersion ($DBversion);
3354 $DBversion = "3.01.00.104";
3355 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3357 my ($maninv_count, $borrnotes_count);
3358 eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
3359 if ($maninv_count == 0) {
3360 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
3362 eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
3363 if ($borrnotes_count == 0) {
3364 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
3367 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
3368 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
3370 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";
3371 SetVersion ($DBversion);
3375 $DBversion = "3.01.00.105";
3376 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3377 $dbh->do("
3378 CREATE TABLE `collections` (
3379 `colId` int(11) NOT NULL auto_increment,
3380 `colTitle` varchar(100) NOT NULL default '',
3381 `colDesc` text NOT NULL,
3382 `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
3383 PRIMARY KEY (`colId`)
3384 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3387 $dbh->do("
3388 CREATE TABLE `collections_tracking` (
3389 `ctId` int(11) NOT NULL auto_increment,
3390 `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
3391 `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
3392 PRIMARY KEY (`ctId`)
3393 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3395 $dbh->do("
3396 INSERT INTO permissions (module_bit, code, description)
3397 VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
3398 print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
3399 SetVersion ($DBversion);
3401 $DBversion = "3.01.00.106";
3402 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3403 $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' )");
3404 print "Upgrade to $DBversion done (added OpacAddMastheadLibraryPulldown system preferences)\n";
3405 SetVersion ($DBversion);
3408 $DBversion = '3.01.00.107';
3409 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3410 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
3411 system("perl $upgrade_script");
3412 print "Upgrade to $DBversion done (Migrated labels and patroncards tables and data to new schema.)\n";
3413 SetVersion ($DBversion);
3416 $DBversion = '3.01.00.108';
3417 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3418 $dbh->do(qq{
3419 ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
3420 ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
3421 ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator`
3423 print "Upgrade to $DBversion done (added separators for csv export)\n";
3424 SetVersion ($DBversion);
3427 $DBversion = "3.01.00.109";
3428 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3429 $dbh->do(qq{
3430 ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
3432 print "Upgrade to $DBversion done (added encoding for csv export)\n";
3433 SetVersion ($DBversion);
3436 $DBversion = '3.01.00.110';
3437 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3438 $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
3439 print "Upgrade to $DBversion done (Add enrolment period date support)\n";
3440 SetVersion ($DBversion);
3443 $DBversion = '3.01.00.111';
3444 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3445 print "Upgrade to $DBversion done (mark DBrev for 3.2-alpha release)\n";
3446 SetVersion ($DBversion);
3449 $DBversion = '3.01.00.112';
3450 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3451 $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');");
3452 print "Upgrade to $DBversion done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
3453 SetVersion ($DBversion);
3456 $DBversion = '3.01.00.113';
3457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3458 my $value = C4::Context->preference("XSLTResultsDisplay");
3459 $dbh->do(
3460 "INSERT INTO systempreferences (variable,value,type)
3461 VALUES('OPACXSLTResultsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3462 $value = C4::Context->preference("XSLTDetailsDisplay");
3463 $dbh->do(
3464 "INSERT INTO systempreferences (variable,value,type)
3465 VALUES('OPACXSLTDetailsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3466 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";
3467 SetVersion ($DBversion);
3470 $DBversion = '3.01.00.114';
3471 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3472 $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')");
3473 $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')");
3474 $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')");
3475 print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
3476 SetVersion ($DBversion);
3479 $DBversion = '3.01.00.115';
3480 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3481 $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
3482 $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
3483 print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
3484 SetVersion ($DBversion);
3487 $DBversion = '3.01.00.116';
3488 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3489 if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
3490 $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
3492 print "Upgrade to $DBversion done (corrected default OrderPdfFormat value if still set wrong )\n";
3493 SetVersion ($DBversion);
3496 $DBversion = '3.01.00.117';
3497 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3498 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'por' WHERE rfc4646_subtag='pt' ");
3499 print "Upgrade to $DBversion done (corrected ISO 639-2 language code for Portuguese)\n";
3500 SetVersion ($DBversion);
3503 $DBversion = '3.01.00.118';
3504 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3505 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns
3506 WHERE table_name = 'aqbudgets_planning'
3507 AND column_name = 'display'");
3508 if ($count < 1) {
3509 $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1");
3511 print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n";
3512 SetVersion ($DBversion);
3515 $DBversion = '3.01.00.119';
3516 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3517 eval{require Locale::Currency::Format};
3518 if (!$@) {
3519 print "Upgrade to $DBversion done (Locale::Currency::Format installed.)\n";
3520 SetVersion ($DBversion);
3522 else {
3523 print "Upgrade to $DBversion done.\n";
3524 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";
3525 SetVersion ($DBversion);
3529 $DBversion = '3.01.00.120';
3530 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3531 $dbh->do(q{
3532 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');
3534 print "Upgrade to $DBversion done (bug 1080: add soundon system preference for circulation sounds)\n";
3535 SetVersion ($DBversion);
3538 $DBversion = '3.01.00.121';
3539 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3540 $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE DEFAULT NULL");
3541 $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3542 $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE DEFAULT NULL");
3543 $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3544 print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
3545 SetVersion ($DBversion);
3548 $DBversion = '3.01.00.122';
3549 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3550 $dbh->do(q{
3551 INSERT INTO systempreferences (variable,value,explanation,options,type)
3552 VALUES ('OAI-PMH:ConfFile', '', 'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','','File');
3554 print "Upgrade to $DBversion done. — Add a new system preference OAI-PMF:ConfFile\n";
3555 SetVersion ($DBversion);
3558 $DBversion = "3.01.00.123";
3559 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3560 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3561 (6, 'place_holds', 'Place holds for patrons')");
3562 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3563 (6, 'modify_holds_priority', 'Modify holds priority')");
3564 $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
3565 print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
3566 SetVersion ($DBversion);
3569 $DBversion = '3.01.00.124';
3570 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3571 $dbh->do("
3572 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>>).');
3574 print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
3575 SetVersion ($DBversion);
3578 $DBversion = '3.01.00.125';
3579 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3580 $dbh->do("
3581 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' );
3583 $dbh->do("
3584 INSERT INTO message_transport_types (message_transport_type) values ('print');
3586 print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
3587 SetVersion ($DBversion);
3590 $DBversion = "3.01.00.126";
3591 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3592 $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')");
3593 $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')");
3595 print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:AuthorizedIPs)\n";
3596 SetVersion ($DBversion);
3599 $DBversion = '3.01.00.127';
3600 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3601 $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
3602 print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
3603 SetVersion ($DBversion);
3606 $DBversion = '3.01.00.128';
3607 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3608 $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
3609 print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
3610 SetVersion ($DBversion);
3613 $DBversion = "3.01.00.129";
3614 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3615 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
3616 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
3617 print "Upgrade to $DBversion done (Change permissions names for item batch modification / deletion)\n";
3619 SetVersion ($DBversion);
3622 $DBversion = "3.01.00.130";
3623 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3624 $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'");
3625 print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n";
3626 SetVersion ($DBversion);
3629 $DBversion = "3.01.00.131";
3630 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3631 $dbh->do(q{
3632 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
3634 print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
3635 SetVersion ($DBversion);
3638 $DBversion = "3.01.00.132";
3639 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3640 $dbh->do(q{
3641 ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
3643 print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
3644 SetVersion ($DBversion);
3647 $DBversion = '3.01.00.133';
3648 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3649 $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')");
3650 print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
3651 SetVersion ($DBversion);
3654 $DBversion = '3.01.00.134';
3655 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3656 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
3657 print "Upgrade to $DBversion done (adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page)\n";
3658 SetVersion ($DBversion);
3661 $DBversion = '3.01.00.135';
3662 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3663 $dbh->do("
3664 INSERT INTO `letter` (module, code, name, title, content) VALUES
3665 ('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')
3667 print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)\n";
3668 SetVersion ($DBversion);
3671 $DBversion = '3.01.00.136';
3672 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3673 $dbh->do(qq{
3674 INSERT INTO permissions (module_bit, code, description) VALUES
3675 ( 9, 'edit_items', 'Edit Items');});
3676 print "Upgrade to $DBversion done (Adding a new permission to edit items)\n";
3677 SetVersion ($DBversion);
3680 $DBversion = "3.01.00.137";
3681 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3682 $dbh->do("
3683 INSERT INTO permissions (module_bit, code, description) VALUES
3684 (15, 'check_expiration', 'Check the expiration of a serial'),
3685 (15, 'claim_serials', 'Claim missing serials'),
3686 (15, 'create_subscription', 'Create a new subscription'),
3687 (15, 'delete_subscription', 'Delete an existing subscription'),
3688 (15, 'edit_subscription', 'Edit an existing subscription'),
3689 (15, 'receive_serials', 'Serials receiving'),
3690 (15, 'renew_subscription', 'Renew a subscription'),
3691 (15, 'routing', 'Routing');
3693 print "Upgrade to $DBversion done (adding granular permissions for serials)\n";
3694 SetVersion ($DBversion);
3697 $DBversion = "3.01.00.138";
3698 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3699 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
3700 print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)\n";
3701 SetVersion ($DBversion);
3704 $DBversion = '3.01.00.139';
3705 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3706 $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
3707 print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
3708 SetVersion ($DBversion);
3711 $DBversion = '3.01.00.140';
3712 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3713 $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'TagsModeration' AND value is NULL");
3714 print "Upgrade to $DBversion done (bug 4312 TagsModeration changed from NULL to 0)\n";
3715 SetVersion ($DBversion);
3718 $DBversion = '3.01.00.141';
3719 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3720 $dbh->do(qq{DELETE FROM message_attributes WHERE message_attribute_id=3;});
3721 $dbh->do(qq{DELETE FROM letter WHERE code='EVENT' AND title='Upcoming Library Event';});
3722 print "Upgrade to $DBversion done Remove upcoming events messaging option (bug 2434)\n";
3723 SetVersion ($DBversion);
3726 $DBversion = '3.01.00.142';
3727 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3728 $dbh->do(qq{DELETE FROM message_transports WHERE message_attribute_id=3;});
3729 print "Upgrade to $DBversion done (Remove upcoming events messaging option part 2 (bug 2434))\n";
3730 SetVersion ($DBversion);
3733 $DBversion = '3.01.00.143';
3734 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3735 $dbh->do(qq{CREATE INDEX auth_value_idx ON authorised_values (authorised_value)});
3736 $dbh->do(qq{CREATE INDEX auth_val_cat_idx ON borrower_attribute_types (authorised_value_category)});
3737 print "Upgrade to $DBversion done (Create index on authorised_values and borrower_attribute_types (bug 4139))\n";
3738 SetVersion ($DBversion);
3741 $DBversion = '3.01.00.144';
3742 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3743 $dbh->do(qq{UPDATE systempreferences SET value='normal' where value='default' and variable='IntranetBiblioDefaultView'});
3744 print "Upgrade to $DBversion done (Update the 'default' to 'normal' for the IntranetBiblioDefaultView syspref (bug 5007))\n";
3745 SetVersion ($DBversion);
3748 $DBversion = "3.01.00.145";
3749 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3750 $dbh->do("ALTER TABLE borrowers ADD KEY `guarantorid` (guarantorid);");
3751 print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3752 SetVersion ($DBversion);
3755 $DBversion = '3.01.00.999';
3756 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3757 print "Upgrade to $DBversion done (3.2.0 release candidate)\n";
3758 SetVersion ($DBversion);
3761 $DBversion = "3.02.00.000";
3762 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3763 my $value = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'HomeOrHoldingBranch'");
3764 $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');");
3765 print "Upgrade to $DBversion done (Add HomeOrHoldingBranchReturn system preference)\n";
3766 SetVersion ($DBversion);
3769 $DBversion = "3.02.00.001";
3770 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3771 $dbh->do(q{DELETE FROM systempreferences WHERE variable IN (
3772 'holdCancelLength',
3773 'PINESISBN',
3774 'sortbynonfiling',
3775 'TemplateEncoding',
3776 'OPACSubscriptionDisplay',
3777 'OPACDisplayExtendedSubInfo',
3778 'OAI-PMH:Set',
3779 'OAI-PMH:Subset',
3780 'libraryAddress',
3781 'kohaspsuggest',
3782 'OrderPdfTemplate',
3783 'marc',
3784 'acquisitions',
3785 'MIME')
3788 print "Upgrade to $DBversion done (bug 3756: remove disused system preferences)\n";
3789 SetVersion ($DBversion);
3792 $DBversion = "3.02.00.002";
3793 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3794 $dbh->do(q{DELETE FROM systempreferences WHERE variable = 'OpacPrivacy'});
3795 print "Upgrade to $DBversion done (bug 3881: remove unused OpacPrivacy system preference)\n";
3796 SetVersion ($DBversion);
3799 $DBversion = "3.02.00.003";
3800 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3801 $dbh->do(q{UPDATE systempreferences SET variable = 'ILS-DI:AuthorizedIPs' WHERE variable = 'ILS-DI:Authorized_IPs'});
3802 print "Upgrade to $DBversion done (correct ILS-DI:AuthorizedIPs)\n";
3803 SetVersion ($DBversion);
3806 $DBversion = "3.02.00.004";
3807 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3808 print "Upgrade to $DBversion done (3.2.0 general release)\n";
3809 SetVersion ($DBversion);
3812 # This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3813 # apply updates that have already been done
3815 $DBversion = "3.03.00.001";
3816 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.005")) {
3817 $dbh->do("DELETE FROM subscriptionroutinglist WHERE borrowernumber IS NULL;");
3818 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `borrowernumber` int(11) NOT NULL;");
3819 $dbh->do("DELETE FROM subscriptionroutinglist WHERE subscriptionid IS NULL;");
3820 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `subscriptionid` int(11) NOT NULL;");
3821 $dbh->do("CREATE TEMPORARY TABLE del_subscriptionroutinglist
3822 SELECT s1.routingid FROM subscriptionroutinglist s1
3823 WHERE EXISTS (SELECT * FROM subscriptionroutinglist s2
3824 WHERE s2.borrowernumber = s1.borrowernumber
3825 AND s2.subscriptionid = s1.subscriptionid
3826 AND s2.routingid < s1.routingid);");
3827 $dbh->do("DELETE FROM subscriptionroutinglist
3828 WHERE routingid IN (SELECT routingid FROM del_subscriptionroutinglist);");
3829 $dbh->do("ALTER TABLE subscriptionroutinglist ADD UNIQUE (subscriptionid, borrowernumber);");
3830 $dbh->do("ALTER TABLE subscriptionroutinglist
3831 ADD CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`)
3832 REFERENCES `borrowers` (`borrowernumber`)
3833 ON DELETE CASCADE ON UPDATE CASCADE");
3834 $dbh->do("ALTER TABLE subscriptionroutinglist
3835 ADD CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`)
3836 REFERENCES `subscription` (`subscriptionid`)
3837 ON DELETE CASCADE ON UPDATE CASCADE");
3838 print "Upgrade to $DBversion done (Make subscriptionroutinglist more strict)\n";
3839 SetVersion ($DBversion);
3842 $DBversion = '3.03.00.002';
3843 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.006")) {
3844 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='arm' WHERE rfc4646_subtag='hy';");
3845 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='eng' WHERE rfc4646_subtag='en';");
3846 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'fi','fin');");
3847 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='fre' WHERE rfc4646_subtag='fr';");
3848 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'lo','lao');");
3849 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it';");
3850 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'sr','srp');");
3851 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'tet','tet');");
3852 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ur','urd');");
3854 print "Upgrade to $DBversion done (Correct language mappings)\n";
3855 SetVersion ($DBversion);
3858 $DBversion = '3.03.00.003';
3859 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.007")) {
3860 $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');");
3861 print "Upgrade to $DBversion done (Add UseTablesortForCirc syspref)\n";
3862 SetVersion ($DBversion);
3865 $DBversion = '3.03.00.004';
3866 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.001")) {
3867 my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ACCEPTED');
3868 $dbh->do(q/
3869 INSERT INTO `letter`
3870 (module, code, name, title, content)
3871 VALUES
3872 ('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>>')
3873 /) unless $count > 0;
3874 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'AVAILABLE');
3875 $dbh->do(q/
3876 INSERT INTO `letter`
3877 (module, code, name, title, content)
3878 VALUES
3879 ('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>>')
3880 /) unless $count > 0;
3881 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ORDERED');
3882 $dbh->do(q/
3883 INSERT INTO `letter`
3884 (module, code, name, title, content)
3885 VALUES
3886 ('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>>')
3887 /) unless $count > 0;
3888 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'REJECTED');
3889 $dbh->do(q/
3890 INSERT INTO `letter`
3891 (module, code, name, title, content)
3892 VALUES
3893 ('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>>')
3894 /) unless $count > 0;
3895 print "Upgrade to $DBversion done (bug 5127: add default templates for suggestion status change notifications)\n";
3896 SetVersion ($DBversion);
3899 $DBversion = '3.03.00.005';
3900 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3901 $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
3902 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
3905 $DBversion = '3.03.00.006';
3906 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.002")) {
3907 $dbh->do("ALTER TABLE deletedborrowers ADD `privacy` int(11) AFTER smsalertnumber;");
3908 $dbh->do("ALTER TABLE deletedborrowers CHANGE `cardnumber` `cardnumber` varchar(16);");
3909 print "Upgrade to $DBversion done (Fix differences between borrowers and deletedborrowers)\n";
3910 SetVersion ($DBversion);
3913 $DBversion = '3.03.00.007';
3914 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3915 $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL,
3916 ADD currency VARCHAR(3) default NULL,
3917 ADD price DECIMAL(28,6) default NULL,
3918 ADD total DECIMAL(28,6) default NULL;
3920 print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n";
3921 SetVersion ($DBversion);
3924 $DBversion = '3.03.00.008';
3925 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3926 $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')");
3927 print "Upgrade to $DBversion done (adding syspref OPACNoResultsFound to control what displays when no results are found for a search in the OPAC.)\n";
3928 SetVersion ($DBversion);
3931 $DBversion = '3.03.00.009';
3932 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.003")) {
3933 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetUserCSS','','Add CSS to be included in the Intranet',NULL,'free')");
3934 print "Upgrade to $DBversion done (Add IntranetUserCSS syspref)\n";
3935 SetVersion ($DBversion);
3938 $DBversion = "3.03.00.010";
3939 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.02.001")) {
3940 $dbh->do("UPDATE `marc_subfield_structure` SET liblibrarian = 'Distance from earth' WHERE liblibrarian = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3941 $dbh->do("UPDATE `marc_subfield_structure` SET libopac = 'Distance from earth' WHERE libopac = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3942 print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
3943 SetVersion ($DBversion);
3946 $DBversion = "3.03.00.011";
3947 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3948 $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3949 print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
3950 SetVersion ($DBversion);
3953 $DBversion = "3.03.00.012";
3954 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3955 $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')");
3956 print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
3957 SetVersion ($DBversion);
3960 $DBversion = "3.03.00.013";
3961 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3962 $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')");
3963 print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n";
3964 SetVersion ($DBversion);
3967 $DBversion = "3.03.00.014";
3968 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3969 $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')");
3970 $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')");
3971 $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')");
3972 print "Upgrade to $DBversion done (Add flexible shelf browser constraints)\n";
3973 SetVersion ($DBversion);
3976 $DBversion = "3.03.00.015";
3977 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3978 my $sth = $dbh->prepare("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`,
3979 `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`)
3980 VALUES ( ?, '9', '9 (RLIN)', '9 (RLIN)', 0, 0, '', 6, '', '', '', 0, -5, '', '', '', NULL)");
3981 $sth->execute('648');
3982 $sth->execute('654');
3983 $sth->execute('655');
3984 $sth->execute('656');
3985 $sth->execute('657');
3986 $sth->execute('658');
3987 $sth->execute('662');
3988 $sth->finish;
3989 print "Upgrade to $DBversion done (Bug 5619: Add subfield 9 to marc21 648,654,655,656,657,658,662)\n";
3990 SetVersion ($DBversion);
3993 $DBversion = '3.03.00.016';
3994 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3995 # reimplement OpacPrivacy system preference
3996 $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')");
3997 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
3998 $dbh->do("ALTER TABLE `deletedborrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
3999 print "Upgrade to $DBversion done (OpacPrivacy reimplementation)\n";
4000 SetVersion($DBversion);
4003 $DBversion = '3.03.00.017';
4004 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.001")) {
4005 $dbh->do("ALTER TABLE `currency` CHANGE `rate` `rate` FLOAT( 15, 5 ) NULL DEFAULT NULL;");
4006 print "Upgrade to $DBversion done (Enable currency rates >= 100)\n";
4007 SetVersion ($DBversion);
4010 $DBversion = '3.03.00.018';
4011 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.002")) {
4012 $dbh->do( q|update language_descriptions set description = 'Nederlands' where lang = 'nl' and subtag = 'nl'|);
4013 $dbh->do( q|update language_descriptions set description = 'Dansk' where lang = 'da' and subtag = 'da'|);
4014 print "Upgrade to $DBversion done (Correct language descriptions)\n";
4015 SetVersion ($DBversion);
4018 $DBversion = '3.03.00.019';
4019 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.03.003")) {
4020 # Fix bokmål
4021 $dbh->do("UPDATE language_subtag_registry SET description = 'Norwegian bokm&#229;l' WHERE subtag = 'nb';");
4022 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nb','nob');");
4023 $dbh->do("UPDATE language_descriptions SET description = 'Norsk bokm&#229;l' WHERE subtag = 'nb' AND lang = 'nb';");
4024 $dbh->do("UPDATE language_descriptions SET description = 'Norwegian bokm&#229;l' WHERE subtag = 'nb' AND lang = 'en';");
4025 $dbh->do("UPDATE language_descriptions SET description = 'Norvégien bokm&#229;l' WHERE subtag = 'nb' AND lang = 'fr';");
4026 # Add nynorsk
4027 $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'nn', 'language', 'Norwegian nynorsk','2011-02-14' )");
4028 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'nn','nno')");
4029 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nb', 'Norsk nynorsk')");
4030 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'nn', 'Norsk nynorsk')");
4031 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'en', 'Norwegian nynorsk')");
4032 $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'nn', 'language', 'fr', 'Norvégien nynorsk')");
4033 print "Upgrade to $DBversion done (Correct language descriptions for Norwegian)\n";
4034 SetVersion ($DBversion);
4037 $DBversion = '3.03.00.020';
4038 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4039 $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')");
4040 $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')");
4041 print "Upgrade to $DBversion done (Bug 5811: Add sysprefs controlling overriding fines)\n";
4042 SetVersion($DBversion);
4045 $DBversion = '3.03.00.021';
4046 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.001")) {
4047 $dbh->do("ALTER TABLE items MODIFY enumchron TEXT");
4048 $dbh->do("ALTER TABLE deleteditems MODIFY enumchron TEXT");
4049 print "Upgrade to $DBversion done (bug 5642: longer serial enumeration)\n";
4050 SetVersion ($DBversion);
4053 $DBversion = '3.03.00.022';
4054 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4055 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo');");
4056 print "Upgrade to $DBversion done (Add AuthoritiesLog syspref)\n";
4057 SetVersion ($DBversion);
4060 # due to a mismatch in kohastructure.sql some koha will have missing columns in aqbasketgroup
4061 # this attempts to fix that
4062 $DBversion = '3.03.00.023';
4063 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.002")) {
4064 my $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'billingplace'");
4065 $sth->execute;
4066 $dbh->do("ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4067 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliveryplace'");
4068 $sth->execute;
4069 $dbh->do("ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10)") if ! $sth->fetchrow_hashref;
4070 $sth = $dbh->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'aqbasketgroups' AND COLUMN_NAME = 'deliverycomment'");
4071 $sth->execute;
4072 $dbh->do("ALTER TABLE aqbasketgroups ADD deliverycomment VARCHAR(255)") if ! $sth->fetchrow_hashref;
4073 print "Upgrade to $DBversion done (Reconcile aqbasketgroups)\n";
4074 SetVersion ($DBversion);
4077 $DBversion = '3.03.00.024';
4078 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4079 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo')");
4080 $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')");
4081 print "Upgrade to $DBversion done (Add syspref to force whole-subfield matching on subject tracings)\n";
4082 SetVersion($DBversion);
4085 $DBversion = "3.03.00.025";
4086 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4087 $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')");
4088 print "Upgrade to $DBversion done (Add syspref to control if user can choose pickup branch for holds)\n";
4089 SetVersion ($DBversion);
4092 $DBversion = '3.03.00.026';
4093 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.05.003")) {
4094 $dbh->do("UPDATE `message_attributes` SET message_name='Item Due' WHERE message_attribute_id=1 AND message_name LIKE 'Item DUE'");
4095 print "Upgrade to $DBversion done ( fix capitalization in message type )\n";
4096 SetVersion ($DBversion);
4099 $DBversion = '3.03.00.027';
4100 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4101 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('displayFacetCount', '0', NULL, NULL, 'YesNo')");
4102 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('maxRecordsForFacets', '20', NULL, NULL, 'Integer')");
4103 print "Upgrade to $DBversion done (Preferences for facet count)\n";
4104 SetVersion ($DBversion);
4107 $DBversion = "3.03.00.028";
4108 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4109 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('FacetLabelTruncationLength', 20, 'Truncate facets length to','','free')");
4110 print "Upgrade to $DBversion done (Add FacetLabelTruncationLength syspref to control facets displayed length)\n";
4111 SetVersion ($DBversion);
4114 $DBversion = "3.03.00.029";
4115 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4116 $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')");
4117 print "Upgrade to $DBversion done (Add syspref to control if user can choose branch when making purchase suggestion)\n";
4118 SetVersion ($DBversion);
4121 $DBversion = "3.03.00.030";
4122 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4123 $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')");
4124 $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')");
4125 print "Upgrade to $DBversion done (Add sysprefs to control custom favicons)\n";
4126 SetVersion ($DBversion);
4129 $DBversion = "3.03.00.031";
4130 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4131 $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');");
4132 print "Upgrade to $DBversion done (Add syspref FineNotifyAtCheckin)\n";
4133 SetVersion ($DBversion);
4136 $DBversion = '3.03.00.032';
4137 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4138 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', 1, 'Create searches on all subdivisions for subject tracings.','1','YesNo')");
4139 print "Upgrade to $DBversion done ( include subdivisions when generating subject tracing searches )\n";
4143 $DBversion = '3.03.00.033';
4144 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4145 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages', '1', '', NULL, 'YesNo')");
4146 print "Upgrade to $DBversion done (System pref StaffAuthorisedValueImages)\n";
4147 SetVersion ($DBversion);
4150 $DBversion = '3.03.00.034';
4151 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4152 $dbh->do("ALTER TABLE `categories` ADD `hidelostitems` tinyint(1) NOT NULL default '0' AFTER `reservefee`");
4153 print "Upgrade to $DBversion done (Add hidelostitems preference to borrower categories)\n";
4154 SetVersion ($DBversion);
4157 $DBversion = '3.03.00.035';
4158 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4159 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedate date default NULL AFTER issuelength");
4160 $dbh->do("ALTER TABLE `issuingrules` ADD hardduedatecompare tinyint NOT NULL default 0 AFTER hardduedate");
4161 my $duedate;
4162 if (C4::Context->preference("globalDueDate")) {
4163 $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("globalDueDate"));
4164 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = 0");
4165 } elsif (C4::Context->preference("ceilingDueDate")) {
4166 $duedate = C4::Dates::format_date_in_iso(C4::Context->preference("ceilingDueDate"));
4167 $dbh->do("UPDATE `issuingrules` SET hardduedate = '$duedate', hardduedatecompare = -1");
4169 $dbh->do("DELETE FROM `systempreferences` WHERE variable = 'globalDueDate' OR variable = 'ceilingDueDate'");
4170 print "Upgrade to $DBversion done (Move global and ceiling due dates to Circ Rules level)\n";
4171 SetVersion ($DBversion);
4174 $DBversion = '3.03.00.036';
4175 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4176 $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')");
4177 print "Upgrade to $DBversion done ( Make COinS optional in OPAC search results )\n";
4178 SetVersion ($DBversion);
4181 $DBversion = '3.03.00.037';
4182 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4183 $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')");
4184 $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')");
4185 print "Upgrade to $DBversion done (Add 'Display856uAsImage' and 'OPACDisplay856uAsImage' syspref)\n";
4186 SetVersion ($DBversion);
4189 $DBversion = '3.03.00.038';
4190 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4191 $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')");
4192 $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')");
4193 $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')");
4194 print "Upgrade to $DBversion done ( Add Self-checkout by Login system preferences )\n";
4197 $DBversion = "3.03.00.039";
4198 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4199 $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');");
4200 print "Upgrade to $DBversion done (Add syspref ShowReviewer)\n";
4203 $DBversion = "3.03.00.040";
4204 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4205 $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');");
4206 print "Upgrade to $DBversion done (Add syspref UseControlNumber)\n";
4209 $DBversion = "3.03.00.041";
4210 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4211 $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')");
4212 $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')");
4213 print "Upgrade to $DBversion done (Add sysprefs to control alternate holdings information display)\n";
4214 SetVersion ($DBversion);
4217 $DBversion = '3.03.00.042';
4218 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4219 stocknumber_checker();
4220 print "Upgrade to $DBversion done (5860 Index itemstocknumber)\n";
4221 SetVersion ($DBversion);
4224 sub stocknumber_checker { #code reused later on
4225 my @row;
4226 #drop the obsolete itemSStocknumber idx if it exists
4227 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemsstocknumberidx'");
4228 $dbh->do("ALTER TABLE `items` DROP INDEX `itemsstocknumberidx`;") if @row;
4230 #check itemstocknumber idx; remove it if it is unique
4231 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx' AND non_unique=0");
4232 $dbh->do("ALTER TABLE `items` DROP INDEX `itemstocknumberidx`;") if @row;
4234 #add itemstocknumber index non-unique IF it still not exists
4235 @row = $dbh->selectrow_array("SHOW INDEXES FROM items WHERE key_name='itemstocknumberidx'");
4236 $dbh->do("ALTER TABLE items ADD INDEX itemstocknumberidx (stocknumber);") unless @row;
4239 $DBversion = "3.03.00.043";
4240 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4242 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No')");
4243 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes')");
4245 print "Upgrade to $DBversion done ( add generic boolean YES_NO authorised_values pair )\n";
4246 SetVersion ($DBversion);
4249 $DBversion = '3.03.00.044';
4250 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4251 $dbh->do("ALTER TABLE `aqbasketgroups` ADD `freedeliveryplace` TEXT NULL AFTER `deliveryplace`;");
4252 print "Upgrade to $DBversion done (adding freedeliveryplace to basketgroups)\n";
4255 $DBversion = '3.03.00.045';
4256 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4257 #Remove obsolete columns from aqbooksellers if needed
4258 my $a = $dbh->selectall_hashref('SHOW columns from aqbooksellers','Field');
4259 my $sqldrop="ALTER TABLE aqbooksellers DROP COLUMN ";
4260 foreach(qw/deliverydays followupdays followupscancel invoicedisc nocalc specialty/) {
4261 $dbh->do($sqldrop.$_) if exists $a->{$_};
4263 #Remove obsolete column from aqbudgets if needed
4264 #The correct column is budget_notes
4265 $a = $dbh->selectall_hashref('SHOW columns from aqbudgets','Field');
4266 if(exists $a->{budget_description}) {
4267 $dbh->do("ALTER TABLE aqbudgets DROP COLUMN budget_description");
4269 print "Upgrade to $DBversion done (Remove obsolete columns from aqbooksellers and aqbudgets if needed)\n";
4270 SetVersion ($DBversion);
4273 $DBversion = "3.03.00.046";
4274 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4275 $dbh->do("ALTER TABLE overduerules ALTER delay1 SET DEFAULT NULL, ALTER delay2 SET DEFAULT NULL, ALTER delay3 SET DEFAULT NULL");
4276 print "Upgrade to $DBversion done (Setting NULL default value for delayn columns in table overduerules)\n";
4277 SetVersion($DBversion);
4280 $DBversion = '3.03.00.047';
4281 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4282 $dbh->do("ALTER TABLE borrowers ADD `state` mediumtext AFTER city;");
4283 $dbh->do("ALTER TABLE borrowers ADD `B_state` mediumtext AFTER B_city;");
4284 $dbh->do("ALTER TABLE borrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4285 $dbh->do("ALTER TABLE deletedborrowers ADD `state` mediumtext AFTER city;");
4286 $dbh->do("ALTER TABLE deletedborrowers ADD `B_state` mediumtext AFTER B_city;");
4287 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactstate` mediumtext AFTER altcontactaddress3;");
4288 print "Upgrade to $DBversion done (Add state field to patron's addresses)\n";
4291 $DBversion = '3.03.00.048';
4292 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4293 $dbh->do("ALTER TABLE branches ADD `branchstate` mediumtext AFTER `branchcity`;");
4294 print "Upgrade to $DBversion done (Add state to branch address)\n";
4295 SetVersion ($DBversion);
4298 $DBversion = '3.03.00.049';
4299 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4300 $dbh->do("ALTER TABLE `accountlines` ADD `note` text NULL default NULL");
4301 $dbh->do("ALTER TABLE `accountlines` ADD `manager_id` int( 11 ) NULL ");
4302 print "Upgrade to $DBversion done (adding note and manager_id fields in accountlines table)\n";
4303 SetVersion($DBversion);
4306 $DBversion = "3.03.00.050";
4307 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4308 $dbh->do("
4309 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');
4311 print "Upgrade to $DBversion done (Adding OpacHiddenItems syspref)\n";
4312 SetVersion($DBversion);
4315 $DBversion = "3.03.00.051";
4316 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4317 print "Upgrade to $DBversion done (Remove spaces and dashes from message_attribute names)\n";
4318 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Due' WHERE message_name='Item Due'");
4319 $dbh->do("UPDATE message_attributes SET message_name = 'Advance_Notice' WHERE message_name='Advance Notice'");
4320 $dbh->do("UPDATE message_attributes SET message_name = 'Hold_Filled' WHERE message_name='Hold Filled'");
4321 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Check_in' WHERE message_name='Item Check-in'");
4322 $dbh->do("UPDATE message_attributes SET message_name = 'Item_Checkout' WHERE message_name='Item Checkout'");
4323 SetVersion ($DBversion);
4326 $DBversion = "3.03.00.052";
4327 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4328 $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');");
4329 print "Upgrade to $DBversion done (Add syspref WaitingNotifyAtCheckin)\n";
4330 SetVersion ($DBversion);
4333 $DBversion = "3.04.00.000";
4334 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4335 print "Upgrade to $DBversion done Koha 3.4.0 release \n";
4336 SetVersion ($DBversion);
4339 $DBversion = "3.05.00.001";
4340 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4341 $dbh->do(qq{
4342 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');
4344 print "Upgrade to $DBversion done (Adds New System preference numSearchRSSResults)\n";
4345 SetVersion($DBversion);
4348 $DBversion = '3.05.00.002';
4349 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4350 #follow up fix 5860: some installs already past 3.3.0.42
4351 stocknumber_checker();
4352 print "Upgrade to $DBversion done (Fix for stocknumber index)\n";
4353 SetVersion ($DBversion);
4356 $DBversion = "3.05.00.003";
4357 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4358 $dbh->do(qq{
4359 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');
4361 print "Upgrade to $DBversion done (Adds New System preference OpacRenewalBranch)\n";
4362 SetVersion($DBversion);
4365 $DBversion = "3.05.00.004";
4366 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4367 $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');");
4368 print "Upgrade to $DBversion done (Add syspref ShowReviewerPhoto)\n";
4369 SetVersion($DBversion);
4372 $DBversion = "3.05.00.005";
4373 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4374 $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');");
4375 print "Upgrade to $DBversion done (Adds pref BasketConfirmations)\n";
4376 SetVersion($DBversion);
4379 $DBversion = "3.05.00.006";
4380 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4381 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea')");
4382 print "Upgrade to $DBversion done (Add syspref MARCAuthorityControlField008)\n";
4383 SetVersion ($DBversion);
4386 $DBversion = "3.05.00.007";
4387 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4388 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo');");
4389 print "Upgrade to $DBversion done (Add syspref OpenLibraryCovers)\n";
4390 SetVersion($DBversion);
4393 $DBversion = "3.05.00.008";
4394 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4395 $dbh->do("ALTER TABLE `cities` ADD `city_state` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_name`;");
4396 $dbh->do("ALTER TABLE `cities` ADD `city_country` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `city_zipcode`;");
4397 print "Add state and country to cities table corresponding to new columns in borrowers\n";
4398 SetVersion($DBversion);
4401 $DBversion = "3.05.00.009";
4402 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4403 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4404 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE borrowernumber IS NULL");
4405 $dbh->do("DELETE FROM issues WHERE borrowernumber IS NULL");
4407 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4408 SELECT borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate FROM issues WHERE itemnumber IS NULL");
4409 $dbh->do("DELETE FROM issues WHERE itemnumber IS NULL");
4411 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4412 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)");
4413 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowernumber = issues.borrowernumber)");
4415 $dbh->do("INSERT INTO old_issues (borrowernumber, itemnumber, date_due, branchcode, issuingbranch, returndate, lastreneweddate, `return`, renewals, timestamp, issuedate)
4416 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)");
4417 $dbh->do("DELETE FROM issues WHERE NOT EXISTS (SELECT * FROM items WHERE itemnumber = issues.itemnumber)");
4419 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_1`");
4420 $dbh->do("ALTER TABLE issues DROP FOREIGN KEY `issues_ibfk_2`");
4421 $dbh->do("ALTER TABLE issues ALTER COLUMN borrowernumber DROP DEFAULT");
4422 $dbh->do("ALTER TABLE issues ALTER COLUMN itemnumber DROP DEFAULT");
4423 $dbh->do("ALTER TABLE issues MODIFY COLUMN borrowernumber int(11) NOT NULL");
4424 $dbh->do("ALTER TABLE issues MODIFY COLUMN itemnumber int(11) NOT NULL");
4425 $dbh->do("ALTER TABLE issues DROP KEY `issuesitemidx`");
4426 $dbh->do("ALTER TABLE issues ADD PRIMARY KEY (`itemnumber`)");
4427 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4428 $dbh->do("ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE");
4430 print "Upgrade to $DBversion done (issues referential integrity)\n";
4431 SetVersion ($DBversion);
4434 $DBversion = "3.05.00.010";
4435 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4436 $dbh->do("CREATE INDEX priorityfoundidx ON reserves (priority,found)");
4437 print "Create an index on reserves to speed up holds awaiting pickup report bug 5866\n";
4438 SetVersion($DBversion);
4442 $DBversion = "3.05.00.011";
4443 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4444 $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')");
4445 print "Upgrade to $DBversion done (add OPACResultsSidebar syspref (enh 6165))\n";
4446 SetVersion($DBversion);
4449 $DBversion = "3.05.00.012";
4450 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4451 $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')");
4452 print "Upgrade to $DBversion done (add RecordLocalUseOnReturn syspref (enh 6403))\n";
4453 SetVersion($DBversion);
4456 $DBversion = "3.05.00.013";
4457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4458 $dbh->do(qq|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','0',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL)|);
4459 print "Upgrade to $DBversion done (Add syspref 'OpacKohaUrl')\n";
4460 SetVersion($DBversion);
4463 $DBversion = "3.05.00.014";
4464 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4465 $dbh->do("ALTER TABLE `borrowers` MODIFY `userid` VARCHAR(75)");
4466 print "Modified userid column length into 75 in borrowers\n";
4467 SetVersion($DBversion);
4470 $DBversion = "3.05.00.015";
4471 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4472 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectEnabled',0,'Enable Novelist Select content. Requires Novelist Profile and Password',NULL,'YesNo')");
4473 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectProfile',NULL,'Novelist Select user Password',NULL,'free')");
4474 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectPassword',NULL,'Enable Novelist user Profile',NULL,'free')");
4475 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('NovelistSelectView','tab','Where to display Novelist Select content','tab|above|below|right','Choice')");
4476 print "Upgrade to $DBversion done (Add support for EBSCO's NoveList Select (enh 6902))\n";
4477 SetVersion($DBversion);
4480 $DBversion = '3.05.00.016';
4481 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4482 $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');");
4483 print "Upgrade to $DBversion done (Add EasyAnalyticalRecords syspref)\n";
4484 SetVersion ($DBversion);
4487 $DBversion = '3.05.00.017';
4488 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4489 if (C4::Context->preference("marcflavour") eq 'MARC21' ||
4490 C4::Context->preference("marcflavour") eq 'NORMARC'){
4491 $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)");
4492 $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)");
4493 print "Upgrade to $DBversion done (Add 773 subfield 9 and 0 to default framework)\n";
4494 SetVersion ($DBversion);
4495 } elsif (C4::Context->preference("marcflavour") eq 'UNIMARC'){
4496 $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)");
4497 print "Upgrade to $DBversion done (Add 461 subfield 9 to default framework)\n";
4498 SetVersion ($DBversion);
4502 $DBversion = "3.05.00.018";
4503 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4504 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacNavBottom','','Links after OpacNav links','70|10','Textarea')");
4505 print "Upgrade to $DBversion done (add OpacNavBottom syspref (enh 6825): if appropriate, you can split OpacNav into OpacNav and OpacNavBottom)\n";
4506 SetVersion($DBversion);
4509 $DBversion = "3.05.00.019";
4510 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4511 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4512 $dbh->do("UPDATE itemtypes SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4513 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book.png' WHERE imageurl = 'vokal/BOOK.png'");
4514 $dbh->do("UPDATE authorised_values SET imageurl = 'vokal/Book-32px.png' WHERE imageurl = 'vokal/BOOK-32px.png'");
4515 print "Upgrade to $DBversion done (remove duplicate VOKAL Book icons, bug 6862)\n";
4516 SetVersion($DBversion);
4519 $DBversion = "3.05.00.020";
4520 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4521 $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')");
4522 print "Upgrade to $DBversion done (Add syspref AcqViewBaskets)\n";
4523 SetVersion($DBversion);
4526 $DBversion = "3.05.00.021";
4527 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4528 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN display_checkout TINYINT(1) NOT NULL DEFAULT '0';");
4529 print "Upgrade to $DBversion done (Added a display_checkout field in borrower_attribute_types table)\n";
4530 SetVersion($DBversion);
4533 $DBversion = "3.05.00.022";
4534 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4535 $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");
4536 print "Upgrade to $DBversion done (6094: Fixing ModAuthority problems, add a need_merge_authorities table)\n";
4537 SetVersion($DBversion);
4540 $DBversion = "3.05.00.023";
4541 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4542 $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');");
4543 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";
4544 SetVersion($DBversion);
4547 $DBversion = "3.06.00.000";
4548 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4549 print "Upgrade to $DBversion done Koha 3.6.0 release \n";
4550 SetVersion ($DBversion);
4553 $DBversion = "3.07.00.001";
4554 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4555 my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred =1;", { Columns => [1] } );
4556 $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
4557 $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
4558 $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4559 $dbh->do("ALTER TABLE deletedborrowers MODIFY debarred DATE DEFAULT NULL;");
4560 $dbh->do("ALTER TABLE deletedborrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
4561 print "Upgrade done (Change borrowers.debarred into Date )\n";
4562 SetVersion($DBversion);
4565 $DBversion = "3.07.00.002";
4566 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4567 $dbh->do("UPDATE borrowers SET debarred=NULL WHERE debarred='0000-00-00';");
4568 print "Setting NULL to debarred where 0000-00-00 is stored (bug 7272)\n";
4569 SetVersion($DBversion);
4572 $DBversion = "3.07.00.003";
4573 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4574 $dbh->do(" UPDATE `message_attributes` SET message_name='Item_Due' WHERE message_name='Item_DUE'");
4575 print "Updating message_name in message_attributes\n";
4576 SetVersion($DBversion);
4579 $DBversion = "3.07.00.004";
4580 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4581 $dbh->do("ALTER TABLE `suggestions` ADD `patronreason` TEXT NULL AFTER `reason`");
4582 print "Upgrade to $DBversion done (Add column to suggestions table to store patrons' reasons for submitting a suggestion. )\n";
4583 SetVersion($DBversion);
4586 $DBversion = "3.07.00.005";
4587 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4588 $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')");
4589 print "Upgrade to $DBversion done (BorrowerUnwantedField syspref)\n";
4590 SetVersion ($DBversion);
4593 $DBversion = "3.07.00.006";
4594 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4595 $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');");
4596 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";
4597 SetVersion($DBversion);
4600 $DBversion = "3.07.00.007";
4601 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4602 $dbh->do("ALTER TABLE items MODIFY materials text;");
4603 print "Upgrade to $DBversion done alter items.material from varchar(10) to text \n";
4604 SetVersion($DBversion);
4607 $DBversion = '3.07.00.008';
4608 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4609 if (C4::Context->preference("marcflavour") eq 'MARC21') {
4610 if (C4::Context->preference("opaclanguages") eq "de") {
4611 $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, '');");
4612 } else {
4613 $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, '');");
4616 print "Upgrade to $DBversion done (add MARC21 field 545 to framework)\n";
4617 SetVersion ($DBversion);
4620 $DBversion = "3.07.00.009";
4621 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4622 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `claims_count` INT(11) DEFAULT 0, ADD COLUMN `claimed_date` DATE DEFAULT NULL AFTER `claims_count`");
4623 print "Upgrade to $DBversion done (Add claims_count and claimed_date fields in aqorders table)\n";
4624 SetVersion($DBversion);
4627 $DBversion = "3.07.00.010";
4628 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4629 $dbh->do(
4630 q|CREATE TABLE `biblioimages` (
4631 `imagenumber` int(11) NOT NULL AUTO_INCREMENT,
4632 `biblionumber` int(11) NOT NULL,
4633 `mimetype` varchar(15) NOT NULL,
4634 `imagefile` mediumblob NOT NULL,
4635 `thumbnail` mediumblob NOT NULL,
4636 PRIMARY KEY (`imagenumber`),
4637 CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
4638 ) ENGINE=InnoDB DEFAULT CHARSET=utf8|
4640 $dbh->do(
4641 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|
4643 $dbh->do(
4644 q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|
4646 $dbh->do(
4647 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')|
4649 $dbh->do(
4650 q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|
4652 print "Upgrade to $DBversion done (Added support for local cover images)\n";
4653 SetVersion($DBversion);
4656 $DBversion = "3.07.00.011";
4657 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4658 $dbh->do(<<ENDOFRENEWAL);
4659 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');
4660 ENDOFRENEWAL
4661 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";
4662 SetVersion($DBversion);
4665 $DBversion = "3.07.00.012";
4666 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4667 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,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')");
4668 print "Upgrade to $DBversion add 'AllowItemsOnHoldCheckout' syspref \n";
4669 SetVersion ($DBversion);
4672 $DBversion = "3.07.00.013";
4673 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4674 $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');");
4675 print "Upgrade to $DBversion done (Bug 7345: Add system preference OpacExportOptions.)\n";
4676 SetVersion ($DBversion);
4679 $DBversion = "3.07.00.014";
4680 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4681 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";
4682 SetVersion($DBversion);
4685 $DBversion = "3.07.00.015";
4686 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4687 my $sth = $dbh->prepare(q|
4688 SELECT COUNT(*) FROM marc_subfield_structure where kohafield="biblioitems.editionstatement"
4690 $sth->execute;
4691 my $already_exists = $sth->fetchrow;
4692 if ( not $already_exists ) {
4693 my $field = C4::Context->preference("marcflavour") eq "UNIMARC" ? "205" : "250";
4694 my $subfield = "a";
4695 my $sth = $dbh->prepare( q|
4696 UPDATE marc_subfield_structure SET kohafield = "biblioitems.editionstatement"
4697 WHERE tagfield = ? AND tagsubfield = ?
4699 $sth->execute( $field, $subfield );
4700 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement.)\n";
4701 } else {
4702 print "Upgrade to $DBversion done (Added a mapping for biblioitems.editionstatement (already exists, nothing to do).)\n";
4704 SetVersion($DBversion);
4707 $DBversion = "3.07.00.016";
4708 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4709 $dbh->do("ALTER TABLE items ADD KEY `itemcallnumber` (itemcallnumber)");
4710 print "Upgrade to $DBversion done (Added index on items.itemcallnumber)\n";
4711 SetVersion($DBversion);
4714 $DBversion = "3.07.00.017";
4715 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4716 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('TransferWhenCancelAllWaitingHolds','0','Transfer items when cancelling all waiting holds',NULL,'YesNo')");
4717 print "Upgrade to $DBversion done (Add sysprefs to control transfer when cancel all waiting holds)\n";
4718 SetVersion ($DBversion);
4721 $DBversion = "3.07.00.018";
4722 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4723 $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;");
4724 print "Upgrade to $DBversion done ( adding offline operations table )\n";
4725 SetVersion($DBversion);
4728 $DBversion = "3.07.00.019";
4729 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4730 $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");
4731 $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");
4732 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";
4733 SetVersion($DBversion);
4736 $DBversion = "3.07.00.020";
4737 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4738 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACpatronimages',0,'Enable patron images in the OPAC',NULL,'YesNo');");
4739 print "Upgrade to $DBversion done (Bug 3516: Add the option to show patron images in the OPAC.)\n";
4740 SetVersion($DBversion);
4743 $DBversion = "3.07.00.021";
4744 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4745 $dbh->do(
4746 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerModule','Default','Chooses which linker module to use (see documentation).','Default|FirstMatchLastMatch','Choice');"
4748 $dbh->do(
4749 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free');"
4751 $dbh->do(
4752 "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');"
4754 $dbh->do(
4755 "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');"
4757 $dbh->do(
4758 "INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AutoCreateAuthorities',0,'Automatically create authorities that do not exist when cataloging records.',NULL,'YesNo');"
4760 $dbh->do(
4761 "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');"
4763 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";
4764 SetVersion($DBversion);
4767 $DBversion = "3.07.00.022";
4768 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4769 $dbh->do("DELETE FROM reviews WHERE biblionumber NOT IN (SELECT biblionumber from biblio)");
4770 $dbh->do("UPDATE reviews SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers)");
4771 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_2 FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
4772 $dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber ) ON UPDATE CASCADE ON DELETE SET NULL");
4773 print "Upgrade to $DBversion done (Bug 7493 - Add constraint linking OPAC comment biblionumber to biblio, OPAC comment borrowernumber to borrowers.)\n";
4774 SetVersion($DBversion);
4777 $DBversion = "3.07.00.023";
4778 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4779 $dbh->do("ALTER TABLE `message_transports` DROP FOREIGN KEY `message_transports_ibfk_3`");
4780 $dbh->do("ALTER TABLE `letter` DROP PRIMARY KEY");
4781 $dbh->do("ALTER TABLE `letter` ADD `branchcode` varchar(10) default NULL AFTER `code`");
4782 $dbh->do("ALTER TABLE `letter` ADD PRIMARY KEY (`module`,`code`, `branchcode`)");
4783 $dbh->do("ALTER TABLE `message_transports` ADD `branchcode` varchar(10) NOT NULL default ''");
4784 $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");
4785 $dbh->do("ALTER TABLE `letter` ADD `is_html` tinyint(1) default 0 AFTER `name`");
4787 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4788 VALUES ('circulation','ISSUESLIP','Issue Slip','Issue Slip', '<h3><<branches.branchname>></h3>
4789 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4790 (<<borrowers.cardnumber>>) <br />
4792 <<today>><br />
4794 <h4>Checked Out</h4>
4795 <checkedout>
4797 <<biblio.title>> <br />
4798 Barcode: <<items.barcode>><br />
4799 Date due: <<issues.date_due>><br />
4800 </p>
4801 </checkedout>
4803 <h4>Overdues</h4>
4804 <overdue>
4806 <<biblio.title>> <br />
4807 Barcode: <<items.barcode>><br />
4808 Date due: <<issues.date_due>><br />
4809 </p>
4810 </overdue>
4812 <hr>
4814 <h4 style=\"text-align: center; font-style:italic;\">News</h4>
4815 <news>
4816 <div class=\"newsitem\">
4817 <h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>
4818 <p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.new>></p>
4819 <p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<opac_news.timestamp>></p>
4820 <hr />
4821 </div>
4822 </news>', 1)");
4823 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4824 VALUES ('circulation','ISSUEQSLIP','Issue Quick Slip','Issue Quick Slip', '<h3><<branches.branchname>></h3>
4825 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
4826 (<<borrowers.cardnumber>>) <br />
4828 <<today>><br />
4830 <h4>Checked Out Today</h4>
4831 <checkedout>
4833 <<biblio.title>> <br />
4834 Barcode: <<items.barcode>><br />
4835 Date due: <<issues.date_due>><br />
4836 </p>
4837 </checkedout>', 1)");
4838 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4839 VALUES ('circulation','RESERVESLIP','Reserve Slip','Reserve Slip', '<h5>Date: <<today>></h5>
4841 <h3> Transfer to/Hold in <<branches.branchname>></h3>
4843 <h3><<borrowers.surname>>, <<borrowers.firstname>></h3>
4845 <ul>
4846 <li><<borrowers.cardnumber>></li>
4847 <li><<borrowers.phone>></li>
4848 <li> <<borrowers.address>><br />
4849 <<borrowers.address2>><br />
4850 <<borrowers.city >> <<borrowers.zipcode>>
4851 </li>
4852 <li><<borrowers.email>></li>
4853 </ul>
4854 <br />
4855 <h3>ITEM ON HOLD</h3>
4856 <h4><<biblio.title>></h4>
4857 <h5><<biblio.author>></h5>
4858 <ul>
4859 <li><<items.barcode>></li>
4860 <li><<items.itemcallnumber>></li>
4861 <li><<reserves.waitingdate>></li>
4862 </ul>
4863 <p>Notes:
4864 <pre><<reserves.reservenotes>></pre>
4865 </p>', 1)");
4866 $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
4867 VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
4868 <h3>Transfer to <<branches.branchname>></h3>
4870 <h3>ITEM</h3>
4871 <h4><<biblio.title>></h4>
4872 <h5><<biblio.author>></h5>
4873 <ul>
4874 <li><<items.barcode>></li>
4875 <li><<items.itemcallnumber>></li>
4876 </ul>', 1)");
4878 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free')");
4879 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free')");
4881 $dbh->do("UPDATE `letter` SET content = replace(content, '<<title>>', '<<biblio.title>>') WHERE code = 'HOLDPLACED'");
4883 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";
4884 SetVersion($DBversion);
4887 $DBversion = "3.07.00.024";
4888 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4889 $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')");
4890 $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')");
4891 print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
4894 $DBversion = "3.07.00.025";
4895 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4896 $dbh->do( q|DROP TABLE bibliocoverimage;| );
4897 $dbh->do(
4898 q|CREATE TABLE biblioimages (
4899 imagenumber int(11) NOT NULL AUTO_INCREMENT,
4900 biblionumber int(11) NOT NULL,
4901 mimetype varchar(15) NOT NULL,
4902 imagefile mediumblob NOT NULL,
4903 thumbnail mediumblob NOT NULL,
4904 PRIMARY KEY (imagenumber),
4905 CONSTRAINT bibliocoverimage_fk1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
4906 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;|
4908 print "Upgrade to $DBversion done (Correct table name for local cover images [please disregard the following error messages: \"Unknown table 'bibliocoverimage'...\" and \"Table 'biblioimages' already exists...\"])\n";
4909 SetVersion($DBversion);
4912 $DBversion = "3.07.00.026";
4913 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4914 $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');");
4915 print "Upgrade to $DBversion done (Add syspref CalendarFirstDayOfWeek used to select the first day of week to use in the calendar. )\n";
4916 SetVersion($DBversion);
4919 $DBversion = "3.07.00.027";
4920 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4921 $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');});
4922 print "Upgrade to $DBversion done (Added system preference RoutingListNote for adding a general note to all routing lists.)\n";
4923 SetVersion($DBversion);
4926 $DBversion = "3.07.00.028";
4927 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4928 $dbh->do(qq{
4929 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');
4931 print "Upgrade to $DBversion done (Bug 6296 New System preference AllowPKIAuth)\n";
4932 SetVersion($DBversion);
4935 $DBversion = "3.07.00.029";
4936 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4937 my $installer = C4::Installer->new();
4938 my $full_path = C4::Context->config('intranetdir') . "/installer/data/$installer->{dbms}/atomicupdate/oai_sets.sql";
4939 my $error = $installer->load_sql($full_path);
4940 warn $error if $error;
4941 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4942 SetVersion($DBversion);
4945 $DBversion = "3.07.00.030";
4946 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4947 $dbh->do("ALTER TABLE default_circ_rules ADD
4948 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4949 $dbh->do("ALTER TABLE branch_item_rules ADD
4950 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4951 $dbh->do("ALTER TABLE default_branch_circ_rules ADD
4952 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4953 $dbh->do("ALTER TABLE default_branch_item_rules ADD
4954 COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4955 # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
4956 my $homeorholdingbranchreturn = C4::Context->prefernce('HomeOrHoldingBranchReturn') || 'homebranch';
4957 $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
4958 print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4959 SetVersion($DBversion);
4962 $DBversion = "3.07.00.031";
4963 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4964 $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')");
4965 print "Upgrade to $DBversion done (Add syspref to tell Koha if ICU indexing is in use for Zebra or not.)\n";
4966 SetVersion ($DBversion);
4969 $DBversion = "3.07.00.032";
4970 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4971 $dbh->do("ALTER TABLE virtualshelves MODIFY COLUMN owner int"); #should have been int already (fk to borrowers)
4972 $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
4973 $dbh->do("DELETE FROM virtualshelves WHERE owner IS NULL and category=1"); #delete private lists without owner (cascades to shelfcontents)
4974 $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");
4975 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=1");
4976 $dbh->do("UPDATE virtualshelves SET allow_add=0, allow_delete_own=1, allow_delete_other=0 WHERE category=2");
4977 $dbh->do("UPDATE virtualshelves SET allow_add=1, allow_delete_own=1, allow_delete_other=1 WHERE category=3");
4978 $dbh->do("UPDATE virtualshelves SET category=2 WHERE category=3");
4980 $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");
4981 $dbh->do("UPDATE virtualshelfcontents co LEFT JOIN virtualshelves sh USING (shelfnumber) SET co.borrowernumber=sh.owner");
4983 $dbh->do("CREATE TABLE virtualshelfshares
4984 (id int AUTO_INCREMENT PRIMARY KEY, shelfnumber int NOT NULL,
4985 borrowernumber int, invitekey varchar(10), sharedate datetime,
4986 CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4987 CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
4989 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo');");
4990 $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');");
4992 print "Upgrade to $DBversion done (BZ7310: Improving list permissions)\n";
4993 SetVersion($DBversion);
4996 $DBversion = "3.07.00.033";
4997 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4998 $dbh->do("ALTER TABLE branches ADD opac_info text;");
4999 print "Upgrade to $DBversion done add opac_info to branches \n";
5000 SetVersion($DBversion);
5003 $DBversion = "3.07.00.034";
5004 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5005 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`");
5006 $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN class VARCHAR(255) NOT NULL DEFAULT '' AFTER `category_code`");
5007 $dbh->do("ALTER TABLE borrower_attribute_types ADD CONSTRAINT category_code_fk FOREIGN KEY (category_code) REFERENCES categories(categorycode)");
5008 print "Upgrade to $DBversion done (New fields category_code and class in borrower_attribute_types table)\n";
5009 SetVersion($DBversion);
5012 $DBversion = "3.07.00.035";
5013 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5014 $dbh->do("ALTER TABLE issues CHANGE date_due date_due datetime");
5015 $dbh->do("ALTER TABLE issues CHANGE returndate returndate datetime");
5016 $dbh->do("ALTER TABLE issues CHANGE lastreneweddate lastreneweddate datetime");
5017 $dbh->do("ALTER TABLE issues CHANGE issuedate issuedate datetime");
5018 $dbh->do("ALTER TABLE old_issues CHANGE date_due date_due datetime");
5019 $dbh->do("ALTER TABLE old_issues CHANGE returndate returndate datetime");
5020 $dbh->do("ALTER TABLE old_issues CHANGE lastreneweddate lastreneweddate datetime");
5021 $dbh->do("ALTER TABLE old_issues CHANGE issuedate issuedate datetime");
5022 print "Upgrade to $DBversion done (Setting up issues tables for hourly loans)\n";
5023 SetVersion($DBversion);
5026 $DBversion = "3.07.00.036";
5027 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5028 $dbh->do(qq{
5029 ALTER TABLE z3950servers ADD timeout INT( 11 ) NOT NULL DEFAULT '0' AFTER syntax;
5031 print "Upgrade to $DBversion done (New timeout field in z3950servers)\n";
5034 $DBversion = "3.07.00.037";
5035 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5036 $dbh->do("
5037 ALTER TABLE `marc_subfield_structure` ADD `maxlength` INT( 4 ) NOT NULL DEFAULT '9999';
5039 $dbh->do("
5040 UPDATE `marc_subfield_structure` SET maxlength=24 WHERE tagfield='000';
5042 $dbh->do("
5043 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='MARC21','40','9999') WHERE tagfield='008';
5045 $dbh->do("
5046 UPDATE marc_subfield_structure SET maxlength = IF ((SELECT value FROM systempreferences WHERE variable = 'marcflavour')='UNIMARC','36','9999') WHERE tagfield='100';
5048 print "Upgrade to $DBversion done (Add new field maxlength to marc_subfield_structure)\n";
5049 SetVersion($DBversion);
5052 $DBversion = "3.07.00.038";
5053 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5054 $dbh->do(qq{
5055 INSERT INTO systempreferences(variable,value,explanation,options,type)
5056 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')
5058 print "Upgrade to $DBversion done (Added system preference 'UniqueItemFields')\n";
5059 SetVersion($DBversion);
5062 $DBversion = "3.07.00.039";
5063 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5064 $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')} );
5065 $dbh->do( qq{CREATE TABLE IF NOT EXISTS social_data
5066 ( isbn VARCHAR(30),
5067 num_critics INT,
5068 num_critics_pro INT,
5069 num_quotations INT,
5070 num_videos INT,
5071 score_avg DECIMAL(5,2),
5072 num_scores INT,
5073 PRIMARY KEY (isbn)
5074 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5075 } );
5076 $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')} );
5077 print "Upgrade to $DBversion done (added syspref and table for babeltheque (Babeltheque_url_js, babeltheque))\n";
5078 SetVersion($DBversion);
5081 $DBversion = "3.07.00.040";
5082 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5083 $dbh->do( qq{INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('SocialNetworks','0','Enable/Disable social networks links in opac detail','','YesNo')} );
5084 print "Upgrade to $DBversion done (added syspref SocialNetworks, to display facebook/ggl+ and other buttons)\n";
5085 SetVersion($DBversion);
5090 $DBversion = "3.07.00.041";
5091 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5092 $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')");
5093 print "Upgrade to $DBversion done (Add System Preferences SubscriptionDuplicateDroppedInput)\n";
5094 SetVersion($DBversion);
5097 $DBversion = "3.07.00.042";
5098 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5099 $dbh->do("ALTER TABLE reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5100 $dbh->do("ALTER TABLE old_reserves ADD suspend BOOLEAN NOT NULL DEFAULT 0");
5102 $dbh->do("ALTER TABLE reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5103 $dbh->do("ALTER TABLE old_reserves ADD suspend_until DATETIME NULL DEFAULT NULL");
5105 $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')");
5107 print "Upgrade to $DBversion done (Add suspend fields to reserves table, add syspref AutoResumeSuspendedHolds)\n";
5108 SetVersion ($DBversion);
5111 $DBversion = "3.07.00.043";
5112 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5113 my $countXSLTDetailsDisplay = 0;
5114 my $valueXSLTDetailsDisplay = "";
5115 my $valueXSLTResultsDisplay = "";
5116 my $valueOPACXSLTDetailsDisplay = "";
5117 my $valueOPACXSLTResultsDisplay = "";
5118 #the line below test if database comes from a BibLibre's branch
5119 $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
5120 if ($countXSLTDetailsDisplay > 0)
5122 #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
5123 $dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
5124 $dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
5126 else
5128 $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
5129 $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
5130 $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
5131 $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
5132 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
5133 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
5134 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
5135 $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
5137 print "XSLT systempreference takes a path to file rather than YesNo\n";
5138 SetVersion($DBversion);
5141 $DBversion = "3.07.00.044";
5142 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5143 $dbh->do("ALTER TABLE aqbooksellers ADD deliverytime INT DEFAULT NULL");
5144 print "Upgrade to $DBversion done (Add deliverytime field in aqbooksellers table)";
5145 SetVersion($DBversion);
5148 $DBversion = "3.07.00.045";
5149 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5150 $dbh->do("ALTER TABLE import_batches MODIFY COLUMN batch_type ENUM('batch','z3950','webservice') NOT NULL default 'batch'");
5151 print "Upgrade to $DBversion done (Add 'webservice' to batch_type enum)\n";
5152 SetVersion ($DBversion);
5155 $DBversion = "3.07.00.046";
5156 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5157 $dbh->do("ALTER TABLE issuingrules ADD COLUMN lengthunit varchar(10) DEFAULT 'days' AFTER issuelength");
5158 print "Upgrade to $DBversion done (Setting up issues tables for hourly loans (lengthunit fix))\n";
5159 SetVersion($DBversion);
5162 $DBversion = "3.07.00.XXX";
5163 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5164 $dbh->do("CREATE INDEX items_location ON items(location)");
5165 $dbh->do("CREATE INDEX items_ccode ON items(ccode)");
5166 print "Upgrade to $DBversion done (items_location and items_ccode indexes added for ShelfBrowser)";
5167 SetVersion($DBversion);
5170 =head1 FUNCTIONS
5172 =head2 DropAllForeignKeys($table)
5174 Drop all foreign keys of the table $table
5176 =cut
5179 sub DropAllForeignKeys {
5180 my ($table) = @_;
5181 # get the table description
5182 my $sth = $dbh->prepare("SHOW CREATE TABLE $table");
5183 $sth->execute;
5184 my $vsc_structure = $sth->fetchrow;
5185 # split on CONSTRAINT keyword
5186 my @fks = split /CONSTRAINT /,$vsc_structure;
5187 # parse each entry
5188 foreach (@fks) {
5189 # isolate what is before FOREIGN KEY, if there is something, it's a foreign key to drop
5190 $_ = /(.*) FOREIGN KEY.*/;
5191 my $id = $1;
5192 if ($id) {
5193 # we have found 1 foreign, drop it
5194 $dbh->do("ALTER TABLE $table DROP FOREIGN KEY $id");
5195 $id="";
5201 =head2 TransformToNum
5203 Transform the Koha version from a 4 parts string
5204 to a number, with just 1 .
5206 =cut
5208 sub TransformToNum {
5209 my $version = shift;
5210 # remove the 3 last . to have a Perl number
5211 $version =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
5212 # three X's at the end indicate that you are testing patch with dbrev
5213 # change it into 999
5214 # prevents error on a < comparison between strings (should be: lt)
5215 $version =~ s/XXX$/999/;
5216 return $version;
5219 =head2 SetVersion
5221 set the DBversion in the systempreferences
5223 =cut
5225 sub SetVersion {
5226 return if $_[0]=~ /XXX$/;
5227 #you are testing a patch with a db revision; do not change version
5228 my $kohaversion = TransformToNum($_[0]);
5229 if (C4::Context->preference('Version')) {
5230 my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'");
5231 $finish->execute($kohaversion);
5232 } else {
5233 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')");
5234 $finish->execute($kohaversion);
5237 exit;