Thanks again, Simon!

Filed 30029 <https://code.djangoproject.com/ticket/30029>

On Sunday, December 9, 2018 at 11:28:54 PM UTC-5, Simon Charette wrote:
>
> Hello Dakota,
>
> From looking at the autodetector code in charge of generating these 
> lists[0]
> and the loader code in charge of resolving them[1][2] I'm pretty confident 
> their order
> doesn't carry any meaning.
>
> They should have been defined as a set from the beginning.
>
> Cheers,
> Simon
>
> [0] 
> https://github.com/django/django/blob/c5568340a525ab9c6898ed02c257394cc47285d7/django/db/migrations/autodetector.py#L274-L323
> [1] 
> https://github.com/django/django/blob/c5568340a525ab9c6898ed02c257394cc47285d7/django/db/migrations/loader.py#L176-L184
> [2] 
> https://github.com/django/django/blob/c5568340a525ab9c6898ed02c257394cc47285d7/django/db/migrations/graph.py#L85-L120
>
> Le dimanche 9 décembre 2018 19:09:42 UTC-5, Dakota Hawkins a écrit :
>>
>> Hi Simon!
>>
>> Thanks for the information, I'll submit a feature request! I dug through 
>> the code a bit and the one thing that concerned me a little was the 
>> possibility that sorting might have to account for dependencies between 
>> your app's dependencies. For example if app2's migration specified that it 
>> must run before auth's migration, does that mean app1's migration must 
>> appear before auth's or should that be sorted out by a different mechanism?
>>
>> Thanks,
>>
>> Dakota
>>
>> On Friday, December 7, 2018 at 7:42:09 AM UTC-5, Simon Charette wrote:
>>>
>>> Hello Dakota,
>>>
>>> Migration.dependencies should really have been defined as a set from the 
>>> start
>>> as Django doesn't care about their order anyway.
>>>
>>> I unfortunately cannot provide a work around but I suggest you submit an
>>> improvement/cleanup ticket to make the order deterministic. It should be
>>> a simple matter of using sorted in MigrationWriter.as_string[0].
>>>
>>> Cheers,
>>> Simon
>>>
>>> [0] 
>>> https://github.com/django/django/blob/79c196cfb287893aadc6b0e74603ffde1512170e/django/db/migrations/writer.py#L156-L164
>>>
>>> Le vendredi 7 décembre 2018 00:51:58 UTC-5, Dakota Hawkins a écrit :
>>>>
>>>> We haven't really deployed yet, so generally to make migrations we're 
>>>> deleting existing migration files and re-running makemigrations.
>>>>
>>>> We have two apps, and one of them depends on the other as well as 
>>>> django.contrib.auth. In that app's migrations the dependencies often swap 
>>>> order seemingly indeterminately.
>>>>
>>>> [image: migrations.png]
>>>> The resulting migration includes either:
>>>>
>>>> class Migration(migrations.Migration):
>>>>     initial = True
>>>>     dependencies = [
>>>>         ('auth', '0009_alter_user_last_name_max_length'),
>>>>         ('app2', '0001_initial'),
>>>>     ]
>>>>     ...
>>>>
>>>>
>>>> or:
>>>>
>>>> class Migration(migrations.Migration):
>>>>     initial = True
>>>>     dependencies = [
>>>>         ('app2', '0001_initial'),
>>>>         ('auth', '0009_alter_user_last_name_max_length'),
>>>>     ]
>>>>     ...
>>>>
>>>>
>>>> and it seems to switch back and forth with nearly every run.
>>>>
>>>> Does anybody know why, or how to nail down the order? It doesn't seem 
>>>> to make a technical difference, but I'd like to avoid the churn/noise in 
>>>> our repo.
>>>>
>>>

-- 
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/339162ef-371e-4ee1-8c96-2ed1888d8eff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to