Add version groups to share routes and boss battles across games

Routes and boss battles now belong to a version_group instead of
individual games, so paired versions (e.g. Red/Blue, Gold/Silver)
share the same route structure and boss battles. Route encounters
gain a game_id column to support game-specific encounter tables
within a shared route. Includes migration, updated seeds, API
changes, and frontend type updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 12:07:42 +01:00
parent 979f57f184
commit 3e88ba50fa
22 changed files with 631 additions and 161 deletions

View File

@@ -8,13 +8,15 @@ class RouteEncounter(Base):
__tablename__ = "route_encounters"
__table_args__ = (
UniqueConstraint(
"route_id", "pokemon_id", "encounter_method", name="uq_route_pokemon_method"
"route_id", "pokemon_id", "encounter_method", "game_id",
name="uq_route_pokemon_method_game"
),
)
id: Mapped[int] = mapped_column(primary_key=True)
route_id: Mapped[int] = mapped_column(ForeignKey("routes.id"), index=True)
pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.id"), index=True)
game_id: Mapped[int] = mapped_column(ForeignKey("games.id"), index=True)
encounter_method: Mapped[str] = mapped_column(String(30))
encounter_rate: Mapped[int] = mapped_column(SmallInteger)
min_level: Mapped[int] = mapped_column(SmallInteger)
@@ -22,6 +24,7 @@ class RouteEncounter(Base):
route: Mapped["Route"] = relationship(back_populates="route_encounters")
pokemon: Mapped["Pokemon"] = relationship(back_populates="route_encounters")
game: Mapped["Game"] = relationship()
def __repr__(self) -> str:
return f"<RouteEncounter(route_id={self.route_id}, pokemon_id={self.pokemon_id}, method='{self.encounter_method}')>"