claude-home/major-domo/database-release-2026.4.7.md

3.9 KiB

title description type domain tags
Database API Release — 2026.4.7 Major cleanup: middleware connection management, security hardening, performance fixes, and Pydantic/Docker upgrades. reference major-domo
release-notes
deployment
database
major-domo

Database API Release — 2026.4.7

Date: 2026-04-07 Tag: TBD (next CalVer tag after 2026.4.5) Image: manticorum67/major-domo-database:{tag} + :latest Server: ssh akamai (~/container-data/sba-database) Deploy method: git tag -a YYYY.M.BUILD -m "description" && git push origin YYYY.M.BUILD → CI builds Docker image → pull + restart on akamai

Release Summary

Large batch merge of 22 PRs covering connection management, security hardening, query performance, code cleanup, and infrastructure upgrades. The headline change is middleware-based DB connection management replacing 177+ manual db.close() calls across all routers.

Changes

Architecture

  • Middleware connection management — replaced all manual db.close() calls with HTTP middleware that opens connections before requests and closes after responses (PR #97)
  • Disabled autoconnect + pool timeoutPooledPostgresqlDatabase now uses autoconnect=False and timeout=5 for tighter connection lifecycle control (PR #87)
  • Migration tracking system — new system for tracking applied database migrations (PR #96)

Security

  • Removed hardcoded webhook URL — Discord webhook URL moved to DISCORD_WEBHOOK_URL env var (PR #83). Old token is in git history — rotate it.
  • Removed hardcoded fallback DB password — no more default password in db_engine.py (PR #55)
  • Removed token from log warnings — Bad Token log messages no longer include the raw token value (PR #85)

Performance

  • Batch standings updates — eliminated N+1 queries in recalculate_standings (PR #93)
  • Bulk DELETE in career recalculation — replaced row-by-row DELETE with single bulk operation (PR #92)
  • Added missing FK indexes — indexes on FK columns in stratplay and stratgame tables (PR #95)
  • Fixed total_count in get_totalstats — count no longer overwritten with page length (PR #102)

Bug Fixes

  • Boolean field comparisons — replaced integer comparisons (== 1) with proper True/False (PR #94)
  • CustomCommandCreator.discord_id — aligned model field with BIGINT column type (PR #88)
  • Literal validation on sort paramGET /api/v3/players now validates sort values (PR #68)
  • PitchingStat combined_season — added missing classmethod for combined season stats (PR #67)

Code Cleanup

  • Removed SQLite fallback code from db_engine.py (PR #89)
  • Replaced deprecated .dict() with .model_dump() across all Pydantic models (PR #90)
  • Added type annotations to untyped query parameters (PR #86)
  • Removed commented-out dead code blocks (PR #48)
  • Replaced print() debug statements with logger calls in db_engine.py (PR #53)
  • Removed unimplemented is_trade parameter from transactions endpoint (PR #57)
  • Eliminated N+1 queries in get_custom_commands (PR #51)

Infrastructure

  • Docker base image upgraded from Python 3.11 to 3.12 (PR #91)
  • CI switched to tag-triggered builds (PR #107)

Known Issues

  • ~20 unit tests broken by SQLite fallback removal — tests relied on SQLite that no longer exists (issue #108)
  • test_get_nonexistent_play returns 500 instead of 404 (issue #109)
  • test_batting_sbaplayer_career_totals returns 422 instead of 200 (issue #110)

Deployment Notes

  • New env var required: DISCORD_WEBHOOK_URL must be set in the container environment. Check docker-compose.yml passes it through.
  • Rotate webhook token — the old hardcoded token is in git history.
  • Migration tracking: new migration table will be created on first run.
  • Rollback: docker compose pull manticorum67/major-domo-database:2026.4.5 && docker compose up -d