Wednesday, October 28, 2015

Missing default callable breaks migration

If I try to change the default on a model field from one callable to another, the migration will fail if the old callable is no longer available. It appears this is because the migration system tries to call the old callable to determine if it returns a different value from the new. 

I don't think this should cause an error; it's not unusual to delete/rename a function used as a field default. 

Moreover, I think comparing output from the old default is a bad idea; I initially had migration failure because I had changed the default from a function that returned timezone-aware dates to one that returned timezone-naive dates. 

Hence I think this general behaviour is a bug that needs to be fixed; exceptions trying to compare old and new defaults during migration should be handled and not break the migration.

Note that I was able to work around this by modifying the previous default in the earlier migration file.

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b0507df4-9ee6-4593-80cd-d906b04ca1d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment