|Version 9 (modified by andrew, 5 years ago) (diff)|
Frequently Asked Questions
Frequently Asked Questions
- Why does my migration with both column changes and data changes fail?
- My data migration involving ContentType is failing
- Why does South keep claiming my migration doesn't exist, when it does?
- Why can't I use --add-field with a ManyToMany field that uses a 'through' …
- I can't alter/delete my ForeignKey column, it claims it doesn't exist.
- Passing a field with unique=False to alter_column doesn't remove that …
- I'm using PostgreSQL, and migrations just hang indefinitely
- South won't see my apps!
If you have a question you think needs to go on here, then get in touch.
Why does my migration with both column changes and data changes fail?
You can't edit the columns and the data in them in the same transaction, and since all migrations are wrapped in transactions your database will complain. See Migration Structure: Transactions for more, and an example of how to start a new transaction.
My data migration involving ContentType is failing
This is probably because you're using ContentType, not orm['contenttypes.ContentType'] - the latter is the frozen model, and is the one your frozen models will be reconstructed using. You'll need to use it for comparisons to work correctly.
Why does South keep claiming my migration doesn't exist, when it does?
Why can't I use --add-field with a ManyToMany field that uses a 'through' model?
It's your responsibility to create the interim table manually, since South can't really tell if it's there or not. Just use ./manage.py startmigration appname migrationname --model ThroughModelName instead.
I can't alter/delete my ForeignKey column, it claims it doesn't exist.
Remember that ForeignKey? columns have an extra _id at the end of their name; you don't need to specify this in add_column, but you do in alter_column and delete_column, as we can't infer it there.
Passing a field with unique=False to alter_column doesn't remove that column's UNIQUE constraint.
No, it doesn't, you need to use delete_unique instead, like so:
Note that in MySQL this will also drop an index you have on the column.
I'm using PostgreSQL, and migrations just hang indefinitely
This is actually PostgreSQL hanging on the schema-altering statement - it usually means it's waiting for other connections. You can "fix" it by closing your other apps with connections to the database (e.g. ./manage.py shell), or by restarting the database to accomplish the same thing.
South won't see my apps!
This is actually usually because Django can't see them either. To see if Django knows about them, do:
./manage.py shell from django.db import models models.get_app("myappname")
If that works, then it may well be a South bug; if it errors, you have an issue with your Django setup.