Issue
I'm blatantly oblivious sometimes, and it led me down a 30 minute blackhole trying to figure out why my constraints
weren't being applied in my tests. Turns out I forgot to run makemigrations
. Is there a way to configure pytest
or django
to fail without makemigrations
?
I know if very clearly warns me
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Just looking for something a little more obvious/in your face?
Solution
These two commands will return an error if you have model changes not in migration files and if you have unapplied migrations respectively. You can run them as part of your test scripts
python manage.py makemigrations --check
python manage.py migrate --check
https://docs.djangoproject.com/en/3.2/ref/django-admin/#cmdoption-makemigrations-check https://docs.djangoproject.com/en/3.2/ref/django-admin/#cmdoption-migrate-check
Answered By - Iain Shelvington
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.