Reputation: 2404
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
Upvotes: 1
Views: 1410
Reputation: 2404
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.
Upvotes: 1