# NOTE: If you do something more than once in here, make it table driven.
-# NOTE: Please keep the version in C4/Context.pm up-to-date!
+# NOTE: Please keep the version in kohaversion.pl up-to-date!
use strict;
+# use warnings;
# CPAN modules
use DBI;
use Getopt::Long;
# Koha modules
use C4::Context;
+use C4::Installer;
use MARC::Record;
use MARC::File::XML ( BinaryEncoding => 'utf8' );
$|=1; # flushes output
=item
+
Deal with virtualshelves
+
=cut
my $DBversion = "3.00.00.001";
#
$dbh->do("ALTER TABLE `bookshelf` RENAME `virtualshelves`");
$dbh->do("ALTER TABLE `shelfcontents` RENAME `virtualshelfcontents`");
- $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL");
+ $dbh->do("ALTER TABLE `virtualshelfcontents` ADD `biblionumber` INT( 11 ) NOT NULL default '0' AFTER shelfnumber");
$dbh->do("UPDATE `virtualshelfcontents` SET biblionumber=(SELECT biblionumber FROM items WHERE items.itemnumber=virtualshelfcontents.itemnumber)");
# drop all foreign keys : otherwise, we can't drop itemnumber field.
DropAllForeignKeys('virtualshelfcontents');
+ $dbh->do("ALTER TABLE `virtualshelfcontents` ADD KEY biblionumber (biblionumber)");
# create the new foreign keys (on biblionumber)
- $dbh->do("ALTER TABLE `virtualshelfcontents` ADD FOREIGN KEY biblionumber_fk (biblionumber) REFERENCES biblio (biblionumber) ON UPDATE CASCADE ON DELETE CASCADE");
+ $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE");
# re-create the foreign key on virtualshelf
- $dbh->do("ALTER TABLE `virtualshelfcontents` ADD FOREIGN KEY shelfnumber_fk (shelfnumber) REFERENCES virtualshelves (shelfnumber) ON UPDATE CASCADE ON DELETE CASCADE");
- # now we can drop the itemnumber column
+ $dbh->do("ALTER TABLE `virtualshelfcontents` ADD CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
$dbh->do("ALTER TABLE `virtualshelfcontents` DROP `itemnumber`");
print "Upgrade to $DBversion done (virtualshelves)\n";
SetVersion ($DBversion);
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("DROP TABLE sessions");
$dbh->do("CREATE TABLE `sessions` (
- `id` char(32) NOT NULL,
+ `id` varchar(32) NOT NULL,
`a_session` text NOT NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
MODIFY `editionstatement` TEXT DEFAULT NULL AFTER `collectionvolume`,
MODIFY `editionresponsibility` TEXT DEFAULT NULL AFTER `editionstatement`,
MODIFY `place` VARCHAR(255) DEFAULT NULL AFTER `size`,
- MODIFY `marc` BLOB,
+ MODIFY `marc` LONGBLOB,
ADD `cn_source` VARCHAR(10) DEFAULT NULL AFTER `url`,
ADD `cn_class` VARCHAR(30) DEFAULT NULL AFTER `cn_source`,
ADD `cn_item` VARCHAR(10) DEFAULT NULL AFTER `cn_class`,
ADD `cn_suffix` VARCHAR(10) DEFAULT NULL AFTER `cn_item`,
ADD `cn_sort` VARCHAR(30) DEFAULT NULL AFTER `cn_suffix`,
ADD `totalissues` INT(10) AFTER `cn_sort`,
+ ADD `marcxml` LONGTEXT NOT NULL AFTER `totalissues`,
ADD KEY `isbn` (`isbn`),
ADD KEY `publishercode` (`publishercode`)
");
$DBversion = "3.00.00.011";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
- $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` char(10) ");
+ $dbh->do("ALTER TABLE `branchcategories` CHANGE `categorycode` `categorycode` varchar(10) ");
$dbh->do("ALTER TABLE `branchcategories` CHANGE `categoryname` `categoryname` varchar(32) ");
$dbh->do("ALTER TABLE `branchcategories` ADD COLUMN `categorytype` varchar(16) ");
$dbh->do("UPDATE `branchcategories` SET `categorytype` = 'properties'");
- $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` char(10) ");
+ $dbh->do("ALTER TABLE `branchrelations` CHANGE `categorycode` `categorycode` varchar(10) ");
print "Upgrade to $DBversion done (added branchcategory type)\n";
SetVersion ($DBversion);
}
$DBversion = "3.00.00.022";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("ALTER TABLE items
- ADD `damaged` tinyint(1) default NULL");
+ ADD `damaged` tinyint(1) default NULL AFTER notforloan");
+ $dbh->do("ALTER TABLE deleteditems
+ ADD `damaged` tinyint(1) default NULL AFTER notforloan");
print "Upgrade to $DBversion done (adding damaged column to items table)\n";
SetVersion ($DBversion);
}
VALUES ('yuipath','http://yui.yahooapis.com/2.3.1/build','Insert the path to YUI libraries','','free')");
print "Upgrade to $DBversion done (adding new system preference for controlling YUI path)\n";
SetVersion ($DBversion);
-}
-
+}
$DBversion = "3.00.00.024";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("ALTER TABLE biblioitems CHANGE itemtype itemtype VARCHAR(10)");
$DBversion = "3.00.00.025";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("ALTER TABLE items ADD COLUMN itype VARCHAR(10)");
+ $dbh->do("ALTER TABLE deleteditems ADD COLUMN itype VARCHAR(10) AFTER uri");
if(C4::Context->preference('item-level_itypes')){
$dbh->do('update items,biblioitems set items.itype=biblioitems.itemtype where items.biblionumber=biblioitems.biblionumber and itype is null');
}
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('staffClientBaseURL','','Specify the base URL of the staff client',NULL,'free')");
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('minPasswordLength',3,'Specify the minimum length of a patron/staff password',NULL,'free')");
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noItemTypeImages',0,'If ON, disables item-type images',NULL,'YesNo')");
-$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noOPACHolds',0,'If ON, disables holds globally',NULL,'YesNo')");
$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')");
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free')");
$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')");
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice')");
$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')");
$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free')");
-$dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noOPACUserLogin',0,'If ON, disables the OPAC User Login',NULL,'YesNo')");
$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')");
$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')");
$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')");
MODIFY damaged tinyint(1) NOT NULL default 0,
MODIFY itemlost tinyint(1) NOT NULL default 0,
MODIFY wthdrawn tinyint(1) NOT NULL default 0");
+ $dbh->do("UPDATE deleteditems SET notforloan = 0 WHERE notforloan IS NULL");
+ $dbh->do("UPDATE deleteditems SET damaged = 0 WHERE damaged IS NULL");
+ $dbh->do("UPDATE deleteditems SET itemlost = 0 WHERE itemlost IS NULL");
+ $dbh->do("UPDATE deleteditems SET wthdrawn = 0 WHERE wthdrawn IS NULL");
+ $dbh->do("ALTER TABLE deleteditems
+ MODIFY notforloan tinyint(1) NOT NULL default 0,
+ MODIFY damaged tinyint(1) NOT NULL default 0,
+ MODIFY itemlost tinyint(1) NOT NULL default 0,
+ MODIFY wthdrawn tinyint(1) NOT NULL default 0");
print "Upgrade to $DBversion done (disallow NULL in several item status columns)\n";
SetVersion ($DBversion);
}
$DBversion = "3.00.00.043";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
- $dbh->do("ALTER TABLE `currency` ADD `symbol` varchar(5) default NULL, ADD `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP");
+ $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");
print "Upgrade to $DBversion done (currency table: add symbol and timestamp columns)\n";
SetVersion ($DBversion);
}
ADD `altcontactaddress3` varchar(255) default NULL,
ADD `altcontactzipcode` varchar(50) default NULL,
ADD `altcontactphone` varchar(50) default NULL
-");
+ ");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
+('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free'),
+('language','en','Set the default language in the staff client.',NULL,'Languages'),
+('QueryAutoTruncate',1,'If ON, query truncation is enabled by default',NULL,'YesNo'),
+('QueryRemoveStopwords',0,'If ON, stopwords listed in the Administration area will be removed from queries',NULL,'YesNo')
+ ");
print "Upgrade to $DBversion done (syncing deletedborrowers table with borrowers table)\n";
SetVersion ($DBversion);
}
$DBversion = "3.00.00.046";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
- $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default NULL ,
- CHANGE `weeklength` `weeklength` int(11) default NULL");
- $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ $dbh->do("ALTER TABLE `subscription` CHANGE `numberlength` `numberlength` int(11) default '0' ,
+ CHANGE `weeklength` `weeklength` int(11) default '0'");
+ $dbh->do("CREATE TABLE `serialitems` (`serialid` int(11) NOT NULL, `itemnumber` int(11) NOT NULL, UNIQUE KEY `serialididx` (`serialid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$dbh->do("INSERT INTO `serialitems` SELECT `serialid`,`itemnumber` from serial where NOT ISNULL(itemnumber) && itemnumber <> '' && itemnumber NOT LIKE '%,%'");
print "Upgrade to $DBversion done (Add serialitems table to link serial issues to items. )\n";
SetVersion ($DBversion);
}
+$DBversion = "3.00.00.047";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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');");
+ print "Upgrade to $DBversion done ( Added OpacRenewalAllowed syspref )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.048";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `items` ADD `more_subfields_xml` longtext default NULL AFTER `itype`");
+ print "Upgrade to $DBversion done (added items.more_subfields_xml)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.049";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `z3950servers` ADD `encoding` text default NULL AFTER type ");
+ print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.050";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
+ print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.051";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("UPDATE systempreferences SET explanation = 'Define the current theme for the OPAC interface.' WHERE variable = 'opacthemes';");
+ print "Upgrade to $DBversion done ( Corrected opacthemes explanation. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.052";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `deleteditems` ADD `more_subfields_xml` LONGTEXT DEFAULT NULL AFTER `itype`");
+ print "Upgrade to $DBversion done ( Adding missing column to deleteditems table. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.053";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE `printers_profile` (
+ `prof_id` int(4) NOT NULL auto_increment,
+ `printername` varchar(40) NOT NULL,
+ `tmpl_id` int(4) NOT NULL,
+ `paper_bin` varchar(20) NOT NULL,
+ `offset_horz` float default NULL,
+ `offset_vert` float default NULL,
+ `creep_horz` float default NULL,
+ `creep_vert` float default NULL,
+ `unit` char(20) NOT NULL default 'POINT',
+ PRIMARY KEY (`prof_id`),
+ UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
+ CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
+ $dbh->do("CREATE TABLE `labels_profile` (
+ `tmpl_id` int(4) NOT NULL,
+ `prof_id` int(4) NOT NULL,
+ UNIQUE KEY `tmpl_id` (`tmpl_id`),
+ UNIQUE KEY `prof_id` (`prof_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
+ print "Upgrade to $DBversion done ( Printer Profile tables added )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.054";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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';");
+ print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.055";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `zebraqueue` ADD KEY `zebraqueue_lookup` (`server`, `biblio_auth_number`, `operation`, `done`)");
+ print "Upgrade to $DBversion done ( Added index on zebraqueue. )\n";
+ SetVersion ($DBversion);
+}
+$DBversion = "3.00.00.056";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
+ $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) ");
+ } else {
+ $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) ");
+ }
+ $dbh->do("ALTER TABLE `items` ADD `enumchron` VARCHAR(80) DEFAULT NULL;");
+ print "Upgrade to $DBversion done ( Added item.enumchron column, and framework map to 952h )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.057";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH:archiveID','KOHA-OAI-TEST','OAI-PMH archive identification',NULL,'Free');");
+ $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');");
+ $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');");
+ $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');");
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.058";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `opac_news`
+ CHANGE `lang` `lang` VARCHAR( 25 )
+ CHARACTER SET utf8
+ COLLATE utf8_general_ci
+ NOT NULL default ''");
+ print "Upgrade to $DBversion done ( lang field in opac_news made longer )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.059";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+
+ $dbh->do("CREATE TABLE IF NOT EXISTS `labels_templates` (
+ `tmpl_id` int(4) NOT NULL auto_increment,
+ `tmpl_code` char(100) default '',
+ `tmpl_desc` char(100) default '',
+ `page_width` float default '0',
+ `page_height` float default '0',
+ `label_width` float default '0',
+ `label_height` float default '0',
+ `topmargin` float default '0',
+ `leftmargin` float default '0',
+ `cols` int(2) default '0',
+ `rows` int(2) default '0',
+ `colgap` float default '0',
+ `rowgap` float default '0',
+ `active` int(1) default NULL,
+ `units` char(20) default 'PX',
+ `fontsize` int(4) NOT NULL default '3',
+ PRIMARY KEY (`tmpl_id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $dbh->do("CREATE TABLE IF NOT EXISTS `printers_profile` (
+ `prof_id` int(4) NOT NULL auto_increment,
+ `printername` varchar(40) NOT NULL,
+ `tmpl_id` int(4) NOT NULL,
+ `paper_bin` varchar(20) NOT NULL,
+ `offset_horz` float default NULL,
+ `offset_vert` float default NULL,
+ `creep_horz` float default NULL,
+ `creep_vert` float default NULL,
+ `unit` char(20) NOT NULL default 'POINT',
+ PRIMARY KEY (`prof_id`),
+ UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`),
+ CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");
+ print "Upgrade to $DBversion done ( Added labels_templates table if it did not exist. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.060";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE IF NOT EXISTS `patronimage` (
+ `cardnumber` varchar(16) NOT NULL,
+ `mimetype` varchar(15) NOT NULL,
+ `imagefile` mediumblob NOT NULL,
+ PRIMARY KEY (`cardnumber`),
+ CONSTRAINT `patronimage_fk1` FOREIGN KEY (`cardnumber`) REFERENCES `borrowers` (`cardnumber`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ print "Upgrade to $DBversion done ( Added patronimage table. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.061";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE labels_templates ADD COLUMN font char(10) NOT NULL DEFAULT 'TR';");
+ print "Upgrade to $DBversion done ( Added font column to labels_templates )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.062";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE `old_issues` (
+ `borrowernumber` int(11) default NULL,
+ `itemnumber` int(11) default NULL,
+ `date_due` date default NULL,
+ `branchcode` varchar(10) default NULL,
+ `issuingbranch` varchar(18) default NULL,
+ `returndate` date default NULL,
+ `lastreneweddate` date default NULL,
+ `return` varchar(4) default NULL,
+ `renewals` tinyint(4) default NULL,
+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `issuedate` date default NULL,
+ KEY `old_issuesborridx` (`borrowernumber`),
+ KEY `old_issuesitemidx` (`itemnumber`),
+ KEY `old_bordate` (`borrowernumber`,`timestamp`),
+ CONSTRAINT `old_issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE SET NULL ON UPDATE SET NULL,
+ CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
+ ON DELETE SET NULL ON UPDATE SET NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ $dbh->do("CREATE TABLE `old_reserves` (
+ `borrowernumber` int(11) default NULL,
+ `reservedate` date default NULL,
+ `biblionumber` int(11) default NULL,
+ `constrainttype` varchar(1) default NULL,
+ `branchcode` varchar(10) default NULL,
+ `notificationdate` date default NULL,
+ `reminderdate` date default NULL,
+ `cancellationdate` date default NULL,
+ `reservenotes` mediumtext,
+ `priority` smallint(6) default NULL,
+ `found` varchar(1) default NULL,
+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `itemnumber` int(11) default NULL,
+ `waitingdate` date default NULL,
+ KEY `old_reserves_borrowernumber` (`borrowernumber`),
+ KEY `old_reserves_biblionumber` (`biblionumber`),
+ KEY `old_reserves_itemnumber` (`itemnumber`),
+ KEY `old_reserves_branchcode` (`branchcode`),
+ CONSTRAINT `old_reserves_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE SET NULL ON UPDATE SET NULL,
+ CONSTRAINT `old_reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`)
+ ON DELETE SET NULL ON UPDATE SET NULL,
+ CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
+ ON DELETE SET NULL ON UPDATE SET NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+
+ # move closed transactions to old_* tables
+ $dbh->do("INSERT INTO old_issues SELECT * FROM issues WHERE returndate IS NOT NULL");
+ $dbh->do("DELETE FROM issues WHERE returndate IS NOT NULL");
+ $dbh->do("INSERT INTO old_reserves SELECT * FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
+ $dbh->do("DELETE FROM reserves WHERE cancellationdate IS NOT NULL OR found = 'F'");
+
+ print "Upgrade to $DBversion done ( Added old_issues and old_reserves tables )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.063";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE deleteditems
+ CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT DEFAULT NULL,
+ ADD COLUMN enumchron VARCHAR(80) DEFAULT NULL AFTER more_subfields_xml,
+ ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
+ $dbh->do("ALTER TABLE items
+ CHANGE COLUMN booksellerid booksellerid MEDIUMTEXT,
+ ADD COLUMN copynumber SMALLINT(6) DEFAULT NULL AFTER enumchron;");
+ 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";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.064";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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');");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AWSAccessKeyID','','See: http://aws.amazon.com','','free');");
+ $dbh->do("DELETE FROM `systempreferences` WHERE variable='AmazonDevKey';");
+ $dbh->do("DELETE FROM `systempreferences` WHERE variable='XISBNAmazonSimilarItems';");
+ $dbh->do("DELETE FROM `systempreferences` WHERE variable='OPACXISBNAmazonSimilarItems';");
+ print "Upgrade to $DBversion done (IMPORTANT: Upgrading to Amazon.com Associates Web Service 4.0 ) \n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.065";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE `patroncards` (
+ `cardid` int(11) NOT NULL auto_increment,
+ `batch_id` varchar(10) NOT NULL default '1',
+ `borrowernumber` int(11) NOT NULL,
+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ PRIMARY KEY (`cardid`),
+ KEY `patroncards_ibfk_1` (`borrowernumber`),
+ CONSTRAINT `patroncards_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ print "Upgrade to $DBversion done (Adding patroncards table for patroncards generation feature. ) \n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.066";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `virtualshelfcontents` MODIFY `dateadded` timestamp NOT NULL
+DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;
+");
+ print "Upgrade to $DBversion done (fix for bug 1873: virtualshelfcontents dateadded column empty. ) \n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.067";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("UPDATE systempreferences SET explanation = 'Enable patron images for the Staff Client', type = 'YesNo' WHERE variable = 'patronimages'");
+ print "Upgrade to $DBversion done (Updating patronimages syspref to reflect current kohastructure.sql. ) \n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.068";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE `permissions` (
+ `module_bit` int(11) NOT NULL DEFAULT 0,
+ `code` varchar(30) DEFAULT NULL,
+ `description` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`module_bit`, `code`),
+ CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`module_bit`) REFERENCES `userflags` (`bit`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ $dbh->do("CREATE TABLE `user_permissions` (
+ `borrowernumber` int(11) NOT NULL DEFAULT 0,
+ `module_bit` int(11) NOT NULL DEFAULT 0,
+ `code` varchar(30) DEFAULT NULL,
+ CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`module_bit`, `code`)
+ REFERENCES `permissions` (`module_bit`, `code`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+
+ $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
+ (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
+ (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
+ (13, 'edit_calendar', 'Define days when the library is closed'),
+ (13, 'moderate_comments', 'Moderate patron comments'),
+ (13, 'edit_notices', 'Define notices'),
+ (13, 'edit_notice_status_triggers', 'Set notice/status triggers for overdue items'),
+ (13, 'view_system_logs', 'Browse the system logs'),
+ (13, 'inventory', 'Perform inventory (stocktaking) of your catalogue'),
+ (13, 'stage_marc_import', 'Stage MARC records into the reservoir'),
+ (13, 'manage_staged_marc', 'Managed staged MARC records, including completing and reversing imports'),
+ (13, 'export_catalog', 'Export bibliographic and holdings data'),
+ (13, 'import_patrons', 'Import patron data'),
+ (13, 'delete_anonymize_patrons', 'Delete old borrowers and anonymize circulation history (deletes borrower reading history)'),
+ (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
+ (13, 'schedule_tasks', 'Schedule tasks to run')");
+
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo')");
+
+ print "Upgrade to $DBversion done (adding permissions and user_permissions tables and GranularPermissions syspref) \n";
+ SetVersion ($DBversion);
+}
+$DBversion = "3.00.00.069";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE labels_conf CHANGE COLUMN class classification int(1) DEFAULT NULL;");
+ print "Upgrade to $DBversion done ( Correcting columname in labels_conf )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.070";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='yuipath'");
+ $sth->execute;
+ my ($value) = $sth->fetchrow;
+ $value =~ s/2.3.1/2.5.1/;
+ $dbh->do("UPDATE systempreferences SET value='$value' WHERE variable='yuipath';");
+ print "Update yuipath syspref to 2.5.1 if necessary\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.071";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do(" ALTER TABLE `subscription` ADD `serialsadditems` TINYINT( 1 ) NOT NULL DEFAULT '0';");
+ # fill the new field with the previous systempreference value, then drop the syspref
+ my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='serialsadditems'");
+ $sth->execute;
+ my ($serialsadditems) = $sth->fetchrow();
+ $dbh->do("UPDATE subscription SET serialsadditems=$serialsadditems");
+ $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
+ print "Upgrade to $DBversion done ( moving serialsadditems from syspref to subscription )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.072";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE labels_conf ADD COLUMN formatstring VARCHAR(64) DEFAULT NULL AFTER printingtype");
+ print "Upgrade to $DBversion done ( Adding format string to labels generator. )\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.073";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("DROP TABLE IF EXISTS `tags_all`;");
+ $dbh->do(q#
+ CREATE TABLE `tags_all` (
+ `tag_id` int(11) NOT NULL auto_increment,
+ `borrowernumber` int(11) NOT NULL,
+ `biblionumber` int(11) NOT NULL,
+ `term` varchar(255) NOT NULL,
+ `language` int(4) default NULL,
+ `date_created` datetime NOT NULL,
+ PRIMARY KEY (`tag_id`),
+ KEY `tags_borrowers_fk_1` (`borrowernumber`),
+ KEY `tags_biblionumber_fk_1` (`biblionumber`),
+ CONSTRAINT `tags_borrowers_fk_1` FOREIGN KEY (`borrowernumber`)
+ REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `tags_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
+ REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ #);
+ $dbh->do("DROP TABLE IF EXISTS `tags_approval`;");
+ $dbh->do(q#
+ CREATE TABLE `tags_approval` (
+ `term` varchar(255) NOT NULL,
+ `approved` int(1) NOT NULL default '0',
+ `date_approved` datetime default NULL,
+ `approved_by` int(11) default NULL,
+ `weight_total` int(9) NOT NULL default '1',
+ PRIMARY KEY (`term`),
+ KEY `tags_approval_borrowers_fk_1` (`approved_by`),
+ CONSTRAINT `tags_approval_borrowers_fk_1` FOREIGN KEY (`approved_by`)
+ REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ #);
+ $dbh->do("DROP TABLE IF EXISTS `tags_index`;");
+ $dbh->do(q#
+ CREATE TABLE `tags_index` (
+ `term` varchar(255) NOT NULL,
+ `biblionumber` int(11) NOT NULL,
+ `weight` int(9) NOT NULL default '1',
+ PRIMARY KEY (`term`,`biblionumber`),
+ KEY `tags_index_biblionumber_fk_1` (`biblionumber`),
+ CONSTRAINT `tags_index_term_fk_1` FOREIGN KEY (`term`)
+ REFERENCES `tags_approval` (`term`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `tags_index_biblionumber_fk_1` FOREIGN KEY (`biblionumber`)
+ REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ #);
+ $dbh->do(q#
+ INSERT INTO `systempreferences` VALUES
+ ('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.<br /> Example: ocls.mylibrarybookstore.com/MLB/actions/searchHandler.do?nextPage=bookDetails&parentNum=10923&key=',''),
+ ('BakerTaylorEnabled','0','','Enable or disable all Baker & Taylor features.','YesNo'),
+ ('BakerTaylorPassword','','','Baker & Taylor Password for Content Cafe (external content)','Textarea'),
+ ('BakerTaylorUsername','','','Baker & Taylor Username for Content Cafe (external content)','Textarea'),
+ ('TagsEnabled','1','','Enables or disables all tagging features. This is the main switch for tags.','YesNo'),
+ ('TagsExternalDictionary',NULL,'','Path on server to local ispell executable, used to set $Lingua::Ispell::path <br />This dictionary is used as a \"whitelist\" of pre-allowed tags.',''),
+ ('TagsInputOnDetail','1','','Allow users to input tags from the detail page.', 'YesNo'),
+ ('TagsInputOnList', '0','','Allow users to input tags from the search results list.', 'YesNo'),
+ ('TagsModeration', NULL,'','Require tags from patrons to be approved before becoming visible.','YesNo'),
+ ('TagsShowOnDetail','10','','Number of tags to display on detail page. 0 is off.', 'Integer'),
+ ('TagsShowOnList', '6','','Number of tags to display on search results list. 0 is off.','Integer')
+ #);
+ print "Upgrade to $DBversion done (Baker/Taylor,Tags: sysprefs and tables (tags_all, tags_index, tags_approval)) \n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.074";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do( q(update itemtypes set imageurl = concat( 'npl/', imageurl )
+ where imageurl not like 'http%'
+ and imageurl is not NULL
+ and imageurl != '') );
+ print "Upgrade to $DBversion done (updating imagetype.imageurls to reflect new icon locations.)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.075";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do( q(alter table authorised_values add imageurl varchar(200) default NULL) );
+ print "Upgrade to $DBversion done (adding imageurl field to authorised_values table)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.076";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE import_batches
+ ADD COLUMN nomatch_action enum('create_new', 'ignore') NOT NULL default 'create_new' AFTER overlay_action");
+ $dbh->do("ALTER TABLE import_batches
+ ADD COLUMN item_action enum('always_add', 'add_only_for_matches', 'add_only_for_new', 'ignore')
+ NOT NULL default 'always_add' AFTER nomatch_action");
+ $dbh->do("ALTER TABLE import_batches
+ MODIFY overlay_action enum('replace', 'create_new', 'use_template', 'ignore')
+ NOT NULL default 'create_new'");
+ $dbh->do("ALTER TABLE import_records
+ MODIFY status enum('error', 'staged', 'imported', 'reverted', 'items_reverted',
+ 'ignored') NOT NULL default 'staged'");
+ $dbh->do("ALTER TABLE import_items
+ MODIFY status enum('error', 'staged', 'imported', 'reverted', 'ignored') NOT NULL default 'staged'");
+
+ print "Upgrade to $DBversion done (changes to import_batches and import_records)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.077";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ # drop these tables only if they exist and none of them are empty
+ # these tables are not defined in the packaged 2.2.9, but since it is believed
+ # that at least one library may be using them in a post-2.2.9 but pre-3.0 Koha,
+ # some care is taken.
+ my ($print_error) = $dbh->{PrintError};
+ $dbh->{PrintError} = 0;
+ my ($raise_error) = $dbh->{RaiseError};
+ $dbh->{RaiseError} = 1;
+
+ my $count = 0;
+ my $do_drop = 1;
+ eval { $count = $dbh->do("SELECT 1 FROM categorytable"); };
+ if ($count > 0) {
+ $do_drop = 0;
+ }
+ eval { $count = $dbh->do("SELECT 1 FROM mediatypetable"); };
+ if ($count > 0) {
+ $do_drop = 0;
+ }
+ eval { $count = $dbh->do("SELECT 1 FROM subcategorytable"); };
+ if ($count > 0) {
+ $do_drop = 0;
+ }
+
+ if ($do_drop) {
+ $dbh->do("DROP TABLE IF EXISTS `categorytable`");
+ $dbh->do("DROP TABLE IF EXISTS `mediatypetable`");
+ $dbh->do("DROP TABLE IF EXISTS `subcategorytable`");
+ }
+
+ $dbh->{PrintError} = $print_error;
+ $dbh->{RaiseError} = $raise_error;
+ print "Upgrade to $DBversion done (drop categorytable, subcategorytable, and mediatypetable)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.078";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ my ($print_error) = $dbh->{PrintError};
+ $dbh->{PrintError} = 0;
+
+ unless ($dbh->do("SELECT 1 FROM browser")) {
+ $dbh->{PrintError} = $print_error;
+ $dbh->do("CREATE TABLE `browser` (
+ `level` int(11) NOT NULL,
+ `classification` varchar(20) NOT NULL,
+ `description` varchar(255) NOT NULL,
+ `number` bigint(20) NOT NULL,
+ `endnode` tinyint(4) NOT NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ }
+ $dbh->{PrintError} = $print_error;
+ print "Upgrade to $DBversion done (add browser table if not already present)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.079";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ my ($print_error) = $dbh->{PrintError};
+ $dbh->{PrintError} = 0;
+
+ $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
+ ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
+ print "Upgrade to $DBversion done (add browser table if not already present)\n";
+ SetVersion ($DBversion);
+}
+
+
+
+$DBversion = "3.00.00.080";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE subscription CHANGE monthlength monthlength int(11) default '0'");
+ $dbh->do("ALTER TABLE deleteditems MODIFY marc LONGBLOB AFTER copynumber");
+ $dbh->do("ALTER TABLE aqbooksellers CHANGE name name mediumtext NOT NULL");
+ print "Upgrade to $DBversion done (catch up on DB schema changes since alpha and beta)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.081";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("CREATE TABLE `borrower_attribute_types` (
+ `code` varchar(10) NOT NULL,
+ `description` varchar(255) NOT NULL,
+ `repeatable` tinyint(1) NOT NULL default 0,
+ `unique_id` tinyint(1) NOT NULL default 0,
+ `opac_display` tinyint(1) NOT NULL default 0,
+ `password_allowed` tinyint(1) NOT NULL default 0,
+ `staff_searchable` tinyint(1) NOT NULL default 0,
+ `authorised_value_category` varchar(10) default NULL,
+ PRIMARY KEY (`code`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ $dbh->do("CREATE TABLE `borrower_attributes` (
+ `borrowernumber` int(11) NOT NULL,
+ `code` varchar(10) NOT NULL,
+ `attribute` varchar(30) default NULL,
+ `password` varchar(30) default NULL,
+ KEY `borrowernumber` (`borrowernumber`),
+ KEY `code_attribute` (`code`, `attribute`),
+ CONSTRAINT `borrower_attributes_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `borrower_attributes_ibfk_2` FOREIGN KEY (`code`) REFERENCES `borrower_attribute_types` (`code`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ExtendedPatronAttributes','0','Use extended patron IDs and attributes',NULL,'YesNo')");
+ print "Upgrade to $DBversion done (added borrower_attributes and borrower_attribute_types)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.082";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do( q(alter table accountlines add column lastincrement decimal(28,6) default NULL) );
+ print "Upgrade to $DBversion done (adding lastincrement column to accountlines table)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.083";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do( qq(UPDATE systempreferences SET value='local' where variable='yuipath' and value like "%/intranet-tmpl/prog/%"));
+ print "Upgrade to $DBversion done (Changing yuipath behaviour in managing a local value)\n";
+ SetVersion ($DBversion);
+}
+$DBversion = "3.00.00.084";
+ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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')");
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo')");
+ print "Upgrade to $DBversion done (add new sysprefs)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.085";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ if (C4::Context->preference("marcflavour") eq 'MARC21') {
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 0 WHERE tab = 9 AND tagfield = '037'");
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 1 WHERE tab = 6 AND tagfield in ('100', '110', '111', '130')");
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 2 WHERE tab = 6 AND tagfield in ('240', '243')");
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 4 WHERE tab = 6 AND tagfield in ('400', '410', '411', '440')");
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 5 WHERE tab = 9 AND tagfield = '584'");
+ $dbh->do("UPDATE marc_subfield_structure SET tab = 7 WHERE tab = -6 AND tagfield = '760'");
+ }
+ print "Upgrade to $DBversion done (move editing tab of various MARC21 subfields)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.086";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do(
+ "CREATE TABLE `tmp_holdsqueue` (
+ `biblionumber` int(11) default NULL,
+ `itemnumber` int(11) default NULL,
+ `barcode` varchar(20) default NULL,
+ `surname` mediumtext NOT NULL,
+ `firstname` text,
+ `phone` text,
+ `borrowernumber` int(11) NOT NULL,
+ `cardnumber` varchar(16) default NULL,
+ `reservedate` date default NULL,
+ `title` mediumtext,
+ `itemcallnumber` varchar(30) default NULL,
+ `holdingbranch` varchar(10) default NULL,
+ `pickbranch` varchar(10) default NULL,
+ `notes` text
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+
+ $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')");
+ $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')");
+
+ print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.087";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` VALUES ('AutoEmailOpacUser','0','','Sends notification emails containing new account details to patrons - when account is created.','YesNo')" );
+ $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')");
+ print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.088";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page','YesNo')");
+ $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')");
+ $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')");
+ $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')");
+ print "Upgrade to $DBversion done (added 2 new 'AutoEmailOpacUser' sysprefs)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.089";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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')");
+ print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.090";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("
+ CREATE TABLE `branch_borrower_circ_rules` (
+ `branchcode` VARCHAR(10) NOT NULL,
+ `categorycode` VARCHAR(10) NOT NULL,
+ `maxissueqty` int(4) default NULL,
+ PRIMARY KEY (`categorycode`, `branchcode`),
+ CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `branch_borrower_circ_rules_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ");
+ $dbh->do("
+ CREATE TABLE `default_borrower_circ_rules` (
+ `categorycode` VARCHAR(10) NOT NULL,
+ `maxissueqty` int(4) default NULL,
+ PRIMARY KEY (`categorycode`),
+ CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ");
+ $dbh->do("
+ CREATE TABLE `default_branch_circ_rules` (
+ `branchcode` VARCHAR(10) NOT NULL,
+ `maxissueqty` int(4) default NULL,
+ PRIMARY KEY (`branchcode`),
+ CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ");
+ $dbh->do("
+ CREATE TABLE `default_circ_rules` (
+ `singleton` enum('singleton') NOT NULL default 'singleton',
+ `maxissueqty` int(4) default NULL,
+ PRIMARY KEY (`singleton`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ");
+ print "Upgrade to $DBversion done (added several circ rules tables)\n";
+ SetVersion ($DBversion);
+}
+
+
+$DBversion = "3.00.00.091";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do(<<'END_SQL');
+ALTER TABLE borrowers
+ADD `smsalertnumber` varchar(50) default NULL
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `message_attributes` (
+ `message_attribute_id` int(11) NOT NULL auto_increment,
+ `message_name` varchar(20) NOT NULL default '',
+ `takes_days` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`message_attribute_id`),
+ UNIQUE KEY `message_name` (`message_name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `message_transport_types` (
+ `message_transport_type` varchar(20) NOT NULL,
+ PRIMARY KEY (`message_transport_type`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `message_transports` (
+ `message_attribute_id` int(11) NOT NULL,
+ `message_transport_type` varchar(20) NOT NULL,
+ `is_digest` tinyint(1) NOT NULL default '0',
+ `letter_module` varchar(20) NOT NULL default '',
+ `letter_code` varchar(20) NOT NULL default '',
+ PRIMARY KEY (`message_attribute_id`,`message_transport_type`,`is_digest`),
+ KEY `message_transport_type` (`message_transport_type`),
+ KEY `letter_module` (`letter_module`,`letter_code`),
+ CONSTRAINT `message_transports_ibfk_1` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `message_transports_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `message_transports_ibfk_3` FOREIGN KEY (`letter_module`, `letter_code`) REFERENCES `letter` (`module`, `code`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `borrower_message_preferences` (
+ `borrower_message_preference_id` int(11) NOT NULL auto_increment,
+ `borrowernumber` int(11) NOT NULL default '0',
+ `message_attribute_id` int(11) default '0',
+ `days_in_advance` int(11) default '0',
+ `wants_digets` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`borrower_message_preference_id`),
+ KEY `borrowernumber` (`borrowernumber`),
+ KEY `message_attribute_id` (`message_attribute_id`),
+ CONSTRAINT `borrower_message_preferences_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `borrower_message_preferences_ibfk_2` FOREIGN KEY (`message_attribute_id`) REFERENCES `message_attributes` (`message_attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `borrower_message_transport_preferences` (
+ `borrower_message_preference_id` int(11) NOT NULL default '0',
+ `message_transport_type` varchar(20) NOT NULL default '0',
+ PRIMARY KEY (`borrower_message_preference_id`,`message_transport_type`),
+ KEY `message_transport_type` (`message_transport_type`),
+ 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,
+ 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
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+CREATE TABLE `message_queue` (
+ `message_id` int(11) NOT NULL auto_increment,
+ `borrowernumber` int(11) NOT NULL,
+ `subject` text,
+ `content` text,
+ `message_transport_type` varchar(20) NOT NULL,
+ `status` enum('sent','pending','failed','deleted') NOT NULL default 'pending',
+ `time_queued` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ KEY `message_id` (`message_id`),
+ KEY `borrowernumber` (`borrowernumber`),
+ KEY `message_transport_type` (`message_transport_type`),
+ CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE RESTRICT ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
+END_SQL
+
+ $dbh->do(<<'END_SQL');
+INSERT INTO `systempreferences`
+ (variable,value,explanation,options,type)
+VALUES
+('EnhancedMessagingPreferences',0,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','','YesNo')
+END_SQL
+
+ $dbh->do( <<'END_SQL');
+INSERT INTO `letter`
+(module, code, name, title, content)
+VALUES
+('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>>'),
+('circulation','DUEDGST','Item Due Reminder (Digest)','Item Due Reminder','You have <<count>> items due'),
+('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>>'),
+('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
+('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.');
+END_SQL
+
+ my @sql_scripts = (
+ 'installer/data/mysql/en/mandatory/message_transport_types.sql',
+ 'installer/data/mysql/en/optional/sample_notices_message_attributes.sql',
+ 'installer/data/mysql/en/optional/sample_notices_message_transports.sql',
+ );
+
+ my $installer = C4::Installer->new();
+ foreach my $script ( @sql_scripts ) {
+ my $full_path = $installer->get_file_path_from_name($script);
+ my $error = $installer->load_sql($full_path);
+ warn $error if $error;
+ }
+
+ 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";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.092";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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')");
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo')");
+ print "Upgrade to $DBversion done (added new AllowOnShelfHolds syspref)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.093";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `items` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
+ $dbh->do("ALTER TABLE `deleteditems` MODIFY COLUMN `copynumber` VARCHAR(32) DEFAULT NULL");
+ print "Upgrade to $DBversion done (Change data type of items.copynumber to allow free text)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.094";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `marc_subfield_structure` MODIFY `tagsubfield` VARCHAR(1) NOT NULL DEFAULT '' COLLATE utf8_bin");
+ print "Upgrade to $DBversion done (Change Collation of marc_subfield_structure to allow mixed case in subfield labels.)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.095";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ if (C4::Context->preference("marcflavour") eq 'MARC21') {
+ $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'MEETI_NAME' WHERE authtypecode = 'Meeting Name'");
+ $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'CORPO_NAME' WHERE authtypecode = 'CORP0_NAME'");
+ }
+ print "Upgrade to $DBversion done (fix invalid authority types in MARC21 frameworks [bug 2254])\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.096";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $sth = $dbh->prepare("SHOW COLUMNS FROM borrower_message_preferences LIKE 'wants_digets'");
+ $sth->execute();
+ if (my $row = $sth->fetchrow_hashref) {
+ $dbh->do("ALTER TABLE borrower_message_preferences CHANGE wants_digets wants_digest tinyint(1) NOT NULL default 0");
+ }
+ print "Upgrade to $DBversion done (fix name borrower_message_preferences.wants_digest)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.00.00.097';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+
+ $dbh->do('ALTER TABLE message_queue ADD to_address mediumtext default NULL');
+ $dbh->do('ALTER TABLE message_queue ADD from_address mediumtext default NULL');
+ $dbh->do('ALTER TABLE message_queue ADD content_type text');
+ $dbh->do('ALTER TABLE message_queue CHANGE borrowernumber borrowernumber int(11) default NULL');
+
+ print "Upgrade to $DBversion done (updating 4 fields in message_queue table)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.098';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+
+ $dbh->do(q(DELETE FROM message_transport_types WHERE message_transport_type = 'rss'));
+ $dbh->do(q(DELETE FROM message_transports WHERE message_transport_type = 'rss'));
+
+ print "Upgrade to $DBversion done (removing unused RSS message_transport_type)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.099';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+ $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')");
+ print "Upgrade to $DBversion done (Adding OpacSuppression syspref)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.100';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+ $dbh->do('ALTER TABLE virtualshelves ADD COLUMN lastmodified timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP');
+ print "Upgrade to $DBversion done (Adding lastmodified column to virtualshelves)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.101';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+ $dbh->do('ALTER TABLE `overduerules` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
+ $dbh->do('ALTER TABLE `deletedborrowers` CHANGE `categorycode` `categorycode` VARCHAR(10) NOT NULL');
+ print "Upgrade to $DBversion done (Updating columnd definitions for patron category codes in notice/statsu triggers and deletedborrowers tables.)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = '3.00.00.102';
+if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
+ $dbh->do('ALTER TABLE serialitems MODIFY `serialid` int(11) NOT NULL AFTER itemnumber' );
+ $dbh->do('ALTER TABLE serialitems DROP KEY serialididx' );
+ $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT UNIQUE KEY serialitemsidx (itemnumber)' );
+ # before setting constraint, delete any unvalid data
+ $dbh->do('DELETE from serialitems WHERE serialid not in (SELECT serial.serialid FROM serial)');
+ $dbh->do('ALTER TABLE serialitems ADD CONSTRAINT serialitems_sfk_1 FOREIGN KEY (serialid) REFERENCES serial (serialid) ON DELETE CASCADE ON UPDATE CASCADE' );
+ print "Upgrade to $DBversion done (Updating serialitems table to allow for multiple items per serial fixing kohabug 2380)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.00.00.103";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("DELETE FROM systempreferences WHERE variable='serialsadditems'");
+ print "Upgrade to $DBversion done ( Verifying the removal of serialsadditems from syspref fixing kohabug 2219)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.00.00.104";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
+ print "Upgrade to $DBversion done (remove superseded 'noOPACHolds' system preference per bug 2413)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.00.00.105';
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+ # it is possible that this syspref is already defined since the feature was added some time ago.
+ unless ( $dbh->do(q(SELECT variable FROM systempreferences WHERE variable = 'SMSSendDriver')) ) {
+ $dbh->do(<<'END_SQL');
+INSERT INTO `systempreferences`
+ (variable,value,explanation,options,type)
+VALUES
+('SMSSendDriver','','Sets which SMS::Send driver is used to send SMS messages.','','free')
+END_SQL
+ }
+ print "Upgrade to $DBversion done (added SMSSendDriver system preference)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.00.00.106";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("DELETE FROM systempreferences WHERE variable='noOPACHolds'");
+ print "Upgrade to $DBversion done (remove default '0000-00-00' in subscriptionhistory.enddate field)\n";
+ $dbh->do("ALTER TABLE `subscriptionhistory` CHANGE `enddate` `enddate` DATE NULL DEFAULT NULL ");
+ $dbh->do("UPDATE subscriptionhistory SET enddate=NULL WHERE enddate='0000-00-00'");
+ SetVersion ($DBversion);
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
-
+
=cut
sub DropAllForeignKeys {
}
-
-
-
-
-
=item TransformToNum
Transform the Koha version from a 4 parts string
to a number, with just 1 .
-
+
=cut
sub TransformToNum {
}
=item SetVersion
+
set the DBversion in the systempreferences
+
=cut
sub SetVersion {