Opened 10 years ago
Last modified 9 years ago
#24653 closed Bug
Migrations: Removing a field with foreign key constraint fails — at Initial Version
Reported by: | László Károlyi | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.9 |
Severity: | Normal | Keywords: | foreign key constraint mysql |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hey,
I have a model that has a foreign key to another model. Let's say I change my mind and want the relation the other way around (the another model having a foreign key to my model), and so I modify the models accordingly, removing the foreign key of my model.
This creates a migration with a migrations.RemoveField
on the model, which is just right. But when running this migration on MySQL, I get an error saying
django.db.utils.OperationalError: (1553, "Cannot drop index 'base_comment_f6be1d8d': needed in a foreign key constraint")
and the migration fails.
Shouldn't the migrations.RemoveField
drop that constraint automatically?