I'm actually running your app here and am not reproducing the issue. There's a few things going on here, and I can see the code here in your "master" branch at least hasn't been updated for 2.0.
I made a few small changes, "engine.has_table()" to "inspect(engine).has_table()", some strings print statements that needed to be changed for URL being a tuple "print('The database "%s" has been successfully initialized' % (engine.url, ))`, and I'm able, after doing "make development.db", to run bits of alembic downgrades and upgrades, with some bumps for various downgrades / upgrades not really being in sequence with what "make development.db" set up, or with each other (downgrades are hard). but for migrations that make it without errors, COMMIT is being emitted at the end, for example: (.venv) [classic@photon3 SoL:master]$ alembic -n app:main -c development.ini upgrade head 10:58:15 [I] sqlalchemy.engine.Engine: BEGIN (implicit) 10:58:15 [I] sqlalchemy.engine.Engine: PRAGMA main.table_info("alembic_version") 10:58:15 [I] sqlalchemy.engine.Engine: [raw sql] () 10:58:15 [I] sqlalchemy.engine.Engine: SELECT alembic_version.version_num FROM alembic_version 10:58:15 [I] sqlalchemy.engine.Engine: [generated in 0.00008s] () 10:58:15 [I] sqlalchemy.engine.Engine: ALTER TABLE competitors ADD COLUMN position SMALLINT DEFAULT 0 NOT NULL 10:58:15 [I] sqlalchemy.engine.Engine: [no key 0.00005s] () 10:58:15 [I] sqlalchemy.engine.Engine: UPDATE alembic_version SET version_num='448c00f2ec1e' WHERE alembic_version.version_num = 'ffec21d0a5a0' 10:58:15 [I] sqlalchemy.engine.Engine: [generated in 0.00010s] () 10:58:15 [I] sqlalchemy.engine.Engine: COMMIT 10:58:15 [I] sqlalchemy.engine.Engine: BEGIN (implicit) 10:58:15 [I] sqlalchemy.engine.Engine: ALTER TABLE matches ADD COLUMN breaker CHAR(1) 10:58:15 [I] sqlalchemy.engine.Engine: [no key 0.00006s] () 10:58:15 [I] sqlalchemy.engine.Engine: UPDATE alembic_version SET version_num='1e49ee0210d7' WHERE alembic_version.version_num = '448c00f2ec1e' 10:58:15 [I] sqlalchemy.engine.Engine: [generated in 0.00008s] () 10:58:15 [I] sqlalchemy.engine.Engine: COMMIT Overall, the issue that you are seeing is likely that there are .commit() calls missing whereas previously autocommit was occurring. So if you run your migrations under SQLAlchemy 1.4 with SQLALCHEMY_WARN_20=1 it *may* show some of these, if there were DDL or DML being emitted at least. But the debug lines for env.py I gave previously should also show if things are not lined up. On Sun, Jan 15, 2023, at 9:16 AM, Mike Bayer wrote: > can you add these assertions to env.py? > > with context.begin_transaction(): > assert not context.get_context()._in_external_transaction > assert not connection.in_transaction() > context.run_migrations() > > that's the condition necessary for begin_transaction() to call commit() at > the end. > > > On Sun, Jan 15, 2023, at 8:57 AM, Mike Bayer wrote: >> 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 >> >> <https://groups.google.com/d/msgid/sqlalchemy/c1edf82e-2051-4e32-b346-1136acfb1124%40app.fastmail.com?utm_medium=email&utm_source=footer>. > > > > -- > 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/79dac31b-500d-4d47-bb69-baae033d7ba5%40app.fastmail.com > > <https://groups.google.com/d/msgid/sqlalchemy/79dac31b-500d-4d47-bb69-baae033d7ba5%40app.fastmail.com?utm_medium=email&utm_source=footer>. -- 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/1103615f-70d3-4332-87f4-1903eea1475d%40app.fastmail.com.