Alembic: Check if revision --autogenerate returns no ops

Created on 30 Sep 2020  路  2Comments  路  Source: sqlalchemy/alembic

Question
What would be the recommended approach to verify that autogenerating a revision would return no operations?

The goal is to have that check run as part of a test suite or on CI so any changes to sqla models that don't have an associated migration are caught immediately.

thanks!

question

Most helpful comment

for CI purposes people usually use some variant of the recipe at https://alembic.sqlalchemy.org/en/latest/api/autogenerate.html#getting-diffs , where you run the diff from your current metadata model against the database. if the diff is empty, then nothing was autogenerated.

All 2 comments

for CI purposes people usually use some variant of the recipe at https://alembic.sqlalchemy.org/en/latest/api/autogenerate.html#getting-diffs , where you run the diff from your current metadata model against the database. if the diff is empty, then nothing was autogenerated.

Exactly what I was looking for. Thank you

Was this page helpful?
0 / 5 - 0 ratings