]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Add commit to cookbook example
authorCaselIT <cfederico87@gmail.com>
Wed, 11 Jan 2023 20:17:33 +0000 (21:17 +0100)
committerCaselIT <cfederico87@gmail.com>
Wed, 11 Jan 2023 20:17:58 +0000 (21:17 +0100)
A commit is now required to end the transaction before start
executing the migration

Fixes: #1150
Change-Id: I704db15155454dafed9d15f768b97f8e2ebfff81

docs/build/cookbook.rst

index 5b12c6b049be1409e8d9e81acd0e297be88b8f29..8ac5bfc00dab9861a3b505dde3b12896a03ce741 100644 (file)
@@ -845,6 +845,8 @@ schema or another.
                 # PostgreSQL will emit all CREATE / ALTER / DROP statements
                 # in terms of this schema by default
                 connection.execute(text('set search_path to "%s"' % current_tenant))
+                # in SQLAlchemy v2+ the search path change needs to be committed
+                connection.commit()
 
                 # make use of non-supported SQLAlchemy attribute to ensure
                 # the dialect reflects tables in terms of the current tenant name