
from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('outdoor', '0002_practice_sitepractice'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='site',
            options={'ordering': ('name',), 'verbose_name': 'Outdoor site', 'verbose_name_plural': 'Outdoor sites'},
        ),
        migrations.AlterField(
            model_name='site',
            name='geom',
            field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
        ),
        migrations.AlterField(
            model_name='sitepractice',
            name='site',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_practices', to='outdoor.site', verbose_name='Outdoor site'),
        ),
    ]


from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('outdoor', '0002_practice_sitepractice'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='site',
            options={'ordering': ('name',), 'verbose_name': 'Outdoor site', 'verbose_name_plural': 'Outdoor sites'},
        ),
        migrations.SeparateDatabaseAndState(
            database_operations=[
                migrations.RunSQL('ALTER TABLE "outdoor_site" ALTER COLUMN "geom" TYPE geometry(GeometryCollection,2154) USING ST_ForceCollection(geom);')
            ],
            state_operations=[
                migrations.AlterField(
                    model_name='site',
                    name='geom',
                    field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
                ),
            ]
        ),
        migrations.AlterField(
            model_name='sitepractice',
            name='site',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_practices', to='outdoor.site', verbose_name='Outdoor site'),
        ),
    ]

Fix migration Site geom to GeometryCollection
Fix migration Site geom to GeometryCollection

  
  from django.conf import settings
  import django.contrib.gis.db.models.fields
  from django.db import migrations, models
  import django.db.models.deletion
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('outdoor', '0002_practice_sitepractice'),
      ]
  
      operations = [
          migrations.AlterModelOptions(
              name='site',
              options={'ordering': ('name',), 'verbose_name': 'Outdoor site', 'verbose_name_plural': 'Outdoor sites'},
          ),
+         migrations.SeparateDatabaseAndState(
+             database_operations=[
+                 migrations.RunSQL('ALTER TABLE "outdoor_site" ALTER COLUMN "geom" TYPE geometry(GeometryCollection,2154) USING ST_ForceCollection(geom);')
+             ],
+             state_operations=[
-         migrations.AlterField(
+                 migrations.AlterField(
-             model_name='site',
+                     model_name='site',
-             name='geom',
+                     name='geom',
-             field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
+                     field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
+                 ),
+             ]
          ),
          migrations.AlterField(
              model_name='sitepractice',
              name='site',
              field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_practices', to='outdoor.site', verbose_name='Outdoor site'),
          ),
      ]
  
Fix migration Site geom to GeometryCollection
## Code Before:

from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('outdoor', '0002_practice_sitepractice'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='site',
            options={'ordering': ('name',), 'verbose_name': 'Outdoor site', 'verbose_name_plural': 'Outdoor sites'},
        ),
        migrations.AlterField(
            model_name='site',
            name='geom',
            field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
        ),
        migrations.AlterField(
            model_name='sitepractice',
            name='site',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_practices', to='outdoor.site', verbose_name='Outdoor site'),
        ),
    ]

## Instruction:
Fix migration Site geom to GeometryCollection
## Code After:

from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('outdoor', '0002_practice_sitepractice'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='site',
            options={'ordering': ('name',), 'verbose_name': 'Outdoor site', 'verbose_name_plural': 'Outdoor sites'},
        ),
        migrations.SeparateDatabaseAndState(
            database_operations=[
                migrations.RunSQL('ALTER TABLE "outdoor_site" ALTER COLUMN "geom" TYPE geometry(GeometryCollection,2154) USING ST_ForceCollection(geom);')
            ],
            state_operations=[
                migrations.AlterField(
                    model_name='site',
                    name='geom',
                    field=django.contrib.gis.db.models.fields.GeometryCollectionField(srid=settings.SRID, verbose_name='Location'),
                ),
            ]
        ),
        migrations.AlterField(
            model_name='sitepractice',
            name='site',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_practices', to='outdoor.site', verbose_name='Outdoor site'),
        ),
    ]
