Ticket #1029 (closed defect: invalid)
Data migration that delete rows does not work - MySQL
|Reported by:||proman@…||Owned by:||andrew|
I created a data migration that deletes some rows that are referenced by other rows.
Code is as simple as this:
def forwards(self, orm):
When I run this migration I get integrity errors from database (I'm using MySQL 5.1 with InnoDB storage backend)
django.db.utils.IntegrityError?: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (myproj.payment_billingrecord, CONSTRAINT account_id_refs_id_3c8fc05 FOREIGN KEY (account_id) REFERENCES accounts_account (id))')
Running the very same Account.objects.all().delete() from django shell works without any problems - all child objects are nicely deleted.
This problem is identical to this: http://south.aeracode.org/ticket/165 which is marked as fixed. I am not sure if it is database-related issue, in the other ticket it was about postgres, here it's MySQL. My south version is 0.7.3.