From 0086d82dff73e92fa713ad2117ce5270158747eb Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 28 Feb 2020 10:37:05 -0500 Subject: [PATCH] Bug 24860: Add reserves.volume_id This feature builds upon bug 24857 and allows placing holds that target a specific volume of a record. It is patterned after the feature that allows limiting hold selection by itemtype ( AllowHoldItemTypeSelection ). Test Plan: 1) Apply bug 24857 and this bug's patches 2) Run updatedatabase.pl 3) Restart all the things! 4) Enable the sysprefs EnableVolumes and EnableVolumeHolds 5) Create a record, items and volumes, with each item being assigned to a volume 6) Place a hold for a patron 7) Note the new selector to choose a volume in addition to record and item level holds 8) Place a volume level hold 9) Check in an item from the record that is not part of that volume 10) Note the hold is not trapped for that item 11) Check in an item from the record that *is* part of that volume 12) Note the hold is trapped for that item 13) Place a volume level hold for another item 14) Run the holds queue builder 15) Note the holds queue targets only items from that volume 16) Check out all the items of that volume to other patrosn 17) Re-run the holds queue builder 18) Note the holds queue no longer has a line for that hold, as all items that could fill that hold are now unavailable Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert --- installer/data/mysql/atomicupdate/volumes.perl | 16 ++++++++++++++++ installer/data/mysql/kohastructure.sql | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/atomicupdate/volumes.perl b/installer/data/mysql/atomicupdate/volumes.perl index c1886b3087..84a0459007 100644 --- a/installer/data/mysql/atomicupdate/volumes.perl +++ b/installer/data/mysql/atomicupdate/volumes.perl @@ -39,6 +39,22 @@ if ( CheckVersion( $DBversion ) ) { }); } + unless ( column_exists( 'reserves', 'volume_id' ) ) { + $dbh->do(q{ + ALTER TABLE reserves + ADD COLUMN `volume_id` int(11) NULL default NULL AFTER biblionumber, + ADD CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; + }); + } + + unless ( column_exists( 'old_reserves', 'volume_id' ) ) { + $dbh->do(q{ + ALTER TABLE old_reserves + ADD COLUMN `volume_id` int(11) NULL default NULL AFTER biblionumber, + ADD CONSTRAINT `old_reserves_ibfk_5` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE SET NULL ON UPDATE SET NULL; + }); + } + # Always end with this (adjust the bug info) SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug XXXXX - Add ability to define volumes for items on a record)\n"; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 803bdd92e0..7fa8d82ebd 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1787,6 +1787,7 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha `borrowernumber` int(11) NOT NULL default 0, -- foreign key from the borrowers table defining which patron this hold is for `reservedate` date default NULL, -- the date the hold was placed `biblionumber` int(11) NOT NULL default 0, -- foreign key from the biblio table defining which bib record this hold is on + `volume_id` int(11) NULL default NULL, -- foreign key from the volumes table defining if this is a volume level hold `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at `notificationdate` date default NULL, -- currently unused `reminderdate` date default NULL, -- currently unused @@ -1815,7 +1816,8 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha CONSTRAINT `reserves_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `reserves_ibfk_4` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `reserves_ibfk_5` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `reserves_ibfk_6` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- @@ -1828,6 +1830,7 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b `borrowernumber` int(11) default NULL, -- foreign key from the borrowers table defining which patron this hold is for `reservedate` date default NULL, -- the date the hold was places `biblionumber` int(11) default NULL, -- foreign key from the biblio table defining which bib record this hold is on + `volume_id` int(11) NULL default NULL, -- foreign key from the volumes table defining if this is a volume level hold `branchcode` varchar(10) default NULL, -- foreign key from the branches table defining which branch the patron wishes to pick this hold up at `notificationdate` date default NULL, -- currently unused `reminderdate` date default NULL, -- currently unused @@ -1858,6 +1861,8 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b CONSTRAINT `old_reserves_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) + ON DELETE SET NULL ON UPDATE SET NULL, + CONSTRAINT `old_reserves_ibfk_5` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`) ON DELETE SET NULL ON UPDATE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.24.1 (Apple Git-126)