how to restore dropped table with django-south? how to restore dropped table with django-south? python python

how to restore dropped table with django-south?


It's a pretty late response but for people who will run into the same issue (like I did).

Normally to drop the db_tables for the app that is managed by south you should use:

python manage.py migrate appname zero

But if you dropped them manually in the db let south know about it

python manage.py migrate appname zero --fake

And of course to recreate the tables

python manage.py migrate appname


Had the identical problem. Not sure this works in all circumstances, but here's what I did:

  1. comment out "south" from INSTALLED_APPS
  2. run manage.py syncdb
  3. uncomment "south" in INSTALLED_APPS
  4. run manage.py migrate

Voila!

Your mileage may vary....


Hmm this exchange covers my very question:

If you modify the database by hand, South won't notice - its only way of keeping track of what version the database is is the south_migrationhistory table, so if you fiddle behind its back, it's your responsibility to fix it.

What I ended up doing was commenting out the model that I dropped in question, doing a schemamigration, creating an empty no-column table of the one I dropped (so South has something to drop), migrateing, then un-commenting the model, schemamigration and migrateing again. A bit more annoying than just dropping the table and syncdb but ah well.