0

is it possible to remove an M2M field from a model and keep the joining table?

context: I am trying to add through model to existing M2M field like described in this post

But doing it simply like this will result in a production app crash when accessing the old table during deployment - short window between migration and code update, when old code will try to access a new database for a few moments - without the old table in it.

Charlestone
  • 1,248
  • 1
  • 13
  • 27

1 Answers1

0

You can use --fake flag when running manage.py migrate. That will make a migration file that says the model field has been removed and mark it as applied in the database migration table, but not actually execute the SQL to remove the corresponding tables etc. Read more here

Felix Eklöf
  • 3,253
  • 2
  • 10
  • 27