| 167 | | output.extend(self.sql_indexes_for_field(model, f, style)) |
| | 167 | if f.db_index and not f.unique: |
| | 168 | output.extend(self.sql_indexes_for_fields(model, [f], style, f.db_tablespace)) |
| | 169 | |
| | 170 | for fields in model._meta.composite_indexes: |
| | 171 | fields = [model._meta.get_field(f) for f in fields] |
| | 172 | output.extend(self.sql_indexes_for_fields(model, fields, style)) |
| 175 | | |
| 176 | | if f.db_index and not f.unique: |
| 177 | | qn = self.connection.ops.quote_name |
| 178 | | tablespace = f.db_tablespace or model._meta.db_tablespace |
| 179 | | if tablespace: |
| 180 | | tablespace_sql = self.connection.ops.tablespace_sql(tablespace) |
| 181 | | if tablespace_sql: |
| 182 | | tablespace_sql = ' ' + tablespace_sql |
| 183 | | else: |
| 184 | | tablespace_sql = '' |
| 185 | | i_name = '%s_%s' % (model._meta.db_table, self._digest(f.column)) |
| 186 | | output = [style.SQL_KEYWORD('CREATE INDEX') + ' ' + |
| 187 | | style.SQL_TABLE(qn(truncate_name( |
| 188 | | i_name, self.connection.ops.max_name_length()))) + ' ' + |
| 189 | | style.SQL_KEYWORD('ON') + ' ' + |
| 190 | | style.SQL_TABLE(qn(model._meta.db_table)) + ' ' + |
| 191 | | "(%s)" % style.SQL_FIELD(qn(f.column)) + |
| 192 | | "%s;" % tablespace_sql] |
| | 180 | qn = self.connection.ops.quote_name |
| | 181 | tablespace = tablespace or model._meta.db_tablespace |
| | 182 | if tablespace: |
| | 183 | tablespace_sql = self.connection.ops.tablespace_sql(tablespace) |
| | 184 | if tablespace_sql: |
| | 185 | tablespace_sql = ' ' + tablespace_sql |
| 194 | | output = [] |
| | 187 | tablespace_sql = '' |
| | 188 | i_name = '%s_%s' % (model._meta.db_table, self._digest(*[f.column for f in fields])) |
| | 189 | output = [style.SQL_KEYWORD('CREATE INDEX') + ' ' + |
| | 190 | style.SQL_TABLE(qn(truncate_name( |
| | 191 | i_name, self.connection.ops.max_name_length()))) + ' ' + |
| | 192 | style.SQL_KEYWORD('ON') + ' ' + |
| | 193 | style.SQL_TABLE(qn(model._meta.db_table)) + ' ' + |
| | 194 | "(%s)" % ','.join(style.SQL_FIELD(qn(f.column)) for f in fields) + |
| | 195 | "%s;" % tablespace_sql] |