https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26911 Bug ID: 26911 Summary: Update for 18936 can cause data loss if constraints are violated Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: blocker Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: nick@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org In 19.11 and before you can create circ rules for an itemtype, delete the itemtype, and the circ rule remains. This also applies to category codes and branches On upgrade from bug 18936 we insert from issuing into circulation rules, however, if rules exist that violate the new constraints on circulation_rules then the upgrade will fail and rules will not be inserted To test: 1 - Checkout 19.11.x 2 - Add a new itemtype 3 - Define some circ rules for that type and some others 4 - Delete that itemtype 5 - Checkout 20.05.x 6 - updatedatabase 7 - See errors: DBD::mysql::db do failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`circulation_rules`, CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE) [for Statement " INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) SELECT IF(categorycode='*', NULL, categorycode), IF(branchcode='*', NULL, branchcode), IF(itemtype='*', NULL, itemtype), 'restrictedtype', COALESCE( restrictedtype, '' ) FROM issuingrules "] at /kohadevbox/koha/installer/data/mysql/updatedatabase.pl line 20712. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.