It's not supposed to have this problem with a clean env.py.    If you were 
running commands on the connection() ahead of calling 
context.begin_transaction(), that would explain things but I dont see that in 
your example.

short answer call connection.commit() at the end of the block , however that 
should not be needed with a plain env.py as you have.   so we'd like to know 
what is happening in this example (or if alembic is just broken and despite all 
my testing I am somehow missing something basic)

On Sun, Jan 15, 2023, at 5:34 AM, Lele Gaifax wrote:
> Hi all,
> 
> I'm in the process of upgrading another app to SA 2, and got no suprises
> in the process: everything works smooth and all tests pass.
> 
> Going one step further, implementing a requested feature that involves a
> database migration, I'm facing a show stopper, probably due to a silly
> oversight of mine that already took a couple of hours of investigation:
> the final step of the "alembic upgrade" is invariably a "ROLLBACK",
> instead of a "COMMIT":
> 
> UPDATE alembic_version SET version_num='aa0288cff765' WHERE 
> alembic_version.version_num = '1e49ee0210d7'
> ROLLBACK
> 
> Simply downgrading SA to 1.4.46, without any other change, "fixes" the
> issue and the migration ends with a "COMMIT" as expected.
> 
> The Alembic environment
> 
>   https://gitlab.com/metapensiero/SoL/-/blob/master/alembic/env.py
> 
> is rather old being the same as when I started using Alembic in this
> project (ten years, omg!), but even modernizing it using Alembic 1.9.2
> template didn't help: when the connection is closed, either explicitly
> by the old try:finally: code or implicitly by the new
> connectable.connect() context manager, a ROLLBACK is issued.
> 
> Do you have an hint on what I'm missing?
> 
> Thanks in advance,
> bye, lele.
> -- 
> nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
> real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
> l...@metapensiero.it  |                 -- Fortunato Depero, 1929.
> 
> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com 
> <mailto:sqlalchemy%2bunsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/87h6wsdr1y.fsf%40metapensiero.it.
> 

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/c1edf82e-2051-4e32-b346-1136acfb1124%40app.fastmail.com.

Reply via email to