1

I am running AWS Elastic Beans which automatically set up a working postgresql database instance and connection for me. Therefore I do not want to just delete the database instance and configure it myself. I would rather just delete all tables in the database from python/django. I also do not want to delete the content of all tables (what python manage.py flush does).

I want the database to return to a state where I can just run python manage.py migrate and it will create all empty tables from my current model definitions.

Thanks

1
  • @IainShelvington yes, it does indeed, thanks Commented Dec 30, 2019 at 0:08

1 Answer 1

2
# Prints the SQL statements that would be executed for the flush command. Will delete all the data from tables in database

django-admin sqlflush

# You can pass the name of your database specifically. Defaults to default.

--database DATABASE

# If you want to delete all the tables of your app, then you can run the command

python manage.py migrate appname zero
Sign up to request clarification or add additional context in comments.

2 Comments

I do not want to delete all data from the tables, I want to delete the tables themselves so that I could just run a fresh python manage.py migrate afterwards to get clean tables with my new (maybe changed) models.
python manage.py migrate appname zero - command will delete your table

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.