Files
nuzlocke-tracker/backend/src/app/models/evolution.py
Julian Tabel a65efa22da Add nullable region field to evolutions for regional form filtering
Regional evolutions (e.g., Pikachu → Alolan Raichu) only occur in specific
regions. This adds a nullable region column so the app can filter evolutions
by the game's region. When a regional evolution exists for a given trigger/item,
the non-regional counterpart is automatically hidden.

Full-stack: migration, model, schemas, API with region query param, seeder,
Go fetch tool, frontend types/API/hook/components, and admin form.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 20:05:07 +01:00

25 lines
1.2 KiB
Python

from sqlalchemy import ForeignKey, SmallInteger, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
class Evolution(Base):
__tablename__ = "evolutions"
id: Mapped[int] = mapped_column(primary_key=True)
from_pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.id"), index=True)
to_pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.id"), index=True)
trigger: Mapped[str] = mapped_column(String(30)) # level-up, trade, use-item, etc.
min_level: Mapped[int | None] = mapped_column(SmallInteger)
item: Mapped[str | None] = mapped_column(String(50)) # e.g. thunder-stone
held_item: Mapped[str | None] = mapped_column(String(50))
condition: Mapped[str | None] = mapped_column(String(200)) # catch-all for other conditions
region: Mapped[str | None] = mapped_column(String(30))
from_pokemon: Mapped["Pokemon"] = relationship(foreign_keys=[from_pokemon_id])
to_pokemon: Mapped["Pokemon"] = relationship(foreign_keys=[to_pokemon_id])
def __repr__(self) -> str:
return f"<Evolution(id={self.id}, from={self.from_pokemon_id}, to={self.to_pokemon_id}, trigger='{self.trigger}')>"