Opened 10 years ago
Last modified 9 years ago
#24653 closed Bug
Migrations: Removing a field with foreign key constraint fails — at Version 1
Description (last modified by ) ¶
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?
This happens using python 3, might have to do something with #24390.