Ticket #23030: spatialite_migrations_regression.patch

File spatialite_migrations_regression.patch, 2.7 KB (added by Lucio Asnaghi, 10 years ago)

It's possible to showcase the error with this test

  • django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py

    a b  
    11from django.db import models, migrations
    22import django.contrib.gis.db.models.fields
    33
    4 
    54# Used for regression test of ticket #22001: https://code.djangoproject.com/ticket/22001
     5# Also used for regression test of ticket #23030: https://code.djangoproject.com/ticket/23030
    66class Migration(migrations.Migration):
    77
    88    operations = [
     
    2929            options={
    3030            },
    3131            bases=(models.Model,),
    32         )
     32        ),
     33        migrations.CreateModel(
     34            name='Family',
     35            fields=[
     36                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
     37                ('name', models.CharField(max_length=100, unique=True)),
     38            ],
     39            options={
     40            },
     41            bases=(models.Model,),
     42        ),
     43        migrations.AddField(
     44            model_name='household',
     45            name='family',
     46            field=models.ForeignKey(blank=True, to='gis.Family', null=True),
     47            preserve_default=True,
     48        ),       
    3349    ]
  • django/contrib/gis/tests/gis_migrations/test_commands.py

    a b  
    3434        Tests basic usage of the migrate command when a model uses Geodjango
    3535        fields. Regression test for ticket #22001:
    3636        https://code.djangoproject.com/ticket/22001
     37       
     38        It's also used to showcase an error in migrations where spatialite is
     39        enabled and geo tables are renamed resulting in unique constraint
     40        failure on geometry_columns. Regression for ticket #23030:
     41        https://code.djangoproject.com/ticket/23030
    3742        """
    3843        # Make sure no tables are created
    3944        self.assertTableNotExists("migrations_neighborhood")
    4045        self.assertTableNotExists("migrations_household")
     46        self.assertTableNotExists("migrations_family")
    4147        # Run the migrations to 0001 only
    4248        call_command("migrate", "gis", "0001", verbosity=0)
    4349        # Make sure the right tables exist
    4450        self.assertTableExists("gis_neighborhood")
    4551        self.assertTableExists("gis_household")
     52        self.assertTableExists("gis_family")
    4653        # Unmigrate everything
    4754        call_command("migrate", "gis", "zero", verbosity=0)
    4855        # Make sure it's all gone
    4956        self.assertTableNotExists("gis_neighborhood")
    5057        self.assertTableNotExists("gis_household")
     58        self.assertTableNotExists("gis_family")
Back to Top