Automatic migrations wants to drop and recreate Foreign Keys created with create_foreign_key #1265
-
After creating a foreignkey using I'm using:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
hi - there's any number of reasons this could happen, check that the names of the FKs were actually generated in the database correctly. I know that's kind of sparse advice however there's no details here for me to go on. |
Beta Was this translation helpful? Give feedback.
-
How can the drop and recreation of identical fkeys possibly a valid behaviour? There is no reason for that. When a fkey point from table_a to table_b on certain columns and have the same name, which is the case in the described issue, then these fkey are identical, and should not be touched by alembic auto-migration. |
Beta Was this translation helpful? Give feedback.
your old migration is lacking the "ON DELETE CASCADE" options in your op.create_foreign_key(). That's why it's correctly trying to drop and recreate them. notice the cascades being added.