--- id: 81f5a09d-e36b-4971-865a-8b79d6fb86d3 type: solution title: "Mantimon TCG: Phase 1 DB Models Complete" tags: [mantimon-tcg, database, sqlalchemy, alembic, phase-1, models] importance: 0.85 confidence: 0.8 created: "2026-01-27T14:52:52.270973+00:00" updated: "2026-01-27T14:52:52.270973+00:00" --- Implemented all Phase 1 database models for Mantimon TCG: MODELS CREATED: - User (app/db/models/user.py): OAuth support, premium subscription, relationships - Collection (app/db/models/collection.py): CardSource enum, card ownership tracking - Deck (app/db/models/deck.py): JSONB cards/energy_cards, validation state, starter decks - CampaignProgress (app/db/models/campaign.py): Single-player progress, medals, mantibucks - ActiveGame (app/db/models/game.py): In-progress games, GameType enum, Redis backup - GameHistory (app/db/models/game.py): Completed games, EndReason enum, replay data ALEMBIC SETUP: - Configured async Alembic in app/db/migrations/env.py - Generated and applied initial migration (7ac994d6f89c_initial_schema.py) - Black formatting enabled for migrations KEY PATTERNS: - All models inherit from Base with UUID id, created_at, updated_at - JSONB for flexible data (deck cards, campaign medals, game state) - Proper indexes on foreign keys and query-heavy columns - Relationships with cascade delete where appropriate - Enum types created at DB level (card_source, game_type, end_reason) DOCKER: - Using ports 5433 (Postgres) and 6380 (Redis) to avoid conflicts - docker-compose.yml updated, .env.example updated, config.py defaults updated