Run alembic upgrade migrations in a transaction

家住魔仙堡 提交于 2019-11-29 09:57:52

My understanding is alembic runs inside a transaction for databases that support it, like Postgres. If you're on a database that does not support this (cough MySQL cough), you can't use this functionality.

Alessandro Cosentino

That's something you can decide within the env.py, which is where you customize the behaviour of the migrations to suit your setup. You can see how to make sure your upgrades happen in a transaction from the template provided as an example for generic databases: https://github.com/zzzeek/alembic/blob/eaaafbca88f85f5432e04affe1f94cbf1ad06080/alembic/templates/generic/env.py#L64

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