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.9 KB
Raw Blame
# Generated by Django 4.2.26 on 2025-11-21 16:00

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

import posthog.models.utils

import products.posthog_ai.backend.models.assistant


class Migration(migrations.Migration):
    dependencies = [
        ("posthog", "0914_alter_userproductlist_reason"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("ee", "0030_singlesessionsummary_distinct_id_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="AgentArtifact",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True)),
                ("deleted", models.BooleanField(blank=True, default=False, null=True)),
                ("deleted_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7, editable=False, primary_key=True, serialize=False
                    ),
                ),
                (
                    "short_id",
                    models.CharField(
                        default=products.posthog_ai.backend.models.assistant.generate_short_id, max_length=4
                    ),
                ),
                ("name", models.CharField(max_length=400)),
                (
                    "type",
                    models.CharField(
                        choices=[("visualization", "Visualization"), ("notebook", "Notebook")], max_length=50
                    ),
                ),
                ("data", models.JSONField(help_text="Artifact content. Structure depends on artifact type.")),
                (
                    "conversation",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="artifacts", to="ee.conversation"
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
                    ),
                ),
                ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
            ],
            options={
                "indexes": [
                    models.Index(fields=["team", "short_id"], name="ee_agentart_team_id_d05587_idx"),
                    models.Index(fields=["team", "conversation", "created_at"], name="ee_agentart_team_id_e402e1_idx"),
                ],
            },
        ),
        migrations.AddConstraint(
            model_name="agentartifact",
            constraint=models.UniqueConstraint(fields=("team", "short_id"), name="unique_team_short_id"),
        ),
    ]