makemigrations throws table does not exist error

1,327 views
Skip to first unread message

Lucian Willoughby

unread,
May 2, 2016, 5:01:24 PM5/2/16
to Django users
I am trying to re-create an older project from a git repository. I do not have the original MySql database. I emptied the migration folders and tried to run "python manage.py makemigrations" which resulted in the following error : "Table 'age-sdb.login_esm_systems_experience_choice' doesn't exist". 'age-sdb.login_esm_systems_experience_choice' is a table from the project. I have tried "python manage.py makemigrations --empty" with the same results. All migrartion folders are empty

Michal Petrucha

unread,
May 3, 2016, 3:24:25 AM5/3/16
to django...@googlegroups.com
Hi Lucian,

First, deleting all migrations is not something you should do, except
in one specific case, and that is when you are moving from South
migrations to native django.core.migrations. In any other case, your
migrations are a part of your code base, and you should treat them as
such. In some situations you might want to squash incremental
migrations into bigger ones as an optimization, but simply removing
all existing migrations is not the right way to do that.

If you are starting with a new database, you can just apply all
existing migrations without removing them and running makemigrations,
that's the purpose of having migrations in the first place.

Second, regarding that error you are getting, that looks very much
like your application is trying to make database queries during
import, which is not possible, because Django needs to import your
application before it can create and apply migrations that will
actually create those tables.

The traceback you get should reveal where you are trying to access the
database on import, you'll have to fix that code.

Good luck,

Michal
signature.asc
Reply all
Reply to author
Forward
0 new messages