1
votes

I ran makemigrations and then ran migrate on django project. But due to some complications the migrations could not be completed and stopped in between.

What is the easiest way to revert the database to earlier state or undo changes of the unfinished migration.

I am using django 1.10 but I think same applies with versions of django after 1.6

1
What database are you using?Alan Avalos
I am using mysql dbsprksh
Check Django documentation for this. Basically you can't roll back to a previous migration due to the lack of support of MySQL for this. You will have to manually omit the changes in the migration in order to run the migration again.Alan Avalos

1 Answers

1
votes

As Alan Avalos told in comments, We cannot rollback the unfinished migration. And As I posted in another of my answer regarding migrations django revert last migration, I had to manually delete all the changes and it took much time as it should be done very carefully.

The idea is you have to check which particular migrations have been run and which particular migration caused the error. Leave all those that have been applied already. delete the changes of the unapplied migration by getting into mysql, then once it is done, find the root cause as to what caused migrations to falter and correct that thing.

Delete the unapplied migration files and rerun makemigration and migrate.