[Django] #33169: migrations fails to run on django32 with mysql5.7

9 views
Skip to first unread message

Django

unread,
Oct 4, 2021, 12:49:11 PM10/4/21
to django-...@googlegroups.com
#33169: migrations fails to run on django32 with mysql5.7
-------------------------------------------+--------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 3.2
Severity: Release blocker | Keywords: django32
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+--------------------------
I am trying to upgrade the project from django22 to 32.
Migrate command gives me this error

django.db.utils.OperationalError: (1059, "Identifier name
'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is too
long")

I did't find any information related to this change in django32 release
notes.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 4, 2021, 2:41:59 PM10/4/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------

Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Uncategorized => Bug
* resolution: => needsinfo
* severity: Release blocker => Normal


Comment:

Thanks for this report, however I don't think you've explained the issue
in enough detail to confirm a bug in Django.
`blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1` is
longer than the maximum identifier name on MySQL. Are you using the built-
in backend for MySQL? Can you provide a minimum project to reproduce?

> I didn't find any information related to this change in django32 release
notes.

Have you checked release notes for Django 3.0 and 3.1?

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:1>

Django

unread,
Oct 4, 2021, 3:00:52 PM10/4/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Awais Qureshi):

I am using mysqlclient==2.0.3 and all django defaults packages/backends.

Yes I have checked django30 and 31 release notes, but no information
available with this change. Same migration is working fine in django22.

`blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1` it has
65 characters but seems fine with django22.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:2>

Django

unread,
Oct 4, 2021, 3:09:41 PM10/4/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

> ... it has 65 characters but seems fine with django22.

This error is not raised by Django, but by MySQL. Can you provide a
minimum project to reproduce?

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:3>

Django

unread,
Oct 4, 2021, 4:44:40 PM10/4/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Jacob Walls):

Have you verified the model field referred to is still in your project? I
can produce your error if I'm executing a previously written migration but
where the field is no longer in my project. Instead, if the field is in my
project, I get this upon `migrate`:

{{{
SystemCheckError: System check identified some issues:

ERRORS:
x.xxxx: (models.E018) Autogenerated column name too long for field
"blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1".
Maximum length is "64" for database "default".
HINT: Set the column name manually using 'db_column'.
}}}

This system check predates 2.2, so if the field is in your project and no
system check is raised, that would be a false negative to address. But we
would need a minimal project to verify that the field exists.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:4>

Django

unread,
Oct 5, 2021, 2:48:56 AM10/5/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Awais Qureshi:

Old description:

> I am trying to upgrade the project from django22 to 32.
> Migrate command gives me this error
>
> django.db.utils.OperationalError: (1059, "Identifier name
> 'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is
> too long")
>
> I did't find any information related to this change in django32 release
> notes.

New description:

I am trying to upgrade the project from django22 to 32.
Migrate command gives me this error

django.db.utils.OperationalError: (1059, "Identifier name
'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is too
long")

I did't find any information related to this change in django32 release
notes.

Important point: `class
BlackboardLearnerAssessmentDataTransmissionAudit(models.Model)` is model
name and app name is `blackboard` also.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:5>

Django

unread,
Oct 5, 2021, 10:24:58 PM10/5/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL.
-------------------------------+--------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: django32 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Awais Qureshi):

My information was wrong. On `githubactions` by default mysql is `8.0.26`
but on production we have `mysql5.7`. That was the root cause of the
failure.

Field is available and every thing is fine but `mysql8` triggers this
error and it started appearing in `django30` and upper versions.

Thanks for debugging it helps me a-lot to find out the actual root cause.
Downgrading `mysql` to `5.7` fixed the problem.
Updating the ticket description also.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:6>

Django

unread,
Oct 5, 2021, 10:29:31 PM10/5/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------

Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Awais Qureshi):

* keywords: django32 => django32,mysql8.0.26


Old description:

> I am trying to upgrade the project from django22 to 32.
> Migrate command gives me this error
>
> django.db.utils.OperationalError: (1059, "Identifier name
> 'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is
> too long")
>
> I did't find any information related to this change in django32 release
> notes.
>

> Important point: `class
> BlackboardLearnerAssessmentDataTransmissionAudit(models.Model)` is model
> name and app name is `blackboard` also.

New description:

I am trying to upgrade the project from django22 to 32.
Migrate command gives me this error

django.db.utils.OperationalError: (1059, "Identifier name
'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is too
long")

This issue appeared in `django30` also.

I did't find any information related to this change in django32 release
notes.

Important point: `class


BlackboardLearnerAssessmentDataTransmissionAudit(models.Model)` is model
name and app name is `blackboard` also.


`OS details`
mysql Ver 8.0.26-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
Python 3.8
Django 30,31,38

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:7>

Django

unread,
Oct 6, 2021, 1:05:01 AM10/6/21
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2

Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Description changed by Awais Qureshi:

Old description:

> I am trying to upgrade the project from django22 to 32.


> Migrate command gives me this error
>
> django.db.utils.OperationalError: (1059, "Identifier name
> 'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is
> too long")
>

> This issue appeared in `django30` also.
>

> I did't find any information related to this change in django32 release
> notes.
>

> Important point: `class
> BlackboardLearnerAssessmentDataTransmissionAudit(models.Model)` is model
> name and app name is `blackboard` also.
>

> `OS details`
> mysql Ver 8.0.26-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
> Python 3.8
> Django 30,31,38

New description:

I am trying to upgrade the project from django22 to 32.
Migrate command gives me this error

django.db.utils.OperationalError: (1059, "Identifier name
'blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1' is too
long")

This issue appeared in `django30` also.

I did't find any information related to this change in django32 release
notes.

Important point: `class


BlackboardLearnerAssessmentDataTransmissionAudit(models.Model)` is model
name and app name is `blackboard` also.


`OS details`
mysql Ver 8.0.26-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
Python 3.8

Django 30,31,32

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:8>

Django

unread,
Jan 13, 2022, 2:35:29 PMJan 13
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Awais Qureshi):

* status: closed => new
* resolution: needsinfo =>


Comment:

I have added all required information. You can consider re-opening this
issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:9>

Django

unread,
Jan 13, 2022, 2:45:16 PMJan 13
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2

Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed

* resolution: => needsinfo


Comment:

Awais, I cannot reproduce this issue in MySQL 8 or 5.7 you also didn't
provide a minimum project to reproduce. I don't think you've explained the
issue in enough detail to confirm a bug in Django. Please reopen the
ticket if you can debug your issue and provide details about why and where
Django is at fault.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:10>

Django

unread,
Jan 24, 2022, 10:54:33 AMJan 24
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2

Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Awais Qureshi):

It's not a django issue. as per mysql8.0
[https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html]

`For constraint definitions that include no constraint name, the server
internally generates a name derived from the associated table name. For
example, internally generated foreign key and CHECK constraint names
consist of the table name plus _ibfk_ or _chk_ and a number. If the table
name is close to the length limit for constraint names, the additional
characters required for the constraint name may cause that name to exceed
the limit, resulting in an error.`

My model is as follows

class BlackboardLearnerAssessmentDataTransmissionAudit(models.Model):
enterprise_course_enrollment_id = models.PositiveIntegerField(
blank=False,
null=False,
db_index=True
)

In mysql8 it generate this query with a check
`enterprise_cou_enrollment_id` integer UNSIGNED NOT NULL CHECK
(`enterprise_cou_enrollment_id` >= 0) having this name
`blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1` ( 65
characters ) and it throws the error.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:11>

Django

unread,
Mar 5, 2022, 6:22:15 AMMar 5
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2

Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Awais Qureshi):

I have created a simple app to reproduce this issue. You can see three
`github` checks are running and `django30` and `django32` are showing
error. Since this feature was introduced in `django30`.

This change is related with Added support for check constraints on MySQL
8.0.16+. [https://github.com/django/django/pull/11743]

Sample project with long table name where `mysql8` and `django` is
generating internal checks if model has PositiveIntegerField.

Possible solution:
In case of `makemigrations` trigger some error with max length or truncate
the check name.
In case of upgrading existing project from `mysql57` to `mysql80` show
some valid error message during `migrate` command.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:12>

Django

unread,
Mar 5, 2022, 6:26:40 AMMar 5
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Awais Qureshi):

* status: closed => new
* resolution: needsinfo =>


--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:13>

Django

unread,
Mar 5, 2022, 6:26:48 AMMar 5
to django-...@googlegroups.com
#33169: Migrations crashes with long identifiers on MySQL (8.0.26 )
-------------------------------------+-------------------------------------
Reporter: Awais Qureshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
django32,mysql8.0.26 | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed

* resolution: => invalid


Comment:

Thanks for extra details and a sample project.

I was able to reproduce this error, however Django is not at fault, it
seems to be an issue in MySQL itself. Django executes:
{{{#!sql
CREATE TABLE
`ticket_33169_whiteboxstudentsexaminationdatatransferauditionf7bf` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`unique_student_enrollment_id` integer UNSIGNED NOT NULL CHECK
(`unique_student_enrollment_id` >= 0)
)
}}}
(I called my app `ticket_33169`) so
`ticket_33169_whiteboxstudentsexaminationdatatransferauditionf7bf_chk_1`
is a internal name generated by MySQL. Surprisingly, MySQL doesn't respect
its own limitations.

--
Ticket URL: <https://code.djangoproject.com/ticket/33169#comment:14>

Reply all
Reply to author
Forward
0 new messages