django.db.utils.OperationalError: no such table abc

2,867 views
Skip to first unread message

Ammon Quackenbush

unread,
Oct 20, 2021, 6:51:47 PM10/20/21
to Django users
I am working on a django project and I am getting this error when I attempt to run the "python manage.py makemigrations" command:

django.db.utils.OperationalError: no such table: myApp_tableStatus

The table tableStatus exists in my models.py.

Any ideas what I can do to fix this problem?

I tried deleting my virtual environment and creating a new one but that did not make a difference.

Lakshyaraj Dash X-D 25

unread,
Oct 20, 2021, 8:18:31 PM10/20/21
to django...@googlegroups.com
It will happen if you have deleted the initial migration or check your settings properly.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/99f2bba5-769c-42ea-8caa-563a6d6757acn%40googlegroups.com.

Ammon Quackenbush

unread,
Oct 21, 2021, 4:08:49 PM10/21/21
to Django users
I think you are right. I did delete the initial migration. How do I restore the initial migration?

Lakshyaraj Dash X-D 25

unread,
Oct 21, 2021, 9:28:12 PM10/21/21
to django...@googlegroups.com
Just search for it in the recycle bin , if you have not permanently deleted the migration, else give me the code in my personal gmail dashlaksh...@gmail.com and I will correct it.

MR INDIA

unread,
Oct 22, 2021, 9:07:26 AM10/22/21
to Django users

After deleting the migration to make it again just  Try Running the makemigrations command. 

Lakshyaraj Dash X-D 25

unread,
Oct 22, 2021, 9:17:39 AM10/22/21
to django...@googlegroups.com
Bro, you will need the initial migration in order to make another migration.

David Nugent

unread,
Oct 24, 2021, 4:34:46 PM10/24/21
to django...@googlegroups.com
On Fri, Oct 22, 2021 at 7:09 AM Ammon Quackenbush <aq...@chem.byu.edu> wrote:
I think you are right. I did delete the initial migration. How do I restore the initial migration?


Can't you restore it from your git repo?  If you're not running any sort of version control you've just hit the reason why doing so is important.

If that is not an option then it can be tricky.

If you have the luxury of backing up your existing data (e.g. using dumpdata), then you can wipe your entire database, run makemigrations, migrate and then re-import your data.  This is the most straight-forward method, but depending on the size of your data may take a while. This would be my recommended way as it is the safest way to restore your migrations state.

On a lesser extreme, and depending on the exact nature of your error and whether current tables are otherwise up to date wrt your models (if not you may run into issues), you can also reset or drop django_migrations table, remove migrations for apps with missing migration files, run makemigrations to re-create them (without any history) then migrate --fake to re-create and re-populate the django_migrations table which will not affect existing tables.


HTH, David
Reply all
Reply to author
Forward
0 new messages