default123
default123

Reputation: 170

How to drop App table with Django and Postgres

I'm trying to drop a single table from my App's database in a Django project. When I enter the database shell using manage.py dbshell, I try to execute DROP TABLE mytable; and get ERROR: table "mytable" does not exist I think the cause of this stems from the database thinking I'm in my project directory instead of my app directory but I don't know how to change that.

This is what the shell looks like after I type ./manage.py dbshell:

myproject=# DROP TABLE mytable; ERROR: table "mytable" does not exist

I think instead of myproject=# it should say something like myapp=# or myproject/myapp=# but I do not know how to accomplish this.

Upvotes: 6

Views: 12471

Answers (1)

inmate37
inmate37

Reputation: 1238

After accessing your local db via: sudo -i -u postgres

Or python manage.py dbshell

Try typing \l to see what databases do you actually have

Then \dt to see a list of relations

And then DROP TABLE some_table;

Upvotes: 23

Related Questions