Reputation: 393
What i need is to get a migration describing the current structure in db and not what i defined in my models file because my models are not aligned to the structure of db, so i would like to get the current status and then apply my modifies defined in my models and make them aligned. Is it possible? And how?
Upvotes: 0
Views: 1097
Reputation: 20682
Django-admin has a command to create models from a database: inspectdb
. You can find the documentation here.
The idea would be to:
inspectdb
, makemigrations
to get the migrations for your current db and makemigrations
again.It's a fairly complex operation, the recommended approach is to have two databases and move the data from the first to the new one. Django will add lots of tables to your db and you probably don't want this on your legacy db. This is nicely described in this blog post
Upvotes: 1