Opened 5 years ago

Closed 5 years ago

#13434 closed (duplicate)

MySQL Index creation with long name fails

Reported by: hgeerts@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

With the introduction of the through model for ManyToManyFields in [11710] django creates an index for all ForeignKeys on the through model.
Because of the naming scheme used by the through model you can easily exceed the 64 character limit for the index name on MySQL.

django-1.1 did not have this problem because it created an index with 'ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' for which the name is already truncated.

Syncdb only generates an error but does not stop so this is only a minor inconvenience.
The attached patch truncates the index name if applicable and sets the max_name_length for mysql to 64.

Attachments (1)

django-mysql-index-length.patch (1.6 KB) - added by hgeerts@… 5 years ago.

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by hgeerts@…

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12977.

Note: See TracTickets for help on using tickets.
Back to Top