Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Add second shortener to create_index_name for very long columns

  • Loading branch information...
1 parent d146b25 commit 0bcfc068b011c41aeed135649276106147d90d70 @andrewgodwin andrewgodwin committed
Showing with 4 additions and 0 deletions.
  1. +4 −0 django/db/backends/
4 django/db/backends/
@@ -1,3 +1,4 @@
+import hashlib
from django.db.backends.creation import BaseDatabaseCreation
from django.db.backends.util import truncate_name
from django.utils.log import getLogger
@@ -615,6 +616,9 @@ def _create_index_name(self, model, column_names, suffix=""):
if len(index_name) > self.connection.features.max_index_name_length:
part = ('_%s%s%s' % (column_names[0], index_unique_name, suffix))
index_name = '%s%s' % (table_name[:(self.connection.features.max_index_name_length - len(part))], part)
+ # If it's STILL too long, just hash it down
+ if len(index_name) > self.connection.features.max_index_name_length:
+ index_name = hashlib.md5(index_name).hexdigest()[:self.connection.features.max_index_name_length]
return index_name
def _constraint_names(self, model, column_names=None, unique=None, primary_key=None, index=None, foreign_key=None, check=None):

0 comments on commit 0bcfc06

Please sign in to comment.
Something went wrong with that request. Please try again.