
import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        (
            "peering",
            "0026_autonomoussystem_potential_internet_exchange_peering_sessions",
        )
    ]

    operations = [
        migrations.AlterField(
            model_name="autonomoussystem",
            name="potential_internet_exchange_peering_sessions",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.GenericIPAddressField(),
                blank=True,
                default=list,
                size=None,
            ),
        )
    ]


import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        (
            "peering",
            "0026_autonomoussystem_potential_internet_exchange_peering_sessions",
        )
    ]

    def forwards_func(apps, schema_editor):
        AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
        db_alias = schema_editor.connection.alias
        AutonomousSystem.objects.using(db_alias).filter(
            potential_internet_exchange_peering_sessions=None
        ).update(potential_internet_exchange_peering_sessions=[])

    def reverse_func(apps, schema_editor):
        AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
        db_alias = schema_editor.connection.alias
        AutonomousSystem.objects.using(db_alias).filter(
            potential_internet_exchange_peering_sessions=[]
        ).update(potential_internet_exchange_peering_sessions=None)

    operations = [
        migrations.AlterField(
            model_name="autonomoussystem",
            name="potential_internet_exchange_peering_sessions",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.GenericIPAddressField(),
                blank=True,
                default=list,
                size=None,
            ),
        ),
        migrations.RunPython(forwards_func, reverse_func),
    ]

Fix issue with migrations introduced lately.
Fix issue with migrations introduced lately.

  
  import django.contrib.postgres.fields
  from django.db import migrations, models
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          (
              "peering",
              "0026_autonomoussystem_potential_internet_exchange_peering_sessions",
          )
      ]
  
+     def forwards_func(apps, schema_editor):
+         AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
+         db_alias = schema_editor.connection.alias
+         AutonomousSystem.objects.using(db_alias).filter(
+             potential_internet_exchange_peering_sessions=None
+         ).update(potential_internet_exchange_peering_sessions=[])
+ 
+     def reverse_func(apps, schema_editor):
+         AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
+         db_alias = schema_editor.connection.alias
+         AutonomousSystem.objects.using(db_alias).filter(
+             potential_internet_exchange_peering_sessions=[]
+         ).update(potential_internet_exchange_peering_sessions=None)
+ 
      operations = [
          migrations.AlterField(
              model_name="autonomoussystem",
              name="potential_internet_exchange_peering_sessions",
              field=django.contrib.postgres.fields.ArrayField(
                  base_field=models.GenericIPAddressField(),
                  blank=True,
                  default=list,
                  size=None,
              ),
-         )
+         ),
+         migrations.RunPython(forwards_func, reverse_func),
      ]
  
Fix issue with migrations introduced lately.
## Code Before:

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        (
            "peering",
            "0026_autonomoussystem_potential_internet_exchange_peering_sessions",
        )
    ]

    operations = [
        migrations.AlterField(
            model_name="autonomoussystem",
            name="potential_internet_exchange_peering_sessions",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.GenericIPAddressField(),
                blank=True,
                default=list,
                size=None,
            ),
        )
    ]

## Instruction:
Fix issue with migrations introduced lately.
## Code After:

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        (
            "peering",
            "0026_autonomoussystem_potential_internet_exchange_peering_sessions",
        )
    ]

    def forwards_func(apps, schema_editor):
        AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
        db_alias = schema_editor.connection.alias
        AutonomousSystem.objects.using(db_alias).filter(
            potential_internet_exchange_peering_sessions=None
        ).update(potential_internet_exchange_peering_sessions=[])

    def reverse_func(apps, schema_editor):
        AutonomousSystem = apps.get_model("peering", "AutonomousSystem")
        db_alias = schema_editor.connection.alias
        AutonomousSystem.objects.using(db_alias).filter(
            potential_internet_exchange_peering_sessions=[]
        ).update(potential_internet_exchange_peering_sessions=None)

    operations = [
        migrations.AlterField(
            model_name="autonomoussystem",
            name="potential_internet_exchange_peering_sessions",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.GenericIPAddressField(),
                blank=True,
                default=list,
                size=None,
            ),
        ),
        migrations.RunPython(forwards_func, reverse_func),
    ]
