SQLite schema, key tables, KanbanStage derivation, and Alembic migration workflow.
The backend uses SQLite for local development with a schema that is PostgreSQL-compatible. Switching databases requires only a change to the DB_ENGINE environment variable — no code changes.
KanbanStage is not a column on callingproposal. The current stage of a proposal is derived from the to_stage value of its most recent kanbanupdate row.
There is no single source-of-truth column — you must query the latest KanbanUpdate to determine where a proposal currently sits in the pipeline.
Value
Stage
Notes
0
SP_APPROVAL
Starting stage for new callings
1
HC_APPROVAL
Auto-advances after SP approval threshold is met
2
INTERVIEW
Starting stage for releases (skips 0–1)
3
SUSTAIN
After interview
4
SET_APART
After sustaining (callings only; releases skip this stage)
5
LCR_UPDATE
After set apart
6
DONE
Terminal stage
Auto-advance thresholds are controlled by the SP_APPROVAL_THRESHOLD and HC_APPROVAL_THRESHOLD environment variables.
Always run Alembic commands from the backend/ directory.
uv run alembic -c alembic.ini revision --autogenerate -m "add my column"
uv run alembic -c alembic.ini upgrade head
uv run alembic -c alembic.ini downgrade -1
uv run alembic -c alembic.ini history --verbose
Autogenerate compares the current SQLModel models against the current database schema. Make sure your model changes are saved before running revision --autogenerate.
Tests override the get_session() FastAPI dependency with a session bound to a temporary SQLite file created at test start and deleted at test end. The real database.db is never touched during a test run.
This means migrations do not need to be applied before running tests — the test database is created fresh from SQLModel metadata each time.
# Run all testsuv run pytest# Run a single test fileuv run pytest src/tests/test_users.py# Run a single testuv run pytest src/tests/test_auth.py::test_login_sets_cookie_and_returns_token