title: Django / MySql not honouring unique_together
body: <p>I am using django with mysql (InnoDB) and have the following in my django model:</p>
  
  <pre><code>class RowLock(models.Model):
      table_name = models.CharField(blank = False, max_length = 30)
      locked_row_id = models.IntegerField(null = False)
      process_id = models.IntegerField(null = True)
      thread_id = models.IntegerField(null = True)
      class Meta:
          db_table = "row_locks"
          unique_together = (("table_name", "locked_row_id"),)
  </code></pre>
  
  <p>Running python manage.py sql app_name gives :</p>
  
  <p>However within mysql client doing desc row_locks gives:</p>
  
  <pre><code>mysql&gt; desc row_locks;
  +---------------+-------------+------+-----+---------+----------------+
  | Field         | Type        | Null | Key | Default | Extra          |
  +---------------+-------------+------+-----+---------+----------------+
  | id            | int(11)     | NO   | PRI | NULL    | auto_increment |
  | table_name    | varchar(30) | NO   |     | NULL    |                |
  | locked_row_id | int(11)     | NO   |     | NULL    |                |
  | process_id    | int(11)     | YES  |     | NULL    |                |
  | thread_id     | int(11)     | YES  |     | NULL    |                |
  +---------------+-------------+------+-----+---------+----------------+
  5 rows in set (0.00 sec)
  </code></pre>
  
  <p>Have also checked that I can enter duplicate rows with same values for table_name and locked_row_id without integrity error.</p>
  
  <p>Now my assumption is that I am doing something wrong here because such an obvious thing could not be in the wild as a bug, but I can't see it, </p>
  
  <p>Any fresh eyes would be appreciated</p>
  
  <p>Rob</p>
  
  <p>Update:
  So as Dominic pointed out the problem was the south migration not creating the unique constraint. I could have looked at doing 2 migrations, one to create the table and then a subsequent one to add the unique_together - don't know if that would have worked or not - may try with more time.</p>
  
  <p>In any case I got around it by manually editing the forward method in the south migration script as follows:</p>
  
  <p>As generated by south:</p>
  
  <pre><code>class Migration(SchemaMigration):
  
      def forwards(self, orm):
  
          # Adding model 'RowLock'                                                                                           
          db.create_table('row_locks', (
              ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
              ('table_name', self.gf('django.db.models.fields.CharField')(max_length=30)),
              ('locked_row_id', self.gf('django.db.models.fields.IntegerField')()),
              ('process_id', self.gf('django.db.models.fields.IntegerField')(null=True)),
              ('thread_id', self.gf('django.db.models.fields.IntegerField')(null=True)),
          ))
          db.send_create_signal('manager', ['RowLock'])
  </code></pre>
  
  <p>Manually edited:</p>
  
  <pre><code>class Migration(SchemaMigration):
  
      def forwards(self, orm):
  
          # Adding model 'RowLock'                                                                                           
          db.create_table('row_locks', (
              ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
              ('table_name', self.gf('django.db.models.fields.CharField')(max_length=30)),
              ('locked_row_id', self.gf('django.db.models.fields.IntegerField')()),
              ('process_id', self.gf('django.db.models.fields.IntegerField')(null=True)),
              ('thread_id', self.gf('django.db.models.fields.IntegerField')(null=True)),
          ))
          db.create_index('row_locks', ['table_name','locked_row_id'], unique=True)
          db.send_create_signal('manager', ['RowLock'])
  </code></pre>