I have two Flask applications using Flask-Migrate and Alembic.
There are three tables, with one table that is shared between the two Flask applications, and is represented by shared_models.py
I am running into the difficulty that the shared table gets stamped with one of the projects alembic_version, and then the other project complains about it, despite the shared_models.py
file being identical.
What is a good strategy for handling this kind of environment?
One option would be to use two separate databases for your two applications. You will have to decide which of the two apps owns the table that is shared. Each application tracks migrations on its own database, and the application that does not own the shared table accesses this table from the other app's database via the binds feature of Flask-SQLAlchemy.
This is not the only option. Another that comes to mind, is to keep using a single database, but configure Alembic on one of the two apps to ignore this shared table. This would have to be done manually on the
env.py
file, Flask-Migrate does not have direct support to generate the code to ignore tables.