﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24102	SchemaEditor.create_model doesn't create a constraint name for unique_together	Damien Nozay	nobody	"In `BaseDatabaseSchemaEditor.create_model` there are currently no names for `unique_together` constraints.

http://stackoverflow.com/a/27836476/1733117

{{{#!python
class BaseDatabaseSchemaEditor(object):
    # Overrideable SQL templates
    sql_create_table_unique = ""UNIQUE (%(columns)s)""
    sql_create_unique = ""ALTER TABLE %(table)s ADD CONSTRAINT %(name)s UNIQUE (%(columns)s)""
    sql_delete_unique = ""ALTER TABLE %(table)s DROP CONSTRAINT %(name)s""
}}}

`create_model` has this bit:
{{{#!python
        # Add any unique_togethers
        for fields in model._meta.unique_together:
            columns = [model._meta.get_field(field).column for field in fields]
            column_sqls.append(self.sql_create_table_unique % {
                ""columns"": "", "".join(self.quote_name(column) for column in columns),
            })
}}}

whereas adding a new unique_together constraint does this:
{{{#!python
    def _create_unique_sql(self, model, columns):
        return self.sql_create_unique % {
            ""table"": self.quote_name(model._meta.db_table),
            ""name"": self.quote_name(self._create_index_name(model, columns, suffix=""_uniq"")),
            ""columns"": "", "".join(self.quote_name(column) for column in columns),
        }
}}}

"	Cleanup/optimization	closed	Migrations	1.7	Normal	fixed			Accepted	1	0	1	0	0	0
