I bulk loaded some data into my Postgresql db, only to realize all of it was a bit wrong. Keen to rectify this I flushed the db in order to reload the correct data.
Data reloaded, I made a change to a model and applied the normal ./manage.py schemamigration app --auto, and then ./manage.py migrate app (which had been working up to this point).
At this point I started getting the error:
django.db.utils.DatabaseError: relation "app_model" already exists
And the traceback appeared to be calling the initial migration file 001. So I think the answer is to do something like:
./manage.py migrate app 0005 --fake
Where the current migration that I’m looking to apply is 0006 (i.e. this is where the migrations began failing), and then the south database within postgres should be back where it was before I foolishly flushed it. At this point I should be able to
./manage.py migrate app
Can someone tell me that this approach is correct? Or if not, what the correct approach is?
After
python manage.py migrate app --fakedo a
python manage.py schemamigration app --autoand then do a
python manage.py migrate app