Question

I am developing on win7 with pycharm 3 with python/django on a portable environment. I've decided to try to add postgresql to my project ("rob1") which is inside my virtualenv "R1" and I have using http://sourceforge.net/projects/pgsqlportable/

I am working with South for the first time.

I changed my models, saved my work and ran:

$ ./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

but when I run:

./manage.py migrate MYAPP

I get a long traceback ending with:

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

My postgres console then shows:

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.

The changes are not reflected in the postgres tables. How can I fix this?

Edit:

$ ./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

I can see you are getting me a lot closer.. Any further advice?

Was it helpful?

Solution

The table south_migrationhistory doesn't seem to exist. You need to run manage.py syncdb once before you can use south migrations.

south_migrationhistory persists, for each app, which migrations are already applied. If you convert an existing app to south, the initial migration should match the current schema state, e.g. you should not do any model changes before creating the initial migration. Then, to make the south_migrationhistory table match the schema state, you can 'fake-apply' the initial migration:

manage.py migrate appname 0001 --fake

that will create the record for the initial migration in the south_migrationhistory table without actually attempting to do any schema changes. Now you can apply the rest of your migrations:

manage.py migrate appname
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top