Ticket #697 (assigned defect)
MySQL rename column and table fails when present in a foreign key
| Reported by: | s_dalton@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0 |
| Component: | databaseapi | Version: | 0.7 |
| Keywords: | mysql foreign key fk rename renaming | Cc: |
Description
MySQL (or south) fails to manage foreign key mappings when renaming either columns or tables.
I found this occuring on south 0.7, against the following mysql
mysql Ver 14.12 Distrib 5.0.51b, for Win32 (ia32)
I will attach a (debug/working) fix for this (I'll provide a proper diff with better code at a later point)
Attachments
Change History
comment:1 Changed 2 years ago by Llew <ortsed@…>
If you change line 29 in mysql.py to:
has_ddl_transactions = True
then it should work. I think that statement was set up for an older version of MYSQL that did not allow DDL Transactions.
comment:2 Changed 2 years ago by andrew
That comment is entirely unrelated; not only is this not a problem with transactions, MySQL still doesn't have DDL transactions, as I pointed out on the mailing list.
comment:3 Changed 2 years ago by andrew
- Status changed from new to assigned
Also, to the original author: This ticket is probably a duplicate of #679 - could you take a look there and see? In addition, whole files are basically useless to me, since I don't know what version of the code to compare them against - I'll need to wait for diffs to give an opinion.
comment:5 Changed 2 years ago by andrew
Alright, sorry for the really, really slow response here.
Firstly, the patch doesn't apply cleanly, but that's probably me waiting five weeks, so no matter.
Secondly, the change to south/db/mysql.py has a call on lines 83 and 133 to self.foreign_key_sql that doesn't do anything with the returned SQL (presumably, it should be executed?)
comment:6 Changed 2 years ago by aarranz@…
Hi,
I've updated the patch s_dalton provided and tested it. You can find the new version in the mysql-fixes branch at https://bitbucket.org/aarranz/south-aarranz.
In the other hand, I've found other problems not directly related to this ticket that I've also "fixed" but I'm not sure they are in shape to be included in south. Please review my commits and if they make sense I can create new tickets for them and/or repair them.
comment:7 Changed 18 months ago by beyondwords
I didn't see aarranz changes until I had started my own solution https://bitbucket.org/beyondwords/south-mysql
I believe this makes fewer database calls and follows the existing structure a bit more closely, but I am open to comments.

Full 0.7 mysql.py file