django-generic-m2m
django-generic-m2m copied to clipboard
Initial migration fails
When creating initial database tables I always get error:
django.db.utils.OperationalError: (1005, 'Can\'t create table
whatever.
#sql-78b5_cf7 (errno: 150 "Foreign key constraint is incorrectly formed")')
Then I do python manage.py migrate
again and everything goes fine. Applications works fine.
I made django print the statement and this is what I get when error happens:
ALTER TABLE `genericm2m_relatedobject` ADD CONSTRAINT `generi_parent_type_id_49334ec02e973f24_fk_django_content_type_id` FOREIGN KEY (`parent_type_id`) REFERENCES `django_content_type` (`id`)
Don't know if I will get errors further in application heavy use or is something I can pass.
Also is a bit of an annoyance for automation scripts.
It looks like the table name is missing from the ALTER TABLE statement. It should theoretically appear before "(parent_type_id)".