# Generated by Django 3.1.11 on 2021-06-02 14:33

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):
    dependencies = [
        ("people", "0004_display_name_and_image"),
        ("msgs", "0002_nullable_person_fields"),
    ]

    operations = [
        migrations.CreateModel(
            name="SupportGroupMessageRecipient",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="date de création",
                    ),
                ),
                (
                    "modified",
                    models.DateTimeField(
                        auto_now=True, verbose_name="dernière modification"
                    ),
                ),
                (
                    "message",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="readers",
                        to="msgs.supportgroupmessage",
                        verbose_name="Message",
                    ),
                ),
                (
                    "recipient",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="read_messages",
                        to="people.person",
                        verbose_name="Destinataire",
                    ),
                ),
            ],
            options={
                "verbose_name": "Message lu par l'utilisateur·ice",
                "verbose_name_plural": "Messages lus par les utilisateur·ices",
            },
        ),
        migrations.AddConstraint(
            model_name="supportgroupmessagerecipient",
            constraint=models.UniqueConstraint(
                fields=("recipient", "message"), name="unique_for_message_and_recipient"
            ),
        ),
    ]
