Clean up unused database tables after removing a Django app?

When I remove a Django app from my list of INSTALLED_APPS, it doesn’t get rid of the old database tables; running ./manage.py makemigrations doesn’t detect any changes.

Apart from going into the database myself and dropping the old tables, is there a better way to clean up unused tables after uninstalling an app from my Django project?

>Solution :

You can use migrate command by specifying a zero for this purpose.
Example-

$ python manage.py migrate appName zero

This will safely revert the database tables.

Relevant Doc

After running the zero migration, you may remove the app from INSTALLED_APPS

Leave a Reply