Fix route deletion failing due to FK constraint violations
All checks were successful
CI / backend-lint (push) Successful in 8s
CI / frontend-lint (push) Successful in 31s

Route deletion failed with two integrity errors:
1. route_encounters had no cascade, so SQLAlchemy tried to NULL
   the non-nullable route_id instead of deleting the rows
2. boss_battles.after_route_id referenced the route being deleted

Added cascade="all, delete-orphan" to Route.route_encounters and
nulled out boss battle after_route_id references before deletion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 15:24:02 +01:00
parent a31e8bf174
commit d1503553ea
3 changed files with 27 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ class Route(Base):
version_group: Mapped["VersionGroup"] = relationship(back_populates="routes")
route_encounters: Mapped[list["RouteEncounter"]] = relationship(
back_populates="route"
back_populates="route", cascade="all, delete-orphan"
)
encounters: Mapped[list["Encounter"]] = relationship(back_populates="route")