Alembic few modules to single database

此生再无相见时 提交于 2019-12-08 06:19:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!