How to resolve the "psycopg2.errors.UndefinedTable: relation "auth_user" does not exist" when running django unittests on Travis

I ran into the same problem after adding a model for an app that was already installed, but forgetting to creating the initial migration. OP hid the answer in the comments so here are explicit steps:

$ mkdir myapp/migrations
$ touch myapp/migrations/__init__.py

After this I got a new error when trying to run python manage.py test

psycopg2.errors.InvalidCursorName: cursor "_django_curs_140073820227328_58" does not exist

One more step was needed:

$ python manage.py makemigrations

And then tests ran fine.


I deleted the sqllite3 database then I ran

$ python manage.py migrate 

then

$ python manage.py migrate --run-syncdb