--- # nuzlocke-tracker-h0dr title: Fix route deletion failing due to missing cascade on route_encounters status: completed type: bug priority: normal created_at: 2026-02-14T14:19:56Z updated_at: 2026-02-14T14:23:10Z --- Deleting a route returns 500 due to two FK constraint issues: 1. `route_encounters.route_id` — missing cascade on the relationship (SQLAlchemy tried to NULL a NOT NULL column) 2. `boss_battles.after_route_id` — references the route being deleted ## Fix - Added `cascade="all, delete-orphan"` to `Route.route_encounters` relationship - Added `update(BossBattle).where(...).values(after_route_id=None)` before deleting the route in the delete endpoint