# Generated by Django 6.0 on 2026-05-18

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


class Migration(migrations.Migration):

    dependencies = [
        ("api", "0381_persistentagentdiscordguild_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="PersistentAgentDiscordWebhookEcho",
            fields=[
                ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ("channel_id", models.CharField(max_length=32)),
                ("discord_webhook_id", models.CharField(max_length=32)),
                ("signature_hash", models.CharField(max_length=64)),
                ("discord_message_id", models.CharField(blank=True, max_length=32)),
                ("expires_at", models.DateTimeField(db_index=True)),
                ("matched_at", models.DateTimeField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "agent",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="discord_webhook_echo_markers",
                        to="api.persistentagent",
                    ),
                ),
                (
                    "webhook",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="echo_markers",
                        to="api.persistentagentdiscordwebhook",
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddIndex(
            model_name="persistentagentdiscordwebhookecho",
            index=models.Index(
                fields=["discord_webhook_id", "channel_id", "signature_hash", "expires_at"],
                name="pa_discord_echo_lookup_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="persistentagentdiscordwebhookecho",
            index=models.Index(fields=["agent", "expires_at"], name="pa_discord_echo_agent_idx"),
        ),
    ]
