Mike Johnson Jr
Mike Johnson Jr

Reputation: 796

django.db.utils.ProgrammingError: relation "auth_user" does not exist - django 2.0.2

I've tried all of the solutions from the top results for this question on Google; none of them work for my situation:

  1. doing python manage.py migrate auth before `python manage.py migrate didn't work (same error)

  2. changing all references to 'auth.User' in my models to AUTH_USER_MODEL didn't work (same error), and neither did get_user_model() (makemigrations detected no changes anyway)

  3. doing python manage.py makemigrations [app_with_user_relation] did not work either (migrations were made, but still got the same error)

  4. have deleted and recreated the database multiple times

Does anyone have any new suggestions?

I hear downgrading to Django 1.7 might work, but that is not an option for me.

If anyone is curious, the app I am trying to migrate is powerdns, from the open source package django-powerdns-manager.

Full traceback: https://dpaste.de/JdT5

The failing migration: https://dpaste.de/rfUn

Custom db router: https://github.com/mike-johnson-jr/django-powerdns-manager/blob/master/src/powerdns_manager/routers.py

Upvotes: 0

Views: 826

Answers (1)

Mike Johnson Jr
Mike Johnson Jr

Reputation: 796

Custom database router routes migrations with app label "auth" to my default database rather than my powerdns database. Because of this, powerdns is making a foreignkey reference to another database, which is not possible in neither postgresql nor mysql, only sqlite. In mysql, error will be "cannot create foreign key constraint"

You can solve this error by only using 1 database or using sqlite for both.

Upvotes: 2

Related Questions