Postgre sql and django admin schema fixing

amitmund April 11, 2026

While working on a django project you need to update the schema.

Quick steps

On code:

# 1. Navigate to the exam app
cd ~/to/your/app/root/

# 2. Delete all migration files except __init__.py
# Be careful to stay in the migrations folder!
find migrations/ -name "00*.py" -delete
find migrations/ -name "__pycache__" -type d -exec rm -rf {} +

# 3. Clear the `global pycache` just in case
cd ~/your/project/root/
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -rf {} +

From Django app side:

rm yourapp/migrations/00*.py
python manage.py dbshell (IMP)

\l (list databases)
\c your_db

# for postgres:
# Inside the shell: (set to schema/namespace)
SET search_path TO your_namespace;

# listing table start with your_table
djangodb=> \dt your_namespace.your_table*

DROP TABLE your_table CASCADE;
or with namespace
# with namespace also work but SET search_path to your_namespace; is a good way.
DROP TABLE your_namespace.your_Table CASCADE;
\q
0 Likes
53 Views

Filters

No filters available for this view.

Reset All