You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(api): replace integer PK with UUID v4 for Player entity (#66)
- Add HyphenatedUUID custom TypeDecorator storing UUIDs as CHAR(36) in
SQLite and returning uuid.UUID objects in Python
- Split PlayerModel into PlayerRequestModel (no id, for POST/PUT) and
PlayerResponseModel (includes id: UUID, for GET/POST responses)
- Update all route path parameters and service signatures from int to UUID
- Add retrieve_by_squad_number_async() service method; expose via
GET /players/squadnumber/{squad_number} route
- Change POST conflict detection from ID lookup to squad_number uniqueness
- Return created Player from create_async() after session refresh
- Add migration_001_starting_eleven.py: recreates players table with UUID
PK and seeds 11 starters with deterministic UUID v5 values
- Add migration_002_substitutes.py: seeds 14 substitutes with deterministic
UUID v5 values (requires migration 001 to run first)
- Update player_stub.py with UUID-based fixtures; unknown_player() now uses
a nil-style UUID instead of an integer
- Update test suite to assert UUID presence and version (UUID v4 for
API-created records); DELETE resolves target UUID via squad number lookup
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
-**Async**: All routes and service functions must be `async def`; use `AsyncSession` (never `Session`); use `aiosqlite` (never `sqlite3`); use SQLAlchemy 2.0 `select()` (never `session.query()`)
-**Models**: `PlayerRequestModel` (no `id`, used for POST/PUT) and `PlayerResponseModel` (includes `id: UUID`, used for GET/POST responses); never use the removed `PlayerModel`
43
+
-**Primary key**: UUID surrogate key (`id`) — opaque, internal, used for all CRUD operations. UUID v4 for API-created records; UUID v5 (deterministic) for migration-seeded records. `squad_number` is the natural key — human-readable, domain-meaningful, preferred lookup for external consumers
-`HyphenatedUUID` custom `TypeDecorator` in `schemas/player_schema.py` storing UUIDs as hyphenated `CHAR(36)` strings in SQLite, returning `uuid.UUID` objects in Python (#66)
53
+
47
54
### Changed
48
55
56
+
-`PlayerModel` split into `PlayerRequestModel` and `PlayerResponseModel` in `models/player_model.py` (#66)
57
+
- All route path parameters and service function signatures updated from `int` to `uuid.UUID` (#66)
58
+
- POST conflict detection changed from ID lookup to `squad_number` uniqueness check (#66)
59
+
-`tests/player_stub.py` updated with UUID-based test fixtures (#66)
60
+
-`tests/test_main.py` updated to assert UUID presence and format in API responses (#66)
0 commit comments