简体   繁体   English

django 1.7关系“ auth_user”在迁移中不存在,但在测试中很好

[英]django 1.7 relation “auth_user” does not exist in migrate but fine in tests

I'm updating a django-1.5 project to django-1.7.2 and when migrating I keep getting "relation "auth_user" does not exist". 我正在将django-1.5项目更新为django-1.7.2,并且在迁移时,我不断收到“关系“ auth_user”不存在”。 However if I run python manage.py test -v2 to see the process of database creation/migration 但是,如果我运行python manage.py test -v2来查看数据库创建/迁移的过程

Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying subscription.0001_initial... OK

Migrations turn out fine. 迁移结果很好。 Am I missing a step? 我错过了一步吗? It is my belief that one does not need to syncdb anymore simply 我认为不再需要syncdb

python manage.py migrate

But doing that does not apply migrations for django apps. 但这并不适用于Django应用程序的迁移。

Note: I'm not using a custom User class just the regular django.contrib.auth.models.User 注意:我不使用常规django.contrib.auth.models.User的自定义User类

May be you faked auth migrations already on real database? 可能您已经在真实数据库上伪造了auth迁移?

Try to check 尝试检查

select * from django_migrations where app='auth'

and if any records exists, delete them. 如果存在任何记录,请将其删除。

You need to do 2 things: 您需要做两件事:

python manage.py makemigrations

and then 接着

python manage.py migrate

The migrate does indeed apply the migrations, but they first need to be created. 迁移确实确实应用了迁移,但是首先需要创建它们。 These two steps are more or less the replacement of the old syncdb. 这两个步骤或多或少地替代了旧的syncdb。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM