So I was being stupid and I went to delete one of the tables in my django app so opened up psql and ran "Drop table ;" and dropped the table. Then I deleted my model and ran "python manage.py migrate" and I get this error...
django.db.utils.ProgrammingError: relation "textchange_myuser" does not exist
among other stuff above it.
So now I can't delete the table properly and I can't get it back. What do I do?
Thanks.
I deleted a table from postgres and then django was unable to detect the change. I tried everything but django didn't created a new table. Finally I fixed this with some alternate way.
login to your database create table manually. - Get the create command from django itself.
python manage.py sqlmigrate 'yourapp' 001
this will give you the initial command django used to create the table.
one by one get all the migrations and execute commands on database by command line.
As per my comment, in your situation you might run:
python manage.py migrate yourapp --fake
to "fake" applying the migration but not actually alter your database.
You can read more HERE
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With