django-generic-m2m icon indicating copy to clipboard operation
django-generic-m2m copied to clipboard

Initial migration fails

Open n3storm opened this issue 8 years ago • 1 comments

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.

n3storm avatar Nov 11 '16 10:11 n3storm

It looks like the table name is missing from the ALTER TABLE statement. It should theoretically appear before "(parent_type_id)".

coleifer avatar Nov 11 '16 21:11 coleifer