5

I cannot seem to get this working.

I need South to do migrations for a bunch of apps.

  1. Downloaded south 0.7.3
  2. Unzipped, ran setup.py develop (as it says in the turorial)
  3. Double checked to see if it south is where it should be by going to python interpreter and doing (no errors)

    import south

  4. I do

C:\Users\j\iMiCode\imi_admin>python ./manage.py syncdb

Syncing... No fixtures found.

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

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

-At this point from what I understand south should have been synced correct? Anything else I do after this, complains that I have no south_migrationhistory tables in the database.

PS. I am working with Django 1.2.7, python 2.6, on Windows7

StanM
  • 827
  • 4
  • 12
  • 33

3 Answers3

17

It seems to me like a bug in South.

Also this may be cause by doing wrong thigs like: running schemamigration --auto south and etc. My suggestion would be install it by running python setup.py install or through easy_install or pip

South documentation says: "Once South is added in, you’ll need to run ./manage.py syncdb to make the South migration-tracking tables (South doesn’t use migrations for its own models, for various reasons)."

But your output says that south skipped making tables for its own models because it thought south app used migrations

As a workaround you could use

python manage.py syncdb --all

Which causes all tables regardless of migrations to be synchronized and

python manage.py migrate --fake 

to fake migrations.

Marius Grigaitis
  • 2,520
  • 3
  • 23
  • 30
  • 1
    Awesome. --all resolved it, thank you!. I did use python setup.py install to install south. That seemed to install it but somehow it just wasn't creating the needed tables. – StanM Mar 12 '12 at 18:08
  • Been hunting around for 4 hours for that --all. Thanks a million. django.contrib.admin was not being picked up by "python manage.py syncdb". It kept on telling me to run "migrate". Running migrate would say "no new changes". So I was left without any admin tables. "--all" went ahead and created if for me. All is well that ends well! – harisibrahimkv Jan 07 '14 at 08:10
0

I ran into this same issue. Turns out, by some magics, I had created migrations inside of hte south app.

Discovered by:

~ $ # cd to python library
~ $ cd `python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
python2.7/site-packages $ cd south
python2.7/site-packages/south $ ls migrations
   0001_initial.py  0002_initial.py 0003_initial.py __init__.py

These are bad, should not be there, and is what triggers south to skip itself. Removed all things south, reinstalled, then syncdb once again worked.

python2.7/site-packages $ rm -rf south* South*
~ $ pip install south
Doug
  • 655
  • 2
  • 6
  • 15
0

For a new app, with no existing tables the steps to adding south are this:

  1. add 'south', to the list of INSTALLED_APPS.

  2. make sure the app you need to migrate is also in INSTALLED_APPS.

  3. run ./manage.py syncdb (or python manage.py syncdb from inside your project directory). This adds the migration tables to the database.

  4. from the command line, perform ./manage.py schemamigration yourappname --initial

  5. run ./manage.py migrate yourappname

Based on the error you're giving, it sounds like after step 1 & 2 you forgot to run syncdb to create the migration tables, and the South app isn't finding the place it wants to store schema migrations.

patrickn
  • 2,501
  • 4
  • 22
  • 21
  • If you're adding South to an existing app, you have to do ./manage.py convert_to_south yourappname, which "fakes" your first migration. Note this quote from the South documentation on the convert_to_south command: – patrickn Mar 09 '12 at 14:32
  • The convert_to_south command only works entirely on the first machine you run it on. Once you’ve committed the initial migrations it made into your VCS, you’ll have to run ./manage.py migrate myapp 0001 --fake on every machine that has a copy of the codebase (make sure they were up-to-date with models and schema first). – patrickn Mar 09 '12 at 14:33
  • Thank you for detailed feedback. I ran syncdb in step 4 (step 3 was a purely optional double-check to see that south was in correct folder because i have 2 python installations on my computer. – StanM Mar 12 '12 at 18:06