The answer is indeed to split this into steps. First step is to allow the field to be nullable if it's not already. Deploy.
Then you create a new deploy (not PR) that stops using the field altogether from all the codebase. You can remove the reference to the field or comment it out. Do not `makemigrations`. Deploy. Create the last step, which is the migration to drop the field from the database. On Thu, Jun 20, 2019 at 6:20 PM Matthieu Rudelle <[email protected]> wrote: > Thank you for the quick answer, although I am not sure what the second > step mean and how it actually solves the problem? > > The missing column error appears even when no backward migration is > called. Both version of the app run side by side, both connected to a > single DB migrated with the new code. So when the 3 step is called, the > older release will fail. > > Best, > Matthieu > > On Thursday, June 20, 2019 at 3:07:54 PM UTC+2, Aldian Fazrihady wrote: >> >> My solution to this problem was by adding more migrations steps: >> 1. Step to make the field nullable. >> 2. Backward step to fill value to the removed field. >> 3. Step to remove the field. >> >> Regards, >> >> Aldian Fazrihady >> >> >> On Thu, 20 Jun 2019, 19:37 Matthieu Rudelle, <[email protected]> wrote: >> >>> Hi there! >>> >>> I am about to file a feature request but I figured this might have been >>> discussed (although I can't find where). >>> >>> The use case is when removing fields in a production environment. We run >>> our django migrations without downtimes, such that basically, from time to >>> time we have an old release working on an DB migrated by the new release. >>> >>> And when we remove a field it breaks. So we're thinking there should be >>> a way to flag a field as "disabled", its value will not be requested on the >>> DB and default to a hardcoded value. No migration should remove the column >>> yet. Once the field is actually removed the column can be safely removed >>> without breaking the old version. >>> >>> What do you guys think? Is there a better way to solve this? >>> >>> *Note: a slightly different usecase that it could solve, the third item >>> on this wishlist: * >>> https://pankrat.github.io/2015/django-migrations-without-downtimes/#django-wishlist >>> >>> Best, >>> Matthieu >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> 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/CANP1NSx%3DRu63c2vR4R%3DfbtBEHV3WRqf1XxWtN%3Dd23j3VoA-ZZw%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CANP1NSx%3DRu63c2vR4R%3DfbtBEHV3WRqf1XxWtN%3Dd23j3VoA-ZZw%40mail.gmail.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 [email protected]. > To post to this group, send email to [email protected]. > 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/420f1671-2c31-428b-b96b-02f840df2df5%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/420f1671-2c31-428b-b96b-02f840df2df5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- George R. C. Silva -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAGyPVTt9BUXWd%3Df-myfD7OVQbwUy8s8ziUa22wM_07P1GK7PZQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

