What is the difference between --fake-initial
and --fake
in Django migrations? What are the dangers of using fake migrations? Anybody knows? Thank you very much to all.
I am using django 1.10
What is the difference between --fake-initial
and --fake
in Django migrations? What are the dangers of using fake migrations? Anybody knows? Thank you very much to all.
I am using django 1.10
Well the documentation is very clear about this
--fake-initial
You were asking about the risks, well here it is
--fake
Once again risks are clearly highlighted
This answer is valid not just for django versions 1.8+ but for other versions as well.
edit Nov, 2018: I sometimes I see answers here and elsewhere that suggest that you should drop your databae. That's almost never the right thing to do. If you drop your database you lose all your data.
@e4c5 already gave an answer about this question, but I would like to add one more thing concerning when to use
--fake
and--fake-initial
.Suppose you have a database from production and you want to use it for development and apply migrations without destroying the data. In that case
--fake-initial
comes in handy.The
--fake-initial
will force Django to look at your migration files and basically skip the creation of tables that are already in your database. Do note, though, that any migrations that don’t create tables (but rather modify existing tables) will be run.Conversely, If you have an existing project with migration files and you want to reset the history of existing migrations, then
--fake
is usually used.