Changes between Initial Version and Version 5 of Ticket #35074


Ignore:
Timestamp:
Dec 30, 2023, 8:31:46 PM (11 months ago)
Author:
Mário Falcão
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.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35074

    • Property Owner changed from nobody to Mário Falcão
    • Property Status newassigned
    • Property Has patch set
  • Ticket #35074 – Description

    initial v5  
    1 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).
     1Changing `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.
    22
    3 Detected on Django 4.2.8 with PostGIS, but also present on latest main branch.
     3E.g. starting with the following model
     4{{{
     5class LocationUpdate(models.Model):
     6    location = PointField(geography=True, spatial_index=False)
     7}}}
     8
     9If we change `spatial_index` to `True`, a migration is generated with a single operation:
     10{{{
     11migrations.AlterField(
     12    model_name="locationupdate",
     13    name="location",
     14    field=django.contrib.gis.db.models.fields.PointField(
     15        geography=True, srid=4326
     16    ),
     17)
     18}}}
     19
     20But applying this migration does not create the expected index and the output of `sqlmigrate` is as follows:
     21{{{
     22BEGIN;
     23--
     24-- Alter field location on locationupdate
     25--
     26-- (no-op)
     27COMMIT;
     28}}}
     29
     30Detected on Django 4.2.8 with PostGIS, but also present on latest main branch across all backends.
Back to Top