Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

South django table already exists

I'm experiencing the same problem as with: django - "manage.py test" fails "table already exists"

The schemamigration / migration worked fine (although did have some problems that required me to --fake, but all subsequent migrations with south work). But when I run a unit test I get:

(1050, "Table '{tablename}' already exists")

I'm just curious how I can get round this, and why this happens. The only answer given in the question linked above was that south could be excluded from unit tests, if I do this does it mean I can't unit test with tables managed by south?

Explanations much appreciated :)

Adam

like image 953
null Avatar asked Feb 10 '11 14:02

null


1 Answers

No, it doesn't mean that. Don't forget that Django already knows what your tables should look like if you create them from scratch now - it just uses the model definitions. South is useful because it allows you to easily transform your table structure when you change your models, but when you're running tests you don't care about that: you just want the tests run on the current versions of the tables.

So yes, disable South when running tests, via SOUTH_TESTS_MIGRATE = False, and Django will automatically create the tables for you.

like image 100
Daniel Roseman Avatar answered Sep 21 '22 11:09

Daniel Roseman