manage.py makemigrations --merge
, then it creates a new leaf that will later also be out of date.Is there a nice way to handle this? I'm tempted just to avoid having any migrations in long-lived dependent branches.
Django keeps track of applied migrations in the Django migrations table. Django migrations consist of plain Python files containing a Migration class. Django knows which changes to perform from the operations list in the Migration classes. Django compares your models to a project state it builds from the migrations.
you can either: temporarily remove your migration, execute python manage.py migrate, add again your migration and re-execute python manage.py migrate. Use this case if the migrations refer to different models and you want different migration files for each one of them.
It is important though to commit migration files! If a conflict arises, Django might even help you solve those conflicts ;) That's the right answer. An operational versioning system workflow seems to be implicit in the django documentation but it's fundamental.
Unapply all migrations from the experimental branch:
manage.py migrate <appname> <previousMigration>
Delete all migrations from the experimental branch.
Create a brand new migration:
manage.py makemigrations
Commit changes to the experimental branch
It's perfectly safe to delete migrations from a repository if no one else has applied them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With