Skip to content

: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.

2.7 KB
Raw Blame
# Generated by Django 5.2.17 on 2026-08-10 17:46

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

import posthog.uuidt


class Migration(migrations.Migration):
    dependencies = [
        ("conversations", "0061_emailchannelsetup_emailchannel_connection_status_and_more"),
        ("posthog", "1297_add_instagram_integration_kind"),
    ]

    operations = [
        migrations.CreateModel(
            name="EmailThreadAccountLink",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.uuidt.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("account_id", models.CharField(max_length=64)),
                (
                    "account_external_id",
                    models.CharField(blank=True, max_length=400, null=True),
                ),
                (
                    "match_source",
                    models.CharField(
                        choices=[
                            ("known_email", "Known email"),
                            ("person_group", "Person group"),
                            ("email_domain", "Email domain"),
                        ],
                        max_length=32,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "team",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="posthog.team",
                    ),
                ),
                (
                    "thread",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="account_links",
                        to="conversations.emailthread",
                    ),
                ),
            ],
            options={
                "db_table": "posthog_conversations_email_thread_account_link",
                "indexes": [
                    models.Index(
                        fields=["team", "account_id", "thread"],
                        name="email_link_team_account_idx",
                    )
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("team", "thread", "account_id"),
                        name="unique_email_thread_account_link",
                    )
                ],
            },
        ),
    ]