Wednesday, November 30, 2016

Re: makemigrations generates new migration when nothing has changed

On 1/12/2016 3:56 AM, Francis Fisher wrote:
> Any idea why makemigrations would fail to recognise that a migration
> has already been generated?

I think migrations is seeing field choices differently each time it
scans the model. Can you use a list rather than a tuple for choices? (Or
vice versa - I don't remember) Or import the choices from another module?


>
> makemigrations.py is a script which calls makemigrations with
> appropriate django settings. If I run this once, it will generate the
> initial migration, but every time I run it subsequently, it will
> regenerate a migration even though nothing has changed in the model.
> This is with django 1.10.3 and postgres. The field sk that is
> constantly regenerated is a foreign key relation to an unmanaged
> database, but I have referred to this in a different app with no bother.
>
> I am using django 1.10.3.
>
> I found a post in this group that had a similar issue with
> instantiating a class in the model that was missing an implementation
> for __eq__ but that doesn't apply in this case as I don't instantiate
> any class in the model file.
>
> Is there any common mistake that leads to this outcome?
>
> ------------------
>
> user@testenv:~/eit/testproj$ ./makemigrations.py
> Migrations for 'sk':
> testproj/sk/migrations/0001_initial.py:
> - Create model SKM
> user@testenv:~/eit/testproj$ ./makemigrations.py
> Migrations for 'sk':
> testproj/sk/migrations/0002_auto_20161130_1643.py:
> - Alter field s on skm
> user@testenv:~/eit/testproj$
> user@testenv:~/eit/testproj$ ./makemigrations.py
> Migrations for 'sk':
> testproj/sk/migrations/0003_auto_20161130_1643.py:
> - Alter field s on skm
>
>
> --
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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/ad7c5eb6-4542-456e-8e53-675c02e897b1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ad7c5eb6-4542-456e-8e53-675c02e897b1%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@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/0ed4c35b-753b-3737-223c-a63e2c45601a%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment