[Koha-bugs] [Bug 34520] Database update 22.06.00.078 breaks update process
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Sun Oct 29 15:01:20 CET 2023
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34520
--- Comment #2 from Katrin Fischer <katrin.fischer at bsz-bw.de> ---
OK, now I totally confused myself here:
kohastructure.sql:
reserves
CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES
`item_groups` (`item_group_id`) ON DELETE CASCADE ON UPDATE CASCADE
This means, that when the item_group is deleted, we delete the reserve. I think
this could create possible issues as we usually should not delete but cancel
(move to old_reserves). If we set to null, it turns itself into a title level
hold, which seems safer at least. I think SET NULL would make more sense here
too.
old_reserves
CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY (`item_group_id`) REFERENCES
`item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE SET NULL
So, when an item_group is deleted, we set it to null in old_reserves. This
makes sense, as we would want to keep the entry for hold statistics.
Database update:
unless ( column_exists( 'reserves', 'item_group_id' ) ) {
$dbh->do(q{
ALTER TABLE reserves
ADD COLUMN `item_group_id` int(11) NULL default NULL AFTER
biblionumber,
ADD CONSTRAINT `reserves_ibfk_ig` FOREIGN KEY (`item_group_id`)
REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL ON UPDATE
CASCADE;
});
}
unless ( column_exists( 'old_reserves', 'item_group_id' ) ) {
$dbh->do(q{
ALTER TABLE old_reserves
ADD COLUMN `item_group_id` int(11) NULL default NULL AFTER
biblionumber,
ADD CONSTRAINT `old_reserves_ibfk_ig` FOREIGN KEY
(`item_group_id`) REFERENCES `item_groups` (`item_group_id`) ON DELETE SET NULL
ON UPDATE SET NULL;
});
}
I suggest to alter the database definition to fit the original updates.
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
More information about the Koha-bugs
mailing list