Add game data seeding from PokeAPI with level ranges
Seed the database with Pokemon game data for 5 games (FireRed, LeafGreen, Emerald, HeartGold, SoulSilver) using pokebase. Includes Alembic migrations for route unique constraints and encounter level ranges, a two-phase seed system (offline fetch to JSON, then idempotent upserts), and Dockerfile updates for the seed runner. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import ForeignKey, SmallInteger, String
|
||||
from sqlalchemy import ForeignKey, SmallInteger, String, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
@@ -6,6 +6,9 @@ from app.core.database import Base
|
||||
|
||||
class Route(Base):
|
||||
__tablename__ = "routes"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("game_id", "name", name="uq_routes_game_name"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(100))
|
||||
|
||||
@@ -17,6 +17,8 @@ class RouteEncounter(Base):
|
||||
pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.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)
|
||||
max_level: Mapped[int] = mapped_column(SmallInteger)
|
||||
|
||||
route: Mapped["Route"] = relationship(back_populates="route_encounters")
|
||||
pokemon: Mapped["Pokemon"] = relationship(back_populates="route_encounters")
|
||||
|
||||
Reference in New Issue
Block a user