3YOURMIND / django-deprecate-fields

This package allows deprecating model fields and allows removing them in a backwards compatible manner.
Apache License 2.0
177 stars 20 forks source link

Handle 0-downtime deploys with high-read-frequency models #23

Closed jackrr closed 2 years ago

jackrr commented 2 years ago

I have a deploy process that runs the migration then rolls out the new app version to our codebase. As a result, there is a period of time where the old version of the model is querying the database after the migration deleting the column has been run. This leads to errors like the following whenever the model with the removed column is read from the DB in the older version of the code:

column TABLE_NAME.COLUMN_NAME does not exist LINE 1: ...

I think this medium post describes part of a potential solution. I think the solution would involve extending the migration logic to add some kind of noop that allows us to remove the column from the model in the app before removing in the migration, while tricking makemigrations into thinking that everything is in a legal state.

jackrr commented 2 years ago

Apologies, after further local testing this appears to handle the case I've described. Much easier than the medium article! Thanks for the project!