In Django 1.8 using Postgres, how do I change the migration order? I have the following....
AUTH_USER_MODEL = 'users.User'
INSTALLED_APPS = [
"test.apps.users",
'django_nose',
'django_coverage',
'oauth2_provider',
'rest_framework',
'django_extensions',
]
and no matter what order my apps are in oauth2_provider
gives me the error...
django.db.utils.ProgrammingError: relation "users_user" does not exist
Operations to perform:
Synchronize unmigrated apps: oauth2_provider, staticfiles, messages, django_extensions, django_coverage, django_nose, rest_framework, common
Apply all migrations: users, sessions, admin, auth, contenttypes
Synchronizing apps without migrations:
Creating tables...
Creating table oauth2_provider_application
Creating table oauth2_provider_grant
Creating table oauth2_provider_accesstoken
Creating table oauth2_provider_refreshtoken
Running deferred SQL...
because its applying its own migrations before the apps.users table has been created.
If I removed oauth2_provider
, apply migrations, then add back in oauth2_provider
then apply migrations again, it works! However, there must be a way to force test.apps.users
migrations to be created before oauth2_provider
or anything else.
What I noticed is that inside oauth2_provider
they have:
migrations.swappable_dependency(settings.AUTH_USER_MODEL) https://github.com/evonove/django-oauth-toolkit/blob/master/oauth2_provider/migrations/0001_initial.py#L14
However, Django just ignores this and try's to apply the migration for oauth2_provider
before my user model giving the error above error when ever I run tests and need to create a new test database.
Which version of django-oauth-toolkit do you have installed? If you installed from PyPI, try installing from the master branch on GitHub. The current version on PyPI (v0.8) does only support South migrations, but not the built-in migrations that were introduced in Django 1.7.