django.db.utils.ProgrammingError:关系在OenBSD vps上已存在

django.db.utils.ProgrammingError:关系在OenBSD vps上已存在,django,python-2.7,celery,Django,Python 2.7,Celery,我得到了这个错误。我试过使用migrate——伪默认值,但它似乎不起作用。附件是“python manage.py migrate”的输出。我的设置是在OneBSD VPS上的Django 1.6+celery3.1.12+postgresql+gunicorn Running migrations for users: - Migrating forwards to 0007_auto__del_field_profile_weekly_digest__del_field_profile_

我得到了这个错误。我试过使用migrate——伪默认值,但它似乎不起作用。附件是“python manage.py migrate”的输出。我的设置是在OneBSD VPS上的Django 1.6+celery3.1.12+postgresql+gunicorn

Running migrations for users:


- Migrating forwards to 0007_auto__del_field_profile_weekly_digest__del_field_profile_daily_digest_.
 > users:0001_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE "users_user" ("id" serial NOT NULL PRIMARY KEY, "password" varchar(128) NOT NULL, "last_login" timestamp with time zone NOT NULL, "email" varchar(255) NOT NULL UNIQUE, "name" varchar(255) NOT NULL, "is_active" boolean NOT NULL, "is_admin" boolean NOT NULL, "is_staff" boolean NOT NULL, "type" integer NOT NULL, "status" integer NOT NULL, "new_messages" integer NOT NULL, "badges" integer NOT NULL, "score" integer NOT NULL, "full_score" integer NOT NULL, "flair" varchar(15) NOT NULL, "site_id" integer NULL)
The error was: relation "users_user" already exists

Error in migration: users:0001_initial
Traceback (most recent call last):
  File "manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 254, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 329, in migrate_many
    result = self.migrate(migration, database)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration, database)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 114, in run
    return self.run_migration(migration, database)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 84, in run_migration
    migration_function()
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/migration/migrators.py", line 60, in <lambda>
    return (lambda: direction(orm))
  File "/home/jay/biostar-central/biostar/apps/users/migrations/0001_initial.py", line 28, in forwards
    ('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['sites.Site'], null=True)),
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/db/generic.py", line 47, in _cache_clear
    return func(self, table, *args, **opts)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/db/generic.py", line 361, in create_table
    "columns": ', '.join([col for col in columns if col]),
  File "/home/jay/biostar-central/lib/python2.7/site-packages/south/db/generic.py", line 282, in execute
    cursor.execute(sql, params)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/jay/biostar-central/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "users_user" already exists
为用户运行迁移:
-正向迁移到0007\u自动\u删除字段\u配置文件\u每周\u摘要\u删除字段\u配置文件\u每日\u摘要\u。
>用户:0001_首字母
致命错误-以下SQL查询失败:创建表“users\u user”(“id”序列不为空主键,“password”varchar(128)不为空,“last\u login”时区不为空的时间戳,“email”varchar(255)不为空唯一,“name”varchar(255)不为空,“is\u active”布尔不为空,“is\u admin”布尔不为空,“is\u staff”布尔不为空,“类型”整数不为空,“状态”整数不为空,“新消息”整数不为空,“徽章”整数不为空,“分数”整数不为空,“满分”整数不为空,“flair”varchar(15)不为空,“站点id”整数为空)
错误是:关系“users\u user”已存在
迁移错误:用户:0001_首字母
回溯(最近一次呼叫最后一次):
文件“manage.py”,第9行,在
从命令行(sys.argv)执行命令
文件“/home/jay/biostar central/lib/python2.7/site packages/django/core/management/_init__.py”,第399行,从命令行执行
utility.execute()
文件“/home/jay/biostar central/lib/python2.7/site packages/django/core/management/_init__.py”,第392行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/home/jay/biostar-central/lib/python2.7/site-packages/django/core/management/base.py”,第242行,从_argv运行
self.execute(*args,**选项._dict__;
文件“/home/jay/biostar central/lib/python2.7/site packages/django/core/management/base.py”,第285行,在execute中
输出=self.handle(*args,**选项)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/management/commands/migrate.py”,第111行,在handle中
忽略重影=忽略重影,
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/_init__.py”,第220行,在migrate_应用程序中
success=migrator.migrate\u many(目标、工作计划、数据库)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第254行,在migrate\u many中
结果=迁移器。\类\迁移\多个(迁移器、目标、迁移、数据库)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第329行,在migrate\u many中
结果=self.migrate(迁移,数据库)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第133行,在migrate中
结果=self.run(迁移、数据库)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第114行,正在运行
返回self.run\u迁移(迁移,数据库)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第84行,运行时迁移
迁移函数()
文件“/home/jay/biostar central/lib/python2.7/site packages/south/migration/migrators.py”,第60行,在
返回(λ:方向(orm))
文件“/home/jay/biostar central/biostar/apps/users/migrations/0001_initial.py”,第28行,向前
('site',self.gf('django.db.models.fields.related.ForeignKey')(to=orm['sites.site'],null=True)),
文件“/home/jay/biostar central/lib/python2.7/site packages/south/db/generic.py”,第47行,在缓存中
返回函数(self,table,*args,**opts)
文件“/home/jay/biostar central/lib/python2.7/site packages/south/db/generic.py”,第361行,在create_表中
“列”:“,”。联接([coll for columns in columns if col]),
文件“/home/jay/biostar central/lib/python2.7/site packages/south/db/generic.py”,第282行,在execute中
cursor.execute(sql,params)
文件“/home/jay/biostar central/lib/python2.7/site packages/django/db/backends/util.py”,第53行,在execute中
返回self.cursor.execute(sql,params)
文件“/home/jay/biostar central/lib/python2.7/site packages/django/db/utils.py”,第99行,在__
6.重新播放(dj_exc_类型、dj_exc_值、回溯)
文件“/home/jay/biostar central/lib/python2.7/site packages/django/db/backends/util.py”,第53行,在execute中
返回self.cursor.execute(sql,params)
django.db.utils.ProgrammingError:关系“users\u user”已存在

如果
python manage.py migrate--fake initial
不起作用,您可以尝试从应用程序中删除迁移文件夹,并通过以下方式创建新文件夹:

python manage.py makemigrations app_name
这对我很有用:

python manage.py migrate --fake

我知道已经晚了,但我在Django 1.11中遇到了这个问题。我使用了一个tables Django模型,它需要另一个依赖于以前模型的TableModel。我必须从初始迁移中删除这些

所以请签入您的迁移文件

app/migrations/some_migration.py

可能有一个表被引用了两次。

非常感谢。