unique_together contraints and South

192 views
Skip to first unread message

Nathan Auch

unread,
Jul 20, 2010, 2:15:03 PM7/20/10
to south...@googlegroups.com
I'm implementing a Sybase SQL Anywhere backend for South to enable the use of OSQA with SQL Anywhere. I'm able to apply all the migrations supplied by OSQA, but I'm seeing significant differences in schema depending on whether or not South was used to create the database. One class of differences is with unique_together constraints. If I disable South, and create the database via syncdb, I get unique indexes created over the columns specified in the model's Meta.unique_together list. With South enabled, applying the migrations in order results in a database that does not have this index created.

I have implemented the create_unique() method in the backend but it doesn't seem to get called for unique_together constraints. I tried looking though the rest of the code in South but I didn't see anything obvious that handled unique_together.

How are unique_together constraints implemented within South?

Thanks!
Nathan Auch
Sybase iAnywhere

Some background about SQL Anywhere for the curious:

http://www.sybase.com/products/databasemanagement/sqlanywhere
http://code.google.com/p/sqlany-django/

Andrew Godwin

unread,
Jul 20, 2010, 3:29:34 PM7/20/10
to south...@googlegroups.com
On 20/07/10 19:15, Nathan Auch wrote:
I'm implementing a Sybase SQL Anywhere backend for South to enable the use of OSQA with SQL Anywhere. I'm able to apply all the migrations supplied by OSQA, but I'm seeing significant differences in schema depending on whether or not South was used to create the database. One class of differences is with unique_together constraints. If I disable South, and create the database via syncdb, I get unique indexes created over the columns specified in the model's Meta.unique_together list. With South enabled, applying the migrations in order results in a database that does not have this index created.

I have implemented the create_unique() method in the backend but it doesn't seem to get called for unique_together constraints. I tried looking though the rest of the code in South but I didn't see anything obvious that handled unique_together.

How are unique_together constraints implemented within South?

So, they're detected by the autodetector (--auto), and that generates create_unique/delete_unique calls in the migration file. If they're not in the files already, either you're not using the autogenerator or there's a bug, in which case, what version of South are you using?

Andrew

Nathan Auch

unread,
Jul 20, 2010, 3:35:28 PM7/20/10
to south...@googlegroups.com
I'm using South 0.7.1. The migration scripts in question were generated by the OSQA project (osqa.net). I'm simply trying to apply them.

The scripts don't contain create_unique statements for the missing indexes. It looks like the OSQA folks are either using a buggy South or haven't used the --auto switch.

Thanks!
 -Nathan

Reply all
Reply to author
Forward
0 new messages