Skip to content

feat: manage database schema via alembic#119

Merged
MateoLostanlen merged 6 commits intomainfrom
feat/alembic-migrations
May 1, 2026
Merged

feat: manage database schema via alembic#119
MateoLostanlen merged 6 commits intomainfrom
feat/alembic-migrations

Conversation

@MateoLostanlen
Copy link
Copy Markdown
Member

  • Replace SQLModel.metadata.create_all with Alembic migrations as the sole owner of the DB schema. Containers now run alembic upgrade head on startup; an autogenerated initial revision captures all current tables, indexes and enums.
  • Adopt the pyro-api migration layout: src/migrations/{env.py, script.py.mako, versions/}, with AutoString rendered as plain sa.String so revision files don't import sqlmodel.
  • Update test conftest to reset schema through alembic upgrade head so tests exercise the same migration path as production. All 331 tests pass.
  • Add make migrate m="..." (autogenerate) and make migrate-up (apply) wrappers, mirroring pyro-api.

Replace SQLModel.metadata.create_all with alembic upgrade head in all
compose entrypoints. Drop init_db from app.db and from main.py
lifespan. Add make migrate / migrate-up wrappers.
Address review feedback: PostgreSQL enum types are not removed by
op.drop_table, so a downgrade-then-upgrade cycle would fail with
duplicate enum errors. Also enable compare_type=True in the online
migration context so autogenerate detects column type changes.
@MateoLostanlen MateoLostanlen merged commit ccd433f into main May 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant