Django Change/Update/Modify Model and recreate the corresponding table.

To change Django Model, I did the following:
1. Change the Model definition in Django's Python code in models.py.
2. Delete your app's migrations folder
3. In the database: DELETE FROM django_migrations WHERE app = 'app_name'.
4. Drop/Delete the corresponding model tables from the database.
5. Update the "id" column to be in a sequence in the django_migrations database table.
6. Decrement the "django_migrations_id_seq" sequence's current value.
7. In python terminal, run "python manage.py makemigrations app_name".
8. In python terminal, run "python manage.py migrate".

[Sources:]
  • https://stackoverflow.com/questions/33259477/how-to-recreate-a-deleted-table-with-django-migrations

Comments