django-planet
Nov. 21, 2024

Django: find ghost tables without associated models

published by Adam Johnson
in blog Adam Johnson
original entry Django: find ghost tables without associated models

Heavy refactoring of models can leave a Django project with “ghost tables”, which were created for a model that was removed without any trace in the migration history. Thankfully, by using some Django internals, you can find such tables.

Use the database introspection methods table_names() to list all tables and …