W dniu poniedziałek, 20 lutego 2017 11:49:38 UTC+1 użytkownik Markus Holtermann napisał: > > On Thu, Feb 16, 2017 at 03:25:16PM -0800, rap...@makeleaps.com > <javascript:> wrote: > >RemoveField('A', 'foo') also references A and foo, but does it reference > B? > >if it does, then it' s hard to have optimizations that pass through this, > >because this field could be referencing any model (theoretically). > > No, that field can not reference any model. It reference exactly one > model (that even holds for FK to abstract models as fields from abstract > models are inlined in the concrete models in migrations). However, > RemoveField doesn't have the information to "just" figure out the > referenced model. RemoveField would need to look into the from_state's > apps and actually even look into the actual field that's referred. > ForeignKeys have an implicit to_field attribute, so, having > > AddField('A', 'foo', ForeignKey('B', to_field='bar')) > > a > > RemoveField('A', 'foo') > > references exactly one field on one particular model. Not more and not > less. The issue here is that RemoveField needs to take that information > from the state and not from one of its attributes. >
Technically it references _some_ model named "B" that was created not sooner than the current migration's explicit dependencies. It may be the model you saw when you created that migration or it may be some other model. You can tell your migration that it has to be executed no sooner than after another migration is complete but there is no way to say "but before model B is modified any further". -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b9964408-8dff-49ec-aa08-89826d35503c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.