We’re trying to rename a column in MySQL (5.1.31, InnoDB) that is a foreign key to another table.
At first, we tried to use Django-South, but came up against a known issue:
OperationalError: (1025, “Error on rename of ‘./xxx/#sql-bf_4d’ to ‘./xxx/cave_event’ (errno: 150)”)
Error on rename of ‘./xxx/#sql-bf_4b’ to ‘./xxx/cave_event’ (errno: 150)
This error 150 definitely pertains to foreign key constraints. See e.g.
So, now we’re trying to do the renaming in raw SQL. It looks like we’re going to have to drop the foreign key first, then do the rename, and then add the foreign key back again. Does that sound right? Is there a better way, since this seems pretty confusing and cumbersome?
Any help would be much appreciated!
AFAIK, dropping the constraint, then rename, then add the constraint back is the only way. Backup first!
Answered By – Dave Swersky
Answer Checked By – Senaida (BugsFixing Volunteer)