4 # This script checks for required updates to the database.
6 # Parts copyright Catalyst IT 2011
8 # Part of the Koha Library Software www.koha-community.org
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 # - Would also be a good idea to offer to do a backup at this time...
26 # NOTE: If you do something more than once in here, make it table driven.
28 # NOTE: Please keep the version in kohaversion.pl up-to-date!
37 use Encode qw( encode_utf8 );
43 use Koha::DateUtils qw( dt_from_string output_pref );
46 use MARC::File::XML ( BinaryEncoding => 'utf8' );
48 use File::Path qw[remove_tree]; # perl core module
50 # FIXME - The user might be installing a new database, so can't rely
51 # on /etc/koha.conf anyway.
60 my $schema = Koha::Database->new()->schema();
62 my ( $silent, $force );
67 my $dbh = C4::Context->dbh;
68 $|=1; # flushes output
70 local $dbh->{RaiseError} = 0;
72 # Record the version we are coming from
74 my $original_version = C4::Context->preference("Version");
76 # Deal with virtualshelves
77 my $DBversion = "3.00.00.001";
78 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
79 # update virtualshelves table to
81 $dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
82 $dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
83 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
84 $dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
85 # drop all foreign keys : otherwise, we can't drop itemnumber field.
86 DropAllForeignKeys('virtualshelfcontents');
87 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
88 # create the new foreign keys (on biblionumber)
89 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
90 # re-create the foreign key on virtualshelf
91 $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
92 $dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
93 print "Upgrade to $DBversion done (virtualshelves)\n";
94 SetVersion ($DBversion);
98 $DBversion = "3.00.00.002";
99 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
100 $dbh->do("DROP TABLE sessions");
101 $dbh->do("CREATE TABLE `sessions` (
102 `id` varchar(32) NOT NULL,
103 `a_session` text NOT NULL,
104 UNIQUE KEY `id` (`id`)
105 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
106 print "Upgrade to $DBversion done (sessions uses CGI::session, new table structure for sessions)\n";
107 SetVersion ($DBversion);
111 $DBversion = "3.00.00.003";
112 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
113 if (C4::Context->preference("opaclanguages") eq "fr") {
114 $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')");
116 $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')");
118 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
119 SetVersion ($DBversion);
123 $DBversion = "3.00.00.004";
124 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
125 $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')");
126 print "Upgrade to $DBversion done (adding DebugLevel systempref, in 'Admin' tab)\n";
127 SetVersion ($DBversion);
130 $DBversion = "3.00.00.005";
131 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
132 $dbh->do("CREATE TABLE `tags` (
133 `entry` varchar(255) NOT NULL default '',
134 `weight` bigint(20) NOT NULL default 0,
135 PRIMARY KEY (`entry`)
136 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
138 $dbh->do("CREATE TABLE `nozebra` (
139 `server` varchar(20) NOT NULL,
140 `indexname` varchar(40) NOT NULL,
141 `value` varchar(250) NOT NULL,
142 `biblionumbers` longtext NOT NULL,
143 KEY `indexname` (`server`,`indexname`),
144 KEY `value` (`server`,`value`))
145 ENGINE=InnoDB DEFAULT CHARSET=utf8;
147 print "Upgrade to $DBversion done (adding tags and nozebra tables )\n";
148 SetVersion ($DBversion);
151 $DBversion = "3.00.00.006";
152 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
153 sanitize_zero_date('issues', 'issuedate');
154 print "Upgrade to $DBversion done (filled issues.issuedate with timestamp)\n";
155 SetVersion ($DBversion);
158 $DBversion = "3.00.00.007";
159 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
160 $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')");
161 print "Upgrade to $DBversion done (set SessionStorage variable)\n";
162 SetVersion ($DBversion);
165 $DBversion = "3.00.00.008";
166 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
167 $dbh->do("ALTER TABLE `biblio` ADD `datecreated` DATE NOT NULL AFTER `timestamp` ;");
168 $dbh->do("UPDATE biblio SET datecreated=timestamp");
169 print "Upgrade to $DBversion done (biblio creation date)\n";
170 SetVersion ($DBversion);
173 $DBversion = "3.00.00.009";
174 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
176 # Create backups of call number columns
177 # in case default migration needs to be customized
179 # UPGRADE NOTE: temp_upg_biblioitems_call_num should be dropped
180 # after call numbers have been transformed to the new structure
182 # Not bothering to do the same with deletedbiblioitems -- assume
183 # default is good enough.
184 $dbh->do("CREATE TABLE `temp_upg_biblioitems_call_num` AS
185 SELECT `biblioitemnumber`, `biblionumber`,
186 `classification`, `dewey`, `subclass`,
188 FROM `biblioitems`");
190 # biblioitems changes
191 $dbh->do("ALTER TABLE `biblioitems` CHANGE COLUMN `volumeddesc` `volumedesc` TEXT,
192 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
193 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
194 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
195 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
196 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
197 ADD `totalissues` INT(10) AFTER `cn_sort`");
199 # default mapping of call number columns:
200 # cn_class = concatentation of classification + dewey,
201 # trimmed to fit -- assumes that most users do not
202 # populate both classification and dewey in a single record
204 # cn_source = left null
207 # After upgrade, cn_sort will have to be set based on whatever
208 # default call number scheme user sets as a preference. Misc
209 # script will be added at some point to do that.
211 $dbh->do("UPDATE `biblioitems`
212 SET cn_class = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
217 # Now drop the old call number columns
218 $dbh->do("ALTER TABLE `biblioitems` DROP COLUMN `classification`,
220 DROP COLUMN `subclass`,
221 DROP COLUMN `lcsort`,
222 DROP COLUMN `ccode`");
224 # deletedbiblio changes
225 $dbh->do("ALTER TABLE `deletedbiblio` ALTER COLUMN `frameworkcode` SET DEFAULT '',
227 ADD `datecreated` DATE NOT NULL AFTER `timestamp`");
228 $dbh->do("UPDATE deletedbiblio SET datecreated = timestamp");
230 # deletedbiblioitems changes
231 $dbh->do("ALTER TABLE `deletedbiblioitems`
232 MODIFY `publicationyear` TEXT,
233 CHANGE `volumeddesc` `volumedesc` TEXT,
234 MODIFY `collectiontitle` MEDIUMTEXT DEFAULT NULL AFTER `volumedesc`,
235 MODIFY `collectionissn` TEXT DEFAULT NULL AFTER `collectiontitle`,
236 MODIFY `collectionvolume` MEDIUMTEXT DEFAULT NULL AFTER `collectionissn`,
237 MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
238 MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
239 MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
240 MODIFY `marc` LONGBLOB,
241 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
242 ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
243 ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
244 ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
245 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
246 ADD `totalissues` INT(10) AFTER `cn_sort`,
247 ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
248 ADD KEY `isbn` (`isbn`),
249 ADD KEY `publishercode` (`publishercode`)
252 $dbh->do("UPDATE `deletedbiblioitems`
253 SET `cn_class` = SUBSTR(TRIM(CONCAT_WS(' ', `classification`, `dewey`)), 1, 30),
254 `cn_item` = `subclass`,
257 $dbh->do("ALTER TABLE `deletedbiblioitems`
258 DROP COLUMN `classification`,
260 DROP COLUMN `subclass`,
261 DROP COLUMN `lcsort`,
265 # deleteditems changes
266 $dbh->do("ALTER TABLE `deleteditems`
267 MODIFY `barcode` VARCHAR(20) DEFAULT NULL,
268 MODIFY `price` DECIMAL(8,2) DEFAULT NULL,
269 MODIFY `replacementprice` DECIMAL(8,2) DEFAULT NULL,
271 MODIFY `itemcallnumber` VARCHAR(30) DEFAULT NULL AFTER `wthdrawn`,
272 MODIFY `holdingbranch` VARCHAR(10) DEFAULT NULL,
274 MODIFY `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP AFTER `paidfor`,
276 ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
277 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
278 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
279 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
280 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`,
281 MODIFY `marc` LONGBLOB AFTER `uri`,
283 DROP KEY `itembarcodeidx`,
284 DROP KEY `itembinoidx`,
285 DROP KEY `itembibnoidx`,
286 ADD UNIQUE KEY `delitembarcodeidx` (`barcode`),
287 ADD KEY `delitembinoidx` (`biblioitemnumber`),
288 ADD KEY `delitembibnoidx` (`biblionumber`),
289 ADD KEY `delhomebranch` (`homebranch`),
290 ADD KEY `delholdingbranch` (`holdingbranch`)");
291 $dbh->do("UPDATE deleteditems SET `ccode` = `itype`");
292 $dbh->do("ALTER TABLE deleteditems DROP `itype`");
293 $dbh->do("UPDATE `deleteditems` SET `cn_sort` = `itemcallnumber`");
296 $dbh->do("ALTER TABLE `items` ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `onloan`,
297 ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
298 ADD `ccode` VARCHAR(10) DEFAULT NULL AFTER `cn_sort`,
299 ADD `materials` VARCHAR(10) DEFAULT NULL AFTER `ccode`,
300 ADD `uri` VARCHAR(255) DEFAULT NULL AFTER `materials`
302 $dbh->do("ALTER TABLE `items`
303 DROP KEY `itembarcodeidx`,
304 ADD UNIQUE KEY `itembarcodeidx` (`barcode`)");
306 # map items.itype to items.ccode and
307 # set cn_sort to itemcallnumber -- as with biblioitems.cn_sort,
308 # will have to be subsequently updated per user's default
309 # classification scheme
310 $dbh->do("UPDATE `items` SET `cn_sort` = `itemcallnumber`,
313 $dbh->do("ALTER TABLE `items` DROP `cutterextra`,
316 print "Upgrade to $DBversion done (major changes to biblio, biblioitems, items, and deleted* versions of same\n";
317 SetVersion ($DBversion);
320 $DBversion = "3.00.00.010";
321 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
322 $dbh->do("CREATE INDEX `userid` ON borrowers (`userid`) ");
323 print "Upgrade to $DBversion done (userid index added)\n";
324 SetVersion ($DBversion);
327 $DBversion = "3.00.00.011";
328 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
329 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
330 $dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
331 $dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
332 $dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
333 $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
334 print "Upgrade to $DBversion done (added branchcategory type)\n";
335 SetVersion ($DBversion);
338 $DBversion = "3.00.00.012";
339 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
340 $dbh->do("CREATE TABLE `class_sort_rules` (
341 `class_sort_rule` varchar(10) NOT NULL default '',
342 `description` mediumtext,
343 `sort_routine` varchar(30) NOT NULL default '',
344 PRIMARY KEY (`class_sort_rule`),
345 UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
346 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
347 $dbh->do("CREATE TABLE `class_sources` (
348 `cn_source` varchar(10) NOT NULL default '',
349 `description` mediumtext,
350 `used` tinyint(4) NOT NULL default 0,
351 `class_sort_rule` varchar(10) NOT NULL default '',
352 PRIMARY KEY (`cn_source`),
353 UNIQUE KEY `cn_source_idx` (`cn_source`),
354 KEY `used_idx` (`used`),
355 CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`)
356 REFERENCES `class_sort_rules` (`class_sort_rule`)
357 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
358 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type)
359 VALUES('DefaultClassificationSource','ddc',
360 'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'free')");
361 $dbh->do("INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
362 ('dewey', 'Default filing rules for DDC', 'Dewey'),
363 ('lcc', 'Default filing rules for LCC', 'LCC'),
364 ('generic', 'Generic call number filing rules', 'Generic')");
365 $dbh->do("INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
366 ('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
367 ('lcc', 'Library of Congress Classification', 1, 'lcc'),
368 ('udc', 'Universal Decimal Classification', 0, 'generic'),
369 ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
370 ('z', 'Other/Generic Classification Scheme', 0, 'generic')");
371 print "Upgrade to $DBversion done (classification sources added)\n";
372 SetVersion ($DBversion);
375 $DBversion = "3.00.00.013";
376 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
377 $dbh->do("CREATE TABLE `import_batches` (
378 `import_batch_id` int(11) NOT NULL auto_increment,
379 `template_id` int(11) default NULL,
380 `branchcode` varchar(10) default NULL,
381 `num_biblios` int(11) NOT NULL default 0,
382 `num_items` int(11) NOT NULL default 0,
383 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
384 `overlay_action` enum('replace', 'create_new', 'use_template') NOT NULL default 'create_new',
385 `import_status` enum('staging', 'staged', 'importing', 'imported', 'reverting', 'reverted', 'cleaned') NOT NULL default 'staging',
386 `batch_type` enum('batch', 'z3950') NOT NULL default 'batch',
387 `file_name` varchar(100),
388 `comments` mediumtext,
389 PRIMARY KEY (`import_batch_id`),
390 KEY `branchcode` (`branchcode`)
391 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
392 $dbh->do("CREATE TABLE `import_records` (
393 `import_record_id` int(11) NOT NULL auto_increment,
394 `import_batch_id` int(11) NOT NULL,
395 `branchcode` varchar(10) default NULL,
396 `record_sequence` int(11) NOT NULL default 0,
397 `upload_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
398 `import_date` DATE default NULL,
399 `marc` longblob NOT NULL,
400 `marcxml` longtext NOT NULL,
401 `marcxml_old` longtext NOT NULL,
402 `record_type` enum('biblio', 'auth', 'holdings') NOT NULL default 'biblio',
403 `overlay_status` enum('no_match', 'auto_match', 'manual_match', 'match_applied') NOT NULL default 'no_match',
404 `status` enum('error', 'staged', 'imported', 'reverted', 'items_reverted') NOT NULL default 'staged',
405 `import_error` mediumtext,
406 `encoding` varchar(40) NOT NULL default '',
407 `z3950random` varchar(40) default NULL,
408 PRIMARY KEY (`import_record_id`),
409 CONSTRAINT `import_records_ifbk_1` FOREIGN KEY (`import_batch_id`)
410 REFERENCES `import_batches` (`import_batch_id`) ON DELETE CASCADE ON UPDATE CASCADE,
411 KEY `branchcode` (`branchcode`),
412 KEY `batch_sequence` (`import_batch_id`, `record_sequence`)
413 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
414 $dbh->do("CREATE TABLE `import_record_matches` (
415 `import_record_id` int(11) NOT NULL,
416 `candidate_match_id` int(11) NOT NULL,
417 `score` int(11) NOT NULL default 0,
418 CONSTRAINT `import_record_matches_ibfk_1` FOREIGN KEY (`import_record_id`)
419 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
420 KEY `record_score` (`import_record_id`, `score`)
421 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
422 $dbh->do("CREATE TABLE `import_biblios` (
423 `import_record_id` int(11) NOT NULL,
424 `matched_biblionumber` int(11) default NULL,
425 `control_number` varchar(25) default NULL,
426 `original_source` varchar(25) default NULL,
427 `title` varchar(128) default NULL,
428 `author` varchar(80) default NULL,
429 `isbn` varchar(14) default NULL,
430 `issn` varchar(9) default NULL,
431 `has_items` tinyint(1) NOT NULL default 0,
432 CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`)
433 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
434 KEY `matched_biblionumber` (`matched_biblionumber`),
435 KEY `title` (`title`),
437 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
438 $dbh->do("CREATE TABLE `import_items` (
439 `import_items_id` int(11) NOT NULL auto_increment,
440 `import_record_id` int(11) NOT NULL,
441 `itemnumber` int(11) default NULL,
442 `branchcode` varchar(10) default NULL,
443 `status` enum('error', 'staged', 'imported', 'reverted') NOT NULL default 'staged',
444 `marcxml` longtext NOT NULL,
445 `import_error` mediumtext,
446 PRIMARY KEY (`import_items_id`),
447 CONSTRAINT `import_items_ibfk_1` FOREIGN KEY (`import_record_id`)
448 REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE,
449 KEY `itemnumber` (`itemnumber`),
450 KEY `branchcode` (`branchcode`)
451 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
453 $dbh->do("INSERT INTO `import_batches`
454 (`overlay_action`, `import_status`, `batch_type`, `file_name`)
455 SELECT distinct 'create_new', 'staged', 'z3950', `file`
456 FROM `marc_breeding`");
458 $dbh->do("INSERT INTO `import_records`
459 (`import_batch_id`, `import_record_id`, `record_sequence`, `marc`, `record_type`, `status`,
460 `encoding`, `z3950random`, `marcxml`, `marcxml_old`)
461 SELECT `import_batch_id`, `id`, 1, `marc`, 'biblio', 'staged', `encoding`, `z3950random`, '', ''
463 JOIN `import_batches` ON (`file_name` = `file`)");
465 $dbh->do("INSERT INTO `import_biblios`
466 (`import_record_id`, `title`, `author`, `isbn`)
467 SELECT `import_record_id`, `title`, `author`, `isbn`
469 JOIN `import_records` ON (`import_record_id` = `id`)");
471 $dbh->do("UPDATE `import_batches`
472 SET `num_biblios` = (
474 FROM `import_records`
475 WHERE `import_batch_id` = `import_batches`.`import_batch_id`
478 $dbh->do("DROP TABLE `marc_breeding`");
480 print "Upgrade to $DBversion done (import_batches et al. added)\n";
481 SetVersion ($DBversion);
484 $DBversion = "3.00.00.014";
485 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
486 $dbh->do("ALTER TABLE subscription ADD lastbranch VARCHAR(4)");
487 print "Upgrade to $DBversion done (userid index added)\n";
488 SetVersion ($DBversion);
491 $DBversion = "3.00.00.015";
492 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
493 $dbh->do("CREATE TABLE `saved_sql` (
494 `id` int(11) NOT NULL auto_increment,
495 `borrowernumber` int(11) default NULL,
496 `date_created` datetime default NULL,
497 `last_modified` datetime default NULL,
499 `last_run` datetime default NULL,
500 `report_name` varchar(255) default NULL,
501 `type` varchar(255) default NULL,
504 KEY boridx (`borrowernumber`)
505 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
506 $dbh->do("CREATE TABLE `saved_reports` (
507 `id` int(11) NOT NULL auto_increment,
508 `report_id` int(11) default NULL,
510 `date_run` datetime default NULL,
512 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
513 print "Upgrade to $DBversion done (saved_sql and saved_reports added)\n";
514 SetVersion ($DBversion);
517 $DBversion = "3.00.00.016";
518 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
519 $dbh->do(" CREATE TABLE reports_dictionary (
520 id int(11) NOT NULL auto_increment,
521 name varchar(255) default NULL,
523 date_created datetime default NULL,
524 date_modified datetime default NULL,
526 area int(11) default NULL,
528 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
529 print "Upgrade to $DBversion done (reports_dictionary) added)\n";
530 SetVersion ($DBversion);
533 $DBversion = "3.00.00.017";
534 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
535 $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
536 $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)");
537 $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
538 $dbh->do("UPDATE action_logs SET action_id = if (\@a, \@a:=\@a+1, \@a:=1)");
539 $dbh->do("ALTER TABLE action_logs MODIFY action_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY");
540 print "Upgrade to $DBversion done (added column to action_logs)\n";
541 SetVersion ($DBversion);
544 $DBversion = "3.00.00.018";
545 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
546 $dbh->do("ALTER TABLE `zebraqueue`
547 ADD `done` INT NOT NULL DEFAULT '0',
548 ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
550 print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
551 SetVersion ($DBversion);
554 $DBversion = "3.00.00.019";
555 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
556 $dbh->do("ALTER TABLE biblio MODIFY biblionumber INT(11) NOT NULL AUTO_INCREMENT");
557 $dbh->do("ALTER TABLE biblioitems MODIFY biblioitemnumber INT(11) NOT NULL AUTO_INCREMENT");
558 $dbh->do("ALTER TABLE items MODIFY itemnumber INT(11) NOT NULL AUTO_INCREMENT");
559 print "Upgrade to $DBversion done (made bib/item PKs auto_increment)\n";
560 SetVersion ($DBversion);
563 $DBversion = "3.00.00.020";
564 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
565 $dbh->do("ALTER TABLE deleteditems
566 DROP KEY `delitembarcodeidx`,
567 ADD KEY `delitembarcodeidx` (`barcode`)");
568 print "Upgrade to $DBversion done (dropped uniqueness of key on deleteditems.barcode)\n";
569 SetVersion ($DBversion);
572 $DBversion = "3.00.00.021";
573 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
574 $dbh->do("ALTER TABLE items CHANGE homebranch homebranch VARCHAR(10)");
575 $dbh->do("ALTER TABLE deleteditems CHANGE homebranch homebranch VARCHAR(10)");
576 $dbh->do("ALTER TABLE statistics CHANGE branch branch VARCHAR(10)");
577 $dbh->do("ALTER TABLE subscription CHANGE lastbranch lastbranch VARCHAR(10)");
578 print "Upgrade to $DBversion done (extended missed branchcode columns to 10 chars)\n";
579 SetVersion ($DBversion);
582 $DBversion = "3.00.00.022";
583 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
584 $dbh->do("ALTER TABLE items
585 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
586 $dbh->do("ALTER TABLE deleteditems
587 ADD `damaged` tinyint(1) default NULL AFTER notforloan");
588 print "Upgrade to $DBversion done (adding damaged column to items table)\n";
589 SetVersion ($DBversion);
592 $DBversion = "3.00.00.023";
593 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
594 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
595 VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
596 print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
597 SetVersion ($DBversion);
599 $DBversion = "3.00.00.024";
600 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
601 $dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
602 print "Upgrade to $DBversion done (changing itemtype to (10))\n";
603 SetVersion ($DBversion);
606 $DBversion = "3.00.00.025";
607 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
608 $dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
609 $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
610 if(C4::Context->preference('item-level_itypes')){
611 $dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
613 print "Upgrade to $DBversion done (reintroduce items.itype - fill from itemtype)\n ";
614 SetVersion ($DBversion);
617 $DBversion = "3.00.00.026";
618 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
619 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
620 VALUES ('HomeOrHoldingBranch','homebranch','homebranch|holdingbranch','With independent branches turned on this decides whether to check the items holdingbranch or homebranch at circulatilon','choice')");
621 print "Upgrade to $DBversion done (adding new system preference for choosing whether homebranch or holdingbranch is checked in circulation)\n";
622 SetVersion ($DBversion);
625 $DBversion = "3.00.00.027";
626 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
627 $dbh->do("CREATE TABLE `marc_matchers` (
628 `matcher_id` int(11) NOT NULL auto_increment,
629 `code` varchar(10) NOT NULL default '',
630 `description` varchar(255) NOT NULL default '',
631 `record_type` varchar(10) NOT NULL default 'biblio',
632 `threshold` int(11) NOT NULL default 0,
633 PRIMARY KEY (`matcher_id`),
635 KEY `record_type` (`record_type`)
636 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
637 $dbh->do("CREATE TABLE `matchpoints` (
638 `matcher_id` int(11) NOT NULL,
639 `matchpoint_id` int(11) NOT NULL auto_increment,
640 `search_index` varchar(30) NOT NULL default '',
641 `score` int(11) NOT NULL default 0,
642 PRIMARY KEY (`matchpoint_id`),
643 CONSTRAINT `matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
644 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE
645 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
646 $dbh->do("CREATE TABLE `matchpoint_components` (
647 `matchpoint_id` int(11) NOT NULL,
648 `matchpoint_component_id` int(11) NOT NULL auto_increment,
649 sequence int(11) NOT NULL default 0,
650 tag varchar(3) NOT NULL default '',
651 subfields varchar(40) NOT NULL default '',
652 offset int(4) NOT NULL default 0,
653 length int(4) NOT NULL default 0,
654 PRIMARY KEY (`matchpoint_component_id`),
655 KEY `by_sequence` (`matchpoint_id`, `sequence`),
656 CONSTRAINT `matchpoint_components_ifbk_1` FOREIGN KEY (`matchpoint_id`)
657 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
658 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
659 $dbh->do("CREATE TABLE `matchpoint_component_norms` (
660 `matchpoint_component_id` int(11) NOT NULL,
661 `sequence` int(11) NOT NULL default 0,
662 `norm_routine` varchar(50) NOT NULL default '',
663 KEY `matchpoint_component_norms` (`matchpoint_component_id`, `sequence`),
664 CONSTRAINT `matchpoint_component_norms_ifbk_1` FOREIGN KEY (`matchpoint_component_id`)
665 REFERENCES `matchpoint_components` (`matchpoint_component_id`) ON DELETE CASCADE ON UPDATE CASCADE
666 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
667 $dbh->do("CREATE TABLE `matcher_matchpoints` (
668 `matcher_id` int(11) NOT NULL,
669 `matchpoint_id` int(11) NOT NULL,
670 CONSTRAINT `matcher_matchpoints_ifbk_1` FOREIGN KEY (`matcher_id`)
671 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
672 CONSTRAINT `matcher_matchpoints_ifbk_2` FOREIGN KEY (`matchpoint_id`)
673 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
674 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
675 $dbh->do("CREATE TABLE `matchchecks` (
676 `matcher_id` int(11) NOT NULL,
677 `matchcheck_id` int(11) NOT NULL auto_increment,
678 `source_matchpoint_id` int(11) NOT NULL,
679 `target_matchpoint_id` int(11) NOT NULL,
680 PRIMARY KEY (`matchcheck_id`),
681 CONSTRAINT `matcher_matchchecks_ifbk_1` FOREIGN KEY (`matcher_id`)
682 REFERENCES `marc_matchers` (`matcher_id`) ON DELETE CASCADE ON UPDATE CASCADE,
683 CONSTRAINT `matcher_matchchecks_ifbk_2` FOREIGN KEY (`source_matchpoint_id`)
684 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE,
685 CONSTRAINT `matcher_matchchecks_ifbk_3` FOREIGN KEY (`target_matchpoint_id`)
686 REFERENCES `matchpoints` (`matchpoint_id`) ON DELETE CASCADE ON UPDATE CASCADE
687 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
688 print "Upgrade to $DBversion done (added C4::Matcher serialization tables)\n ";
689 SetVersion ($DBversion);
692 $DBversion = "3.00.00.028";
693 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
694 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
695 VALUES ('canreservefromotherbranches','1','','With Independent branches on, can a user from one library reserve an item from another library','YesNo')");
696 print "Upgrade to $DBversion done (adding new system preference for changing reserve/holds behaviour with independent branches)\n";
697 SetVersion ($DBversion);
701 $DBversion = "3.00.00.029";
702 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
703 $dbh->do("ALTER TABLE `import_batches` ADD `matcher_id` int(11) NULL AFTER `import_batch_id`");
704 print "Upgrade to $DBversion done (adding matcher_id to import_batches)\n";
705 SetVersion ($DBversion);
708 $DBversion = "3.00.00.030";
709 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
711 CREATE TABLE services_throttle (
712 service_type varchar(10) NOT NULL default '',
713 service_count varchar(45) default NULL,
714 PRIMARY KEY (service_type)
715 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
717 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
718 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')");
719 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
720 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')");
721 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
722 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')");
723 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
724 VALUES ('XISBNDailyLimit',499,'','The xISBN Web service is free for non-commercial use when usage does not exceed 500 requests per day','free')");
725 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
726 VALUES ('PINESISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use PINES OISBN web service in the Editions tab on the detail pages.','YesNo')");
727 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type)
728 VALUES ('ThingISBN',0,'','Use with FRBRizeEditions. If ON, Koha will use the ThingISBN web service in the Editions tab on the detail pages.','YesNo')");
729 print "Upgrade to $DBversion done (adding services throttle table and sysprefs for xISBN)\n";
730 SetVersion ($DBversion);
733 $DBversion = "3.00.00.031";
734 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
736 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryStemming',1,'If ON, enables query stemming',NULL,'YesNo')");
737 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryFuzzy',1,'If ON, enables fuzzy option for searches',NULL,'YesNo')");
738 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('QueryWeightFields',1,'If ON, enables field weighting',NULL,'YesNo')");
739 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON, enables the web-based self-check system',NULL,'YesNo')");
740 $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')");
741 $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')");
742 $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')");
743 $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')");
744 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('defaultSortOrder',NULL,'Specify the default sort order','asc|dsc|az|za','Choice')");
745 $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')");
746 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACdefaultSortOrder',NULL,'Specify the default sort order','asc|dsc|za|az','Choice')");
747 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
748 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
749 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
750 $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')");
751 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
752 $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')");
753 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice')");
754 $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')");
755 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
756 $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')");
757 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
758 $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')");
759 $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')");
760 $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')");
761 $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')");
762 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACUserCSS',0,'Add CSS to be included in the OPAC',NULL,'free')");
764 print "Upgrade to $DBversion done (adding additional system preference)\n";
765 SetVersion ($DBversion);
768 $DBversion = "3.00.00.032";
769 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
770 $dbh->do("UPDATE `marc_subfield_structure` SET `kohafield` = 'items.wthdrawn' WHERE `kohafield` = 'items.withdrawn'");
771 print "Upgrade to $DBversion done (fixed MARC framework references to items.withdrawn)\n";
772 SetVersion ($DBversion);
775 $DBversion = "3.00.00.033";
776 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
777 $dbh->do("INSERT INTO `userflags` VALUES(17,'staffaccess','Modify login / permissions for staff users',0)");
778 print "Upgrade to $DBversion done (Adding permissions flag for staff member access modification. )\n";
779 SetVersion ($DBversion);
782 $DBversion = "3.00.00.034";
783 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
784 $dbh->do("ALTER TABLE `virtualshelves` ADD COLUMN `sortfield` VARCHAR(16) ");
785 print "Upgrade to $DBversion done (Adding sortfield for Virtual Shelves. )\n";
786 SetVersion ($DBversion);
789 $DBversion = "3.00.00.035";
790 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
791 $dbh->do("UPDATE marc_subfield_structure
792 SET authorised_value = 'cn_source'
793 WHERE kohafield IN ('items.cn_source', 'biblioitems.cn_source')
794 AND (authorised_value is NULL OR authorised_value = '')");
795 print "Upgrade to $DBversion done (MARC frameworks: make classification source a drop-down)\n";
796 SetVersion ($DBversion);
799 $DBversion = "3.00.00.036";
800 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
801 $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');");
802 print "Upgrade to $DBversion done (OPACItemsResultsDisplay systempreference added)\n";
803 SetVersion ($DBversion);
806 $DBversion = "3.00.00.037";
807 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
808 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactfirstname` varchar(255)");
809 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactsurname` varchar(255)");
810 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress1` varchar(255)");
811 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress2` varchar(255)");
812 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactaddress3` varchar(255)");
813 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactzipcode` varchar(50)");
814 $dbh->do("ALTER TABLE `borrowers` ADD COLUMN `altcontactphone` varchar(50)");
815 print "Upgrade to $DBversion done (Adding Alternative Contact Person information to borrowers table)\n";
816 SetVersion ($DBversion);
819 $DBversion = "3.00.00.038";
820 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
821 $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'");
822 $dbh->do("DELETE FROM `systempreferences` WHERE variable='hideBiblioNumber'");
823 print "Upgrade to $DBversion done ('alter finesMode systempreference, remove superfluous syspref.')\n";
824 SetVersion ($DBversion);
827 $DBversion = "3.00.00.039";
828 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
829 $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')");
830 $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')");
831 $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')");
832 # $dbh->do("DELETE FROM `systempreferences` WHERE variable='HomeOrHoldingBranch'"); # Bug #2752
833 print "Upgrade to $DBversion done ('add circ sysprefs CircControl, finesCalendar, and uppercasesurnames, and delete HomeOrHoldingBranch.')\n";
834 SetVersion ($DBversion);
837 $DBversion = "3.00.00.040";
838 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
839 $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')");
840 $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')");
841 print "Upgrade to $DBversion done ('add circ sysprefs todaysIssuesDefaultSortOrder and previousIssuesDefaultSortOrder.')\n";
842 SetVersion ($DBversion);
846 $DBversion = "3.00.00.041";
847 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
848 # Strictly speaking it is not necessary to explicitly change
849 # NULL values to 0, because the ALTER TABLE statement will do that.
850 # However, setting them first avoids a warning.
851 $dbh->do("UPDATE items SET notforloan = 0 WHERE notforloan IS NULL");
852 $dbh->do("UPDATE items SET damaged = 0 WHERE damaged IS NULL");
853 $dbh->do("UPDATE items SET itemlost = 0 WHERE itemlost IS NULL");
854 $dbh->do("UPDATE items SET wthdrawn = 0 WHERE wthdrawn IS NULL");
855 $dbh->do("ALTER TABLE items
856 MODIFY notforloan tinyint(1) NOT NULL default 0,
857 MODIFY damaged tinyint(1) NOT NULL default 0,
858 MODIFY itemlost tinyint(1) NOT NULL default 0,
859 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
860 $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
861 $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
862 $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
863 $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
864 $dbh->do("ALTER TABLE deleteditems
865 MODIFY notforloan tinyint(1) NOT NULL default 0,
866 MODIFY damaged tinyint(1) NOT NULL default 0,
867 MODIFY itemlost tinyint(1) NOT NULL default 0,
868 MODIFY wthdrawn tinyint(1) NOT NULL default 0");
869 print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
870 SetVersion ($DBversion);
873 $DBversion = "3.00.00.04";
874 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
875 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
876 print "Upgrade to $DBversion done (disallow NULL in aqbooksellers.name; part of fix for bug 1251)\n";
877 SetVersion ($DBversion);
880 $DBversion = "3.00.00.043";
881 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
882 $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");
883 print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
884 SetVersion ($DBversion);
887 $DBversion = "3.00.00.044";
888 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
889 $dbh->do("ALTER TABLE deletedborrowers
890 ADD `altcontactfirstname` varchar(255) default NULL,
891 ADD `altcontactsurname` varchar(255) default NULL,
892 ADD `altcontactaddress1` varchar(255) default NULL,
893 ADD `altcontactaddress2` varchar(255) default NULL,
894 ADD `altcontactaddress3` varchar(255) default NULL,
895 ADD `altcontactzipcode` varchar(50) default NULL,
896 ADD `altcontactphone` varchar(50) default NULL
898 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
899 ('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
900 ('language','en','Set the default language in the staff client.',NULL,'Languages'),
901 ('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
902 ('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
904 print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
905 SetVersion ($DBversion);
908 #-- http://www.w3.org/International/articles/language-tags/
911 $DBversion = "3.00.00.045";
912 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
914 CREATE TABLE language_subtag_registry (
916 type varchar(25), -- language-script-region-variant-extension-privateuse
917 description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
919 KEY `subtag` (`subtag`)
920 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
922 #-- TODO: add suppress_scripts
923 #-- this maps three letter codes defined in iso639.2 back to their
924 #-- two letter equivilents in rfc4646 (LOC maintains iso639+)
925 $dbh->do("CREATE TABLE language_rfc4646_to_iso639 (
926 rfc4646_subtag varchar(25),
927 iso639_2_code varchar(25),
928 KEY `rfc4646_subtag` (`rfc4646_subtag`)
929 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
931 $dbh->do("CREATE TABLE language_descriptions (
935 description varchar(255),
937 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
939 #-- bi-directional support, keyed by script subcode
940 $dbh->do("CREATE TABLE language_script_bidi (
941 rfc4646_subtag varchar(25), -- script subtag, Arab, Hebr, etc.
942 bidi varchar(3), -- rtl ltr
943 KEY `rfc4646_subtag` (`rfc4646_subtag`)
944 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
946 #-- BIDI Stuff, Arabic and Hebrew
947 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
948 VALUES( 'Arab', 'rtl')");
949 $dbh->do("INSERT INTO language_script_bidi(rfc4646_subtag,bidi)
950 VALUES( 'Hebr', 'rtl')");
952 #-- TODO: need to map language subtags to script subtags for detection
953 #-- of bidi when script is not specified (like ar, he)
954 $dbh->do("CREATE TABLE language_script_mapping (
955 language_subtag varchar(25),
956 script_subtag varchar(25),
957 KEY `language_subtag` (`language_subtag`)
958 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
960 #-- Default mappings between script and language subcodes
961 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
962 VALUES( 'ar', 'Arab')");
963 $dbh->do("INSERT INTO language_script_mapping(language_subtag,script_subtag)
964 VALUES( 'he', 'Hebr')");
966 print "Upgrade to $DBversion done (adding language subtag registry and basic BiDi support NOTE: You should import the subtag registry SQL)\n";
967 SetVersion ($DBversion);
970 $DBversion = "3.00.00.046";
971 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
972 $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
973 CHANGE `weeklength` `weeklength` int(11) default '0'");
974 $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
975 $dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
976 print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
977 SetVersion ($DBversion);
980 $DBversion = "3.00.00.047";
981 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
982 $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');");
983 print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
984 SetVersion ($DBversion);
987 $DBversion = "3.00.00.048";
988 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
989 $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
990 print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
991 SetVersion ($DBversion);
994 $DBversion = "3.00.00.049";
995 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
996 $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
997 print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
998 SetVersion ($DBversion);
1001 $DBversion = "3.00.00.050";
1002 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1003 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
1004 print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
1005 SetVersion ($DBversion);
1008 $DBversion = "3.00.00.051";
1009 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1010 $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
1011 print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
1012 SetVersion ($DBversion);
1015 $DBversion = "3.00.00.052";
1016 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1017 $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
1018 print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
1019 SetVersion ($DBversion);
1022 $DBversion = "3.00.00.053";
1023 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1024 $dbh->do("CREATE TABLE `printers_profile` (
1025 `prof_id` int(4) NOT NULL auto_increment,
1026 `printername` varchar(40) NOT NULL,
1027 `tmpl_id` int(4) NOT NULL,
1028 `paper_bin` varchar(20) NOT NULL,
1029 `offset_horz` float default NULL,
1030 `offset_vert` float default NULL,
1031 `creep_horz` float default NULL,
1032 `creep_vert` float default NULL,
1033 `unit` char(20) NOT NULL default 'POINT',
1034 PRIMARY KEY (`prof_id`),
1035 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1036 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1037 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1038 $dbh->do("CREATE TABLE `labels_profile` (
1039 `tmpl_id` int(4) NOT NULL,
1040 `prof_id` int(4) NOT NULL,
1041 UNIQUE KEY `tmpl_id` (`tmpl_id`),
1042 UNIQUE KEY `prof_id` (`prof_id`)
1043 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1044 print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
1045 SetVersion ($DBversion);
1048 $DBversion = "3.00.00.054";
1049 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1050 $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';");
1051 print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
1052 SetVersion ($DBversion);
1055 $DBversion = "3.00.00.055";
1056 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1057 $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
1058 print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
1059 SetVersion ($DBversion);
1061 $DBversion = "3.00.00.056";
1062 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1063 if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
1064 $dbh->do("INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value` , `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('995', 'v', 'Note sur le N° de périodique','Note sur le N° de périodique', 0, 0, 'items.enumchron', 10, '', '', '', 0, 0, '', '', '', NULL) ");
1066 $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) ");
1068 $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
1069 print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
1070 SetVersion ($DBversion);
1073 $DBversion = "3.00.00.057";
1074 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1075 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
1076 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
1077 $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');");
1078 $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');");
1079 $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');");
1080 SetVersion ($DBversion);
1083 $DBversion = "3.00.00.058";
1084 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1085 $dbh->do("ALTER TABLE `opac_news`
1086 CHANGE `lang` `lang` VARCHAR( 25 )
1088 COLLATE utf8_general_ci
1089 NOT NULL default ''");
1090 print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
1091 SetVersion ($DBversion);
1094 $DBversion = "3.00.00.059";
1095 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1097 $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
1098 `tmpl_id` int(4) NOT NULL auto_increment,
1099 `tmpl_code` char(100) default '',
1100 `tmpl_desc` char(100) default '',
1101 `page_width` float default '0',
1102 `page_height` float default '0',
1103 `label_width` float default '0',
1104 `label_height` float default '0',
1105 `topmargin` float default '0',
1106 `leftmargin` float default '0',
1107 `cols` int(2) default '0',
1108 `rows` int(2) default '0',
1109 `colgap` float default '0',
1110 `rowgap` float default '0',
1111 `active` int(1) default NULL,
1112 `units` char(20) default 'PX',
1113 `fontsize` int(4) NOT NULL default '3',
1114 PRIMARY KEY (`tmpl_id`)
1115 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1116 $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
1117 `prof_id` int(4) NOT NULL auto_increment,
1118 `printername` varchar(40) NOT NULL,
1119 `tmpl_id` int(4) NOT NULL,
1120 `paper_bin` varchar(20) NOT NULL,
1121 `offset_horz` float default NULL,
1122 `offset_vert` float default NULL,
1123 `creep_horz` float default NULL,
1124 `creep_vert` float default NULL,
1125 `unit` char(20) NOT NULL default 'POINT',
1126 PRIMARY KEY (`prof_id`),
1127 UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
1128 CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
1129 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
1130 print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
1131 SetVersion ($DBversion);
1134 $DBversion = "3.00.00.060";
1135 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1136 $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
1137 `cardnumber` varchar(16) NOT NULL,
1138 `mimetype` varchar(15) NOT NULL,
1139 `imagefile` mediumblob NOT NULL,
1140 PRIMARY KEY (`cardnumber`),
1141 CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
1142 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1143 print "Upgrade to $DBversion done ( Added patronimage table. )\n";
1144 SetVersion ($DBversion);
1147 $DBversion = "3.00.00.061";
1148 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1149 $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
1150 print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
1151 SetVersion ($DBversion);
1154 $DBversion = "3.00.00.062";
1155 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1156 $dbh->do("CREATE TABLE `old_issues` (
1157 `borrowernumber` int(11) default NULL,
1158 `itemnumber` int(11) default NULL,
1159 `date_due` date default NULL,
1160 `branchcode` varchar(10) default NULL,
1161 `issuingbranch` varchar(18) default NULL,
1162 `returndate` date default NULL,
1163 `lastreneweddate` date default NULL,
1164 `return` varchar(4) default NULL,
1165 `renewals` tinyint(4) default NULL,
1166 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1167 `issuedate` date default NULL,
1168 KEY `old_issuesborridx` (`borrowernumber`),
1169 KEY `old_issuesitemidx` (`itemnumber`),
1170 KEY `old_bordate` (`borrowernumber`,`timestamp`),
1171 CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1172 ON DELETE SET NULL ON UPDATE SET NULL,
1173 CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1174 ON DELETE SET NULL ON UPDATE SET NULL
1175 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1176 $dbh->do("CREATE TABLE `old_reserves` (
1177 `borrowernumber` int(11) default NULL,
1178 `reservedate` date default NULL,
1179 `biblionumber` int(11) default NULL,
1180 `constrainttype` varchar(1) default NULL,
1181 `branchcode` varchar(10) default NULL,
1182 `notificationdate` date default NULL,
1183 `reminderdate` date default NULL,
1184 `cancellationdate` date default NULL,
1185 `reservenotes` mediumtext,
1186 `priority` smallint(6) default NULL,
1187 `found` varchar(1) default NULL,
1188 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1189 `itemnumber` int(11) default NULL,
1190 `waitingdate` date default NULL,
1191 KEY `old_reserves_borrowernumber` (`borrowernumber`),
1192 KEY `old_reserves_biblionumber` (`biblionumber`),
1193 KEY `old_reserves_itemnumber` (`itemnumber`),
1194 KEY `old_reserves_branchcode` (`branchcode`),
1195 CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1196 ON DELETE SET NULL ON UPDATE SET NULL,
1197 CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
1198 ON DELETE SET NULL ON UPDATE SET NULL,
1199 CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1200 ON DELETE SET NULL ON UPDATE SET NULL
1201 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1203 # move closed transactions to old_* tables
1204 $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
1205 $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
1206 $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1207 $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
1209 print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
1210 SetVersion ($DBversion);
1213 $DBversion = "3.00.00.063";
1214 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1215 $dbh->do("ALTER TABLE deleteditems
1216 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
1217 ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
1218 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1219 $dbh->do("ALTER TABLE items
1220 CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
1221 ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
1222 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";
1223 SetVersion ($DBversion);
1226 $DBversion = "3.00.00.064";
1227 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1228 $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');");
1229 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
1230 $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
1231 $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
1232 $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
1233 print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
1234 SetVersion ($DBversion);
1237 $DBversion = "3.00.00.065";
1238 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1239 $dbh->do("CREATE TABLE `patroncards` (
1240 `cardid` int(11) NOT NULL auto_increment,
1241 `batch_id` varchar(10) NOT NULL default '1',
1242 `borrowernumber` int(11) NOT NULL,
1243 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1244 PRIMARY KEY (`cardid`),
1245 KEY `patroncards_ibfk_1` (`borrowernumber`),
1246 CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1247 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
1248 print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
1249 SetVersion ($DBversion);
1252 $DBversion = "3.00.00.066";
1253 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1254 $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
1255 DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
1257 print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
1258 SetVersion ($DBversion);
1261 $DBversion = "3.00.00.067";
1262 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1263 $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
1264 print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
1265 SetVersion ($DBversion);
1268 $DBversion = "3.00.00.068";
1269 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1270 $dbh->do("CREATE TABLE `permissions` (
1271 `module_bit` int(11) NOT NULL DEFAULT 0,
1272 `code` varchar(30) DEFAULT NULL,
1273 `description` varchar(255) DEFAULT NULL,
1274 PRIMARY KEY (`module_bit`, `code`),
1275 CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
1276 ON DELETE CASCADE ON UPDATE CASCADE
1277 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1278 $dbh->do("CREATE TABLE `user_permissions` (
1279 `borrowernumber` int(11) NOT NULL DEFAULT 0,
1280 `module_bit` int(11) NOT NULL DEFAULT 0,
1281 `code` varchar(30) DEFAULT NULL,
1282 CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1283 ON DELETE CASCADE ON UPDATE CASCADE,
1284 CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
1285 REFERENCES `permissions` (`module_bit`, `code`)
1286 ON DELETE CASCADE ON UPDATE CASCADE
1287 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1289 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
1290 (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
1291 (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
1292 (13, 'edit_calendar', 'Define days when the library is closed'),
1293 (13, 'moderate_comments', 'Moderate patron comments'),
1294 (13, 'edit_notices', 'Define notices'),
1295 (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
1296 (13, 'view_system_logs', 'Browse the system logs'),
1297 (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
1298 (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
1299 (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
1300 (13, 'export_catalog', 'Export bibliographic and holdings data'),
1301 (13, 'import_patrons', 'Import patron data'),
1302 (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
1303 (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
1304 (13, 'schedule_tasks', 'Schedule tasks to run')");
1306 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
1308 print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
1309 SetVersion ($DBversion);
1311 $DBversion = "3.00.00.069";
1312 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1313 $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
1314 print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
1315 SetVersion ($DBversion);
1318 $DBversion = "3.00.00.070";
1319 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1320 $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
1322 my ($value) = $sth->fetchrow;
1323 $value =~ s/2.3.1/2.5.1/;
1324 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
1325 print "Update yuipath syspref to 2.5.1 if necessary\n";
1326 SetVersion ($DBversion);
1329 $DBversion = "3.00.00.071";
1330 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1331 $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
1332 # fill the new field with the previous systempreference value, then drop the syspref
1333 my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
1335 my ($serialsadditems) = $sth->fetchrow();
1336 $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
1337 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1338 print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
1339 SetVersion ($DBversion);
1342 $DBversion = "3.00.00.072";
1343 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1344 $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring mediumtext DEFAULT NULL AFTER printingtype");
1345 print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
1346 SetVersion ($DBversion);
1349 $DBversion = "3.00.00.073";
1350 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1351 $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
1353 CREATE TABLE `tags_all` (
1354 `tag_id` int(11) NOT NULL auto_increment,
1355 `borrowernumber` int(11) NOT NULL,
1356 `biblionumber` int(11) NOT NULL,
1357 `term` varchar(255) NOT NULL,
1358 `language` int(4) default NULL,
1359 `date_created` datetime NOT NULL,
1360 PRIMARY KEY (`tag_id`),
1361 KEY `tags_borrowers_fk_1` (`borrowernumber`),
1362 KEY `tags_biblionumber_fk_1` (`biblionumber`),
1363 CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
1364 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1365 CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1366 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1367 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1369 $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
1371 CREATE TABLE `tags_approval` (
1372 `term` varchar(255) NOT NULL,
1373 `approved` int(1) NOT NULL default '0',
1374 `date_approved` datetime default NULL,
1375 `approved_by` int(11) default NULL,
1376 `weight_total` int(9) NOT NULL default '1',
1377 PRIMARY KEY (`term`),
1378 KEY `tags_approval_borrowers_fk_1` (`approved_by`),
1379 CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
1380 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1381 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1383 $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
1385 CREATE TABLE `tags_index` (
1386 `term` varchar(255) NOT NULL,
1387 `biblionumber` int(11) NOT NULL,
1388 `weight` int(9) NOT NULL default '1',
1389 PRIMARY KEY (`term`,`biblionumber`),
1390 KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
1391 CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
1392 REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
1393 CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
1394 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
1395 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1398 INSERT INTO `systempreferences` VALUES
1399 ('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=',''),
1400 ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
1401 ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
1402 ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
1403 ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
1404 ('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.',''),
1405 ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
1406 ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
1407 ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
1408 ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
1409 ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
1411 print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
1412 SetVersion ($DBversion);
1415 $DBversion = "3.00.00.074";
1416 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1417 $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
1418 where imageurl not like 'http%'
1419 and imageurl is not NULL
1420 and imageurl != '') );
1421 print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
1422 SetVersion ($DBversion);
1425 $DBversion = "3.00.00.075";
1426 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1427 $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
1428 print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
1429 SetVersion ($DBversion);
1432 $DBversion = "3.00.00.076";
1433 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1434 $dbh->do("ALTER TABLE import_batches
1435 ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
1436 $dbh->do("ALTER TABLE import_batches
1437 ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
1438 NOT NULL default 'always_add' AFTER nomatch_action");
1439 $dbh->do("ALTER TABLE import_batches
1440 MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
1441 NOT NULL default 'create_new'");
1442 $dbh->do("ALTER TABLE import_records
1443 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
1444 'ignored') NOT NULL default 'staged'");
1445 $dbh->do("ALTER TABLE import_items
1446 MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
1448 print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
1449 SetVersion ($DBversion);
1452 $DBversion = "3.00.00.077";
1453 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1454 # drop these tables only if they exist and none of them are empty
1455 # these tables are not defined in the packaged 2.2.9, but since it is believed
1456 # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
1457 # some care is taken.
1458 my ($print_error) = $dbh->{PrintError};
1459 $dbh->{PrintError} = 0;
1460 my ($raise_error) = $dbh->{RaiseError};
1461 $dbh->{RaiseError} = 1;
1465 eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
1469 eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
1473 eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
1479 $dbh->do("DROP TABLE IF EXISTS `categorytable`");
1480 $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
1481 $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
1484 $dbh->{PrintError} = $print_error;
1485 $dbh->{RaiseError} = $raise_error;
1486 print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
1487 SetVersion ($DBversion);
1490 $DBversion = "3.00.00.078";
1491 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1492 my ($print_error) = $dbh->{PrintError};
1493 $dbh->{PrintError} = 0;
1495 unless ($dbh->do("SELECT 1 FROM browser")) {
1496 $dbh->{PrintError} = $print_error;
1497 $dbh->do("CREATE TABLE `browser` (
1498 `level` int(11) NOT NULL,
1499 `classification` varchar(20) NOT NULL,
1500 `description` varchar(255) NOT NULL,
1501 `number` bigint(20) NOT NULL,
1502 `endnode` tinyint(4) NOT NULL
1503 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1505 $dbh->{PrintError} = $print_error;
1506 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1507 SetVersion ($DBversion);
1510 $DBversion = "3.00.00.079";
1511 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1512 my ($print_error) = $dbh->{PrintError};
1513 $dbh->{PrintError} = 0;
1515 $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
1516 ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
1517 print "Upgrade to $DBversion done (add browser table if not already present)\n";
1518 SetVersion ($DBversion);
1521 $DBversion = "3.00.00.080";
1522 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1523 $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
1524 $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
1525 $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
1526 print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
1527 SetVersion ($DBversion);
1530 $DBversion = "3.00.00.081";
1531 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1532 $dbh->do("CREATE TABLE `borrower_attribute_types` (
1533 `code` varchar(10) NOT NULL,
1534 `description` varchar(255) NOT NULL,
1535 `repeatable` tinyint(1) NOT NULL default 0,
1536 `unique_id` tinyint(1) NOT NULL default 0,
1537 `opac_display` tinyint(1) NOT NULL default 0,
1538 `password_allowed` tinyint(1) NOT NULL default 0,
1539 `staff_searchable` tinyint(1) NOT NULL default 0,
1540 `authorised_value_category` varchar(10) default NULL,
1541 PRIMARY KEY (`code`)
1542 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1543 $dbh->do("CREATE TABLE `borrower_attributes` (
1544 `borrowernumber` int(11) NOT NULL,
1545 `code` varchar(10) NOT NULL,
1546 `attribute` varchar(30) default NULL,
1547 `password` varchar(30) default NULL,
1548 KEY `borrowernumber` (`borrowernumber`),
1549 KEY `code_attribute` (`code`, `attribute`),
1550 CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
1551 ON DELETE CASCADE ON UPDATE CASCADE,
1552 CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
1553 ON DELETE CASCADE ON UPDATE CASCADE
1554 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1555 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
1556 print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
1557 SetVersion ($DBversion);
1560 $DBversion = "3.00.00.082";
1561 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1562 $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
1563 print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
1564 SetVersion ($DBversion);
1567 $DBversion = "3.00.00.083";
1568 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1569 $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
1570 print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
1571 SetVersion ($DBversion);
1573 $DBversion = "3.00.00.084";
1574 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1575 $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')");
1576 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
1577 print "Upgrade to $DBversion done (add new sysprefs)\n";
1578 SetVersion ($DBversion);
1581 $DBversion = "3.00.00.085";
1582 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1583 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1584 $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
1585 $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
1586 $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
1587 $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
1588 $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
1589 $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
1591 print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
1592 SetVersion ($DBversion);
1595 $DBversion = "3.00.00.086";
1596 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1598 "CREATE TABLE `tmp_holdsqueue` (
1599 `biblionumber` int(11) default NULL,
1600 `itemnumber` int(11) default NULL,
1601 `barcode` varchar(20) default NULL,
1602 `surname` mediumtext NOT NULL,
1605 `borrowernumber` int(11) NOT NULL,
1606 `cardnumber` varchar(16) default NULL,
1607 `reservedate` date default NULL,
1609 `itemcallnumber` varchar(30) default NULL,
1610 `holdingbranch` varchar(10) default NULL,
1611 `pickbranch` varchar(10) default NULL,
1613 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
1615 $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')");
1616 $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')");
1618 print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
1619 SetVersion ($DBversion);
1622 $DBversion = "3.00.00.087";
1623 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1624 $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
1625 $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')");
1626 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1627 SetVersion ($DBversion);
1630 $DBversion = "3.00.00.088";
1631 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1632 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
1633 $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')");
1634 $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')");
1635 $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')");
1636 print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
1637 SetVersion ($DBversion);
1640 $DBversion = "3.00.00.089";
1641 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1642 $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')");
1643 print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
1644 SetVersion ($DBversion);
1647 $DBversion = "3.00.00.090";
1648 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1650 CREATE TABLE `branch_borrower_circ_rules` (
1651 `branchcode` VARCHAR(10) NOT NULL,
1652 `categorycode` VARCHAR(10) NOT NULL,
1653 `maxissueqty` int(4) default NULL,
1654 PRIMARY KEY (`categorycode`, `branchcode`),
1655 CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1656 ON DELETE CASCADE ON UPDATE CASCADE,
1657 CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1658 ON DELETE CASCADE ON UPDATE CASCADE
1659 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1662 CREATE TABLE `default_borrower_circ_rules` (
1663 `categorycode` VARCHAR(10) NOT NULL,
1664 `maxissueqty` int(4) default NULL,
1665 PRIMARY KEY (`categorycode`),
1666 CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
1667 ON DELETE CASCADE ON UPDATE CASCADE
1668 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1671 CREATE TABLE `default_branch_circ_rules` (
1672 `branchcode` VARCHAR(10) NOT NULL,
1673 `maxissueqty` int(4) default NULL,
1674 PRIMARY KEY (`branchcode`),
1675 CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
1676 ON DELETE CASCADE ON UPDATE CASCADE
1677 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1680 CREATE TABLE `default_circ_rules` (
1681 `singleton` enum('singleton') NOT NULL default 'singleton',
1682 `maxissueqty` int(4) default NULL,
1683 PRIMARY KEY (`singleton`)
1684 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1686 print "Upgrade to $DBversion done (added several circ rules tables)\n";
1687 SetVersion ($DBversion);
1691 $DBversion = "3.00.00.091";
1692 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1693 $dbh->do(<<'END_SQL');
1694 ALTER TABLE borrowers
1695 ADD `smsalertnumber` varchar(50) default NULL
1698 $dbh->do(<<'END_SQL');
1699 CREATE TABLE `message_attributes` (
1700 `message_attribute_id` int(11) NOT NULL auto_increment,
1701 `message_name` varchar(20) NOT NULL default '',
1702 `takes_days` tinyint(1) NOT NULL default '0',
1703 PRIMARY KEY (`message_attribute_id`),
1704 UNIQUE KEY `message_name` (`message_name`)
1705 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1708 $dbh->do(<<'END_SQL');
1709 CREATE TABLE `message_transport_types` (
1710 `message_transport_type` varchar(20) NOT NULL,
1711 PRIMARY KEY (`message_transport_type`)
1712 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1715 $dbh->do(<<'END_SQL');
1716 CREATE TABLE `message_transports` (
1717 `message_attribute_id` int(11) NOT NULL,
1718 `message_transport_type` varchar(20) NOT NULL,
1719 `is_digest` tinyint(1) NOT NULL default '0',
1720 `letter_module` varchar(20) NOT NULL default '',
1721 `letter_code` varchar(20) NOT NULL default '',
1722 PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
1723 KEY `message_transport_type` (`message_transport_type`),
1724 KEY `letter_module` (`letter_module`,`letter_code`),
1725 CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
1726 CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
1727 CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
1728 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1731 $dbh->do(<<'END_SQL');
1732 CREATE TABLE `borrower_message_preferences` (
1733 `borrower_message_preference_id` int(11) NOT NULL auto_increment,
1734 `borrowernumber` int(11) NOT NULL default '0',
1735 `message_attribute_id` int(11) default '0',
1736 `days_in_advance` int(11) default '0',
1737 `wants_digets` tinyint(1) NOT NULL default '0',
1738 PRIMARY KEY (`borrower_message_preference_id`),
1739 KEY `borrowernumber` (`borrowernumber`),
1740 KEY `message_attribute_id` (`message_attribute_id`),
1741 CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1742 CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
1743 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1746 $dbh->do(<<'END_SQL');
1747 CREATE TABLE `borrower_message_transport_preferences` (
1748 `borrower_message_preference_id` int(11) NOT NULL default '0',
1749 `message_transport_type` varchar(20) NOT NULL default '0',
1750 PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
1751 KEY `message_transport_type` (`message_transport_type`),
1752 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,
1753 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
1754 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1757 $dbh->do(<<'END_SQL');
1758 CREATE TABLE `message_queue` (
1759 `message_id` int(11) NOT NULL auto_increment,
1760 `borrowernumber` int(11) NOT NULL,
1763 `message_transport_type` varchar(20) NOT NULL,
1764 `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
1765 `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
1766 KEY `message_id` (`message_id`),
1767 KEY `borrowernumber` (`borrowernumber`),
1768 KEY `message_transport_type` (`message_transport_type`),
1769 CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1770 CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
1771 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
1774 $dbh->do(<<'END_SQL');
1775 INSERT INTO `systempreferences`
1776 (variable,value,explanation,options,type)
1778 ('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
1781 $dbh->do( <<'END_SQL');
1782 INSERT INTO `letter`
1783 (module, code, name, title, content)
1785 ('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>>'),
1786 ('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
1787 ('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>>'),
1788 ('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
1789 ('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.');
1793 'installer/data/mysql/en/mandatory/message_transport_types.sql',
1794 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
1795 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
1798 my $installer = C4::Installer->new();
1799 foreach my $script ( @sql_scripts ) {
1800 my $full_path = $installer->get_file_path_from_name($script);
1801 my $error = $installer->load_sql($full_path);
1802 warn $error if $error;
1805 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";
1806 SetVersion ($DBversion);
1809 $DBversion = "3.00.00.092";
1810 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1811 $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')");
1812 $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
1813 print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
1814 SetVersion ($DBversion);
1817 $DBversion = "3.00.00.093";
1818 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1819 $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1820 $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
1821 print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
1822 SetVersion ($DBversion);
1825 $DBversion = "3.00.00.094";
1826 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1827 $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
1828 print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
1829 SetVersion ($DBversion);
1832 $DBversion = "3.00.00.095";
1833 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1834 if (C4::Context->preference("marcflavour") eq 'MARC21') {
1835 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
1836 $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
1838 print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
1839 SetVersion ($DBversion);
1842 $DBversion = "3.00.00.096";
1843 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1844 $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
1846 if (my $row = $sth->fetchrow_hashref) {
1847 $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
1849 print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
1850 SetVersion ($DBversion);
1853 $DBversion = '3.00.00.097';
1854 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1856 $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
1857 $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
1858 $dbh->do('ALTER TABLE message_queue ADD content_type text');
1859 $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
1861 print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
1862 SetVersion($DBversion);
1865 $DBversion = '3.00.00.098';
1866 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1868 $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
1869 $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
1871 print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
1872 SetVersion($DBversion);
1875 $DBversion = '3.00.00.099';
1876 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1877 $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')");
1878 print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
1879 SetVersion($DBversion);
1882 $DBversion = '3.00.00.100';
1883 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1884 $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
1885 print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
1886 SetVersion($DBversion);
1889 $DBversion = '3.00.00.101';
1890 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1891 $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1892 $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
1893 print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
1894 SetVersion($DBversion);
1897 $DBversion = '3.00.00.102';
1898 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1899 $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
1900 $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
1901 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
1902 # before setting constraint, delete any unvalid data
1903 $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
1904 $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
1905 print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
1906 SetVersion($DBversion);
1909 $DBversion = "3.00.00.103";
1910 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1911 $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
1912 print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
1913 SetVersion ($DBversion);
1916 $DBversion = "3.00.00.104";
1917 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1918 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1919 print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
1920 SetVersion ($DBversion);
1923 $DBversion = '3.00.00.105';
1924 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
1926 # it is possible that this syspref is already defined since the feature was added some time ago.
1927 unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
1928 $dbh->do(<<'END_SQL');
1929 INSERT INTO `systempreferences`
1930 (variable,value,explanation,options,type)
1932 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
1935 print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
1936 SetVersion($DBversion);
1939 $DBversion = "3.00.00.106";
1940 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1941 $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
1943 # db revision 105 didn't apply correctly, so we're rolling this into 106
1944 $dbh->do("INSERT INTO `systempreferences`
1945 (variable,value,explanation,options,type)
1947 ('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')");
1949 print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
1950 $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
1952 sanitize_zero_date('subscriptionhistory', 'enddate');
1954 SetVersion ($DBversion);
1957 $DBversion = '3.00.00.107';
1958 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1959 $dbh->do(<<'END_SQL');
1960 UPDATE systempreferences
1961 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming on collections with large numbers of items.' )
1962 WHERE variable = 'OPACShelfBrowser'
1963 AND explanation NOT LIKE '%WARNING%'
1965 $dbh->do(<<'END_SQL');
1966 UPDATE systempreferences
1967 SET explanation = CONCAT( explanation, '. WARNING: this feature is very resource consuming.' )
1968 WHERE variable = 'CataloguingLog'
1969 AND explanation NOT LIKE '%WARNING%'
1971 $dbh->do(<<'END_SQL');
1972 UPDATE systempreferences
1973 SET explanation = CONCAT( explanation, '. WARNING: using NoZebra on even modest sized collections is very slow.' )
1974 WHERE variable = 'NoZebra'
1975 AND explanation NOT LIKE '%WARNING%'
1977 print "Upgrade to $DBversion done (warning added to OPACShelfBrowser system preference)\n";
1978 SetVersion ($DBversion);
1981 $DBversion = '3.01.00.000';
1982 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
1983 print "Upgrade to $DBversion done (start of 3.1)\n";
1984 SetVersion ($DBversion);
1987 $DBversion = '3.01.00.001';
1988 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
1990 CREATE TABLE hold_fill_targets (
1991 `borrowernumber` int(11) NOT NULL,
1992 `biblionumber` int(11) NOT NULL,
1993 `itemnumber` int(11) NOT NULL,
1994 `source_branchcode` varchar(10) default NULL,
1995 `item_level_request` tinyint(4) NOT NULL default 0,
1996 PRIMARY KEY `itemnumber` (`itemnumber`),
1997 KEY `bib_branch` (`biblionumber`, `source_branchcode`),
1998 CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
1999 REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2000 CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
2001 REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2002 CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
2003 REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
2004 CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
2005 REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2006 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2009 ALTER TABLE tmp_holdsqueue
2010 ADD item_level_request tinyint(4) NOT NULL default 0
2013 print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
2014 SetVersion($DBversion);
2017 $DBversion = '3.01.00.002';
2018 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2019 # use statistics where available
2021 ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
2026 SELECT max(datetime)
2028 WHERE type = 'issue'
2029 AND itemnumber = iss.itemnumber
2030 AND borrowernumber = iss.borrowernumber
2032 WHERE issuedate IS NULL;
2034 $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
2036 # default to last renewal date
2039 SET issuedate = lastreneweddate
2040 WHERE issuedate IS NULL
2041 and lastreneweddate IS NOT NULL
2044 my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
2045 if ($num_bad_issuedates > 0) {
2046 print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
2047 "Please check the issues table in your database.";
2049 print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
2050 SetVersion($DBversion);
2053 $DBversion = "3.01.00.003";
2054 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2055 $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')");
2056 print "Upgrade to $DBversion done (add new syspref)\n";
2057 SetVersion ($DBversion);
2060 $DBversion = '3.01.00.004';
2061 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2062 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACDisplayRequestPriority','0','Show patrons the priority level on holds in the OPAC','','YesNo')");
2063 print "Upgrade to $DBversion done (added OPACDisplayRequestPriority system preference)\n";
2064 SetVersion ($DBversion);
2067 $DBversion = '3.01.00.005';
2068 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2070 INSERT INTO `letter` (module, code, name, title, content)
2071 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>>')
2073 $dbh->do("INSERT INTO `message_attributes` (message_attribute_id, message_name, takes_days) values(4, 'Hold Filled', 0)");
2074 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'sms', 0, 'reserves', 'HOLD')");
2075 $dbh->do("INSERT INTO `message_transports` (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) values(4, 'email', 0, 'reserves', 'HOLD')");
2076 print "Upgrade to $DBversion done (Add letter for holds notifications)\n";
2077 SetVersion ($DBversion);
2080 $DBversion = '3.01.00.006';
2081 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2082 $dbh->do("ALTER TABLE `biblioitems` ADD KEY issn (issn)");
2083 print "Upgrade to $DBversion done (add index on biblioitems.issn)\n";
2084 SetVersion ($DBversion);
2087 $DBversion = "3.01.00.007";
2088 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2089 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetmainUserblock'");
2090 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='intranetuserjs'");
2091 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacheader'");
2092 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacMainUserBlock'");
2093 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='OpacNav'");
2094 $dbh->do("UPDATE `systempreferences` SET options='70|10' WHERE variable='opacuserjs'");
2095 $dbh->do("UPDATE `systempreferences` SET options='30|10', type='Textarea' WHERE variable='OAI-PMH:Set'");
2096 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetstylesheet'");
2097 $dbh->do("UPDATE `systempreferences` SET options='50' WHERE variable='intranetcolorstylesheet'");
2098 $dbh->do("UPDATE `systempreferences` SET options='10' WHERE variable='globalDueDate'");
2099 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='numSearchResults'");
2100 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='OPACnumSearchResults'");
2101 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='ReservesMaxPickupDelay'");
2102 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='TransfersMaxDaysWarning'");
2103 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='StaticHoldsQueueWeight'");
2104 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='holdCancelLength'");
2105 $dbh->do("UPDATE `systempreferences` SET type='Integer' WHERE variable='XISBNDailyLimit'");
2106 $dbh->do("UPDATE `systempreferences` SET type='Float' WHERE variable='gist'");
2107 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorUsername'");
2108 $dbh->do("UPDATE `systempreferences` SET type='Free' WHERE variable='BakerTaylorPassword'");
2109 $dbh->do("UPDATE `systempreferences` SET type='Textarea', options='70|10' WHERE variable='ISBD'");
2110 $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'");
2111 print "Upgrade to $DBversion done (fix display of many sysprefs)\n";
2112 SetVersion ($DBversion);
2115 $DBversion = '3.01.00.008';
2116 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2118 $dbh->do("CREATE TABLE branch_transfer_limits (
2119 limitId int(8) NOT NULL auto_increment,
2120 toBranch varchar(4) NOT NULL,
2121 fromBranch varchar(4) NOT NULL,
2122 itemtype varchar(4) NOT NULL,
2123 PRIMARY KEY (limitId)
2124 ) ENGINE=InnoDB DEFAULT CHARSET=utf8"
2127 $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')");
2129 print "Upgrade to $DBversion done (added branch_transfer_limits table and UseBranchTransferLimits system preference)\n";
2130 SetVersion ($DBversion);
2133 $DBversion = "3.01.00.009";
2134 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2135 $dbh->do("ALTER TABLE permissions MODIFY `code` varchar(64) DEFAULT NULL");
2136 $dbh->do("ALTER TABLE user_permissions MODIFY `code` varchar(64) DEFAULT NULL");
2137 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'circulate_remaining_permissions', 'Remaining circulation permissions')");
2138 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'override_renewals', 'Override blocked renewals')");
2139 print "Upgrade to $DBversion done (added subpermissions for circulate permission)\n";
2142 $DBversion = '3.01.00.010';
2143 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2144 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `attribute` VARCHAR(64) DEFAULT NULL");
2145 $dbh->do("ALTER TABLE `borrower_attributes` MODIFY COLUMN `password` VARCHAR(64) DEFAULT NULL");
2146 print "Upgrade to $DBversion done (bug 2687: increase length of borrower attribute fields)\n";
2147 SetVersion ($DBversion);
2150 $DBversion = '3.01.00.011';
2151 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2153 # Yes, the old value was ^M terminated.
2154 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);";
2156 my $intranetuserjs = C4::Context->preference('intranetuserjs');
2157 if ($intranetuserjs and $intranetuserjs eq $bad_value) {
2158 my $sql = <<'END_SQL';
2159 UPDATE systempreferences
2161 WHERE variable = 'intranetuserjs'
2165 print "Upgrade to $DBversion done (removed bogus intranetuserjs syspref)\n";
2166 SetVersion($DBversion);
2169 $DBversion = "3.01.00.012";
2170 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2171 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowHoldPolicyOverride', '0', 'Allow staff to override hold policies when placing holds',NULL,'YesNo')");
2173 CREATE TABLE `branch_item_rules` (
2174 `branchcode` varchar(10) NOT NULL,
2175 `itemtype` varchar(10) NOT NULL,
2176 `holdallowed` tinyint(1) default NULL,
2177 PRIMARY KEY (`itemtype`,`branchcode`),
2178 KEY `branch_item_rules_ibfk_2` (`branchcode`),
2179 CONSTRAINT `branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
2180 CONSTRAINT `branch_item_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
2181 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2184 CREATE TABLE `default_branch_item_rules` (
2185 `itemtype` varchar(10) NOT NULL,
2186 `holdallowed` tinyint(1) default NULL,
2187 PRIMARY KEY (`itemtype`),
2188 CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
2189 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
2192 ALTER TABLE default_branch_circ_rules
2193 ADD COLUMN holdallowed tinyint(1) NULL
2196 ALTER TABLE default_circ_rules
2197 ADD COLUMN holdallowed tinyint(1) NULL
2199 print "Upgrade to $DBversion done (Add tables and system preferences for holds policies)\n";
2200 SetVersion ($DBversion);
2203 $DBversion = '3.01.00.013';
2204 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2206 CREATE TABLE item_circulation_alert_preferences (
2207 id int(11) AUTO_INCREMENT,
2208 branchcode varchar(10) NOT NULL,
2209 categorycode varchar(10) NOT NULL,
2210 item_type varchar(10) NOT NULL,
2211 notification varchar(16) NOT NULL,
2213 KEY (branchcode, categorycode, item_type, notification)
2214 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2217 $dbh->do(q{ ALTER TABLE `message_queue` ADD metadata text DEFAULT NULL AFTER content; });
2218 $dbh->do(q{ ALTER TABLE `message_queue` ADD letter_code varchar(64) DEFAULT NULL AFTER metadata; });
2221 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2222 ('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.');
2225 INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES
2226 ('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>>.');
2229 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (5, 'Item Check-in', 0);});
2230 $dbh->do(q{INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (6, 'Item Checkout', 0);});
2232 $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');});
2233 $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');});
2234 $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');});
2235 $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');});
2237 print "Upgrade to $DBversion done (data for Email Checkout Slips project)\n";
2238 SetVersion ($DBversion);
2241 $DBversion = "3.01.00.014";
2242 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2243 $dbh->do("ALTER TABLE `branch_transfer_limits` CHANGE `itemtype` `itemtype` VARCHAR( 4 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL");
2244 $dbh->do("ALTER TABLE `branch_transfer_limits` ADD `ccode` VARCHAR( 10 ) NULL ;");
2245 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2247 'BranchTransferLimitsType', 'ccode', 'itemtype|ccode', 'When using branch transfer limits, choose whether to limit by itemtype or collection code.', 'Choice'
2250 print "Upgrade to $DBversion done ( Updated table for Branch Transfer Limits)\n";
2251 SetVersion ($DBversion);
2254 $DBversion = '3.01.00.015';
2255 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2256 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsClientCode', '0', 'Client Code for using Syndetics Solutions content','','free')");
2258 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEnabled', '0', 'Turn on Syndetics Enhanced Content','','YesNo')");
2260 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsCoverImages', '0', 'Display Cover Images from Syndetics','','YesNo')");
2262 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsTOC', '0', 'Display Table of Content information from Syndetics','','YesNo')");
2264 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSummary', '0', 'Display Summary Information from Syndetics','','YesNo')");
2266 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsEditions', '0', 'Display Editions from Syndetics','','YesNo')");
2268 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsExcerpt', '0', 'Display Excerpts and first chapters on OPAC from Syndetics','','YesNo')");
2270 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsReviews', '0', 'Display Reviews on OPAC from Syndetics','','YesNo')");
2272 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAuthorNotes', '0', 'Display Notes about the Author on OPAC from Syndetics','','YesNo')");
2274 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsAwards', '0', 'Display Awards on OPAC from Syndetics','','YesNo')");
2276 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SyndeticsSeries', '0', 'Display Series information on OPAC from Syndetics','','YesNo')");
2278 $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')");
2280 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from Amazon Web Services','','YesNo')");
2282 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from Amazon Web Services','','YesNo')");
2284 $dbh->do("UPDATE systempreferences SET variable='AmazonEnabled' WHERE variable = 'AmazonContent'");
2286 $dbh->do("UPDATE systempreferences SET variable='OPACAmazonEnabled' WHERE variable = 'OPACAmazonContent'");
2288 print "Upgrade to $DBversion done (added Syndetics Enhanced Content system preferences)\n";
2289 SetVersion ($DBversion);
2292 $DBversion = "3.01.00.016";
2293 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2294 $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')");
2295 print "Upgrade to $DBversion done (Added Babeltheque syspref)\n";
2296 SetVersion ($DBversion);
2299 $DBversion = "3.01.00.017";
2300 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2301 $dbh->do("ALTER TABLE `subscription` ADD `staffdisplaycount` VARCHAR(10) NULL;");
2302 $dbh->do("ALTER TABLE `subscription` ADD `opacdisplaycount` VARCHAR(10) NULL;");
2303 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2305 'StaffSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the Staff client', 'Integer'
2307 $dbh->do("INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` )
2309 'OPACSerialIssueDisplayCount', '3', '', 'Number of serial issues to display per subscription in the OPAC', 'Integer'
2312 print "Upgrade to $DBversion done ( Updated table for Serials Display)\n";
2313 SetVersion ($DBversion);
2316 $DBversion = "3.01.00.018";
2317 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2318 $dbh->do("ALTER TABLE deletedborrowers ADD `smsalertnumber` varchar(50) default NULL");
2319 print "Upgrade to $DBversion done (added deletedborrowers.smsalertnumber, missed in 3.00.00.091)\n";
2320 SetVersion ($DBversion);
2323 $DBversion = "3.01.00.019";
2324 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2325 $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')");
2326 print "Upgrade to $DBversion done (adding OPACShowCheckoutName systempref)\n";
2327 SetVersion ($DBversion);
2330 $DBversion = "3.01.00.020";
2331 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2332 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesID','','See:http://librarything.com/forlibraries/','','free')");
2333 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesEnabled','0','Enable or Disable Library Thing for Libraries Features','','YesNo')");
2334 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('LibraryThingForLibrariesTabbedView','0','Put LibraryThingForLibraries Content in Tabs.','','YesNo')");
2335 print "Upgrade to $DBversion done (adding LibraryThing for Libraries sysprefs)\n";
2336 SetVersion ($DBversion);
2339 $DBversion = "3.01.00.021";
2340 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2341 my $enable_reviews = C4::Context->preference('OPACAmazonEnabled') ? '1' : '0';
2342 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAmazonReviews', '$enable_reviews', 'Display Amazon readers reviews on OPAC','','YesNo')");
2343 print "Upgrade to $DBversion done (adding OPACAmazonReviews syspref)\n";
2344 SetVersion ($DBversion);
2347 $DBversion = '3.01.00.022';
2348 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2349 $dbh->do("ALTER TABLE `labels_conf` MODIFY COLUMN `formatstring` mediumtext DEFAULT NULL");
2350 print "Upgrade to $DBversion done (bug 2945: increase size of labels_conf.formatstring)\n";
2351 SetVersion ($DBversion);
2354 $DBversion = '3.01.00.023';
2355 if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
2356 $dbh->do("ALTER TABLE biblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2357 $dbh->do("ALTER TABLE deletedbiblioitems MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2358 $dbh->do("ALTER TABLE import_biblios MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2359 $dbh->do("ALTER TABLE suggestions MODIFY COLUMN isbn VARCHAR(30) DEFAULT NULL");
2360 print "Upgrade to $DBversion done (bug 2765: increase width of isbn column in several tables)\n";
2361 SetVersion ($DBversion);
2364 $DBversion = "3.01.00.024";
2365 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2366 $dbh->do("ALTER TABLE labels MODIFY COLUMN batch_id int(10) NOT NULL default 1;");
2367 print "Upgrade to $DBversion done (change labels.batch_id from varchar to int)\n";
2368 SetVersion ($DBversion);
2371 $DBversion = '3.01.00.025';
2372 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2373 $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')");
2375 print "Upgrade to $DBversion done (added ceilingDueDate system preference)\n";
2376 SetVersion ($DBversion);
2379 $DBversion = '3.01.00.026';
2380 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2381 $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')");
2383 print "Upgrade to $DBversion done (added numReturnedItemsToShow system preference)\n";
2384 SetVersion ($DBversion);
2387 $DBversion = '3.01.00.027';
2388 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2389 $dbh->do("ALTER TABLE zebraqueue CHANGE `biblio_auth_number` `biblio_auth_number` bigint(20) unsigned NOT NULL default 0");
2390 print "Upgrade to $DBversion done (Increased size of zebraqueue biblio_auth_number to address bug 3148.)\n";
2391 SetVersion ($DBversion);
2394 $DBversion = '3.01.00.028';
2395 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2396 my $enable_reviews = C4::Context->preference('AmazonEnabled') ? '1' : '0';
2397 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AmazonReviews', '$enable_reviews', 'Display Amazon reviews on staff interface','','YesNo')");
2398 print "Upgrade to $DBversion done (added AmazonReviews)\n";
2399 SetVersion ($DBversion);
2402 $DBversion = '3.01.00.029';
2403 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2404 $dbh->do(q( UPDATE language_rfc4646_to_iso639
2405 SET iso639_2_code = 'spa'
2406 WHERE rfc4646_subtag = 'es'
2407 AND iso639_2_code = 'rus' )
2409 print "Upgrade to $DBversion done (fixed bug 2599: using Spanish search limit retrieves Russian results)\n";
2410 SetVersion ($DBversion);
2413 $DBversion = "3.01.00.030";
2414 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2415 $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')");
2416 print "Upgrade to $DBversion done (added AllowNotForLoanOverride system preference)\n";
2417 SetVersion ($DBversion);
2420 $DBversion = "3.01.00.031";
2421 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2422 $dbh->do("ALTER TABLE branch_transfer_limits
2423 MODIFY toBranch varchar(10) NOT NULL,
2424 MODIFY fromBranch varchar(10) NOT NULL,
2425 MODIFY itemtype varchar(10) NULL");
2426 print "Upgrade to $DBversion done (fix column widths in branch_transfer_limits)\n";
2427 SetVersion ($DBversion);
2430 $DBversion = "3.01.00.032";
2431 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2432 $dbh->do(<<ENDOFRENEWAL);
2433 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');
2435 print "Upgrade to $DBversion done (Change the field)\n";
2436 SetVersion ($DBversion);
2439 $DBversion = "3.01.00.033";
2440 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2442 ALTER TABLE borrower_message_preferences
2443 MODIFY borrowernumber int(11) default NULL,
2444 ADD categorycode varchar(10) default NULL AFTER borrowernumber,
2445 ADD KEY `categorycode` (`categorycode`),
2446 ADD CONSTRAINT `borrower_message_preferences_ibfk_3`
2447 FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
2448 ON DELETE CASCADE ON UPDATE CASCADE
2450 print "Upgrade to $DBversion done (DB changes to allow patron category defaults for messaging preferences)\n";
2451 SetVersion ($DBversion);
2454 $DBversion = "3.01.00.034";
2455 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2456 $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
2457 print "Upgrade to $DBversion done (Adding graceperiod column to subscription table)\n";
2458 SetVersion ($DBversion);
2461 $DBversion = '3.01.00.035';
2462 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2463 $dbh->do(q{ ALTER TABLE `subscription` ADD location varchar(80) NULL DEFAULT '' AFTER callnumber; });
2464 print "Upgrade to $DBversion done (Adding location to subscription table)\n";
2465 SetVersion ($DBversion);
2468 $DBversion = '3.01.00.036';
2469 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2470 $dbh->do("UPDATE systempreferences SET explanation = 'Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd'
2471 WHERE variable = 'IntranetBiblioDefaultView'
2472 AND explanation = 'IntranetBiblioDefaultView'");
2473 $dbh->do("UPDATE systempreferences SET type = 'Choice', options = 'normal|marc|isbd|labeled_marc'
2474 WHERE variable = 'IntranetBiblioDefaultView'");
2475 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewISBD','1','Allow display of ISBD view of bibiographic records','','YesNo')");
2476 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewLabeledMARC','0','Allow display of labeled MARC view of bibiographic records','','YesNo')");
2477 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('viewMARC','1','Allow display of MARC view of bibiographic records','','YesNo')");
2478 print "Upgrade to $DBversion done (new viewISBD, viewLabeledMARC, viewMARC sysprefs and tweak IntranetBiblioDefaultView)\n";
2479 SetVersion ($DBversion);
2482 $DBversion = '3.01.00.037';
2483 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2484 $dbh->do('ALTER TABLE authorised_values ADD KEY `lib` (`lib`)');
2485 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('FilterBeforeOverdueReport','0','Do not run overdue report until filter selected','','YesNo')");
2486 SetVersion ($DBversion);
2487 print "Upgrade to $DBversion done (added FilterBeforeOverdueReport syspref and new index on authorised_values)\n";
2490 $DBversion = "3.01.00.038";
2491 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2492 # update branches table
2494 $dbh->do("ALTER TABLE branches ADD `branchzip` varchar(25) default NULL AFTER `branchaddress3`");
2495 $dbh->do("ALTER TABLE branches ADD `branchcity` mediumtext AFTER `branchzip`");
2496 $dbh->do("ALTER TABLE branches ADD `branchcountry` text AFTER `branchcity`");
2497 $dbh->do("ALTER TABLE branches ADD `branchurl` mediumtext AFTER `branchemail`");
2498 $dbh->do("ALTER TABLE branches ADD `branchnotes` mediumtext AFTER `branchprinter`");
2499 print "Upgrade to $DBversion done (add ZIP, city, country, URL, and notes column to branches)\n";
2500 SetVersion ($DBversion);
2503 $DBversion = '3.01.00.039';
2504 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2505 $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')");
2506 $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')");
2507 SetVersion ($DBversion);
2508 print "Upgrade to $DBversion done (added SpineLabelFormat and SpineLabelAutoPrint sysprefs)\n";
2511 $DBversion = '3.01.00.040';
2512 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2513 $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')");
2514 $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')");
2515 SetVersion ($DBversion);
2516 print "Upgrade to $DBversion done (AllowHoldDateInFuture and OPACAllowHoldDateInFuture sysprefs)\n";
2519 $DBversion = '3.01.00.041';
2520 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2521 $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')");
2522 SetVersion ($DBversion);
2523 print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that if you use enhanced content from Amazon, this should be set right away.)\n";
2526 $DBversion = '3.01.00.042';
2527 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2528 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACFineNoRenewals','99999','Fine Limit above which user canmot renew books via OPAC','','Integer')");
2529 SetVersion ($DBversion);
2530 print "Upgrade to $DBversion done (added OPACFineNoRenewals syspref)\n";
2533 $DBversion = '3.01.00.043';
2534 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2535 $dbh->do('ALTER TABLE items ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2536 $dbh->do('UPDATE items SET permanent_location = location');
2537 $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 )', '')");
2538 $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')");
2539 $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')");
2540 SetVersion ($DBversion);
2541 print "Upgrade to $DBversion done (amended Item added NewItemsDefaultLocation, InProcessingToShelvingCart, ReturnToShelvingCart sysprefs)\n";
2544 $DBversion = '3.01.00.044';
2545 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2546 $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')");
2547 SetVersion ($DBversion);
2548 print "Upgrade to $DBversion done (added DisplayClearScreenButton system preference)\n";
2551 $DBversion = '3.01.00.045';
2552 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2553 $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')");
2554 SetVersion ($DBversion);
2555 print "Upgrade to $DBversion done (added a preference to hide the patrons name in the staff catalog)\n";
2558 $DBversion = "3.01.00.046";
2559 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2560 # update borrowers table
2562 $dbh->do("ALTER TABLE borrowers ADD `country` text AFTER zipcode");
2563 $dbh->do("ALTER TABLE borrowers ADD `B_country` text AFTER B_zipcode");
2564 $dbh->do("ALTER TABLE deletedborrowers ADD `country` text AFTER zipcode");
2565 $dbh->do("ALTER TABLE deletedborrowers ADD `B_country` text AFTER B_zipcode");
2566 print "Upgrade to $DBversion done (add country and B_country to borrowers)\n";
2567 SetVersion ($DBversion);
2570 $DBversion = '3.01.00.047';
2571 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2572 $dbh->do("ALTER TABLE items MODIFY itemcallnumber varchar(255);");
2573 $dbh->do("ALTER TABLE deleteditems MODIFY itemcallnumber varchar(255);");
2574 $dbh->do("ALTER TABLE tmp_holdsqueue MODIFY itemcallnumber varchar(255);");
2575 SetVersion ($DBversion);
2576 print " Upgrade to $DBversion done (bug 2761: change max length of itemcallnumber to 255 from 30)\n";
2579 $DBversion = '3.01.00.048';
2580 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2581 $dbh->do("UPDATE userflags SET flagdesc='View Catalog (Librarian Interface)' WHERE bit=2;");
2582 $dbh->do("UPDATE userflags SET flagdesc='Edit Catalog (Modify bibliographic/holdings data)' WHERE bit=9;");
2583 $dbh->do("UPDATE userflags SET flagdesc='Allow to edit authorities' WHERE bit=14;");
2584 $dbh->do("UPDATE userflags SET flagdesc='Allow to access to the reports module' WHERE bit=16;");
2585 $dbh->do("UPDATE userflags SET flagdesc='Allow to manage serials subscriptions' WHERE bit=15;");
2586 SetVersion ($DBversion);
2587 print " Upgrade to $DBversion done (bug 2611: fix spelling/capitalization in permission flag descriptions)\n";
2590 $DBversion = '3.01.00.049';
2591 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2592 $dbh->do("UPDATE permissions SET description = 'Perform inventory (stocktaking) of your catalog' WHERE code = 'inventory';");
2593 SetVersion ($DBversion);
2594 print "Upgrade to $DBversion done (bug 2611: changed catalogue to catalog per the standard)\n";
2597 $DBversion = '3.01.00.050';
2598 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2599 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACSearchForTitleIn','<li class=\"yuimenuitem\">\n<a target=\"_blank\" class=\"yuimenuitemlabel\" href=\"http://worldcat.org/search?q=TITLE\">Other Libraries (WorldCat)</a></li>\n<li class=\"yuimenuitem\">\n<a class=\"yuimenuitemlabel\" href=\"http://www.scholar.google.com/scholar?q=TITLE\" target=\"_blank\">Other Databases (Google Scholar)</a></li>\n<li class=\"yuimenuitem\">\n<a class=\"yuimenuitemlabel\" href=\"http://www.bookfinder.com/search/?author=AUTHOR&title=TITLE&st=xl&ac=qr\" target=\"_blank\">Online Stores (Bookfinder.com)</a></li>','Enter the HTML that will appear in the ''Search for this title in'' box on the detail page in the OPAC. Enter TITLE, AUTHOR, or ISBN in place of their respective variables in the URL. Leave blank to disable ''More Searches'' menu.','70|10','Textarea');");
2600 SetVersion ($DBversion);
2601 print "Upgrade to $DBversion done (bug 1934: Add OPACSearchForTitleIn syspref)\n";
2604 $DBversion = '3.01.00.051';
2605 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2606 $dbh->do("UPDATE systempreferences SET explanation='Fine limit above which user cannot renew books via OPAC' WHERE variable='OPACFineNoRenewals';");
2607 $dbh->do("UPDATE systempreferences SET explanation='If set to ON, a clear screen button will appear on the circulation page.' WHERE variable='DisplayClearScreenButton';");
2608 SetVersion ($DBversion);
2609 print "Upgrade to $DBversion done (fixed typos in new sysprefs)\n";
2612 $DBversion = '3.01.00.052';
2613 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2614 $dbh->do('ALTER TABLE deleteditems ADD COLUMN permanent_location VARCHAR(80) DEFAULT NULL AFTER location');
2615 SetVersion ($DBversion);
2616 print "Upgrade to $DBversion done (bug 3481: add permanent_location column to deleteditems)\n";
2619 $DBversion = '3.01.00.053';
2620 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2621 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/labels_upgrade.pl";
2622 system("perl $upgrade_script");
2623 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";
2624 SetVersion ($DBversion);
2627 $DBversion = '3.01.00.054';
2628 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2629 $dbh->do("ALTER TABLE borrowers ADD `B_address2` text AFTER B_address");
2630 $dbh->do("ALTER TABLE borrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2631 $dbh->do("ALTER TABLE deletedborrowers ADD `B_address2` text AFTER B_address");
2632 $dbh->do("ALTER TABLE deletedborrowers ADD `altcontactcountry` text AFTER altcontactzipcode");
2633 SetVersion ($DBversion);
2634 print "Upgrade to $DBversion done (bug 1600, bug 3454: add altcontactcountry and B_address2 to borrowers and deletedborrowers)\n";
2637 $DBversion = '3.01.00.055';
2638 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2639 $dbh->do(qq|UPDATE systempreferences set explanation='Enter the HTML that will appear in the ''Search for this title in'' box on the detail page in the OPAC. Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable ''More Searches'' menu.', value='<li><a href="http://worldcat.org/search?q={TITLE}" target="_blank">Other Libraries (WorldCat)</a></li>\n<li><a href="http://www.scholar.google.com/scholar?q={TITLE}" target="_blank">Other Databases (Google Scholar)</a></li>\n<li><a href="http://www.bookfinder.com/search/?author={AUTHOR}&title={TITLE}&st=xl&ac=qr" target="_blank">Online Stores (Bookfinder.com)</a></li>' WHERE variable='OPACSearchForTitleIn'|);
2640 SetVersion ($DBversion);
2641 print "Upgrade to $DBversion done (changed OPACSearchForTitleIn per requests in bug 1934)\n";
2644 $DBversion = '3.01.00.056';
2645 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2646 $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');");
2647 SetVersion ($DBversion);
2648 print "Upgrade to $DBversion done (Bug 1172 : Add OPACPatronDetails syspref)\n";
2651 $DBversion = '3.01.00.057';
2652 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2653 $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');");
2654 SetVersion ($DBversion);
2655 print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
2658 $DBversion = '3.01.00.058';
2659 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2660 $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2661 $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2662 $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
2663 SetVersion ($DBversion);
2664 print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
2667 $DBversion = '3.01.00.059';
2668 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2669 $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')");
2670 SetVersion ($DBversion);
2671 print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
2674 $DBversion = '3.01.00.060';
2675 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2676 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');");
2677 $dbh->do('DROP TABLE IF EXISTS messages');
2678 $dbh->do("CREATE TABLE messages ( `message_id` int(11) NOT NULL auto_increment,
2679 `borrowernumber` int(11) NOT NULL,
2680 `branchcode` varchar(4) default NULL,
2681 `message_type` varchar(1) NOT NULL,
2682 `message` text NOT NULL,
2683 `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2684 PRIMARY KEY (`message_id`)
2685 ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
2687 print "Upgrade to $DBversion done ( Added AllowAllMessageDeletion syspref and messages table )\n";
2688 SetVersion ($DBversion);
2691 $DBversion = '3.01.00.061';
2692 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2693 $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')");
2694 print "Upgrade to $DBversion done ( Added ShowPatronImageInWebBasedSelfCheck system preference )\n";
2695 SetVersion ($DBversion);
2698 $DBversion = "3.01.00.062";
2699 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2700 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'manage_csv_profiles', 'Manage CSV export profiles')");
2702 CREATE TABLE `export_format` (
2703 `export_format_id` int(11) NOT NULL auto_increment,
2704 `profile` varchar(255) NOT NULL,
2705 `description` mediumtext NOT NULL,
2706 `marcfields` mediumtext NOT NULL,
2707 PRIMARY KEY (`export_format_id`)
2708 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Used for CSV export';
2710 print "Upgrade to $DBversion done (added csv export profiles)\n";
2713 $DBversion = "3.01.00.063";
2714 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2716 CREATE TABLE `fieldmapping` (
2717 `id` int(11) NOT NULL auto_increment,
2718 `field` varchar(255) NOT NULL,
2719 `frameworkcode` char(4) NOT NULL default '',
2720 `fieldcode` char(3) NOT NULL,
2721 `subfieldcode` char(1) NOT NULL,
2723 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2725 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";
2728 $DBversion = '3.01.00.065';
2729 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2730 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `renewalsallowed` smallint(6) NOT NULL default "0" AFTER `issuelength`;');
2731 $sth = $dbh->prepare("SELECT itemtype, renewalsallowed FROM itemtypes");
2734 my $sthupd = $dbh->prepare("UPDATE issuingrules SET renewalsallowed = ? WHERE itemtype = ?");
2736 while(my $row = $sth->fetchrow_hashref){
2737 $sthupd->execute($row->{renewalsallowed}, $row->{itemtype});
2740 $dbh->do('ALTER TABLE itemtypes DROP COLUMN `renewalsallowed`;');
2742 SetVersion ($DBversion);
2743 print "Upgrade to $DBversion done (Moving allowed renewals from itemtypes to issuingrule)\n";
2746 $DBversion = '3.01.00.066';
2747 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2748 $dbh->do('ALTER TABLE issuingrules ADD COLUMN `reservesallowed` smallint(6) NOT NULL default "0" AFTER `renewalsallowed`;');
2750 my $maxreserves = C4::Context->preference('maxreserves');
2751 $sth = $dbh->prepare('UPDATE issuingrules SET reservesallowed = ?;');
2752 $sth->execute($maxreserves);
2754 $dbh->do('DELETE FROM systempreferences WHERE variable = "maxreserves";');
2756 $dbh->do("INSERT INTO systempreferences (variable,value, options, explanation, type) VALUES('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice')");
2758 SetVersion ($DBversion);
2759 print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
2762 $DBversion = "3.01.00.067";
2763 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2764 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchmod', 'Perform batch modification of items')");
2765 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchdel', 'Perform batch deletion of items')");
2766 print "Upgrade to $DBversion done (added permissions for batch modification and deletion)\n";
2767 SetVersion ($DBversion);
2770 $DBversion = "3.01.00.068";
2771 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2772 $dbh->do("ALTER TABLE issuingrules ADD COLUMN `finedays` int(11) default NULL AFTER `fine` ");
2773 print "Upgrade to $DBversion done (Adding finedays in issuingrules table)\n";
2774 SetVersion ($DBversion);
2778 $DBversion = "3.01.00.069";
2779 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2780 $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableOpacSearchHistory', '1', '', 'Enable or disable opac search history', 'YesNo')");
2782 my $create = <<SEARCHHIST;
2783 CREATE TABLE IF NOT EXISTS `search_history` (
2784 `userid` int(11) NOT NULL,
2785 `sessionid` varchar(32) NOT NULL,
2786 `query_desc` varchar(255) NOT NULL,
2787 `query_cgi` varchar(255) NOT NULL,
2788 `total` int(11) NOT NULL,
2789 `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
2790 KEY `userid` (`userid`),
2791 KEY `sessionid` (`sessionid`)
2792 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Opac search history results';
2796 print "Upgrade to $DBversion done (added OPAC search history preference and table)\n";
2799 $DBversion = "3.01.00.070";
2800 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2801 $dbh->do("ALTER TABLE authorised_values ADD COLUMN `lib_opac` VARCHAR(80) default NULL AFTER `lib`");
2802 print "Upgrade to $DBversion done (Added a lib_opac field in authorised_values table)\n";
2805 $DBversion = "3.01.00.071";
2806 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2807 $dbh->do("ALTER TABLE `subscription` ADD `enddate` date default NULL");
2808 $dbh->do("ALTER TABLE subscriptionhistory CHANGE enddate histenddate DATE default NULL");
2809 print "Upgrade to $DBversion done ( Adding enddate to subscription)\n";
2812 # Acquisitions update
2814 $DBversion = "3.01.00.072";
2815 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2816 $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')");
2817 # create a new syspref for the 'Mr anonymous' patron
2818 $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,'')");
2819 # fill AnonymousPatron with AnonymousSuggestion value (copy)
2820 my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='AnonSuggestions'");
2822 my ($value) = $sth->fetchrow() || 0;
2823 $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='AnonymousPatron'");
2824 # set AnonymousSuggestion do YesNo
2825 # 1st, set the value (1/True if it had a borrowernumber)
2826 $dbh->do("UPDATE systempreferences SET value=1 WHERE variable='AnonSuggestions' AND value>0");
2827 # 2nd, change the type to Choice
2828 $dbh->do("UPDATE systempreferences SET type='YesNo' WHERE variable='AnonSuggestions'");
2829 # borrower reading record privacy : 0 : forever, 1 : laws, 2 : don't keep at all
2830 $dbh->do("ALTER TABLE `borrowers` ADD `privacy` INTEGER NOT NULL DEFAULT 1;");
2831 print "Upgrade to $DBversion done (add new syspref and column in borrowers)\n";
2832 SetVersion ($DBversion);
2835 $DBversion = '3.01.00.073';
2836 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2837 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2838 $dbh->do(<<'END_SQL');
2839 CREATE TABLE IF NOT EXISTS `aqcontract` (
2840 `contractnumber` int(11) NOT NULL auto_increment,
2841 `contractstartdate` date default NULL,
2842 `contractenddate` date default NULL,
2843 `contractname` varchar(50) default NULL,
2844 `contractdescription` mediumtext,
2845 `booksellerid` int(11) not NULL,
2846 PRIMARY KEY (`contractnumber`),
2847 CONSTRAINT `booksellerid_fk1` FOREIGN KEY (`booksellerid`)
2848 REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
2849 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
2851 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2852 print "Upgrade to $DBversion done (adding aqcontract table)\n";
2853 SetVersion ($DBversion);
2856 $DBversion = '3.01.00.074';
2857 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2858 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `basketname` varchar(50) default NULL AFTER `basketno`");
2859 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `note` mediumtext AFTER `basketname`");
2860 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `booksellernote` mediumtext AFTER `note`");
2861 $dbh->do("ALTER TABLE `aqbasket` ADD COLUMN `contractnumber` int(11) AFTER `booksellernote`");
2862 $dbh->do("ALTER TABLE `aqbasket` ADD FOREIGN KEY (`contractnumber`) REFERENCES `aqcontract` (`contractnumber`)");
2863 print "Upgrade to $DBversion done (edit aqbasket table done)\n";
2864 SetVersion ($DBversion);
2867 $DBversion = '3.01.00.075';
2868 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2869 $dbh->do("ALTER TABLE `aqorders` ADD COLUMN `uncertainprice` tinyint(1)");
2871 print "Upgrade to $DBversion done (adding uncertainprices)\n";
2872 SetVersion ($DBversion);
2875 $DBversion = '3.01.00.076';
2876 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2877 $dbh->do('SET FOREIGN_KEY_CHECKS=0 ');
2878 $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` (
2879 `id` int(11) NOT NULL auto_increment,
2880 `name` varchar(50) default NULL,
2881 `closed` tinyint(1) default NULL,
2882 `booksellerid` int(11) NOT NULL,
2884 KEY `booksellerid` (`booksellerid`),
2885 CONSTRAINT `aqbasketgroups_ibfk_1` FOREIGN KEY (`booksellerid`) REFERENCES `aqbooksellers` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
2886 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
2887 $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)");
2888 $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL");
2889 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')");
2890 $dbh->do('SET FOREIGN_KEY_CHECKS=1 ');
2891 print "Upgrade to $DBversion done (adding basketgroups)\n";
2892 SetVersion ($DBversion);
2894 $DBversion = '3.01.00.077';
2895 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
2897 $dbh->do("SET FOREIGN_KEY_CHECKS=0 ");
2898 # create a mapping table holding the info we need to match orders to budgets
2899 $dbh->do('DROP TABLE IF EXISTS fundmapping');
2901 q|CREATE TABLE fundmapping AS
2902 SELECT aqorderbreakdown.ordernumber, branchcode, bookfundid, budgetdate, entrydate
2903 FROM aqorderbreakdown JOIN aqorders ON aqorderbreakdown.ordernumber = aqorders.ordernumber|);
2904 # match the new type of the corresponding field
2905 $dbh->do('ALTER TABLE fundmapping modify column bookfundid varchar(30)');
2906 # System did not ensure budgetdate was valid historically
2907 sanitize_zero_date('fundmapping', 'budgetdate');
2908 $dbh->do(q|UPDATE fundmapping SET budgetdate = entrydate WHERE budgetdate IS NULL|);
2909 # We save the map in fundmapping in case you need later processing
2910 $dbh->do(q|ALTER TABLE fundmapping add column aqbudgetid integer|);
2911 # these can speed processing up
2912 $dbh->do(q|CREATE INDEX fundmaporder ON fundmapping (ordernumber)|);
2913 $dbh->do(q|CREATE INDEX fundmapid ON fundmapping (bookfundid)|);
2915 $dbh->do("DROP TABLE IF EXISTS `aqbudgetperiods` ");
2918 CREATE TABLE `aqbudgetperiods` (
2919 `budget_period_id` int(11) NOT NULL auto_increment,
2920 `budget_period_startdate` date NOT NULL,
2921 `budget_period_enddate` date NOT NULL,
2922 `budget_period_active` tinyint(1) default '0',
2923 `budget_period_description` mediumtext,
2924 `budget_period_locked` tinyint(1) default NULL,
2925 `sort1_authcat` varchar(10) default NULL,
2926 `sort2_authcat` varchar(10) default NULL,
2927 PRIMARY KEY (`budget_period_id`)
2928 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |);
2930 $dbh->do(<<ADDPERIODS);
2931 INSERT INTO aqbudgetperiods (budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_locked)
2932 SELECT DISTINCT startdate, enddate, NOW() BETWEEN startdate and enddate, concat(startdate," ",enddate),NOT NOW() BETWEEN startdate AND enddate from aqbudget
2934 # SORRY , NO AQBUDGET/AQBOOKFUND -> AQBUDGETS IMPORT JUST YET,
2935 # BUT A NEW CLEAN AQBUDGETS TABLE CREATE FOR NOW..
2936 # DROP TABLE IF EXISTS `aqbudget`;
2937 #CREATE TABLE `aqbudget` (
2938 # `bookfundid` varchar(10) NOT NULL default ',
2939 # `startdate` date NOT NULL default 0,
2940 # `enddate` date default NULL,
2941 # `budgetamount` decimal(13,2) default NULL,
2942 # `aqbudgetid` tinyint(4) NOT NULL auto_increment,
2943 # `branchcode` varchar(10) default NULL,
2944 DropAllForeignKeys('aqbudget');
2945 #$dbh->do("drop table aqbudget;");
2948 my $maxbudgetid = $dbh->selectcol_arrayref(<<IDsBUDGET);
2949 SELECT MAX(aqbudgetid) from aqbudget
2952 $$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
2954 $dbh->do(<<BUDGETAUTOINCREMENT);
2955 ALTER TABLE aqbudget AUTO_INCREMENT=$$maxbudgetid[0]
2958 $dbh->do(<<BUDGETNAME);
2959 ALTER TABLE aqbudget RENAME `aqbudgets`
2962 $dbh->do(<<BUDGETS);
2963 ALTER TABLE `aqbudgets`
2964 CHANGE COLUMN aqbudgetid `budget_id` int(11) NOT NULL AUTO_INCREMENT,
2965 CHANGE COLUMN branchcode `budget_branchcode` varchar(10) default NULL,
2966 CHANGE COLUMN budgetamount `budget_amount` decimal(28,6) NOT NULL default '0.00',
2967 CHANGE COLUMN bookfundid `budget_code` varchar(30) default NULL,
2968 ADD COLUMN `budget_parent_id` int(11) default NULL,
2969 ADD COLUMN `budget_name` varchar(80) default NULL,
2970 ADD COLUMN `budget_encumb` decimal(28,6) default '0.00',
2971 ADD COLUMN `budget_expend` decimal(28,6) default '0.00',
2972 ADD COLUMN `budget_notes` mediumtext,
2973 ADD COLUMN `budget_description` mediumtext,
2974 ADD COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2975 ADD COLUMN `budget_amount_sublevel` decimal(28,6) AFTER `budget_amount`,
2976 ADD COLUMN `budget_period_id` int(11) default NULL,
2977 ADD COLUMN `sort1_authcat` varchar(80) default NULL,
2978 ADD COLUMN `sort2_authcat` varchar(80) default NULL,
2979 ADD COLUMN `budget_owner_id` int(11) default NULL,
2980 ADD COLUMN `budget_permission` int(1) default '0';
2983 $dbh->do(<<BUDGETCONSTRAINTS);
2984 ALTER TABLE `aqbudgets`
2985 ADD CONSTRAINT `aqbudgets_ifbk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON DELETE CASCADE ON UPDATE CASCADE
2987 # $dbh->do(<<BUDGETPKDROP);
2988 #ALTER TABLE `aqbudgets`
2991 # $dbh->do(<<BUDGETPKADD);
2992 #ALTER TABLE `aqbudgets`
2993 # ADD PRIMARY KEY budget_id
2997 my $query_period= $dbh->prepare(qq|SELECT budget_period_id from aqbudgetperiods where budget_period_startdate=? and budget_period_enddate=?|);
2998 my $query_bookfund= $dbh->prepare(qq|SELECT * from aqbookfund where bookfundid=?|);
2999 my $selectbudgets=$dbh->prepare(qq|SELECT * from aqbudgets|);
3000 my $updatebudgets=$dbh->prepare(qq|UPDATE aqbudgets SET budget_period_id= ? , budget_name=?, budget_branchcode=? where budget_id=?|);
3001 $selectbudgets->execute;
3002 while (my $databudget=$selectbudgets->fetchrow_hashref){
3003 $query_period->execute ($$databudget{startdate},$$databudget{enddate});
3004 my ($budgetperiodid)=$query_period->fetchrow;
3005 $query_bookfund->execute ($$databudget{budget_code});
3006 my $databf=$query_bookfund->fetchrow_hashref;
3007 my $branchcode=$$databudget{budget_branchcode}||$$databf{branchcode};
3008 $updatebudgets->execute($budgetperiodid,$$databf{bookfundname},$branchcode,$$databudget{budget_id});
3010 $dbh->do(<<BUDGETDROPDATES);
3011 ALTER TABLE `aqbudgets`
3017 $dbh->do("DROP TABLE IF EXISTS `aqbudgets_planning` ");
3018 $dbh->do("CREATE TABLE `aqbudgets_planning` (
3019 `plan_id` int(11) NOT NULL auto_increment,
3020 `budget_id` int(11) NOT NULL,
3021 `budget_period_id` int(11) NOT NULL,
3022 `estimated_amount` decimal(28,6) default NULL,
3023 `authcat` varchar(30) NOT NULL,
3024 `authvalue` varchar(30) NOT NULL,
3025 `display` tinyint(1) DEFAULT 1,
3026 PRIMARY KEY (`plan_id`),
3027 CONSTRAINT `aqbudgets_planning_ifbk_1` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE
3028 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
3030 $dbh->do("ALTER TABLE `aqorders`
3031 ADD COLUMN `budget_id` tinyint(4) NOT NULL,
3032 ADD COLUMN `budgetgroup_id` int(11) NOT NULL,
3033 ADD COLUMN `sort1_authcat` varchar(10) default NULL,
3034 ADD COLUMN `sort2_authcat` varchar(10) default NULL" );
3035 # We need to map the orders to the budgets
3036 # For Historic reasons this is more complex than it should be on occasions
3037 my $budg_arr = $dbh->selectall_arrayref(
3038 q|SELECT aqbudgets.budget_id, aqbudgets.budget_code, aqbudgetperiods.budget_period_startdate,
3039 aqbudgetperiods.budget_period_enddate
3040 FROM aqbudgets JOIN aqbudgetperiods ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id
3041 ORDER BY budget_code, budget_period_startdate|, { Slice => {} });
3042 # We arbitarily order on start date, this means if you have overlapping periods the order will be
3043 # linked to the latest matching budget YMMV
3044 my $b_sth = $dbh->prepare(
3045 'UPDATE fundmapping set aqbudgetid = ? where bookfundid =? AND budgetdate >= ? AND budgetdate <= ?');
3046 for my $b ( @{$budg_arr}) {
3047 $b_sth->execute($b->{budget_id}, $b->{budget_code}, $b->{budget_period_startdate}, $b->{budget_period_enddate});
3049 # move the budgetids to aqorders
3050 $dbh->do(q|UPDATE aqorders, fundmapping SET aqorders.budget_id = fundmapping.aqbudgetid
3051 WHERE aqorders.ordernumber = fundmapping.ordernumber AND fundmapping.aqbudgetid IS NOT NULL|);
3052 # NB fundmapping is left as an accontants trail also if you have budgetids that werent set
3053 # you can decide what to do with them
3056 q|UPDATE aqorders, aqbudgets SET aqorders.budgetgroup_id = aqbudgets.budget_period_id
3057 WHERE aqorders.budget_id = aqbudgets.budget_id|);
3058 # cannot do until aqorderbreakdown removed
3059 # $dbh->do("DROP TABLE aqbookfund ");
3060 # $dbh->do("ALTER TABLE aqorders ADD FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON UPDATE CASCADE " ); ????
3061 $dbh->do("SET FOREIGN_KEY_CHECKS=1 ");
3063 print "Upgrade to $DBversion done (Adding new aqbudgetperiods, aqbudgets and aqbudget_planning tables )\n";
3064 SetVersion ($DBversion);
3069 $DBversion = '3.01.00.078';
3070 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3071 $dbh->do("ALTER TABLE aqbudgetperiods ADD COLUMN budget_period_total decimal(28,6)");
3072 print "Upgrade to $DBversion done (adds 'budget_period_total' column to aqbudgetperiods table)\n";
3073 SetVersion($DBversion);
3077 $DBversion = '3.01.00.079';
3078 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3079 $dbh->do("ALTER TABLE currency ADD COLUMN active tinyint(1)");
3081 print "Upgrade to $DBversion done (adds 'active' column to currencies table)\n";
3082 SetVersion($DBversion);
3085 $DBversion = '3.01.00.080';
3086 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3087 $dbh->do(<<BUDG_PERM );
3088 INSERT INTO permissions (module_bit, code, description) VALUES
3089 (11, 'vendors_manage', 'Manage vendors'),
3090 (11, 'contracts_manage', 'Manage contracts'),
3091 (11, 'period_manage', 'Manage periods'),
3092 (11, 'budget_manage', 'Manage budgets'),
3093 (11, 'budget_modify', "Modify budget (can't create lines but can modify existing ones)"),
3094 (11, 'planning_manage', 'Manage budget plannings'),
3095 (11, 'order_manage', 'Manage orders & basket'),
3096 (11, 'group_manage', 'Manage orders & basketgroups'),
3097 (11, 'order_receive', 'Manage orders & basket'),
3098 (11, 'budget_add_del', "Add and delete budgets (but can't modify budgets)");
3101 print "Upgrade to $DBversion done (adds permissions for the acquisitions module)\n";
3102 SetVersion($DBversion);
3106 $DBversion = '3.01.00.081';
3107 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
3108 $dbh->do("ALTER TABLE aqbooksellers ADD COLUMN `gstrate` decimal(6,4) default NULL");
3109 if (my $gist=C4::Context->preference("gist")){
3110 my $sql=$dbh->prepare("UPDATE aqbooksellers set `gstrate`=? ");
3111 $sql->execute($gist) ;
3113 print "Upgrade to $DBversion done (added per-supplier gstrate setting)\n";
3114 SetVersion($DBversion);
3117 $DBversion = "3.01.00.082";
3118 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3119 if (C4::Context->preference("opaclanguages") eq "fr") {
3120 $dbh->do(qq#INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AcqCreateItem','ordering',"Définit quand l'exemplaire est créé : à la commande, à la livraison, au catalogage",'ordering|receiving|cataloguing','Choice')#);
3122 $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')");
3124 print "Upgrade to $DBversion done (adding ReservesNeedReturns systempref, in circulation)\n";
3125 SetVersion ($DBversion);
3128 $DBversion = "3.01.00.083";
3129 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3131 CREATE TABLE `aqorders_items` (
3132 `ordernumber` int(11) NOT NULL,
3133 `itemnumber` int(11) NOT NULL,
3134 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
3135 PRIMARY KEY (`itemnumber`),
3136 KEY `ordernumber` (`ordernumber`)
3137 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
3140 $dbh->do(qq| DROP TABLE aqorderbreakdown |);
3141 $dbh->do('DROP TABLE aqbookfund');
3142 print "Upgrade to $DBversion done (New aqorders_items table for acqui)\n";
3143 SetVersion ($DBversion);
3146 $DBversion = "3.01.00.084";
3147 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3148 $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') #);
3150 print "Upgrade to $DBversion done (CurrencyFormat syspref added)\n";
3151 SetVersion ($DBversion);
3154 $DBversion = "3.01.00.085";
3155 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3156 $dbh->do("ALTER table aqorders drop column title");
3157 $dbh->do("ALTER TABLE `aqorders` CHANGE `budget_id` `budget_id` INT( 11 ) NOT NULL");
3158 print "Upgrade to $DBversion done update budget_id size that should not be a tinyint\n";
3159 SetVersion ($DBversion);
3162 $DBversion = "3.01.00.086";
3163 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3164 $dbh->do(<<SUGGESTIONS);
3165 ALTER table suggestions
3166 ADD budgetid INT(11),
3167 ADD branchcode VARCHAR(10) default NULL,
3168 ADD acceptedby INT(11) default NULL,
3169 ADD accepteddate date default NULL,
3170 ADD suggesteddate date default NULL,
3171 ADD manageddate date default NULL,
3172 ADD rejectedby INT(11) default NULL,
3173 ADD rejecteddate date default NULL,
3174 ADD collectiontitle text default NULL,
3175 ADD itemtype VARCHAR(30) default NULL
3178 print "Upgrade to $DBversion done (Suggestions)\n";
3179 SetVersion ($DBversion);
3182 $DBversion = "3.01.00.087";
3183 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3184 $dbh->do("ALTER table aqbudgets drop column budget_amount_sublevel;");
3185 print "Upgrade to $DBversion done (Drop column budget_amount_sublevel from aqbudgets)\n";
3186 SetVersion ($DBversion);
3189 $DBversion = "3.01.00.088";
3190 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3191 $dbh->do( qq# INSERT INTO `systempreferences` VALUES ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo') #);
3193 print "Upgrade to $DBversion done (intranetbookbag syspref added)\n";
3194 SetVersion ($DBversion);
3197 $DBversion = "3.01.00.090";
3198 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3200 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3201 (16, 'execute_reports', 'Execute SQL reports'),
3202 (16, 'create_reports', 'Create SQL Reports')
3205 print "Upgrade to $DBversion done (granular permissions for guided reports added)\n";
3206 SetVersion ($DBversion);
3209 $DBversion = "3.01.00.091";
3210 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3212 UPDATE `systempreferences` SET `options` = 'holdings|serialcollection|subscriptions'
3213 WHERE `systempreferences`.`variable` = 'opacSerialDefaultTab' LIMIT 1
3216 print "Upgrade to $DBversion done (opac-detail default tag updated)\n";
3217 SetVersion ($DBversion);
3220 $DBversion = "3.01.00.092";
3221 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3222 if (C4::Context->preference("opaclanguages") =~ /fr/) {
3224 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');
3228 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');
3231 print "Upgrade to $DBversion done (Added RoutingListAddReserves syspref)\n";
3232 SetVersion ($DBversion);
3235 $DBversion = "3.01.00.093";
3236 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3238 ALTER TABLE biblioitems ADD INDEX issn_idx (issn);
3240 print "Upgrade to $DBversion done (added index to ISSN)\n";
3241 SetVersion ($DBversion);
3244 $DBversion = "3.01.00.094";
3245 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3247 ALTER TABLE aqbasketgroups ADD deliveryplace VARCHAR(10) default NULL, ADD deliverycomment VARCHAR(255) default NULL;
3250 print "Upgrade to $DBversion done (adding deliveryplace deliverycomment to basketgroups)\n";
3251 SetVersion ($DBversion);
3254 $DBversion = "3.01.00.095";
3255 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3257 ALTER TABLE items ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number";
3260 ALTER TABLE items ADD UNIQUE INDEX itemsstocknumberidx (stocknumber);
3263 ALTER TABLE deleteditems ADD stocknumber VARCHAR(32) DEFAULT NULL COMMENT "stores the inventory number of deleted items";
3266 ALTER TABLE deleteditems ADD UNIQUE INDEX deleteditemsstocknumberidx (stocknumber);
3268 if (C4::Context->preference('marcflavour') eq 'UNIMARC'){
3270 INSERT IGNORE INTO marc_subfield_structure (frameworkcode,tagfield, tagsubfield, tab, repeatable, mandatory,kohafield)
3271 SELECT DISTINCT (frameworkcode),995,"j",10,0,0,"items.stocknumber" from biblio_framework ;
3273 #Previously, copynumber was used as stocknumber
3275 UPDATE items set stocknumber=copynumber;
3278 UPDATE items set copynumber=NULL;
3281 print "Upgrade to $DBversion done (stocknumber field added)\n";
3282 SetVersion ($DBversion);
3285 $DBversion = "3.01.00.096";
3286 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3287 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OrderPdfTemplate','','Uploads a PDF template to use for printing baskets','NULL','Upload')");
3288 $dbh->do("UPDATE systempreferences SET variable='OrderPdfFormat' WHERE variable='pdfformat'");
3289 print "Upgrade to $DBversion done (PDF orders system preferences added and updated)\n";
3290 SetVersion ($DBversion);
3293 $DBversion = "3.01.00.097";
3294 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3296 ALTER TABLE aqbasketgroups ADD billingplace VARCHAR(10) NOT NULL AFTER deliverycomment;
3299 print "Upgrade to $DBversion done (Adding billingplace to aqbasketgroups)\n";
3300 SetVersion ($DBversion);
3303 $DBversion = "3.01.00.098";
3304 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3306 ALTER TABLE auth_subfield_structure MODIFY frameworkcode VARCHAR(10) NULL;
3309 print "Upgrade to $DBversion done (changing frameworkcode length in auth_subfield_structure)\n";
3310 SetVersion ($DBversion);
3313 $DBversion = "3.01.00.099";
3314 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3316 INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3317 (9, 'edit_catalogue', 'Edit catalogue'),
3318 (9, 'fast_cataloging', 'Fast cataloging')
3321 print "Upgrade to $DBversion done (granular permissions for cataloging added)\n";
3322 SetVersion ($DBversion);
3325 $DBversion = "3.01.00.100";
3326 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3327 $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')");
3328 print "Upgrade to $DBversion done (added CAS authentication system preferences)\n";
3329 SetVersion ($DBversion);
3332 $DBversion = "3.01.00.101";
3333 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3335 "INSERT INTO systempreferences
3336 (variable, value, options, explanation, type)
3338 'OverdueNoticeBcc', '', '',
3339 'Email address to Bcc outgoing notices sent by email',
3342 print "Upgrade to $DBversion done (added OverdueNoticeBcc system preferences)\n";
3343 SetVersion ($DBversion);
3345 $DBversion = "3.01.00.102";
3346 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3348 "UPDATE permissions set description = 'Edit catalog (Modify bibliographic/holdings data)' where module_bit = 9 and code = 'edit_catalogue'"
3350 print "Upgrade to $DBversion done (fixed spelling error in edit_catalogue permission)\n";
3351 SetVersion ($DBversion);
3354 $DBversion = "3.01.00.103";
3355 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3356 $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES (13, 'moderate_tags', 'Moderate patron tags')");
3357 print "Upgrade to $DBversion done (adding patron permissions for tags tool)\n";
3358 SetVersion ($DBversion);
3361 $DBversion = "3.01.00.104";
3362 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3364 my ($maninv_count, $borrnotes_count);
3365 eval { $maninv_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='MANUAL_INV'"); };
3366 if ($maninv_count == 0) {
3367 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('MANUAL_INV','Copier Fees','.25')");
3369 eval { $borrnotes_count = $dbh->do("SELECT 1 FROM authorised_values WHERE category='BOR_NOTES'"); };
3370 if ($borrnotes_count == 0) {
3371 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('BOR_NOTES','ADDR','Address Notes')");
3374 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','CART','Book Cart')");
3375 $dbh->do("INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOC','PROC','Processing Center')");
3377 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";
3378 SetVersion ($DBversion);
3382 $DBversion = "3.01.00.105";
3383 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3385 CREATE TABLE `collections` (
3386 `colId` int(11) NOT NULL auto_increment,
3387 `colTitle` varchar(100) NOT NULL default '',
3388 `colDesc` text NOT NULL,
3389 `colBranchcode` varchar(4) default NULL COMMENT 'branchcode for branch where item should be held.',
3390 PRIMARY KEY (`colId`)
3391 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3395 CREATE TABLE `collections_tracking` (
3396 `ctId` int(11) NOT NULL auto_increment,
3397 `colId` int(11) NOT NULL default '0' COMMENT 'collections.colId',
3398 `itemnumber` int(11) NOT NULL default '0' COMMENT 'items.itemnumber',
3399 PRIMARY KEY (`ctId`)
3400 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3403 INSERT INTO permissions (module_bit, code, description)
3404 VALUES ( 13, 'rotating_collections', 'Manage Rotating collections')" );
3405 print "Upgrade to $DBversion done (added collection and collection_tracking tables for rotating collections functionality)\n";
3406 SetVersion ($DBversion);
3408 $DBversion = "3.01.00.106";
3409 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3410 $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' )");
3411 print "Upgrade to $DBversion done (added OpacAddMastheadLibraryPulldown system preferences)\n";
3412 SetVersion ($DBversion);
3415 $DBversion = '3.01.00.107';
3416 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3417 my $upgrade_script = C4::Context->config("intranetdir") . "/installer/data/mysql/patroncards_upgrade.pl";
3418 system("perl $upgrade_script");
3419 print "Upgrade to $DBversion done (Migrated labels and patroncards tables and data to new schema.)\n";
3420 SetVersion ($DBversion);
3423 $DBversion = '3.01.00.108';
3424 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3426 ALTER TABLE `export_format` ADD `csv_separator` VARCHAR( 2 ) NOT NULL AFTER `marcfields` ,
3427 ADD `field_separator` VARCHAR( 2 ) NOT NULL AFTER `csv_separator` ,
3428 ADD `subfield_separator` VARCHAR( 2 ) NOT NULL AFTER `field_separator`
3430 print "Upgrade to $DBversion done (added separators for csv export)\n";
3431 SetVersion ($DBversion);
3434 $DBversion = "3.01.00.109";
3435 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3437 ALTER TABLE `export_format` ADD `encoding` VARCHAR(255) NOT NULL AFTER `subfield_separator`
3439 print "Upgrade to $DBversion done (added encoding for csv export)\n";
3440 SetVersion ($DBversion);
3443 $DBversion = '3.01.00.110';
3444 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3445 $dbh->do('ALTER TABLE `categories` ADD COLUMN `enrolmentperioddate` DATE NULL DEFAULT NULL AFTER `enrolmentperiod`');
3446 print "Upgrade to $DBversion done (Add enrolment period date support)\n";
3447 SetVersion ($DBversion);
3450 $DBversion = '3.01.00.111';
3451 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3452 print "Upgrade to $DBversion done (mark DBrev for 3.2-alpha release)\n";
3453 SetVersion ($DBversion);
3456 $DBversion = '3.01.00.112';
3457 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3458 $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');");
3459 print "Upgrade to $DBversion done ( added Show Spine Label Printer on Bib Items Details preferences )\n";
3460 SetVersion ($DBversion);
3463 $DBversion = '3.01.00.113';
3464 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3465 my $value = C4::Context->preference("XSLTResultsDisplay");
3467 "INSERT INTO systempreferences (variable,value,type)
3468 VALUES('OPACXSLTResultsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3469 $value = C4::Context->preference("XSLTDetailsDisplay");
3471 "INSERT INTO systempreferences (variable,value,type)
3472 VALUES('OPACXSLTDetailsDisplay',?,'YesNo')", {}, $value ? 1 : 0);
3473 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";
3474 SetVersion ($DBversion);
3477 $DBversion = '3.01.00.114';
3478 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3479 $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')");
3480 $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')");
3481 $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')");
3482 print "Upgrade to $DBversion done ( Added AutoSelfCheckAllowed, AutoSelfCheckID, and AutoShelfCheckPass system preference )\n";
3483 SetVersion ($DBversion);
3486 $DBversion = '3.01.00.115';
3487 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3488 $dbh->do('UPDATE aqorders SET quantityreceived = 0 WHERE quantityreceived IS NULL');
3489 $dbh->do('ALTER TABLE aqorders MODIFY COLUMN quantityreceived smallint(6) NOT NULL DEFAULT 0');
3490 print "Upgrade to $DBversion done ( Default aqorders.quantityreceived to 0 )\n";
3491 SetVersion ($DBversion);
3494 $DBversion = '3.01.00.116';
3495 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3496 if (C4::Context->preference('OrderPdfFormat') eq 'pdfformat::example'){
3497 $dbh->do("UPDATE `systempreferences` set value='pdfformat::layout2pages' WHERE variable='OrderPdfFormat'");
3499 print "Upgrade to $DBversion done (corrected default OrderPdfFormat value if still set wrong )\n";
3500 SetVersion ($DBversion);
3503 $DBversion = '3.01.00.117';
3504 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3505 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'por' WHERE rfc4646_subtag='pt' ");
3506 print "Upgrade to $DBversion done (corrected ISO 639-2 language code for Portuguese)\n";
3507 SetVersion ($DBversion);
3510 $DBversion = '3.01.00.118';
3511 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3512 my ($count) = $dbh->selectrow_array("SELECT count(*) FROM information_schema.columns
3513 WHERE table_name = 'aqbudgets_planning'
3514 AND column_name = 'display'");
3516 $dbh->do("ALTER TABLE aqbudgets_planning ADD COLUMN display tinyint(1) DEFAULT 1");
3518 print "Upgrade to $DBversion done (bug 4203: add display column to aqbudgets_planning if missing)\n";
3519 SetVersion ($DBversion);
3522 $DBversion = '3.01.00.119';
3523 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3524 eval{require Locale::Currency::Format};
3526 print "Upgrade to $DBversion done (Locale::Currency::Format installed.)\n";
3527 SetVersion ($DBversion);
3530 print "Upgrade to $DBversion done.\n";
3531 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";
3532 SetVersion ($DBversion);
3536 $DBversion = '3.01.00.120';
3537 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3539 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');
3541 print "Upgrade to $DBversion done (bug 1080: add soundon system preference for circulation sounds)\n";
3542 SetVersion ($DBversion);
3545 $DBversion = '3.01.00.121';
3546 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3547 $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE DEFAULT NULL");
3548 $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3549 $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE DEFAULT NULL");
3550 $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` tinyint(1) NOT NULL");
3551 print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
3552 SetVersion ($DBversion);
3555 $DBversion = '3.01.00.122';
3556 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3558 INSERT INTO systempreferences (variable,value,explanation,options,type)
3559 VALUES ('OAI-PMH:ConfFile', '', 'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','','File');
3561 print "Upgrade to $DBversion done. — Add a new system preference OAI-PMF:ConfFile\n";
3562 SetVersion ($DBversion);
3565 $DBversion = "3.01.00.123";
3566 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3567 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3568 (6, 'place_holds', 'Place holds for patrons')");
3569 $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
3570 (6, 'modify_holds_priority', 'Modify holds priority')");
3571 $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
3572 print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
3573 SetVersion ($DBversion);
3576 $DBversion = '3.01.00.124';
3577 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3579 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>>).');
3581 print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
3582 SetVersion ($DBversion);
3585 $DBversion = '3.01.00.125';
3586 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3588 INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'PrintNoticesMaxLines', '0', '', 'If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.', 'Integer' );
3591 INSERT INTO message_transport_types (message_transport_type) values ('print');
3593 print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
3594 SetVersion ($DBversion);
3597 $DBversion = "3.01.00.126";
3598 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3599 $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')");
3600 $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')");
3602 print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:AuthorizedIPs)\n";
3603 SetVersion ($DBversion);
3606 $DBversion = '3.01.00.127';
3607 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3608 $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
3609 print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
3610 SetVersion ($DBversion);
3613 $DBversion = '3.01.00.128';
3614 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3615 $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
3616 print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
3617 SetVersion ($DBversion);
3620 $DBversion = "3.01.00.129";
3621 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3622 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
3623 $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
3624 print "Upgrade to $DBversion done (Change permissions names for item batch modification / deletion)\n";
3626 SetVersion ($DBversion);
3629 $DBversion = "3.01.00.130";
3630 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3631 sanitize_zero_date('reserves', 'expirationdate');
3632 print "Upgrade to $DBversion done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)\n";
3633 SetVersion ($DBversion);
3636 $DBversion = "3.01.00.131";
3637 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3639 INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
3641 print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
3642 SetVersion ($DBversion);
3645 $DBversion = "3.01.00.132";
3646 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3648 ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
3650 print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
3651 SetVersion ($DBversion);
3654 $DBversion = '3.01.00.133';
3655 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3656 $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')");
3657 print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
3658 SetVersion ($DBversion);
3661 $DBversion = '3.01.00.134';
3662 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3663 $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
3664 print "Upgrade to $DBversion done (adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page)\n";
3665 SetVersion ($DBversion);
3668 $DBversion = '3.01.00.135';
3669 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3671 INSERT INTO `letter` (module, code, name, title, content) VALUES
3672 ('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')
3674 print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)\n";
3675 SetVersion ($DBversion);
3678 $DBversion = '3.01.00.136';
3679 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3681 INSERT INTO permissions (module_bit, code, description) VALUES
3682 ( 9, 'edit_items', 'Edit Items');});
3683 print "Upgrade to $DBversion done (Adding a new permission to edit items)\n";
3684 SetVersion ($DBversion);
3687 $DBversion = "3.01.00.137";
3688 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3690 INSERT INTO permissions (module_bit, code, description) VALUES
3691 (15, 'check_expiration', 'Check the expiration of a serial'),
3692 (15, 'claim_serials', 'Claim missing serials'),
3693 (15, 'create_subscription', 'Create a new subscription'),
3694 (15, 'delete_subscription', 'Delete an existing subscription'),
3695 (15, 'edit_subscription', 'Edit an existing subscription'),
3696 (15, 'receive_serials', 'Serials receiving'),
3697 (15, 'renew_subscription', 'Renew a subscription'),
3698 (15, 'routing', 'Routing');
3700 print "Upgrade to $DBversion done (adding granular permissions for serials)\n";
3701 SetVersion ($DBversion);
3704 $DBversion = "3.01.00.138";
3705 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3706 $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
3707 print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)\n";
3708 SetVersion ($DBversion);
3711 $DBversion = '3.01.00.139';
3712 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3713 $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
3714 print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
3715 SetVersion ($DBversion);
3718 $DBversion = '3.01.00.140';
3719 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3720 $dbh->do("UPDATE systempreferences SET value = '0' WHERE variable = 'TagsModeration' AND value is NULL");
3721 print "Upgrade to $DBversion done (bug 4312 TagsModeration changed from NULL to 0)\n";
3722 SetVersion ($DBversion);
3725 $DBversion = '3.01.00.141';
3726 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3727 $dbh->do(qq{DELETE FROM message_attributes WHERE message_attribute_id=3;});
3728 $dbh->do(qq{DELETE FROM letter WHERE code='EVENT' AND title='Upcoming Library Event';});
3729 print "Upgrade to $DBversion done Remove upcoming events messaging option (bug 2434)\n";
3730 SetVersion ($DBversion);
3733 $DBversion = '3.01.00.142';
3734 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3735 $dbh->do(qq{DELETE FROM message_transports WHERE message_attribute_id=3;});
3736 print "Upgrade to $DBversion done (Remove upcoming events messaging option part 2 (bug 2434))\n";
3737 SetVersion ($DBversion);
3740 $DBversion = '3.01.00.143';
3741 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3742 $dbh->do(qq{CREATE INDEX auth_value_idx ON authorised_values (authorised_value)});
3743 $dbh->do(qq{CREATE INDEX auth_val_cat_idx ON borrower_attribute_types (authorised_value_category)});
3744 print "Upgrade to $DBversion done (Create index on authorised_values and borrower_attribute_types (bug 4139))\n";
3745 SetVersion ($DBversion);
3748 $DBversion = '3.01.00.144';
3749 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3750 $dbh->do(qq{UPDATE systempreferences SET value='normal' where value='default' and variable='IntranetBiblioDefaultView'});
3751 print "Upgrade to $DBversion done (Update the 'default' to 'normal' for the IntranetBiblioDefaultView syspref (bug 5007))\n";
3752 SetVersion ($DBversion);
3755 $DBversion = "3.01.00.145";
3756 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3757 $dbh->do("ALTER TABLE borrowers ADD KEY `guarantorid` (guarantorid);");
3758 print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3759 SetVersion ($DBversion);
3762 $DBversion = '3.01.00.999';
3763 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3764 print "Upgrade to $DBversion done (3.2.0 release candidate)\n";
3765 SetVersion ($DBversion);
3768 $DBversion = "3.02.00.000";
3769 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3770 my $value = $dbh->selectrow_array("SELECT value FROM systempreferences WHERE variable = 'HomeOrHoldingBranch'");
3771 $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');");
3772 print "Upgrade to $DBversion done (Add HomeOrHoldingBranchReturn system preference)\n";
3773 SetVersion ($DBversion);
3776 $DBversion = "3.02.00.001";
3777 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3778 $dbh->do(q{DELETE FROM systempreferences WHERE variable IN (
3783 'OPACSubscriptionDisplay',
3784 'OPACDisplayExtendedSubInfo',
3795 print "Upgrade to $DBversion done (bug 3756: remove disused system preferences)\n";
3796 SetVersion ($DBversion);
3799 $DBversion = "3.02.00.002";
3800 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3801 $dbh->do(q{DELETE FROM systempreferences WHERE variable = 'OpacPrivacy'});
3802 print "Upgrade to $DBversion done (bug 3881: remove unused OpacPrivacy system preference)\n";
3803 SetVersion ($DBversion);
3806 $DBversion = "3.02.00.003";
3807 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3808 $dbh->do(q{UPDATE systempreferences SET variable = 'ILS-DI:AuthorizedIPs' WHERE variable = 'ILS-DI:Authorized_IPs'});
3809 print "Upgrade to $DBversion done (correct ILS-DI:AuthorizedIPs)\n";
3810 SetVersion ($DBversion);
3813 $DBversion = "3.02.00.004";
3814 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3815 print "Upgrade to $DBversion done (3.2.0 general release)\n";
3816 SetVersion ($DBversion);
3818 # This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3820 # apply updates that have already been done
3822 $DBversion = "3.03.00.001";
3823 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.005")) {
3824 $dbh->do("DELETE FROM subscriptionroutinglist WHERE borrowernumber IS NULL;");
3825 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `borrowernumber` int(11) NOT NULL;");
3826 $dbh->do("DELETE FROM subscriptionroutinglist WHERE subscriptionid IS NULL;");
3827 $dbh->do("ALTER TABLE subscriptionroutinglist MODIFY COLUMN `subscriptionid` int(11) NOT NULL;");
3828 $dbh->do("CREATE TEMPORARY TABLE del_subscriptionroutinglist
3829 SELECT s1.routingid FROM subscriptionroutinglist s1
3830 WHERE EXISTS (SELECT * FROM subscriptionroutinglist s2
3831 WHERE s2.borrowernumber = s1.borrowernumber
3832 AND s2.subscriptionid = s1.subscriptionid
3833 AND s2.routingid < s1.routingid);");
3834 $dbh->do("DELETE FROM subscriptionroutinglist
3835 WHERE routingid IN (SELECT routingid FROM del_subscriptionroutinglist);");
3836 $dbh->do("ALTER TABLE subscriptionroutinglist ADD UNIQUE (subscriptionid, borrowernumber);");
3837 $dbh->do("ALTER TABLE subscriptionroutinglist
3838 ADD CONSTRAINT `subscriptionroutinglist_ibfk_1` FOREIGN KEY (`borrowernumber`)
3839 REFERENCES `borrowers` (`borrowernumber`)
3840 ON DELETE CASCADE ON UPDATE CASCADE");
3841 $dbh->do("ALTER TABLE subscriptionroutinglist
3842 ADD CONSTRAINT `subscriptionroutinglist_ibfk_2` FOREIGN KEY (`subscriptionid`)
3843 REFERENCES `subscription` (`subscriptionid`)
3844 ON DELETE CASCADE ON UPDATE CASCADE");
3845 print "Upgrade to $DBversion done (Make subscriptionroutinglist more strict)\n";
3846 SetVersion ($DBversion);
3849 $DBversion = '3.03.00.002';
3850 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.006")) {
3851 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='arm' WHERE rfc4646_subtag='hy';");
3852 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='eng' WHERE rfc4646_subtag='en';");
3853 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'fi','fin');");
3854 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='fre' WHERE rfc4646_subtag='fr';");
3855 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'lo','lao');");
3856 $dbh->do("UPDATE language_rfc4646_to_iso639 SET iso639_2_code='ita' WHERE rfc4646_subtag='it';");
3857 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'sr','srp');");
3858 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'tet','tet');");
3859 $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ur','urd');");
3861 print "Upgrade to $DBversion done (Correct language mappings)\n";
3862 SetVersion ($DBversion);
3865 $DBversion = '3.03.00.003';
3866 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.00.007")) {
3867 $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');");
3868 print "Upgrade to $DBversion done (Add UseTablesortForCirc syspref)\n";
3869 SetVersion ($DBversion);
3872 $DBversion = '3.03.00.004';
3873 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.001")) {
3874 my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ACCEPTED');
3876 INSERT INTO `letter`
3877 (module, code, name, title, content)
3879 ('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>>')
3880 /) unless $count > 0;
3881 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'AVAILABLE');
3883 INSERT INTO `letter`
3884 (module, code, name, title, content)
3886 ('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>>')
3887 /) unless $count > 0;
3888 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'ORDERED');
3890 INSERT INTO `letter`
3891 (module, code, name, title, content)
3893 ('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>>')
3894 /) unless $count > 0;
3895 $count = $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE module = ? AND code = ?', {}, 'suggestions', 'REJECTED');
3897 INSERT INTO `letter`
3898 (module, code, name, title, content)
3900 ('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>>')
3901 /) unless $count > 0;
3902 print "Upgrade to $DBversion done (bug 5127: add default templates for suggestion status change notifications)\n";
3903 SetVersion ($DBversion);
3906 $DBversion = '3.03.00.005';
3907 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3908 $dbh->do("update `systempreferences` set options='whitespace|T-prefix|cuecat|libsuite8' where variable='itemBarcodeInputFilter'");
3909 print "Upgrade to $DBversion done (Add itemBarcodeInputFilter choice libsuite8)\n";
3912 $DBversion = '3.03.00.006';
3913 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.002")) {
3914 $dbh->do("ALTER TABLE deletedborrowers ADD `privacy` int(11) AFTER smsalertnumber;");
3915 $dbh->do("ALTER TABLE deletedborrowers CHANGE `cardnumber` `cardnumber` varchar(16);");
3916 print "Upgrade to $DBversion done (Fix differences between borrowers and deletedborrowers)\n";
3917 SetVersion ($DBversion);
3920 $DBversion = '3.03.00.007';
3921 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3922 $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL,
3923 ADD currency VARCHAR(3) default NULL,
3924 ADD price DECIMAL(28,6) default NULL,
3925 ADD total DECIMAL(28,6) default NULL;
3927 print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n";
3928 SetVersion ($DBversion);
3931 $DBversion = '3.03.00.008';
3932 if (C4::Context->preference('Version') < TransformToNum($DBversion)){
3933 $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')");
3934 print "Upgrade to $DBversion done (adding syspref OPACNoResultsFound to control what displays when no results are found for a search in the OPAC.)\n";
3935 SetVersion ($DBversion);
3938 $DBversion = '3.03.00.009';
3939 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.01.003")) {
3940 $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetUserCSS','','Add CSS to be included in the Intranet',NULL,'free')");
3941 print "Upgrade to $DBversion done (Add IntranetUserCSS syspref)\n";
3942 SetVersion ($DBversion);
3945 $DBversion = "3.03.00.010";
3946 if (C4::Context->preference("Version") < TransformToNum($DBversion) && $original_version < TransformToNum("3.02.02.001")) {
3947 $dbh->do("UPDATE `marc_subfield_structure` SET liblibrarian = 'Distance from earth' WHERE liblibrarian = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3948 $dbh->do("UPDATE `marc_subfield_structure` SET libopac = 'Distance from earth' WHERE libopac = 'Distrance from earth' AND tagfield = '034' AND tagsubfield = 'r';");
3949 print "Upgrade to $DBversion done (Fix misspelled 034r subfield in MARC21 Frameworks)\n";
3950 SetVersion ($DBversion);
3953 $DBversion = "3.03.00.011";
3954 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3955 $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3956 print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
3957 SetVersion ($DBversion);
3960 $DBversion = "3.03.00.012";
3961 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3962 $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')");
3963 print "Upgrade to $DBversion done (Bug 2142: maxItemsInSearchResults syspref resurrected)\n";
3964 SetVersion ($DBversion);
3967 $DBversion = "3.03.00.013";
3968 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3969 $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')");
3970 print "Upgrade to $DBversion done (added 'OpacPublic' syspref)\n";
3971 SetVersion ($DBversion);
3974 $DBversion = "3.03.00.014";
3975 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3976 $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')");
3977 $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')");
3978 $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')");
3979 print "Upgrade to $DBversion done (Add flexible shelf browser constraints)\n";
3980 SetVersion ($DBversion);
3983 $DBversion = "3.03.00.015";
3984 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {