# Generated by Django 4.2.4 on 2023-08-11 08:25

from datetime import timedelta
from django.db import migrations


def populate_retention_policies(apps, schema_editor):
    INITIAL_RETENTION_POLICIES = [
        ("annual", 365),
        ("monthly", 30),
        ("weekly", 7),
        ("daily", 1),
    ]

    RetentionPolicy = apps.get_model("eremaea", "RetentionPolicy")

    for (name, duration) in INITIAL_RETENTION_POLICIES:
        RetentionPolicy.objects.get_or_create(name = name, duration = timedelta(days = duration))

class Migration(migrations.Migration):

    dependencies = [
        ('eremaea', '0002_drop_index_together'),
    ]

    operations = [
        migrations.RunPython(populate_retention_policies),
    ]
