Discussion:
Order of migration dependencies when running makemigrations from scratch
(too old to reply)
Dakota Hawkins
2018-12-06 22:30:24 UTC
Permalink
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+***@googlegroups.com.
To post to this group, send email to django-***@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/2ff2da48-99e6-4dd8-a284-cf64af9a26c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Simon Charette
2018-12-07 12:42:09 UTC
Permalink
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
Post by Dakota Hawkins
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]
initial = True
dependencies = [
('auth', '0009_alter_user_last_name_max_length'),
('app2', '0001_initial'),
]
...
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+***@googlegroups.com.
To post to this group, send email to django-***@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/ea7dbcae-87cc-4691-8e73-b394ab154e84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...