PH1.1 — Schema 0002: master data tables and typed mapped classes #9

Closed
opened 2026-09-11 09:02:09 +00:00 by bart · 2 comments
Collaborator

Parent

Row PH1.1 in docs/12-implementation-plan.md (branch, owned paths and doc section are defined there).

What to build

Migration 0002 creates every master-data table from docs/08-data-model.md (vehicle, ingest_record, site, presence_block, presence_window, catalogue tables, site_suitability, job, person with preferred_username, crew, crew_member, crew_skill, shift) with all indexes, soft-delete columns and geography(…, 4326) geometry, and the matching typed SQLAlchemy mapped classes.

Acceptance criteria

  • alembic upgrade head then downgrade -1 round-trips cleanly on a real Postgres (testcontainers)
  • Every table, column, constraint and index in docs/08-data-model.md for these aggregates exists in the migration
  • Mapped classes are fully typed and pass mypy --strict; catalogue values are table rows, not enums
  • Soft-delete (deleted_at) present on all master data; no hard-delete path

Blocked by

  • #4 — API skeleton: core, router discovery, healthz, db + audit hook, alembic 0001, CLI
## Parent Row **PH1.1** in `docs/12-implementation-plan.md` (branch, owned paths and doc section are defined there). ## What to build Migration `0002` creates every master-data table from docs/08-data-model.md (vehicle, ingest_record, site, presence_block, presence_window, catalogue tables, site_suitability, job, person with `preferred_username`, crew, crew_member, crew_skill, shift) with all indexes, soft-delete columns and `geography(…, 4326)` geometry, and the matching typed SQLAlchemy mapped classes. ## Acceptance criteria - [x] `alembic upgrade head` then `downgrade -1` round-trips cleanly on a real Postgres (testcontainers) - [x] Every table, column, constraint and index in docs/08-data-model.md for these aggregates exists in the migration - [x] Mapped classes are fully typed and pass `mypy --strict`; catalogue values are table rows, not enums - [x] Soft-delete (`deleted_at`) present on all master data; no hard-delete path ## Blocked by - #4 — API skeleton: core, router discovery, healthz, db + audit hook, alembic 0001, CLI
Owner

Starting on this. Branch feature/db-schema-master-data, branched from origin/develop (not mainmain does not yet contain backend/; #4/#51 API-skeleton only merged into develop so far). Owning backend/alembic/versions/** and backend/src/polaris/db/models/** only, per CLAUDE.md.

Note: backend/tests/conftest.py and backend/tests/integration/db/test_migrations.py currently pin postgres:16-alpine for the testcontainers fixture; per conftest.py's own header comment ("Geography-typed tables ... will need to switch this fixture's image"), this is the first ticket to introduce geography columns, so I'll switch those two fixtures to a PostGIS-enabled image as part of this PR rather than opening a separate seam request, since the header explicitly anticipates this. Will call it out clearly in the PR.

Starting on this. Branch `feature/db-schema-master-data`, branched from `origin/develop` (not `main` — `main` does not yet contain `backend/`; #4/#51 API-skeleton only merged into `develop` so far). Owning `backend/alembic/versions/**` and `backend/src/polaris/db/models/**` only, per CLAUDE.md. Note: `backend/tests/conftest.py` and `backend/tests/integration/db/test_migrations.py` currently pin `postgres:16-alpine` for the testcontainers fixture; per `conftest.py`'s own header comment ("Geography-typed tables ... will need to switch this fixture's image"), this is the first ticket to introduce `geography` columns, so I'll switch those two fixtures to a PostGIS-enabled image as part of this PR rather than opening a separate seam request, since the header explicitly anticipates this. Will call it out clearly in the PR.
Owner

Done — PR #58 (feature/db-schema-master-datamain): #58

All four acceptance criteria ticked above. mypy --strict, ruff, and the full backend test suite (35 tests, incl. alembic upgrade head / downgrade -1 / upgrade +1 against real Postgres+PostGIS via testcontainers) are green.

Two notes for other sessions:

  • Branched from origin/develop originally (main had no backend/ yet at the time); rebased onto main once develop was retired mid-session — PR now targets main.
  • Discovered and fixed a real bug in polaris/db/audit.py (outside this ticket's owned paths) blocking every future Auditable class with a server-generated identity PK — see seam-request issue #57 for the full writeup. db/audit.py on main after this merges has that fix; rebase onto it if you're touching Auditable/audit_entity_id.
Done — PR #58 (`feature/db-schema-master-data` → `main`): https://git.xor.nu/patrick/Polaris/pulls/58 All four acceptance criteria ticked above. mypy --strict, ruff, and the full backend test suite (35 tests, incl. `alembic upgrade head` / `downgrade -1` / `upgrade +1` against real Postgres+PostGIS via testcontainers) are green. Two notes for other sessions: - Branched from `origin/develop` originally (main had no `backend/` yet at the time); rebased onto `main` once `develop` was retired mid-session — PR now targets `main`. - Discovered and fixed a real bug in `polaris/db/audit.py` (outside this ticket's owned paths) blocking every future `Auditable` class with a server-generated identity PK — see seam-request issue #57 for the full writeup. `db/audit.py` on `main` after this merges has that fix; rebase onto it if you're touching `Auditable`/`audit_entity_id`.
patrick self-assigned this 2026-09-11 11:44:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
patrick/Polaris#9
No description provided.