SetVersion ($DBversion);
}
if (C4::Context->preference("Version") =~/3\.00/) {
- warn "inside 3.00";
my $perllibdir=C4::Context->config('intranetdir');
my $return=do qq($perllibdir/installer/data/mysql/updatedatabase30.pl);
unless ($return){
}
}
-$DBversion = '3.00.04.001';
-if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
- $dbh->do("
- CREATE TABLE hold_fill_targets (
- `borrowernumber` int(11) NOT NULL,
- `biblionumber` int(11) NOT NULL,
- `itemnumber` int(11) NOT NULL,
- `source_branchcode` varchar(10) default NULL,
- `item_level_request` tinyint(4) NOT NULL default 0,
- PRIMARY KEY `itemnumber` (`itemnumber`),
- KEY `bib_branch` (`biblionumber`, `source_branchcode`),
- CONSTRAINT `hold_fill_targets_ibfk_1` FOREIGN KEY (`borrowernumber`)
- REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `hold_fill_targets_ibfk_2` FOREIGN KEY (`biblionumber`)
- REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `hold_fill_targets_ibfk_3` FOREIGN KEY (`itemnumber`)
- REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `hold_fill_targets_ibfk_4` FOREIGN KEY (`source_branchcode`)
- REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- ");
- $dbh->do("
- ALTER TABLE tmp_holdsqueue
- ADD item_level_request tinyint(4) NOT NULL default 0
- ");
-
- print "Upgrade to $DBversion done (add hold_fill_targets table and a column to tmp_holdsqueue)\n";
- SetVersion($DBversion);
-}
-
-$DBversion = '3.00.04.002';
-if ( C4::Context->preference('Version') < TransformToNum($DBversion) ) {
- # use statistics where available
- $dbh->do("
- ALTER TABLE statistics ADD KEY tmp_stats (type, itemnumber, borrowernumber)
- ");
- $dbh->do("
- UPDATE issues iss
- SET issuedate = (
- SELECT max(datetime)
- FROM statistics
- WHERE type = 'issue'
- AND itemnumber = iss.itemnumber
- AND borrowernumber = iss.borrowernumber
- )
- WHERE issuedate IS NULL;
- ");
- $dbh->do("ALTER TABLE statistics DROP KEY tmp_stats");
-
- # default to last renewal date
- $dbh->do("
- UPDATE issues
- SET issuedate = lastreneweddate
- WHERE issuedate IS NULL
- and lastreneweddate IS NOT NULL
- ");
-
- my $num_bad_issuedates = $dbh->selectrow_array("SELECT COUNT(*) FROM issues WHERE issuedate IS NULL");
- if ($num_bad_issuedates > 0) {
- print STDERR "After the upgrade to $DBversion, there are still $num_bad_issuedates loan(s) with a NULL (blank) loan date. ",
- "Please check the issues table in your database.";
- }
- print "Upgrade to $DBversion done (bug 2582: set null issues.issuedate to lastreneweddate)\n";
- SetVersion($DBversion);
-}
-
-$DBversion = "3.00.04.003";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
- $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')");
- print "Upgrade to $DBversion done (add new syspref)\n";
- SetVersion ($DBversion);
-}
=item DropAllForeignKeys($table)