10

I'm new to South so I am wondering if I ever need to call

./manage.py syncdb

or doing

./manage.py schemamigration appname --auto
./manage.py migrate appname

is sufficient in all cases South can handle on its own.

Dan Abramov
  • 264,556
  • 84
  • 409
  • 511
  • I had this exact same question after reading the south docs. They are good but a clearer explanation of this relationship would definitely not be out of place. – markdsievers Aug 09 '12 at 23:19

2 Answers2

21

South isn't project wide. It is app wide.
Some apps use south, some apps don't use it.

if an app is integrated south, to do db changes you will use

./manage.py schemamigration appname --auto
./manage.py migrate appname

but not all apps are integrated with south.

When you add a new app that don't use south to your project, you need to call ./manage.py syncdb for these apps. (For example, django.contrib apps)

In short, use ./manage.py syncdb when an app doesn't use south, and ./manage.py migrate for south integrated apps.

Dan Abramov
  • 264,556
  • 84
  • 409
  • 511
mumino
  • 2,119
  • 1
  • 15
  • 8
  • Thank you for a clear explanation. I edited your answer to add some formatting. – Dan Abramov Jun 14 '11 at 01:08
  • 3
    I found South behavior confusing until I realized that South changes syncdb behavior. One installed, syncdb is a no-op on apps managed by South. So you can run syncdb on a site even if it has some apps managed by south. You have to be careful when you first install south that the syncdb and initial migrations are consistent, but once you've done that, it's nicely error-tolerant. – Nils Mar 20 '12 at 17:07
  • 1
    Something to be aware of is that South migrations are run before any fixture for the app is loaded. I've just come across this, because I was trying to run a data migration that was assuming that rows in the initial_data.json fixture had already been loaded. – tobych Jan 03 '13 at 20:16
  • Note: If you're converting an existing app (one that had already been managed by `./manage.py syncdb`) check out http://south.readthedocs.org/en/latest/convertinganapp.html#converting-an-app – smholloway May 14 '14 at 21:13
8

When you create or install a new app MyApp, you should first execute the following commands:

./manage.py schemamigration MyApp --inital
./manage.py migrate MyApp

After that whenever you execute ./manage.py syncdb you will see:

Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

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

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

You can see that manage.py syncdb is able to differentiate between apps managed by South (Not synced section) and those not managed by South (Synced section). It also reminds you to use ./manage.py migrate.

The important point is to let South manage a new app by executing ./manage.py schemamigration MyApp --inital and ./manage.py migrate MyApp before executing ./manage.py syncdb.

smholloway
  • 589
  • 7
  • 14
Toff'
  • 389
  • 3
  • 10