> On Jul 4, 2017, at 8:39 PM, taylor@cedar.com wrote:
>
> I am having some trouble figuring out the best way to remove model fields in Django. If I remove a field from a model and then run makemigrations, it creates a RemoveField operation in a migration. That is great, but if I decide to run the migration before releasing the new code, the existing code will break (for a short time between running the migration and releasing the new code) because the old code is still querying for the removed column (Django queries for all columns by default). I could run the migration after the release, but that won't work if I also have an AddField operation because the new code needs the new column, so it needs to be run before. I am wondering if anyone has solved this issue?
A common practice is to do this in several upgrade steps:
1) Add new field as nullable.
2) Add code to populate and use new field, and migrate.
3) Remove code using old field.
4) Remove old field, and migrate.
With a large development team the work flow is perhaps not much different that managing production releases, since you may not want to have broken installations. It also gives needed practice at managing deployed releases for upgrades.
hth
- Tom
--
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/722E4F78-636D-4FEB-A9D5-783CA3227A9C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment