SQL Database: SQLModel + Alembic
Recipes (PostgreSQL)
uv add psycopg[binary] sqlmodel alembic
uv run alembic init --template pyproject alembic
# alembic/env.py
from sqlmodel import SQLModel
target_metadata = SQLModel.metadata
# alembic/script.py.mako
import sqlmodel
uv run alembic revision --autogenerate -m "Initial migration."
uv run alembic upgrade head
# rollback to the previous migration
uv run alembic downgrade -1
# show migration history
uv run alembic history
# show the current revision
uv run alembic current
References