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:
Julian Tabel
2026-02-05 15:08:54 +01:00
parent 08c05f2a2f
commit cfd4c51514
22 changed files with 56871 additions and 17 deletions

View File

@@ -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))

View File

@@ -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")