2014-01-15 48 views
0

我正在使用python/python 3在win7上进行开发,在python/django上使用便携式环境。我决定尝试将postgresql添加到我的项目(“rob1”)中,该项目位于我的virtualenv“R1”中,并且我使用的是http://sourceforge.net/projects/pgsqlportable/django south:“由于目标机器主动拒绝,所以无法建立连接。”

我正在首次与South合作。

我改变了我的模特,救了我的工作,跑到:

$ ./manage.py schemamigration MYAPP--auto 
- Deleted field date on getPost.Url 
Created 0005_auto__del_field_url_date.py. You can now apply this migration with: ./manage.py migrate MYAPP 

但是当我运行:

./manage.py migrate MYAPP 

我得到一个长回溯结尾:

django.db.utils.ProgrammingError: no existe la relación «south_migrationhistory» 
LINE 1: ...gration", "south_migrationhistory"."applied" FROM "south_mig... 

我postgres控制台然后显示:

ERROR: no existe la relación «south_migrationhistory» en carácter 154 
SENTENCIA: SELECT "south_migrationhistory"."id", "south_migrationhistory"."app_ 
name", "south_migrationhistory"."migration", "south_migrationhistory"."applied" 
FROM "south_migrationhistory" WHERE "south_migrationhistory"."applied" IS NOT NU 
LL ORDER BY "south_migrationhistory"."applied" ASC 
LOG: no se pudo recibir datos del cliente: No connection could be made because 
the target machine actively refused it. 

这些更改未反映在postgres表中。我怎样才能解决这个问题?

编辑:

$ ./manage.py syncdb   
Syncing... 
Creating tables ... 
Creating table south_migrationhistory 
Installing custom SQL ... 
Installing indexes ... 
Installed 0 object(s) from 0 fixture(s)  

Synced: 
> django.contrib.admin 
> django.contrib.auth 
> django.contrib.contenttypes 
> django.contrib.sessions 
> django.contrib.messages 
> django.contrib.staticfiles 
> south  

Not synced (use migrations): 
- getPost 
(use ./manage.py migrate to migrate these) 
(r1)  

$ ./manage.py migrate getPost 

Running migrations for getPost: 
- Migrating forwards to 0005_auto__del_field_url_date. 
> getPost:0001_initial 
FATAL ERROR - The following SQL query failed: CREATE TABLE "getPost_poll" ("id" serial NOT NULL PRIMARY KEY, "question" varchar(200) NOT NULL, "pub_date" timestamp with 
time zone NOT NULL) 
The error was: la relación «getPost_poll» ya existe  

Error in migration: getPost:0001_initial 

我可以看到你让我拉近了许多。任何进一步的建议?

回答

1

south_migrationhistory似乎不存在。在使用南迁移之前,您需要运行一次manage.py syncdb

south_migrationhistory对于每个应用程序,已存在哪些迁移。如果您将现有应用转换为南,则初始迁移应与当前架构状态匹配,例如,在创建初始迁移之前,您不应该进行任何模型更改。然后,使south_migrationhistory表匹配模式状态下,可以“假申请”初始迁移:

manage.py migrate appname 0001 --fake 

,将创建在south_migrationhistory表中的初始迁移记录而不实际试图做任何架构变化。现在,您可以应用其余的迁移:

manage.py migrate appname 
+0

请参阅编辑 – user61629

+0

我猜'ya existe'表示已存在?在创建迁移之前,您是否为'getPost'执行'syncdb'?这样,表格就会存在,但南方'认为'它们没有。如果最初的迁移0001匹配您当前的数据库状态,您可以执行'manage.py migrate getPost 0001 --fake'然后'manage.py migrate' – sk1p

+0

再次感谢sk1p。你有它的工作!我在004迁移中遇到迁移错误。但至少它已经达到了这一点。最好的问候 - 比尔 – user61629

相关问题