https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42068 Bug ID: 42068 Summary: Update on bug 26993 breaks items deletions with a corrupted foreign key Initiative type: --- Sponsorship --- status: Product: Koha Version: Main 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 On bug 26993 we turned off foreign key cheks to remove a unique constraint, then enabled them This meant the existing rows got wrong :-) To recreate: 1 - Checkout 25.11.x - reset_all 2 - Enable StoreLastBorrower 3 - Issue an item 4 - Ensure item has a row in items_last_borrower SELECT * FROM items_last_borrower 5 - Checkout main 6 - updatedatabase 7 - Try to delete any item, doesn't have to be the one you issued DELETE FROM items WHERE itemnumber=93; 8 - ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`koha_kohadev`.`items_last_borrower`, CONSTRAINT `items_last_borrower_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE) TO fix you must recreate the constraint: ALTER TABLE items_last_borrower DROP FOREIGN KEY items_last_borrower_ibfk_1; ALTER TABLE items_last_borrower ADD INDEX itemnumber (itemnumber); ALTER TABLE items_last_borrower ADD CONSTRAINT items_last_borrower_ibfk_1 FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE; -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.