问题
We need to build a large application that split to multiple modules,
App
- Module1 --> AppDb
- Module2 --> AppDb
- Module3 --> AppDb
Each module, we would like to add alembic version, all modules connect to single database. But we cannot add revision, because it's conflict to other module's revision (because all version store in same table alembic_version, so the migrations conflict with each other).
回答1:
If you're using separate simple migrations in each of Module1
, Module2
and Module3
each with their own env.py
(or similar), the solution could be to use the version_table
argument to context.configure, that allows you to override the name of the version table.
i.e. modify the env.py
to something like
context.configure(
connection=connection,
target_metadata=target_metadata,
version_table='alembic_module1_version'
)
来源:https://stackoverflow.com/questions/46073846/alembic-few-modules-to-single-database