Yes, when running tests (which happen on a clean database), the migration 
history is run all from the initial migrations (by Django itself). At this 
point, app b's initial migration (which have a reference to a.A) will fail 
because it cannot find such model:

ValueError: Related model 'a.A' cannot be resolved

fredag den 8. marts 2019 kl. 15.23.51 UTC+1 skrev Clara Daia:
>
> Are you getting an error? I think migration dependencies should solve that 
> by themselves, running "step 2" before "step 3". Doesn't Django complain if 
> you try to migrate "step 3" before "step 2"?
>
> Em sex, 8 de mar de 2019 às 11:07, Henrik Ossipoff Hansen <
> henrik....@gmail.com <javascript:>> escreveu:
>
>> We're trying to remove a model completely from one of our apps - an 
>> operation I think we've done many times without issues, but this time it's 
>> causing us some headache. Consider we have two apps:
>>
>> An app called a with a model A
>> An app called b with a model B, and this model B has a foreign key to A.
>>
>> This means the initial Django migration file for app b contains an entry 
>> for a foreign key to the string 'a.A'. Let's call this step 1.
>>
>> Now later, we remove the foreign key on model B. This of course creates a 
>> new migration, but the initial migration still has the 'a.A' foreign key 
>> definition in it (obviously). Let's call this step 2.
>>
>> Now the tricky part: we want to remove the whole model A. This in itself 
>> creates a migration for app a to that deletes the model, but poses a new 
>> problem; when running the full migration history (for example during 
>> tests), the initial migration of app b will fail, because it can no longer 
>> resolve 'a.A'. Let's call this step 3.
>>
>> How are people coping with the issue the best? One solution I can think 
>> of involves doing a migration squash (and would be sort of easy in our 
>> case, since we're actually going to remove the whole app a as well), but it 
>> seems a bit extreme. Is there anyone out there with a better and less 
>> intrusive solution?
>>
>> Regards,
>> Henrik Ossipoff Hansen
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/162da80d-ca64-48d1-b555-4ce44d6040aa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/162da80d-ca64-48d1-b555-4ce44d6040aa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/236407fc-b903-4504-b31b-952fb9f0c47b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to