mysql - Why this database migration error after I upgrade my version django-mptt? -


my django application has requirements.txt file (shown here) use install modules in virtual environment. works fine.

however, i'm trying upgrade django-mptt 0.6.1 latest version. (i don't care upgrade django-mptt. want upgrade version of django. seems upgrade django, must first upgrade django-mptt described here). pip install -u django-mptt. causes django-mptt go 0.6.1 0.7.4 , django go 1.7.1 1.8.2. , causes django-cache-machine origin master. can see changes in screenshot below.

then when manage.py runserver prompts me migrate. that. no problems. subsequently if drop tables , run migrate again, error during migration:

django.db.utils.operationalerror:  (1005, 'can\'t create table `mydb_instance`.`#sql-21b_1e`  (errno: 150 "foreign key constraint incorrectly formed")') 

full stack trace here.

what error? have fact i'm using mariadb (server version: 10.0.15-mariadb homebrew) instead of mysql database?

enter image description here

edit: portion below point added on july 6,2015 @ 5:28 utc

i mentioned above after upgrade, prompted migrate. strangely, occurred though upgrading mptt doesn't cause new migration files created! when did manage.py runserver, got following warning message. why? makes no sense:

you have unapplied migrations; app may not work until applied. run 'python manage.py migrate' apply them. 

edit: portion below point added on july 6,2015 @ 17:00 utc

as experiment, switched out underlying database mariadb mysql (server version: 5.6.25). problem persisted. error got cannot add foreign key constraint. full stack trace here.

edit: portion below point added on july 6,2015 @ 17:05 utc

going through stack trace posted 5 minutes ago, found error being triggered following sql statement:

alter table `myapp2_mymodel2` add constraint `mymod_mymodel5_id_335ee73cecd6ecbf_fk_myapp5_mymodel5_id` foreign key (`mymodel5_id`) references `myapp5_mymodel5`; 

i see issue is. myapp2_mymodel has foreign key constraint myapp5_mymodel. when tries create fk, fails because target of foreign key doesn't yet exist! why order of table creation different after upgrade?

i solved problem myself. looks 1 of django applications lacked myapp2 lacked migrations folder. repaired , things started working fine.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -