# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-10-29 00:02
from __future__ import unicode_literals
from datetime import date


from django.db import migrations


from psycopg2.extras import DateRange


DEFAULT_RUN_DATE = DateRange(
    date(2017, 1, 1),
    date(2017, 1, 4),
    '[)'
)


def provide_default_date_range(apps, schema_editor):
    ContentPlacement = apps.get_model('budget', 'ContentPlacement')

    for placement in ContentPlacement.objects.filter(run_date__isnull=True):
        placement.run_date = DEFAULT_RUN_DATE
        placement.save()


class Migration(migrations.Migration):

    dependencies = [
        ('budget', '0036_auto_20171028_1655'),
    ]

    operations = [
        migrations.RunPython(provide_default_date_range),
    ]
