# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-09-14 16:15
from __future__ import unicode_literals

from django.db import migrations, models


def limpa_observacao_igual_ementa(apps, schema_editor):

    ExpedienteMateria = apps.get_model('sessao', 'ExpedienteMateria')
    OrdemDia = apps.get_model('sessao', 'OrdemDia')

    q = models.Q(observacao__iexact=models.F('materia__ementa'))

    ExpedienteMateria.objects.filter(q).update(observacao='')
    OrdemDia.objects.filter(q).update(observacao='')


class Migration(migrations.Migration):

    dependencies = [
        ('sessao', '0022_auto_20180618_1625'),
    ]

    operations = [
        migrations.AlterField(
            model_name='expedientemateria',
            name='observacao',
            field=models.TextField(blank=True, verbose_name='Observação'),
        ),
        migrations.AlterField(
            model_name='ordemdia',
            name='observacao',
            field=models.TextField(blank=True, verbose_name='Observação'),
        ),
        migrations.RunPython(limpa_observacao_igual_ementa),
    ]
