Tuesday, May 3, 2016

Re: makemigrations throws table does not exist error

On Mon, May 02, 2016 at 02:01:24PM -0700, Lucian Willoughby wrote:
> 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

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

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20160503072349.GR435%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment