3.9 KiB
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 |
|
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 timeout —
PooledPostgresqlDatabasenow usesautoconnect=Falseandtimeout=5for 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_URLenv 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
stratplayandstratgametables (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 properTrue/False(PR #94) - CustomCommandCreator.discord_id — aligned model field with BIGINT column type (PR #88)
- Literal validation on sort param —
GET /api/v3/playersnow 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 withloggercalls indb_engine.py(PR #53) - Removed unimplemented
is_tradeparameter 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_playreturns 500 instead of 404 (issue #109)test_batting_sbaplayer_career_totalsreturns 422 instead of 200 (issue #110)
Deployment Notes
- New env var required:
DISCORD_WEBHOOK_URLmust be set in the container environment. Checkdocker-compose.ymlpasses 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