Re: [Django] #34217: Migration removing a CheckConstraint results in ProgrammingError using MySQL < 8.0.16. (was: Migration removing a CheckConstraint results in ProgrammingError using MySQL (5.7.31))

2 views
Skip to first unread message

Django

unread,
Dec 19, 2022, 12:08:23 AM12/19/22
to django-...@googlegroups.com
#34217: Migration removing a CheckConstraint results in ProgrammingError using
MySQL < 8.0.16.
----------------------------+------------------------------------
Reporter: Max F. | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


Comment:

Thanks for the report. Agreed, removing a check constraint should be no-op
when not supported, the following diff fix it for me:
{{{#!diff
diff --git a/django/db/backends/base/schema.py
b/django/db/backends/base/schema.py
index fe31967ce2..8e6c21647e 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -1667,6 +1667,8 @@ class BaseDatabaseSchemaEditor:
)

def _delete_check_sql(self, model, name):
+ if not self.connection.features.supports_table_check_constraints:
+ return None
return self._delete_constraint_sql(self.sql_delete_check, model,
name)

def _delete_constraint_sql(self, template, model, name):

}}}
Would you like to prepare a patch? (a regression test in
`migrations.test_operations.OperationTests` is required.)

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

Reply all
Reply to author
Forward
0 new messages