Constraint renaming in batch operations (Possible incompatibility with sqlalchemy v2.0.45) #1833
Replies: 3 comments 10 replies
|
odd because it's not like we dont have tests for renaming constraints in batch mode. though i guess the issue here is that the naming convention is using the older name. will have to see if we have regression tests for that. |
|
(edit: claude generated comment) Thanks for the detailed report. I dug into this and split it out into a tracked issue: #1834. Short version: this is an alembic batch-mode bug (surfaced, not caused, by the SQLAlchemy 2.0.45 SQLite reflection fix #12954). When a |
|
Thanks for looking into this! Should there be an addition to the current options?
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Used alembic version: 1.16.1 and 1.18.5
After upgrading sqlalchemy to version 2.0.45, one of my alembic migrations generated different SQL for constraints names.
It fails to rename an existing constraint to a new table name, which means that further migrations might fail to drop said constraint as it it still referring to the old name. Is my usage wrong?
The migration in question looks like this:
in version 2.0.44, the generated SQL reads like this:
Now in version 2.0.45 and newer, it reads like this:
I assume this is related to either sqlalchemy#12954 or sqlalchemy#12924. See also other changes in sqlalchemy v2.0.45
In addition, when trying to use
batch_op.create_forgeign_keyto manually create the missing constraint, there is no SQL rendered for a constraint at all.All reactions