🗑️ Orphaned Tables Report

Database: {{ database_name }} | Generated: {{ timestamp }}

{% if orphaned_tables %}
⚠️ Found {{ orphaned_tables|length }} orphaned table{{ orphaned_tables|length|pluralize }} that don't correspond to any Django models
{{ orphaned_tables|length }}
Orphaned Tables
{{ total_rows|default:"N/A" }}
Total Rows
{{ total_size|default:"N/A" }}
Total Size

🔧 Quick Cleanup Commands:

# Drop all orphaned tables (⚠️ DANGEROUS!)
python manage.py dbsync --cleanup-orphaned --auto-approve
# Backup before cleanup
python manage.py dbsync --cleanup-orphaned --backup
# Interactive cleanup (recommended)
python manage.py dbsync --cleanup-orphaned
{% for table in orphaned_tables %}
🗃️ {{ table.name }}
Rows: {{ table.row_count|default:"Unknown" }}
Size: {{ table.size|default:"Unknown" }}
Columns: {{ table.column_count|default:"Unknown" }}
Last Modified: {{ table.last_modified|default:"Unknown" }}
{% if table.estimated_origin %}
Likely Origin: {{ table.estimated_origin }}
{% endif %}
{% endfor %}
{% else %}

🎉 No Orphaned Tables Found!

Your database is clean - all tables correspond to Django models.

{% endif %}