I have a wagtail app that deployed to docker, but then I get a very strange error, below are the steps:
Step 1:
docker-compose run app /venv/bin/python manage.py makemigrations`
Migrations for 'locations':
bakerydemo/locations/migrations/0008_alter_locationoperatinghours_day.py
- Alter field day on locationoperatinghours`
Step 2:
docker-compose run app /venv/bin/python manage.py migrate locations
Operations to perform:
Apply all migrations: locations
Running migrations:
===> No migrations to apply. <=== HUH?
Your models in app(s): 'locations' have changes that are not yet reflected in a migration, and so won't be applied.
===> Run 'manage.py makemigrations' to make new migrations,
and then re-run 'manage.py migrate' to apply them. <=== DOUBLE HUH?
Any wagtail or django or docker afficianados that can tell me what might be going on here? A similar question regarding Heroku mentioned running running the migrations before Heroku-izing, that is something I tried here, but it created an error in my locations app after dockerizing the container. The solution is from https://github.com/wagtail/bakerydemo and I added a few customizations to the locations app.
CodePudding user response:
You need to create your migration files locally and re-build your image with the new migration files included. Your migration files are just like any other code in the application and should be included in the image as part of the image build process.
When you run makemigrations
in the first command, you are creating a new container that creates the new migration files in that container... but when you run the second command, you create yet another separate container. Because the container created by the second command is separate, it won't contain the files created from the fist command -- hence, why you see the message No migrations to apply because the new migration files are not present.