Commit Graph

38 Commits

Author SHA1 Message Date
Cal Corum
985a6ed2b0 Add default ORDER BY id to BaseModel.select() for PostgreSQL compatibility
PostgreSQL does not guarantee row order without ORDER BY, unlike SQLite
which implicitly returned rows by rowid. This caused bugs where queries
returned results in unexpected order (e.g., get_team_by_owner returning
gauntlet team instead of main team).

Override select() in BaseModel to add default ordering by id. Explicit
.order_by() calls will override this default.

Also mark legacy db_engine.py as deprecated.
2026-01-31 16:06:44 -06:00
Cal Corum
8c039dedf8 Fix DateTimeField defaults for PostgreSQL compatibility
Paperdex and GauntletRun models used int timestamps as defaults which
worked in SQLite but fail in PostgreSQL. Changed to datetime.now.
2026-01-31 15:56:33 -06:00
Cal Corum
3dce457463 Fix flashback cardset legality and rewards timestamp handling
- Add 2018 Promos (14) and 2022 Promos (4) to flashback mode legal cardsets
- Convert Unix timestamps to datetime in rewards POST/PATCH for PostgreSQL

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:08:21 -06:00
Cal Corum
92fc101e38 Fix PostgreSQL compatibility for GROUP BY queries and aggregations
- Fix NULL handling for FK checks in stratplays.py: use x.field_id instead
  of x.field to avoid triggering FK lookups on potentially missing rows
- Cast boolean is_start to integer for SUM() - PostgreSQL cannot sum booleans
- Add missing GROUP BY clause to Decision aggregate query
- Add Case import for boolean-to-integer casting
- Update migration script with boolean/datetime column mappings
- Exclude legacy battingstat/pitchingstat tables from migration
- Add comprehensive POSTGRES_MIGRATION_GUIDE.md documentation

Tested: /plays/batting and /plays/pitching endpoints work with group_by=player
2026-01-26 21:59:25 -06:00
Cal Corum
0cba52cea5 PostgreSQL migration: Complete code preparation phase
- Add db_helpers.py with cross-database upsert functions for SQLite/PostgreSQL
- Replace 12 on_conflict_replace() calls with PostgreSQL-compatible upserts
- Add unique indexes: StratPlay(game, play_num), Decision(game, pitcher)
- Add max_length to Team model fields (abbrev, sname, lname)
- Fix boolean comparison in teams.py (== 0/1 to == False/True)
- Create migrate_to_postgres.py with ID-preserving migration logic
- Create audit_sqlite.py for pre-migration data integrity checks
- Add PROJECT_PLAN.json for migration tracking
- Add .secrets/ to .gitignore for credentials

Audit results: 658,963 records across 29 tables, 2,390 orphaned stats (expected)

Based on Major Domo migration lessons learned (33 issues resolved there)
2026-01-25 23:05:54 -06:00
Cal Corum
fbe8623eb4 Merge branch 'main' into postgres-migration 2026-01-25 22:53:35 -06:00
Cal Corum
a34e553b25 2005 Live Series Updates 2025-11-08 18:25:08 -06:00
Cal Corum
f6e8aa7108 CLAUDE: Add PostgreSQL support and table names to models
- Add environment-based PostgreSQL configuration to db_engine.py
- Add table_name to all 30 models (Meta class)
- Update db_migrations.py to auto-select migrator based on DB type
- Add comprehensive PostgreSQL migration plan document
2025-11-07 10:23:14 -06:00
Cal Corum
2791e1964b Gauntlet 8 updates 2025-05-29 22:19:19 -05:00
Cal Corum
acb65ef47c Gauntlet 7 cardsets 2024-12-23 16:13:05 -06:00
Cal Corum
21fe5c419a Flip image libraries due to white bar bug 2024-11-04 23:17:07 -06:00
Cal Corum
1e4569dfbf Clean up root_validators
Remove root_path from FastAPI
Update Season 8 Cardsets
Force pydantic 1.x
2024-11-03 01:46:40 -05:00
Cal Corum
17416cd50f Log mlbplayer dupes
Update cardsets for season 8
2024-11-02 23:44:32 -05:00
Cal Corum
889db717d1 Update for Swagger URL 2024-07-07 22:18:51 -05:00
Cal Corum
d0c3caaf87 Add support for buying Promo pack 2024-05-13 17:03:48 -05:00
Cal Corum
f0e3b38938 Cardset updates 2024-05-13 15:37:08 -05:00
Cal Corum
b9a64e8333 2024 Updates 2024-04-21 17:48:51 -05:00
Cal Corum
62bcfd5e45 Cardset updates 2024-03-08 00:26:00 -06:00
Cal Corum
563f46c30c Update human legal-check 2024-03-01 20:01:56 -06:00
Cal Corum
ac14e8517e Add high-inning preference for AI lineups 2024-02-24 23:34:36 -06:00
Cal Corum
1f917b8a6b Mark '18 Promo as ranked legal 2024-02-24 21:36:56 -06:00
Cal Corum
e217375974 Update db_engine.py
Update ranked cardsets
2023-12-04 13:40:10 -06:00
Cal Corum
dbbe257654 Update db_engine.py
Move 2023 from primary to secondary in the gauntlet
2023-11-29 10:34:41 -06:00
Cal Corum
eb0babc78c Major League Campaign update
Prep for flashback campaign
2023-11-05 20:04:30 -06:00
Cal Corum
ed296a0b13 Update Major League cardsets 2023-10-29 14:10:27 -05:00
Cal Corum
e8a5c6f503 Added gauntlet cardset data 2023-10-23 00:58:47 -05:00
Cal Corum
714345c589 Decision endpoint functional 2023-10-22 00:08:11 -05:00
Cal Corum
edde7a1b82 StratPlays added 2023-10-21 19:54:31 -05:00
Cal Corum
0a59d3e98d Moved AI lineup creation to db 2023-10-21 15:31:36 -05:00
Cal Corum
96be768ec9 Pre-Season 6 Updates 2023-10-19 23:16:47 -05:00
Cal Corum
485a046855 First pass of real card gen 2023-10-11 00:58:30 -05:00
Cal Corum
07c1b51d0f Bug fixes for unique indeces 2023-10-03 12:06:48 -05:00
Cal Corum
8a0d094227 Scouting tables added to db 2023-09-22 01:29:35 -05:00
Cal Corum
995735d878 Added cardpositions 2023-09-16 18:36:15 -05:00
Cal Corum
51a5251c92 Add pitchercards and ratings 2023-09-16 00:05:10 -05:00
Cal Corum
22cc01d200 Added battingcards and ratings 2023-09-15 22:38:15 -05:00
Cal Corum
88b723d9f2 Added query_to_csv helper 2023-09-15 00:01:59 -05:00
Cal Corum
e7039eb83e Initial Commit with /current 2023-09-13 14:44:26 -05:00