I'd really like to know how to reset Django database. Specifically, I accidentally deleted a table with this command,
$ python manage.py dbshell
$ DROP TABLE qaapp_question;
and everything messed up.
I followd a stackoverflow post and just deleted the table, and, haha, completely messed up. syncdb stuff is apparently deprecated so cannot use it.
I tried all the ways I googled and found, as followings:
$ python manage.py migrate qaapp zero
django.db.utils.OperationalError: no such table: qaapp_question
Not working.
$ manage.py migrate --fake <appname> zero
$ rm -rf migrations # I deleted the app migrations folder manually
$ manage.py makemigrations <appname>
$ manage.py migrate --fake <appname>
Not working.
$ python manage.py flush
Not working.
$ python manage.py reset_db
Reset successful.
Not working.
manually trying to delete the sqlite database file -> resource busy or locked
Not working.
I wanted to restore the deleted table, but I don't care anymore, just kindly tell me how to delete, initialize the database, then be able to rebuild the database with python manage.py makemigrations
and python manage.py migrate
.
Thanks for your help.