Django 1.8 Migrations: AlterField Migration calls default callable for ForeignKey even when no Model Instances Exist

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Django 1.8 Migrations: AlterField Migration calls default callable for ForeignKey even when no Model Instances Exist

Dylan Young
Steps to reproduce:

Create Model
Make migrations
Add FK to model with a callable default that has some side effect (e.g. creating the default instance in the database)
Make migrations
Migrate (or run tests on clean db)
Observe the side effect


I couldn't find this on the Bug Tracker. Is this still an issue in dev branch?

I haven't reproduced in a controlled test, but if this is something that others have observed or think may be an issue, I can look into reproducing cleanly.

If this is the intended behaviour then documentation is needed, though I don't see why it would be since defaults aren't enforced on the DB level.  

Note: it runs cleanly if the default is placed in an AddField migration. 

Best,

Casey Meijer   

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAPGJNu7QCVkQKT0xVwDjF-8ySb%2BM6_XDK37e8%2BX2OtDbS2OJ0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.8 Migrations: AlterField Migration calls default callable for ForeignKey even when no Model Instances Exist

Tim Graham-2
Hi, I think the issue is described in https://code.djangoproject.com/ticket/24182.

On Tuesday, March 14, 2017 at 12:50:52 PM UTC-4, Dylan Young wrote:
Steps to reproduce:

Create Model
Make migrations
Add FK to model with a callable default that has some side effect (e.g. creating the default instance in the database)
Make migrations
Migrate (or run tests on clean db)
Observe the side effect


I couldn't find this on the Bug Tracker. Is this still an issue in dev branch?

I haven't reproduced in a controlled test, but if this is something that others have observed or think may be an issue, I can look into reproducing cleanly.

If this is the intended behaviour then documentation is needed, though I don't see why it would be since defaults aren't enforced on the DB level.  

Note: it runs cleanly if the default is placed in an AddField migration. 

Best,

Casey Meijer   

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/0be300f3-374a-424f-b971-87c64a898274%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...