Detected on Django 4.2.8 with PostGIS, but also present on latest main
branch.
--
Ticket URL: <https://code.djangoproject.com/ticket/35074>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Mário Falcão
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:2>
* stage: Accepted => Unreviewed
Comment:
Thanks for the report. However please don't accept your own tickets. I'll
revert to unaccepted until someone else can review the report.
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:3>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
Comment:
Got it. FYI I am working on a patch:
https://github.com/django/django/pull/17662
It properly fixed this on PostGIS but the issue appears to also be present
on MySQL as the tests I added fail there. I'll improve it and post an
update here when it's ready.
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:4>
* needs_better_patch: 1 => 0
Old description:
> Changing `spatial_index` on existing spatial fields causes migrations to
> be generated as expected, but they do not actually drop/create the
> indexes as desired when applied (`manage.py sqlmigrate` reports them as
> no-ops).
>
> Detected on Django 4.2.8 with PostGIS, but also present on latest main
> branch.
New description:
Changing `spatial_index` on existing spatial fields causes migrations to
be generated as expected, but they do not actually drop/create the indexes
as desired when applied.
E.g. starting with the following model
{{{
class LocationUpdate(models.Model):
location = PointField(geography=True, spatial_index=False)
}}}
If we change `spatial_index` to `True`, a migration is generated with a
single operation:
{{{
migrations.AlterField(
model_name="locationupdate",
name="location",
field=django.contrib.gis.db.models.fields.PointField(
geography=True, srid=4326
),
)
}}}
But applying this migration does not create the expected index and the
output of `sqlmigrate` is as follows:
{{{
BEGIN;
--
-- Alter field location on locationupdate
--
-- (no-op)
COMMIT;
}}}
Detected on Django 4.2.8 with PostGIS, but also present on latest main
branch across all backends.
--
Comment:
Turns out that none of the GIS backends handled this and I believe they
never did.
My patch is now ready for review - it should fix this on PostGIS, MySQL
and Oracle. Spatialite is not implemented as it does not support altering
geo fields.
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:5>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/35074#comment:7>