# Generated by Django 5.2.11 on 2026-04-09 14:41

import core.enums
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0024_channel_encrypted_settings_scope_level'),
    ]

    operations = [
        migrations.AlterField(
            model_name='threadevent',
            name='type',
            field=models.CharField(choices=core.enums.thread_event_type_choices, max_length=36, verbose_name='type'),
        ),
        migrations.CreateModel(
            name='UserEvent',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='primary key for the record as UUID', primary_key=True, serialize=False, verbose_name='id')),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='date and time at which a record was created', verbose_name='created on')),
                ('updated_at', models.DateTimeField(auto_now=True, help_text='date and time at which a record was last updated', verbose_name='updated on')),
                ('type', models.CharField(choices=core.enums.user_event_type_choices, max_length=36, verbose_name='type')),
                ('read_at', models.DateTimeField(blank=True, null=True, verbose_name='read at')),
                ('thread', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_events', to='core.thread')),
                ('thread_event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_events', to='core.threadevent')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_events', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'user event',
                'verbose_name_plural': 'user events',
                'db_table': 'messages_userevent',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['user', 'type', 'read_at'], name='usrevt_user_type_read'), models.Index(fields=['thread', 'type'], name='usrevt_thread_type')],
                'constraints': [models.UniqueConstraint(fields=('user', 'thread_event', 'type'), name='usrevt_user_event_type_uniq')],
            },
        ),
    ]
