Bug 14205: Deleting an Item/Record does not remove link to course reserve

A constraint is missing on the course_reserves.ci_id field.
This patch adds it and removes orphan rows.

Test plan:
0/ Don't apply the patch
1/ Login to Staff Site.
2/ Go to Course Reserves
3/ Create Course
4/ Add Reserve
5/ Go to item added (delete item/record)
6/ Refresh Course (see no items attached)
7/ Delete Course
8/ See course still listed in the courses (Not deleted)
9/ Apply the patch and execute the updatedatabase entry.
10/ Delete the Course
Note that the course has correctly been removed.

NOTE: Make sure to set the UseCourseReserves system preference to test.
      Tested before (problem existed) and after (problem solved) update.
      Dropped DB, web installed, and put in dummy data and retested.
      Problem solved.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
Jonathan Druart 2015-08-04 10:00:51 +01:00 committed by Tomas Cohen Arazi
parent 438b62e8ff
commit fc568dfb22
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,2 @@
DELETE cr.* FROM course_reserves AS cr LEFT JOIN course_items USING(ci_id) WHERE course_items.ci_id IS NULL;
ALTER TABLE course_reserves add CONSTRAINT course_reserves_ibfk_2 FOREIGN KEY (ci_id) REFERENCES course_items (ci_id) ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -623,7 +623,9 @@ CREATE TABLE `course_reserves` (
-- Constraints for table `course_reserves`
--
ALTER TABLE `course_reserves`
ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
ADD CONSTRAINT `course_reserves_ibfk_2` FOREIGN KEY (`ci_id`) REFERENCES `course_items` (`ci_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Table structure for table `branch_borrower_circ_rules`