# Generated by Django 4.2.11 on 2024-05-08 08:55

from django.db import migrations, models



def _migrate_recurrences(apps, schema_editor):
    CalendarEvent = apps.get_model('core', 'CalendarEvent')
    for event in CalendarEvent.objects.using(schema_editor.connection.alias).all():
        if not event.recurrences:
            continue
        rule = event.recurrences.rrules[0]
        event.rrule_until = rule.until
        event.save()

class Migration(migrations.Migration):

    dependencies = [
        ('core', '0066_group_type_owner_permissions'),
    ]

    operations = [
        migrations.AddField(
            model_name='calendarevent',
            name='rrule_until',
            field=models.DateTimeField(blank=True, editable=False, null=True),
        ),
        migrations.RunPython(_migrate_recurrences)
    ]
