Reputation: 1
How do I delete migration In django 1.11 I have tried to delete the particular field in model and make migration again but it's still showing me that I have 3 unapplied migration How do I deal with it ?
Upvotes: 0
Views: 218
Reputation: 501
Option 1: Delete newly created migrations and revert to a specific one
Under the "migrations" folder in your app, find the migration that you want to go back to. Run "python manage.py migrate your_app_name name_of_migration_file". This will bring you back to whatever migration you chose.
Example: if I wanted to go back to the fourth migration, I would do: "python manage.py migrate myapp 0004_auto_20180701_1748". After you have migrated backwards, delete all of the migrations that come after it. For me, I would delete any files 0005 or higher.
Run "python manage.py makemigrations" and then "python manage.py migrate" afterwards.
Option 2: Delete all migrations and reset every single field in your db
This will wipe all of your database data, so I don't recommend doing this every single time. But if you have messed up everything, it is useful because it cleans every single field and migrates all of the ones you currently have in your model file currently.
Answer borrowed from here: django revert last migration
Upvotes: 1