# Generated by Django 6.0.4 on 2026-06-06 02:55

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('chat', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='conversation',
            name='created_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_conversations', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='conversationparticipant',
            name='conversation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='chat.conversation'),
        ),
        migrations.AddField(
            model_name='conversationparticipant',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='conversation',
            name='participants',
            field=models.ManyToManyField(related_name='conversations', through='chat.ConversationParticipant', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='message',
            name='conversation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='chat.conversation'),
        ),
        migrations.AddField(
            model_name='message',
            name='sender',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sent_messages', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='messageattachment',
            name='message',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='chat.message'),
        ),
        migrations.AddField(
            model_name='messagekeywrap',
            name='message',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='key_wraps', to='chat.message'),
        ),
        migrations.AddField(
            model_name='messagekeywrap',
            name='recipient',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='messagereaction',
            name='message',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reactions', to='chat.message'),
        ),
        migrations.AddField(
            model_name='messagereaction',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='userkey',
            name='user',
            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='chat_key', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='conversationparticipant',
            unique_together={('conversation', 'user')},
        ),
        migrations.AddIndex(
            model_name='message',
            index=models.Index(fields=['is_read'], name='chat_messag_is_read_6e9c3b_idx'),
        ),
        migrations.AddIndex(
            model_name='message',
            index=models.Index(fields=['conversation', 'created_at'], name='chat_messag_convers_0a903c_idx'),
        ),
        migrations.AddIndex(
            model_name='messagekeywrap',
            index=models.Index(fields=['recipient', 'message'], name='chat_messag_recipie_b7d288_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='messagekeywrap',
            unique_together={('message', 'recipient')},
        ),
        migrations.AlterUniqueTogether(
            name='messagereaction',
            unique_together={('message', 'user', 'reaction')},
        ),
    ]
