tags:

views:

534

answers:

2

I am trying to get started with South.

I had an existing database.

I added South (syncdb, schemamigration --initial).

I updated models.py to add a field.

I ran ./manage.py schemamigration myapp --auto

It seemed to find the field and said I could apply this with ./manage.py migrate myapp

Doing that gave the error:

django.db.utils.DatabaseError: table "myapp_tablename" already exists

tablename is the first table listed in models.py.

I am running Django 1.2, South 0.7

+4  A: 

since you already have the tables created in the database, you just need to run the initial migration as fake

./manage.py migrate myapp --fake

make sure that the schema of models is same as schema of tables in database.

Ashok
Got it, thanks. It's actually migrate and not schemamigration, but your answer got me in the right direction.
Steve
my mistake just copied the command from OP, correct command./manage.py migrate myapp --fake
Ashok
+1  A: 

Although the table "myapp_tablename" already exists error stop raising after I did ./manage.py migrate myapp --fake, the DatabaseError shows no such column: myapp_mymodel.added_field.

any hints?

Mark Renton
Was added_field in your models.py when you did your initial migration? If so, South did not actually update your database. It thinks added_field is already in the database when it isn't. When you run --init and then --fake, you must make sure your models.py reflects the database as it is starting out. This is the reference point South will start out with. Then you can add fields and run migrations.
Steve
actually the added_field is not in models.py when running --init. and I didn't get any results after searching south's documents. I will try to use some simple model to test it fisrt. thanks anyway.
Mark Renton
Yep, am experiencing the same problems, any head way on this...
gath