unnamed constraint concerns #1715
-
A few years ago I was working on a PR for SQLAlchemy and was testing the naming conventions on a project. I accidentally never undid this change:
I'm now integrating Alembic onto this project and seeing a few oddities: 1- If I use autogenerate for migrations, alembic wants to set up a named foreign key. I can disable this by removing the 2- Unique constraints are an issue. If I run a migration with the
This seems weird and is problematic. I assume I am doing something very wrong here, as Alembic and SQLAlchemy are rock solid. This is an example of the generated migration that causes the behavior:
UPDATE After a bit of testing and digging through Alembic and SQLAlchemy, I think I figured out what is happening. 1- The call to a- the naming_convention on the base MetaData defines
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
if you ran migrations without naming conventions for awhile, and this is NOT SQLite, I would go into the DB, get all those names, and assign them to the constraints in question, overriding the naming convention. if this IS SQLite, I'd manually write a migration that gives names to all unnamed constraints (drops and recreates all of them with names). the idea is the same, get control over those names |
Beta Was this translation helpful? Give feedback.
yeah you have to recreate the tables in order to drop the old constraints, since they have no name.
I always wince at the weekly "SQLIte is so amazing!" posts on hacker news. it's such garbage from my pov