Files
nuzlocke-tracker/.beans/nuzlocke-tracker-l7e3--database-schema-design.md
Julian Tabel d94364d6ce Add database schema with SQLAlchemy async + Alembic migrations
Set up PostgreSQL database layer with async SQLAlchemy 2.0 and asyncpg driver.
Implements 6 core tables (games, routes, pokemon, route_encounters, nuzlocke_runs,
encounters) with foreign keys, indexes, and an initial Alembic migration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:29:34 +01:00

1.6 KiB

title, status, type, priority, created_at, updated_at, parent, blocking
title status type priority created_at updated_at parent blocking
Database Schema Design completed task normal 2026-02-04T15:46:54Z 2026-02-05T12:29:19Z nuzlocke-tracker-f5ob
nuzlocke-tracker-bkhs
nuzlocke-tracker-k5lm
nuzlocke-tracker-hy41

Design and implement the database schema for persistent storage.

Decisions

  • Database: PostgreSQL 16 (already in docker-compose)
  • ORM: SQLAlchemy 2.0 (async) with asyncpg driver
  • Migrations: Alembic
  • Async: Full async — asyncpg + async SQLAlchemy sessions

Checklist

  • Choose database (PostgreSQL)
  • Set up database connection and ORM/query builder (SQLAlchemy 2.0 async + asyncpg)
  • Design and create tables/collections:
    • Games (id, name, slug, generation, region, box_art_url, release_year)
    • Routes (id, name, game_id, order)
    • Pokemon (id, national_dex, name, types[], sprite_url)
    • RouteEncounters (id, route_id, pokemon_id, encounter_method, encounter_rate) — unique(route, pokemon, method)
    • NuzlockeRuns (id, game_id, name, status, rules jsonb, started_at, completed_at)
    • Encounters (id, run_id, route_id, pokemon_id, nickname, status, catch_level, faint_level, caught_at)
  • Set up migrations system (Alembic)
  • Add seed data for initial games/routes/Pokémon
  • Create indexes for common queries (FK indexes on routes, route_encounters, nuzlocke_runs, encounters; status index on nuzlocke_runs)

Notes

  • Use foreign keys for referential integrity
  • Status fields should be enums
  • Use PostgreSQL enums or check constraints for status/type fields