﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36129	Geodjango migrations ignore change of dimension in MultiPointField	Paweł Kotiuk		"I think I found a bug in GeoDjango migration mechanism.


== Reproduction

1. Create a simple model

{{{#!div style=""font-size: 80%""
  {{{#!python
  class MultiPointTester(models.Model):
    multipoint = models.MultiPointField(
        dim=2,
        blank=True,
        null=True,
        default=""SRID=4326;MULTIPOINT EMPTY"",
    )
  }}}
}}}


and test for it


{{{#!div style=""font-size: 80%""
  {{{#!python
class MultipointTest(TransactionTestCase):
    def test_multipoint_creation(self):
        instance = models.MultiPointTester()
        instance.save()
        self.assertEqual(instance.multipoint.ewkt, ""SRID=4326;MULTIPOINT EMPTY"")
  }}}
}}}


2. Generate migration for it `./manage.py makemigrations`
3. Run test - it succeeds ✅
4. Change dim from 2 to 3 and create migration
  It contains migration like this (it does not mention dim change):
{{{#!div style=""font-size: 80%""
  {{{#!python
    operations = [
        migrations.AlterField(
            model_name='multipointtester',
            name='multipoint',
            field=django.contrib.gis.db.models.fields.MultiPointField(
                  blank=True, 
                  default='SRID=4326;MULTIPOINT EMPTY', 
                  null=True, srid=4326),
        ),
    ]
  }}}
}}}

6. Run test again - it fails ❌ with error: 
  `E               ValueError: Cannot alter field test.MultiPointTester.multipoint into test.MultiPointTester.multipoint - they do not properly define db_type (are you using a badly-written custom field?)`
7. Remove all existing migration files and again generate migration `./manage.py makemigrations`
8. Run test again - - it succeeds ✅

Is is a bug, or do I make some kind of mistake in the code?"	Bug	closed	GIS	dev	Normal	invalid	migrations	Claude Paroz	Unreviewed	0	0	0	0	0	0
