:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
# Generated by Django 5.2.17 on 2026-09-09 10:36
import django.utils.timezone
import django.db.models.lookups
import django.db.models.deletion
import django.db.models.functions.comparison
from django.db import migrations, models
import posthog.uuidt
import products.conversations.backend.models.inbound_event
class Migration(migrations.Migration):
dependencies = [
("conversations", "0066_squash_2026_09_07_schema_addons"),
("posthog", "1346_untrack_organization_is_hipaa"),
]
operations = [
migrations.CreateModel(
name="ConversationInboundEvent",
fields=[
(
"id",
models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
),
(
"source",
models.CharField(
choices=products.conversations.backend.models.inbound_event.conversation_inbound_event_source_choices,
max_length=32,
),
),
("source_id", models.CharField(max_length=512)),
("provider_account_id", models.CharField(max_length=255)),
("provider_retry_num", models.PositiveIntegerField(blank=True, null=True)),
("provider_retry_reason", models.CharField(blank=True, default="", max_length=64)),
(
"status",
models.CharField(
choices=[
("pending", "Pending"),
("processing", "Processing"),
("processed", "Processed"),
("failed", "Failed"),
],
default="pending",
max_length=32,
),
),
("attempts", models.PositiveIntegerField(default=0)),
("due_at", models.DateTimeField(default=django.utils.timezone.now)),
("lease_expires_at", models.DateTimeField(blank=True, null=True)),
("fencing_token", models.PositiveBigIntegerField(default=0)),
("last_error_code", models.CharField(blank=True, default="", max_length=64)),
("last_error", models.CharField(blank=True, default="", max_length=1024)),
("ticket_id", models.UUIDField(blank=True, null=True)),
("comment_id", models.UUIDField(blank=True, null=True)),
("payload", models.JSONField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("terminal_at", models.DateTimeField(blank=True, null=True)),
(
"team",
models.ForeignKey(
db_constraint=False,
db_index=False,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="posthog.team",
),
),
],
options={
"db_table": "posthog_conversations_inbound_event",
"indexes": [
models.Index(
condition=models.Q(("status", "pending")), fields=["due_at"], name="conv_inbound_pending_idx"
),
models.Index(
condition=models.Q(("status", "processing")),
fields=["lease_expires_at"],
name="conv_inbound_lease_idx",
),
models.Index(
condition=models.Q(("status__in", ["processed", "failed"])),
fields=["terminal_at"],
name="conv_inbound_terminal_idx",
),
models.Index(
condition=models.Q(("payload__isnull", False), ("status__in", ["processed", "failed"])),
fields=["terminal_at"],
name="conv_inbound_payload_gc_idx",
),
],
"constraints": [
models.UniqueConstraint(
fields=("team", "source", "source_id"), name="unique_inbound_event_per_source"
),
models.CheckConstraint(
condition=models.Q(("source_id", ""), _negated=True), name="inbound_event_source_id_not_empty"
),
models.CheckConstraint(
condition=models.Q(("provider_account_id", ""), _negated=True),
name="inbound_event_provider_id_not_empty",
),
models.CheckConstraint(
condition=models.Q(
("payload__isnull", True),
django.db.models.lookups.LessThanOrEqual(
models.Func(
django.db.models.functions.comparison.Cast(
models.F("payload"), output_field=models.TextField()
),
function="octet_length",
output_field=models.IntegerField(),
),
models.Value(262144),
),
_connector="OR",
),
name="inbound_event_payload_size",
),
models.CheckConstraint(
condition=models.Q(
models.Q(("status__in", ["processed", "failed"]), ("terminal_at__isnull", False)),
models.Q(("status__in", ["pending", "processing"]), ("terminal_at__isnull", True)),
_connector="OR",
),
name="inbound_event_terminal_at",
),
],
},
),
]