From 20c2d625d3d5062e43918d1d7b6f623202491dd4 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 18 Jun 2024 22:19:11 +0200 Subject: Refs #35074 -- Avoided failed attempts to remove spatial indexes on nullable fields on MySQL. MySQL doesn't support spatial indexes on NULL columns, so there is no point in removing them. --- django/contrib/gis/db/backends/mysql/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/contrib/gis/db/backends/mysql/schema.py b/django/contrib/gis/db/backends/mysql/schema.py index 27f6df174a..f3ddf14fa7 100644 --- a/django/contrib/gis/db/backends/mysql/schema.py +++ b/django/contrib/gis/db/backends/mysql/schema.py @@ -54,7 +54,7 @@ class MySQLGISSchemaEditor(DatabaseSchemaEditor): self.create_spatial_indexes() def remove_field(self, model, field): - if isinstance(field, GeometryField) and field.spatial_index: + if isinstance(field, GeometryField) and field.spatial_index and not field.null: index_name = self._create_spatial_index_name(model, field) sql = self._delete_index_sql(model, index_name) try: -- cgit v1.3