Reputation: 657
I'm having a weird problem when migrating my project from django 1.7.4 to 1.8.5
In my project I extend the basic User model like so:
App users:
class User(AbstractUser):
age = models.IntegerField()
def __unicode__(self):
return self.username
Now when migrating in django 1.8.5 for some reasons I have to start by doing
python manage.py makemigrations
Which will make the migrations for the users app.
If I do
python manage.py migrate
directly after this it fails with this error
django.db.utils.ProgrammingError: relation "users_user" does not exist
Then I do:
python manage.py migrate users
Which fails
"Error creating new content types. Please make sure contenttypes "
RuntimeError: Error creating new content types. Please make sure
contenttypes is migrated before trying to migrate apps individually.
What is interesting is that even if this fails, now running
python manage.py migrate
Works
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles, django_extensions, allauth, avatar, crispy_forms, debug_toolbar
Apply all migrations: sessions, users, contenttypes, admin, sites, account, auth, socialaccount
Synchronizing apps without migrations:
Creating tables...
Creating table avatar_avatar
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying account.0001_initial... OK
Applying account.0002_email_max_length... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK
Applying sites.0001_initial... OK
Applying sites.0002_set_site_domain_and_name... OK
Applying sites.0003_auto_20151104_1309... OK
Applying socialaccount.0001_initial... OK
Has anyone experienced the same problems when migrating from an older django version to 1.8?
Upvotes: 2
Views: 811
Reputation: 5496
contenttypes is migrated before trying to migrate apps individually.
All you need to do is add the dependencies so your migrations will run in order.
Have a look at django.contrib.contenttypes.migrations
, add the latest one as a dependency in account.migrations
and it should all work fine.
Upvotes: 2