31
From the Django docs:
Because migrations are stored in version control, you’ll occasionally come across situations where you and another developer have both committed a migration to the same app at the same time, resulting in two migrations with the same number.
Don’t worry – the numbers are just there for developers’ reference, Django just cares that each migration has a different name [emphasis added].
6
The simplest way to do this without any worry is this:
- Revert to a stable point (before conflicts):
python manage.py migrate usersmaster 0021_signup_status
-
Delete new migration files.
-
Re-make migrations:
python manage.py makemigrations
- [Django]-NumPy array is not JSON serializable
- [Django]-Import error cannot import name execute_manager in windows environment
- [Django]-Change Django Templates Based on User-Agent
1
When you are ready, you should merge from master to your development branch. At that time you should fix all conflicts, your migrations should go after master’s migrations, and after all of that your database should look as you want it be like.
Since that process takes time, and is quite painful, most people consider short living development branches. That way you need to deal with one or two migration files at a time.
- [Django]-Why would running scheduled tasks with Celery be preferable over crontab?
- [Django]-Get path of virtual environment in pipenv
- [Django]-Update django database to reflect changes in existing models
0
You can resolve migration errors using django-migration-fixer
Fixing migrations on your dev branch can be done using
$ git checkout [dev-branch]
$ git merge [main/master]
Follow the installation instructions here
Run
$ python manage.py makemigrations --fix -b [main/master]
commit the changes and push to the remote branch
$ git add .
$ git commit -am ...
$ git push ...
- [Django]-Django CSRF check failing with an Ajax POST request
- [Django]-Django: manage.py does not print stack trace for errors
- [Django]-How can I render a ManyToManyField as checkboxes?