6

I am having trouble having south to work with my django project, i have followed the south documentation on converting apps to south and also looked here (Why don't my south migrations work?) but all in vain.

After adding south to INSTALLED_APPS and run syncdb,

Synced:
 > django.contrib.messages
 > django.contrib.staticfiles
 > smartmin
 > nsms.console
 > django_extensions
 > pagination
 > restaurant_detail
 > live
 > debug_toolbar
 > orders
 > django.contrib.admindocs

Not synced (use migrations):
 - django.contrib.auth
 - django.contrib.contenttypes
 - django.contrib.sessions
 - django.contrib.sites
 - guardian
 - south
 - django_quickblocks
 - rapidsms
 - rapidsms_httprouter
 - sorl.thumbnail
 - djangoratings
 - agon_ratings
 - django.contrib.admin
(use ./manage.py migrate to migrate these)

at this point i execute this command,python manage.py migrate, this gives error django.db.utils.DatabaseError: relation "south_migrationhistory" does not exist LINE 1: ...gration", "south_migrationhistory"."applied" FROM "south_mig... What am i doing wrong here?

Community
  • 1
  • 1
Suziemac Tani
  • 455
  • 9
  • 23

5 Answers5

14

If this is your first migration or you just want to start over:

  1. Drop and create your current database
  2. Remove your migrations directory: rm -Rf your_app/migrations/
  3. Sync and migrate in just one command: python manage.py syncdb --migrate

Next migrations would need:

  1. python manage.py schemamigration your_app --auto
  2. python manage.py migrate your_app

That works for me :)

chachan
  • 2,382
  • 1
  • 26
  • 41
  • note: you might need to delete migrations folders in other directories, like `site-packages/django/contrib/auth/migrations` – BenjaminGolder Apr 10 '14 at 04:35
4

This all came about because south in my site_packages had a migrations directory already, which i didn't know was there.When i got rid of the directory everything worked just fine. Apologoies the stackoverflow folks that toiled to solve a problem that was caused due to my absent mindedness.

Suziemac Tani
  • 455
  • 9
  • 23
2

This problem can be created by following well meaning advice: if you tried python manage.py schemamigration south --initial at any point in your debugging attempts, you'll create a 'migrations' folder in your site-packages in the South app itself. Unfortunately, the existence of a migrations folder is how South determines if it should skip an app when performing its altered syncdb process. Including if that app... is South.

When you drop your database to try and debug from scratch, South's modified syncdb will skip creating the south_migrationhistory table, assuming that the migrations folder will know better, and the migrations table requires the south_migrationhistory table to work.

To solve the issue:

  1. Go into your site packages and delete the migrations/ folder in the south app.
  2. Run python ./manage.py syncdb one last time

Uninstalling/reinstalling South via pip won't actually cut it, as it'll leave the offending folder untouched.

Alternately, Marius Grigaitis proposed a workaround to the same error, although it was attributed at the time to a south bug.

Community
  • 1
  • 1
TimClifford
  • 255
  • 4
  • 10
1

You have to first migrate south itself to create south tables, then you can migrate your other applications:

# python manage.py migrate south
# python manage.py migrate
bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
0

It seems that the migrations' tables are not being created in your database. It's a little bit odd by maybe this will work:

python manage.py schemamigration south --initial
python manage.py migrate south

and then continue with the other migrations.

Paulo Bu
  • 29,294
  • 6
  • 74
  • 73
  • If you don't have your south tables, you want to add south tables to your non-existing south tables ? – AlvaroAV Mar 14 '14 at 09:07
  • @Liarez I really appreciate your feedback but as you can see, the answer of this questions was kind of _odd_ and it is almost one year old. When I answered this I was just taking a hunch (as you can see, there were others too). How do you expect me to remind what I was thinking in that moment? Anyways, feel free to downvote :) – Paulo Bu Mar 14 '14 at 09:14
  • I just had that problem, and I saw many people repeating things like your answer, and it doesn't have any sense if south is not working trying to migrate to himself, thats why the downvote, because the answer doesn't help at all – AlvaroAV Mar 14 '14 at 09:51
  • @Liarez fair enough. Good to know you found the answer to your problem. – Paulo Bu Mar 14 '14 at 09:53