Issue
I am new to Django, but every time I do any change to the models, I need to do 'python manage.py makemigrations' then 'python manage.py migrate'
makemigrations will create new files under migrations folder:
0001_xx
0002_xx
0003_xx
...
My question is, is this the right way to do it? Because if every time there is a change to the DB model, then a new migration file is created, in the end I could end up having many migration files. Then how to do migration when I want to move to production? Just run the 'python manage.py migrate'?
Solution
Yes, this is the right way to handle migration files. At the beginning, it may feel little discomfort to see a lot of files created after a certain period of development but it’s ok to have as many migration files created within an app. But Don't try to delete or change any of the migration file because each files has track of what migrations is done before. If it is accidentally deleted, you will face trouble on future migrations. In local server, you may get rid of it easily. But in production, it may come as a nightmare most of the time.
Answered By - Rabeul Hasan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.