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:
@@ -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})>"
|
||||
|
||||
Reference in New Issue
Block a user