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.

6.0 KB
Raw Blame
# Generated by Django 4.2.15 on 2024-12-11 15:51

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

import posthog.models.utils


class Migration(migrations.Migration):
    dependencies = [
        ("posthog", "0528_project_field_in_taxonomy"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("ee", "0017_accesscontrol_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="Conversation",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
                    ),
                ),
                ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
                ("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ConversationCheckpoint",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
                    ),
                ),
                (
                    "checkpoint_ns",
                    models.TextField(
                        default="",
                        help_text='Checkpoint namespace. Denotes the path to the subgraph node the checkpoint originates from, separated by `|` character, e.g. `"child|grandchild"`. Defaults to "" (root graph).',
                    ),
                ),
                ("checkpoint", models.JSONField(help_text="Serialized checkpoint data.", null=True)),
                ("metadata", models.JSONField(help_text="Serialized checkpoint metadata.", null=True)),
                (
                    "parent_checkpoint",
                    models.ForeignKey(
                        help_text="Parent checkpoint ID.",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="ee.conversationcheckpoint",
                    ),
                ),
                (
                    "thread",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="checkpoints", to="ee.conversation"
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ConversationCheckpointWrite",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
                    ),
                ),
                ("task_id", models.UUIDField(help_text="Identifier for the task creating the checkpoint write.")),
                (
                    "idx",
                    models.IntegerField(
                        help_text="Index of the checkpoint write. It is an integer value where negative numbers are reserved for special cases, such as node interruption."
                    ),
                ),
                (
                    "channel",
                    models.TextField(
                        help_text="An arbitrary string defining the channel name. For example, it can be a node name or a reserved LangGraph's enum."
                    ),
                ),
                ("type", models.TextField(help_text="Type of the serialized blob. For example, `json`.", null=True)),
                ("blob", models.BinaryField(null=True)),
                (
                    "checkpoint",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="writes",
                        to="ee.conversationcheckpoint",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ConversationCheckpointBlob",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
                    ),
                ),
                (
                    "channel",
                    models.TextField(
                        help_text="An arbitrary string defining the channel name. For example, it can be a node name or a reserved LangGraph's enum."
                    ),
                ),
                ("version", models.TextField(help_text="Monotonically increasing version of the channel.")),
                ("type", models.TextField(help_text="Type of the serialized blob. For example, `json`.", null=True)),
                ("blob", models.BinaryField(null=True)),
                (
                    "checkpoint",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="blobs",
                        to="ee.conversationcheckpoint",
                    ),
                ),
            ],
        ),
        migrations.AddConstraint(
            model_name="conversationcheckpointwrite",
            constraint=models.UniqueConstraint(
                fields=("checkpoint_id", "task_id", "idx"), name="unique_checkpoint_write"
            ),
        ),
        migrations.AddConstraint(
            model_name="conversationcheckpointblob",
            constraint=models.UniqueConstraint(
                fields=("checkpoint_id", "channel", "version"), name="unique_checkpoint_blob"
            ),
        ),
        migrations.AddConstraint(
            model_name="conversationcheckpoint",
            constraint=models.UniqueConstraint(fields=("id", "checkpoint_ns", "thread"), name="unique_checkpoint"),
        ),
    ]