Separate PokeAPI ID from national dex for correct form identification

Pokemon forms (e.g., Alolan Rattata) had their PokeAPI ID (10091) stored as
national_dex, causing them to display incorrectly. This renames the unique
identifier to pokeapi_id and adds a real national_dex field shared between
forms and their base species, so Alolan Rattata correctly shows as #19.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 14:55:06 +01:00
parent cb027e5215
commit d168d99bba
46 changed files with 23459 additions and 22289 deletions

View File

@@ -1,4 +1,4 @@
from sqlalchemy import SmallInteger, String
from sqlalchemy import Integer, SmallInteger, String
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.orm import Mapped, mapped_column, relationship
@@ -9,7 +9,8 @@ class Pokemon(Base):
__tablename__ = "pokemon"
id: Mapped[int] = mapped_column(primary_key=True)
national_dex: Mapped[int] = mapped_column(SmallInteger, unique=True)
pokeapi_id: Mapped[int] = mapped_column(Integer, unique=True)
national_dex: Mapped[int] = mapped_column(SmallInteger)
name: Mapped[str] = mapped_column(String(50))
types: Mapped[list[str]] = mapped_column(ARRAY(String(20)))
sprite_url: Mapped[str | None] = mapped_column(String(500))
@@ -22,4 +23,4 @@ class Pokemon(Base):
)
def __repr__(self) -> str:
return f"<Pokemon(id={self.id}, name='{self.name}', dex={self.national_dex})>"
return f"<Pokemon(id={self.id}, name='{self.name}', pokeapi_id={self.pokeapi_id}, dex={self.national_dex})>"