Question

I have an existing django app and would like to add a field to a model. But because the website is already in production, just deleting the database is not an option any more.

These are the steps I took:

  • pip install south
  • added 'south' to INSTALLED_APPS
  • python manage.py syncdb
  • python manage.py convert_to_south [myapp]

So now I have the initial migration and south will recognize the changes. Then I added the field to my model and ran:

  • python manage.py schemamigration [myapp] --auto
  • python manage.py migrate [myapp]

Now I have the following migrations:

  • 0001_initial.py
  • 0002_auto__add_field_myapp_fieldname.py

Which commands should I run on my production server now to migrate? Also should I install south first and then pull the code changes and migrations?

Was it helpful?

Solution

first is to fake the initial migration:

python manage.py migrate [yourapp] --fake 0001

then you can apply the migration to the db

python manage.py migrate [yourapp]


I'm assuming you ran convert_to_south on development, in which case production still wouldn't be aware of the migrations yet. convert_to_south automatically fakes the initial migration for you! If you were to just run migrate on production without faking, it should error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top