here's the error on a 16.05.09 pkg install # koha-shell -c ' perl /usr/share/koha/bin/maintenance/borrowers-force-messaging-defaults --doit --truncate ' demo DBD::mysql::st execute failed: Cannot truncate a table referenced in a foreign key constraint (`koha_demo`.`borrower_message_transport_preferences`, CONSTRAINT `borrower_message_transport_preferences_ibfk_1` FOREIGN KEY (`borrower_message_preference_id`) REFERENCES `koha_demo`.`borrower) [for Statement "TRUNCATE borrower_message_preferences"] at /usr/share/koha/bin/maintenance/borrowers-force-messaging-defaults line 52. note: i haven't confirmed this on newer versions, yet
Created attachment 60202 [details] [review] Bug 18058: Allow borrower_message_preferences to be truncated borrower_message_preferences cannot be truncated because of the foreign. DBMS fails with "Cannot truncate a table referenced in a foreign key constraint" To avoid that we should remove the FK check and truncate the other table as well. I am wondering if we really need a truncate here DELETE FROM borrower_message_preferences; should do the job, but leave it as it because of the param name. Test plan perl misc/maintenance/borrowers-force-messaging-defaults --doit --truncate Should no longer raise the error message
Created attachment 60479 [details] [review] [SIGNED-OFF] Bug 18058: Allow borrower_message_preferences to be truncated borrower_message_preferences cannot be truncated because of the foreign. DBMS fails with "Cannot truncate a table referenced in a foreign key constraint" To avoid that we should remove the FK check and truncate the other table as well. I am wondering if we really need a truncate here DELETE FROM borrower_message_preferences; should do the job, but leave it as it because of the param name. Test plan perl misc/maintenance/borrowers-force-messaging-defaults --doit --truncate Should no longer raise the error message Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Created attachment 60985 [details] [review] Bug 18058: Allow borrower_message_preferences to be truncated borrower_message_preferences cannot be truncated because of the foreign. DBMS fails with "Cannot truncate a table referenced in a foreign key constraint" To avoid that we should remove the FK check and truncate the other table as well. I am wondering if we really need a truncate here DELETE FROM borrower_message_preferences; should do the job, but leave it as it because of the param name. Test plan perl misc/maintenance/borrowers-force-messaging-defaults --doit --truncate Should no longer raise the error message Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Delete instead of truncate indeed seems to be a better idea here..
Pushed to master for 17.05, thanks Jonathan!
This patch has been pushed to 16.11.x and will be in 16.11.07. Could not reproduce the error before the patch, but it seems better with it.
Pushed to 3.22.x for 3.22.20
Pushed to 16.05.x, for 16.05.12 release