[Django]-Django schemamigration creates the same migration change

1👍

Here’s what I think happened.

I have a branch which I branched off from upstream/master.
This doesn’t have database schema changes I have in my local git repo.
I worked on this branch and merged to my local branch.

Now the migration files from the merged-in branch don’t have latest schema changes in the migrations files. (Yes that’s what it think is current status of DB, and compare it to my models.py files. This was the key to solve the problem.)

Below is simplified view of what happened.

003 — change made in local branch
004 — change made in branch(from upstream/master) and doesn’t have changes introduced in 003

When I run schemamigration it creates

005 — reapplies the changes in 003

and run migrate, and fails.

I fixed the problem by modifying the contents of migrations files manually.

👤eugene

3👍

Try to:

python manage.py migrate your_app_name
to ensure you’ve got no changes that aren’t already in the migrations

and than:

python manage.py schemamigration –empty your_app_name name_of_migration
will make an empty migration but which has up-to-date info in it.

👤KravAn

Leave a comment