I would love to have the option to check, in my ci pipeline, if the migrations are up to date with the implementation of the models in the code.
We are almost there
I feel like we can get quite close to this. We can spin up an SQLite and apply the migration to the database, we can even call command.revision(alembic_cfg, autogenerate=True). However, that, of course, creates a migration file instead of returning a concise list of changes to the python runtime.
My search for solutions
It seems like the generation of changes happens somewhere in alembic.autogenerate.compare._populate_migration_script but since this is a protected method I am hesitant to develop against it.
What I would love
I would absolutely love it if there would be some documentation on how to properly test alembic:
- Assert that upgrading works
- Assert that downgrading works
- Assert that migrations are up-to-date with the current codebase. (IMO the most important one)
Of course, the documentation would actually require a good interface to do those things with. But I do believe this would eliminate a significant set of production database issues.
I would love to have the option to check, in my ci pipeline, if the migrations are up to date with the implementation of the models in the code.
We are almost there
I feel like we can get quite close to this. We can spin up an SQLite and apply the migration to the database, we can even call
command.revision(alembic_cfg, autogenerate=True). However, that, of course, creates a migration file instead of returning a concise list of changes to the python runtime.My search for solutions
It seems like the generation of changes happens somewhere in
alembic.autogenerate.compare._populate_migration_scriptbut since this is a protected method I am hesitant to develop against it.What I would love
I would absolutely love it if there would be some documentation on how to properly test alembic:
Of course, the documentation would actually require a good interface to do those things with. But I do believe this would eliminate a significant set of production database issues.