# Generated by Django 3.0.2 on 2020-01-06 16:27

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("awt", "0009_auto_20191210_1048"),
    ]

    operations = [
        migrations.AddField(
            model_name="absence",
            name="reason",
            field=models.CharField(
                choices=[
                    ("vacation", "vacation"),
                    ("sickness", "sickness"),
                    ("other", "other reasons"),
                ],
                default="",
                max_length=10,
                verbose_name="reason",
            ),
            preserve_default=False,
        ),
        migrations.RunSQL(
            """
            UPDATE awt_absence
            SET reason=CASE
                WHEN is_vacation THEN 'vacation'
                WHEN description ~* '.*(krank|erkältung|grippe|arzt|sickness).*' THEN 'sickness'
                ELSE 'other'
            END
            """,
            "",
        ),
    ]
