1
votes

I want to use south to manage database changes in both development and production using mercurial. However I cannot find out what should I do !

Let's say that I have a project that doesn't use south at all. It is syncded in both production and development with mercurial. Everything is working fine !

Now, one day I want to make a change to a model of the application test. So, what I in my development environment is

1. python manage.py convert_to_south test
2. python manage.py migrate

Now I change the model and then

3. python manage.py schemamigration test --auto
4. python manage.py migrate

Now I commit everything to mercurial

5. hg addremove
6. hg commit -m "Converted to south and changed stuff"
7. hg push production

Everything seems to work fine in the uat but, I cannot make it work in production :(

So I thought that the correct workflow would be to log into production and apply changes

1. hg update

and then just migrate the application

2. python manage.py migrate

But this is not working, I am getting a strange error of "test_table" already exists (for some reason south wants to crate again the table). Also, I read here Adding South to Django project, development & production that I should do a python manage.py migrate test --fake 0001 before doing the migration - but this also didn't work (i got an error for a missing table or somthing like that).

So ? What should I do ? What is the correct way to apply migrations to both development and environment ? Should I leave the /migrations/ directory of my applications out of mercurial and run

python manage.py convert_to_south test 
and
python manage.py schemamigration test --auto 

to both development and production ?

1

1 Answers

4
votes

convert_to_south is just two commands chained together: schemamigration --init + migrate --fake. So init just creates a migration as usual, and fake makes sure you don't need to apply migration manually. But your server gets a migration, not creates it, so you really need to run manage.py migrate test 0001 --fake and it should be working. Possibly, you haven't run syncdb after installing south so server DB does not have south tables.

So, run:

manage.py syncdb
manage.py migrate test 0001 --fake