
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('signage', '0012_auto_20200406_1411'),
    ]

    operations = [
        migrations.RunSQL(sql=[("DELETE FROM geotrek.signage_blade WHERE deleted=TRUE;", )]),
        migrations.RemoveField(
            model_name='blade',
            name='deleted',
        ),
        migrations.RemoveField(
            model_name='blade',
            name='structure',
        ),
        migrations.RemoveField(
            model_name='line',
            name='structure',
        ),
        migrations.AlterField(
            model_name='line',
            name='blade',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
                                    to='signage.Blade', verbose_name='Blade'),
        ),
    ]


from django.db import migrations, models
import django.db.models.deletion


def delete_force(apps, schema_editor):
    # We can't import Infrastructure models directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Blade = apps.get_model('signage', 'Blade')
    for blade in Blade.objects.filter(deleted=True):
        blade.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('signage', '0012_auto_20200406_1411'),
    ]

    operations = [
        migrations.AlterField(
            model_name='line',
            name='blade',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
                                    to='signage.Blade', verbose_name='Blade'),
        ),
        migrations.RunPython(delete_force),
        migrations.RemoveField(
            model_name='blade',
            name='deleted',
        ),
        migrations.RemoveField(
            model_name='blade',
            name='structure',
        ),
        migrations.RemoveField(
            model_name='line',
            name='structure',
        ),
    ]

Change order migration, user runpython instead
Change order migration, user runpython instead

  
  from django.db import migrations, models
  import django.db.models.deletion
+ 
+ 
+ def delete_force(apps, schema_editor):
+     # We can't import Infrastructure models directly as it may be a newer
+     # version than this migration expects. We use the historical version.
+     Blade = apps.get_model('signage', 'Blade')
+     for blade in Blade.objects.filter(deleted=True):
+         blade.delete()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('signage', '0012_auto_20200406_1411'),
      ]
  
      operations = [
-         migrations.RunSQL(sql=[("DELETE FROM geotrek.signage_blade WHERE deleted=TRUE;", )]),
+         migrations.AlterField(
+             model_name='line',
+             name='blade',
+             field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
+                                     to='signage.Blade', verbose_name='Blade'),
+         ),
+         migrations.RunPython(delete_force),
          migrations.RemoveField(
              model_name='blade',
              name='deleted',
          ),
          migrations.RemoveField(
              model_name='blade',
              name='structure',
          ),
          migrations.RemoveField(
              model_name='line',
              name='structure',
          ),
-         migrations.AlterField(
-             model_name='line',
-             name='blade',
-             field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
-                                     to='signage.Blade', verbose_name='Blade'),
-         ),
      ]
  
Change order migration, user runpython instead
## Code Before:

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('signage', '0012_auto_20200406_1411'),
    ]

    operations = [
        migrations.RunSQL(sql=[("DELETE FROM geotrek.signage_blade WHERE deleted=TRUE;", )]),
        migrations.RemoveField(
            model_name='blade',
            name='deleted',
        ),
        migrations.RemoveField(
            model_name='blade',
            name='structure',
        ),
        migrations.RemoveField(
            model_name='line',
            name='structure',
        ),
        migrations.AlterField(
            model_name='line',
            name='blade',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
                                    to='signage.Blade', verbose_name='Blade'),
        ),
    ]

## Instruction:
Change order migration, user runpython instead
## Code After:

from django.db import migrations, models
import django.db.models.deletion


def delete_force(apps, schema_editor):
    # We can't import Infrastructure models directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Blade = apps.get_model('signage', 'Blade')
    for blade in Blade.objects.filter(deleted=True):
        blade.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('signage', '0012_auto_20200406_1411'),
    ]

    operations = [
        migrations.AlterField(
            model_name='line',
            name='blade',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines',
                                    to='signage.Blade', verbose_name='Blade'),
        ),
        migrations.RunPython(delete_force),
        migrations.RemoveField(
            model_name='blade',
            name='deleted',
        ),
        migrations.RemoveField(
            model_name='blade',
            name='structure',
        ),
        migrations.RemoveField(
            model_name='line',
            name='structure',
        ),
    ]
