Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 944
default123 Avatar asked Apr 04 '18 07:04

default123


1 Answers

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;

like image 90
Madi7 Avatar answered Oct 14 '22 12:10

Madi7