To recreate: 1. Add or have a patron category. 2. Go to Tools > Overdue notice/status triggers 3. Set some rules for that category. 4. Delete the patron category 5. Now do "select distinct categorycode from overduerules;" 6. The rule remains with a non-existent categorycode
Just notices this is also true of branches. If I make a rule for a specific branch and then deleted the branch, the overduerule remains.
Created attachment 189564 [details] [review] Bug 41246: Add foreign key constraints to overduerules table and cascade on delete To test: 0. APPLY PATCH, updatedatabase, restart_all 1. Add or have a patron category. 2. Go to Tools > Overdue notice/status triggers 3. Set some rules for that category. 4. Delete the patron category 5. Now do "select distinct categorycode from overduerules;" 6. All rules should be gone.
Created attachment 189565 [details] [review] Bug 41246: Add foreign key constraints to overduerules table and cascade on delete To test: 0. APPLY PATCH, updatedatabase, restart_all 1. Add or have a patron category. 2. Go to Tools > Overdue notice/status triggers 3. Set some rules for that category. 4. Delete the patron category 5. Now do "select distinct categorycode from overduerules;" 6. All rules should be gone.
Created attachment 189566 [details] [review] Bug 41246: DBIC changes [DO NOT PUSH]
It's worth noting explicitly that these orphaned rules cause the overdues cron to fail and not generate notices for anyone.