-
Notifications
You must be signed in to change notification settings - Fork 3
Using South to Migrate Django Models
Dyland Xue edited this page Apr 12, 2014
·
9 revisions
- Pull from github master.
git pull origin master
- Delete your database and create a new one -- important, don't try to be smart, just do it! (In PSQL, run
DROP DATABASE dbname; CREATE DATABASE dbname;
) - Create the initial database.
./manage.py syncdb [--settings=settings.dev]
- Tell south where the current database is in migration history. At the time of this writing, the number is 0002.
./manage.py migrate nice 0002 --fake [--settings=settings.dev]
NOTE: Maxim had trouble doing migrate --fake to 0002. Instead, he saw Not synced (use migrations): - nice
in syncdb
output, so the right migrate command to run is python manage.py nice [--settings=settings.dev]
.
- Pull from github master.
git pull origin master
- Sync other (non-south) tables in the database.
./manage.py syncdb [--settings=settings.dev]
- Migrate.
./manage.py migrate nice [--settings=settings.dev]
- Before modifying anything, pull from github and migrate (see Pulling)
- Modify models as needed.
- Tell South of your modifications. This will add new python files to nice/migrations.
./manage.py schemamigration nice --auto [--settings=settings.dev]
- Apply your migrations.
./manage.py migrate nice [--settings=settings.dev]
- Push to server - this won't do anything to heroku.
git push origin master
- Update your models locally (see Modifying Django Models)
- Push to heroku.
git push heroku master
- Apply the migration. !!SYNCDB FIRST!!
heroku run ./manage.py syncdb
heroku run ./manage.py migrate nice