# Generated by Django 2.2 on 2019-07-03 09:36

from django.contrib.postgres.functions import TransactionNow
from django.db import migrations


def migrate_to_policy_config(apps, schema_editor):
    Policy = apps.get_model("mds", "Policy")

    for policy in Policy.objects.all():
        policy.config = {
            "fixed_price": policy.fixed_price,
            "daily_penalty": policy.daily_penalty,
            "grace_period_days": 0,
            "rule_type": "count",
        }
        policy.save()


class Migration(migrations.Migration):
    dependencies = [("mds", "0049_pre_add_policy_config")]

    operations = [migrations.RunPython(migrate_to_policy_config, migrations.RunPython.noop)]
