我在win7上使用pycharm 3和python / django在便携式环境中进行开发。我决定尝试将postgresql添加到我的virtualenv“R1”中的项目(“rob1”)中,并使用http://sourceforge.net/projects/pgsqlportable/
我是第一次和南方合作。
我改变了模型,保存了我的工作并运行了:
$ ./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
我可以看到你让我更接近了......还有什么进一步的建议吗?
答案 0 :(得分:1)
表south_migrationhistory
似乎不存在。在使用南迁移之前,您需要运行manage.py syncdb
一次。
south_migrationhistory
会保留已应用的迁移。如果将现有应用程序转换为南方,则初始迁移应与当前架构状态匹配,例如在创建初始迁移之前,不应进行任何模型更改。然后,要使south_migrationhistory
表与架构状态匹配,您可以“伪申请”初始迁移:
manage.py migrate appname 0001 --fake
将在south_migrationhistory
表中创建初始迁移的记录,而不会实际尝试进行任何架构更改。现在,您可以应用其余的迁移:
manage.py migrate appname