This is probably a duplicate of this question.
My question is how should I approach this when working in a docker environment so for my project I have a docker-compose.yml and docker-compose-deploy.yml for my production environment and obviously migration files are generated only in the docker images and aren't included in my version control system.
How should I approach this? should I stop using Docker as my development environment and go for something like virtual environments or even machines?
CodePudding user response:
No. The migration files are there so you can update your database without destroying it and rebuilding it from scratch (or doing the sql update statements by hand).
So you definitely want to track them in your version control.
During development, a classic scenario would be
- write code
- make migrations
- apply migrations on your dev database
- test the changes locally
- check in and push the commit to your production server
- execute the migrations (so only do
python manage.py migrate
) in production
Edit: I forgot to answer your docker question. Usually you put your source code in a volume outside the container, that you then mount into the container. So you can do docker development like this. That way the migration files and up in your codebase and you can track it.