0001: Postgres, SQLModel and Alembic
Status: Accepted Date: 2026-10-17
Context
We need relational data (trips and their members now; itinerary and expenses later) and, eventually, vector search for the AI agent. Two developers need identical local databases, and the schema must evolve without breaking older app builds.
Decision
- PostgreSQL 17. pgvector can be added later as an extension, so embeddings need no second database; RDS supports both.
- SQLModel for models: one class serves as the table definition and the Pydantic schema, which matches FastAPI. Anything SQLModel can't express uses SQLAlchemy directly:
sa_columnfor column-level options (foreign-keyondelete, and later enums andJSONB), and__table_args__for table constraints such as CHECKs. - Alembic owns the schema, with autogenerate as a starting point that is always reviewed by hand.
- Two roles: the API can't run DDL; only the migrator can.
- Postgres in Docker, everything else native on Windows, matching how the team already works (see the README history).
Alternatives considered
- Plain SQLAlchemy 2.0 models: more explicit, but they duplicate the Pydantic schemas. We'd revisit this if
sa_columnworkarounds start to dominate. - A dedicated vector DB (Pinecone, Qdrant): an extra service and a sync problem, for data that's always filtered by
trip_idanyway. - Running the API in Docker too: slower reloads on Windows. We'll containerise it once deploys need it.
Consequences
- Every schema change is a reviewed migration, and
reset-dbproves its downgrade. vesper_appcan't create tables, so a bug or an injection can't change the schema.- Changing the role setup requires recreating the local volume.