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/8126c93f-bc07-4b56-8b3b-0a3484123d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to