Files
nuzlocke-tracker/backend/src/app/models/game.py
Julian Tabel 3e88ba50fa 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>
2026-02-08 12:07:42 +01:00

29 lines
1.1 KiB
Python

from sqlalchemy import ForeignKey, SmallInteger, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
class Game(Base):
__tablename__ = "games"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(String(100))
slug: Mapped[str] = mapped_column(String(100), unique=True)
generation: Mapped[int] = mapped_column(SmallInteger)
region: Mapped[str] = mapped_column(String(50))
box_art_url: Mapped[str | None] = mapped_column(String(500))
release_year: Mapped[int | None] = mapped_column(SmallInteger)
color: Mapped[str | None] = mapped_column(String(7)) # Hex color e.g. #FF0000
version_group_id: Mapped[int | None] = mapped_column(
ForeignKey("version_groups.id"), index=True
)
version_group: Mapped["VersionGroup | None"] = relationship(
back_populates="games"
)
runs: Mapped[list["NuzlockeRun"]] = relationship(back_populates="game")
def __repr__(self) -> str:
return f"<Game(id={self.id}, name='{self.name}')>"