# Generated by Django 4.2.24 on 2025-12-27 06:52

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


class Migration(migrations.Migration):

    dependencies = [
        ("conversations", "0013_alter_chatmessage_backend_lock_and_more"),
        ("documents", "0027_alter_document_backend_lock_and_more"),
        ("corpuses", "0031_corpus_action_execution"),
    ]

    operations = [
        migrations.AddField(
            model_name="corpusactionexecution",
            name="conversation",
            field=models.ForeignKey(
                blank=True,
                help_text="The thread that triggered this execution (for thread-based actions)",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="corpus_action_executions",
                to="conversations.conversation",
            ),
        ),
        migrations.AddField(
            model_name="corpusactionexecution",
            name="message",
            field=models.ForeignKey(
                blank=True,
                help_text="The message that triggered this execution (for NEW_MESSAGE trigger)",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="corpus_action_executions",
                to="conversations.chatmessage",
            ),
        ),
        migrations.AlterField(
            model_name="corpusaction",
            name="trigger",
            field=models.CharField(
                choices=[
                    ("add_document", "Add Document"),
                    ("edit_document", "Edit Document"),
                    ("new_thread", "New Thread Created"),
                    ("new_message", "New Message Posted"),
                ],
                max_length=256,
            ),
        ),
        migrations.AlterField(
            model_name="corpusactionexecution",
            name="document",
            field=models.ForeignKey(
                blank=True,
                help_text="The document this action was executed on (null for thread-based actions)",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="corpus_action_executions",
                to="documents.document",
            ),
        ),
        migrations.AlterField(
            model_name="corpusactionexecution",
            name="trigger",
            field=models.CharField(
                choices=[
                    ("add_document", "Add Document"),
                    ("edit_document", "Edit Document"),
                    ("new_thread", "New Thread Created"),
                    ("new_message", "New Message Posted"),
                ],
                help_text="What triggered this execution",
                max_length=128,
            ),
        ),
        migrations.AddIndex(
            model_name="corpusactionexecution",
            index=models.Index(
                fields=["conversation", "-queued_at"],
                name="corpusactionexec_conv_queue",
            ),
        ),
    ]
