From 25652bd554a355a4bd978b2f6e659d0eec404ad0 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 14 Aug 2008 20:59:49 -0500 Subject: [PATCH] bug 2522 [1/3]: DB rev 3.1/001 - hold request targetting For bug 2522, add a new table called hold_fill_targets to implement hold request targeting. This table has the following columns: borrowernumber - identify request biblionumber - ditto itemnumber - item targeted to fill request source_branchcode - current location of item item_level_request - if 1, request is item-level For bug 2331, adds a column called item_level_request to tmp_holdsqueue. Note: both of the item_level_request columns can go away once reserves is modified so that it is clear whether a request is item-level or bib-level. Signed-off-by: Galen Charlton --- installer/data/mysql/kohastructure.sql | 25 ++++++++++++++++++- installer/data/mysql/updatedatabase.pl | 34 +++++++++++++++++++++++++- kohaversion.pl | 2 +- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 01e281331e..ee04682123 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -940,6 +940,28 @@ CREATE TABLE `ethnicity` ( PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `hold_fill_targets` +-- + +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; + -- -- Table structure for table `import_batches` -- @@ -2178,7 +2200,8 @@ CREATE TABLE `tmp_holdsqueue` ( `itemcallnumber` varchar(30) default NULL, `holdingbranch` varchar(10) default NULL, `pickbranch` varchar(10) default NULL, - `notes` text + `notes` text, + `item_level_request` tinyint(4) NOT NULL default 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index b98834ca47..19793ad6e1 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -15,7 +15,7 @@ # NOTE: Please keep the version in kohaversion.pl up-to-date! use strict; -# use warnings; +use warnings; # CPAN modules use DBI; @@ -1968,6 +1968,38 @@ if (C4::Context->preference("Version") =~/3\.00/) { print STDERR "cannot read file $ENV{'PERL5LIB'}/installer/data/mysql/updatedatabase30.pl : $@ \n" if ($@); } } + +$DBversion = '3.00.02.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)"; + SetVersion($DBversion); +} + + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/kohaversion.pl b/kohaversion.pl index f198463885..754b2267b3 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.00.02.012'; + our $VERSION = '3.00.04.001'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.20.1