#30029: Generate migration dependencies in a deterministic order
-------------------------------------+-------------------------------------
Reporter: Dakota | Owner: nobody
Hawkins |
Type: | Status: new
Cleanup/optimization |
Component: Core | Version: 2.1
(Management commands) | Keywords: migrations,
Severity: Normal | makemigrations
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
From
[https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg
/django-users/GUBw8lp1U24/mMyIBeiSAgAJ this google groups discussion]:
> 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(https://i.imgur.com/nJxyuXT.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.
According to Simon Charette in that discussion:
> It should be a simple matter of using sorted in
MigrationWriter.as_string[0].
I poked around the code a bit, in hopes of first writing a failing unit
test and then fixing the issue, but I'm not sure how to write the test
with multiple interdependent apps since `temporary_migration_module` seems
to support only a single app. Another concern is that the test may be
flaky since the current order is indeterminate... it may take some
arbitrary number of iterations to be reasonably certain the case could
have been reproduced by one of them.
I'd be happy to investigate further if somebody could help me get started
with some advice on writing that test.
--
Ticket URL: <https://code.djangoproject.com/ticket/30029>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.5b136ca0e79e4eb3b6c0d65048640ed1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.