Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#34423 closed Cleanup/optimization (wontfix)

Migrations, UniqueConstraint lenght of identifier can be too long for Postgres/MySQL

Reported by: Joel Shapiro Owned by: nobody
Component: Migrations Version: 4.1
Severity: Normal Keywords: migrations, unique_constraint, UniqeConstraint
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When creating a new unique constraint it is quite easy with the interpolation of %(class)s to generate a very long name as identifier (name) of the constraint.

Postgres and MySQL both have limits on how long the name can be (63/64) characters, Postgres does allow for a longer name but it will be truncated.

Creating two names with the same first part will make it so that we have two identical identifiers and the migrations will not work.

An error like this will be thrown;

django.db.utils.ProgrammingError: relation "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" already exists

Change History (3)

comment:2 by Mariusz Felisiak, 20 months ago

Resolution: wontfix
Status: newclosed
Type: BugCleanup/optimization

Thanks for this ticket, however, I'm against this change. First of all it is backward incompatible. Constraints have been introduced in Django 2.2 and constraints with a name of length greater than 63 characters are valid on other databases (64 on MySQL, 128 on MSSQL, etc.). I agree that it is a inconsistency between constraints and indexes policy but still we need to be careful with introducing incompatibilities. See also a related ticket, #30614.

Please first start a discussion on the DevelopersMailingList, where you'll reach a wider audience and see what other think, and follow the triaging guidelines with regards to wontfix tickets.

in reply to:  2 comment:3 by Joel Shapiro, 20 months ago

Replying to Mariusz Felisiak:

Thanks for this ticket, however, I'm against this change. First of all it is backward incompatible. Constraints have been introduced in Django 2.2 and constraints with a name of length greater than 63 characters are valid on other databases (64 on MySQL, 128 on MSSQL, etc.). I agree that it is a inconsistency between constraints and indexes policy but still we need to be careful with introducing incompatibilities. See also a related ticket, #30614.

Please first start a discussion on the DevelopersMailingList, where you'll reach a wider audience and see what other think, and follow the triaging guidelines with regards to wontfix tickets.

Thanks for the fast response!

Yes, I agree. Not great to break compatibility.

Version 0, edited 20 months ago by Joel Shapiro (next)
Note: See TracTickets for help on using tickets.
Back to Top