From 4c037341e4ca1aa9e9d3bf8a3ff599d83f357426 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 | 32 +++++++++++++++++++++++++- kohaversion.pl | 2 +- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 53da4fe656..09aaf9773f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -938,6 +938,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` -- @@ -2172,7 +2194,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 042a80b0c3..1dd86a187f 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; @@ -1967,6 +1967,36 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.01.00.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 a0404b20e3..9a9221fee6 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.01.00.000'; + our $VERSION = '3.01.00.001'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5