Skip to content
Discussion options

You must be logged in to vote

After some debugging, caught the mistake in env.py:

try:
    if isinstance(connectable, AsyncEngine):
        async with connectable.connect() as conn: # <-- here
            await conn.run_sync(do_run_migrations)
    else:
        with connectable.connect() as conn: # <-- and here
            do_run_migrations(conn)
finally:
    if isinstance(connectable, AsyncEngine):
        await connectable.dispose()
    else:
        connectable.dispose()

With the previous code, it starts a transaction before the migration starts, which causes the final code that executes in the migration script to fail because a new transaction wasn't started. This could very well be a bug.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by smac89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant