--- id: a918ab78-70dc-49bf-bcb8-e98e6bdd624e type: solution title: "Paper Dynasty: Fixed card generation after PostgreSQL migration" tags: [paper-dynasty, postgresql, card-generation, jinja2, templates, migration, fix] importance: 0.9 confidence: 0.8 created: "2026-02-02T01:39:08.756078+00:00" updated: "2026-02-02T01:39:08.756078+00:00" relations: - target: 2937a962-4a6e-44fb-b7c7-7d472df7fc0e type: RELATED_TO direction: outgoing strength: 0.5 - target: 4bb882a6-1ef9-4ec4-873d-816881f6670b type: RELATED_TO direction: incoming strength: 0.5 --- **Problem**: After migrating Paper Dynasty database from SQLite to PostgreSQL, card generation endpoints returned 'Internal Server Error' with jinja2.exceptions.TemplateNotFound for 'player_card.html'. **Root Cause**: The storage/templates/ directory containing card rendering templates (player_card.html, topright_batter.html, topright_pitcher.html, etc.) was not included in the production deployment. The directory is gitignored and was lost during migration. **Solution**: 1. Recovered templates from old server: `scp pd-database:/home/cal/container-data/pd-database/storage/templates/*.html ../database/storage/templates/` 2. Updated .gitignore to allow templates: Add `!storage/templates/` after `storage/` 3. Force-added to git: `git add -f storage/templates/` 4. For immediate fix, SCP'd directly to production: `scp -r ../database/storage/templates/ akamai:/root/container-data/paper-dynasty/storage/` 5. Restarted API: `ssh akamai 'cd /root/container-data/paper-dynasty && docker compose restart api'` **Templates Required**: - player_card.html (main card template) - topright_batter.html, topright_pitcher.html (position-specific headers) - results_vl.html, results_vr.html (batting results vs L/R) - result_columns.html, style.html (layout/styling) **Prevention**: When deploying database container updates, verify storage/templates/ is mounted or included in image. **Related**: PostgreSQL migration guide at /mnt/NV2/Development/paper-dynasty/database/docs/POSTGRES_MIGRATION_GUIDE.md