3.6 KiB
3.6 KiB
MTG Online Backend - Docker Migration Plan
Overview
Migrate from internal database to Dockerized PostgreSQL with mtgjson.com "All Printings" dataset.
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Docker Compose │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────┐ ┌──────────────────────────┐ │
│ │ Backend Container │───▶│ PostgreSQL Container │ │
│ │ (FastAPI app) │ │ (MTG Data + App DB) │ │
│ │ │ │ │ │
│ │ - API endpoints │ │ - mtgonline_db (app) │ │
│ │ - Auth system │ │ - mtgdata_db (mtgjson) │ │
│ │ - Weekly refresh │ │ │ │
│ └─────────────────────┘ └──────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Tasks
1. mtgjson Dataset Analysis
- Download and examine All Printings dataset
- Map mtgjson schema to SQLAlchemy models
- Identify card image files (PNG/JPG)
- Plan database schema for card data
2. Docker Infrastructure
- Create Dockerfile for backend
- Create docker-compose.yml with PostgreSQL
- Configure environment variables
- Set up volume mounts for data persistence
- Configure health checks
3. Database Migration
- Create migration script for mtgjson schema
- Update models.py with MTG card models
- Add multi-database support (mtgonline + mtgdata)
- Create schema for weekly refresh
4. Weekly Refresh Logic
- Create refresh script to download latest mtgjson
- Implement incremental update logic
- Add database cleanup for unused cards
- Schedule via cron in Docker container
5. Card Image Support
- Verify image files in dataset (setJSON)
- Add image storage/CDN support
- Create API endpoints for card images
Files to Create/Modify
Docker Files
backend/Dockerfiledocker-compose.ymlbackend/.dockerignore
Database Migration
backend/app/core/database_multi.py(multi-database support)backend/scripts/refresh_mtg.py(weekly refresh)backend/scripts/init_mtg_db.py(initial mtgjson import)
Configuration
backend/.env.example(updated with Docker settings)backend/app/core/settings.py(add MTG settings)
Models
backend/app/models/mtg_models.py(mtgjson card models)backend/app/models/models.py(update for multi-DB)
Commands
Build and Run
cd /home/wall-o/projects/mtgonline
docker-compose up -d
docker-compose logs -f backend
Database Refresh
docker-compose exec backend python -m app.scripts.refresh_mtg
Check Status
docker-compose ps
docker-compose logs backend
Status: IN PROGRESS
- Current step: Creating Docker infrastructure
- Next: Download mtgjson dataset and analyze schema