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.

12.9 KB
Raw Blame
# Generated by Django 5.2.14 on 2026-07-10 16:36

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

import posthog.models.utils

import products.pulse.backend.models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("annotations", "0003_annotation_hidden_in_user_interface"),
        ("dashboards", "0013_dashboardtile_button_tile_id_idx"),
        ("experiments", "0025_remove_teamexperimentsconfig_funnel_steps_data_disabled"),
        ("posthog", "1247_oauthaccesstoken_token_idx"),
        ("product_analytics", "0001_migrate_product_analytics_models"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="BriefConfig",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True)),
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("name", models.CharField(max_length=400)),
                (
                    "focus_prompt",
                    models.TextField(blank=True, default="", max_length=2000),
                ),
                ("anchors", models.JSONField(default=dict)),
                ("settings", models.JSONField(default=dict)),
                ("enabled", models.BooleanField(default=True)),
                ("deleted", models.BooleanField(default=False)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="posthog.team",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_manager_name": "all_teams",
            },
            managers=[
                ("all_teams", django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name="ProductBrief",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True)),
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("generating", "Generating"),
                            ("ready", "Ready"),
                            ("quiet", "Quiet"),
                            ("failed", "Failed"),
                        ],
                        default="generating",
                        max_length=20,
                    ),
                ),
                (
                    "trigger",
                    models.CharField(
                        choices=[
                            ("on_demand", "On Demand"),
                            ("scheduled", "Scheduled"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "period",
                    models.JSONField(default=products.pulse.backend.models.default_period),
                ),
                ("sections", models.JSONField(default=list)),
                ("sources_used", models.JSONField(default=list)),
                ("error", models.TextField(blank=True, null=True)),
                ("feedback", models.JSONField(default=dict)),
                (
                    "config",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pulse.briefconfig",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="posthog.team",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_manager_name": "all_teams",
            },
            managers=[
                ("all_teams", django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name="Opportunity",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True)),
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "kind",
                    models.CharField(
                        choices=[
                            ("build", "Build"),
                            ("fix", "Fix"),
                            ("instrument", "Instrument"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("open", "Open"),
                            ("dismissed", "Dismissed"),
                            ("acted", "Acted"),
                            ("resolved", "Resolved"),
                        ],
                        default="open",
                        max_length=20,
                    ),
                ),
                ("title", models.CharField(max_length=400)),
                ("summary", models.TextField()),
                (
                    "action",
                    models.JSONField(default=products.pulse.backend.models.default_action),
                ),
                ("metric_ref", models.JSONField(blank=True, null=True)),
                ("baseline", models.JSONField(blank=True, null=True)),
                ("fingerprint", models.CharField(max_length=512)),
                ("feedback", models.JSONField(default=dict)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="posthog.team",
                    ),
                ),
                (
                    "first_seen_brief",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="pulse.productbrief",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_manager_name": "all_teams",
            },
            managers=[
                ("all_teams", django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name="ResourceLink",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True, null=True)),
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "resource_type",
                    models.CharField(
                        choices=[
                            ("insight", "Insight"),
                            ("dashboard", "Dashboard"),
                            ("annotation", "Annotation"),
                            ("experiment", "Experiment"),
                            ("event", "Event"),
                        ],
                        max_length=20,
                    ),
                ),
                ("ref", models.CharField(max_length=400)),
                ("label", models.CharField(max_length=400)),
                ("url", models.CharField(blank=True, default="", max_length=1000)),
                (
                    "annotation",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="annotations.annotation",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "dashboard",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="dashboards.dashboard",
                    ),
                ),
                (
                    "experiment",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="experiments.experiment",
                    ),
                ),
                (
                    "insight",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="product_analytics.insight",
                    ),
                ),
                (
                    "opportunity",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="resource_links",
                        to="pulse.opportunity",
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(
                        db_constraint=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="posthog.team",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_manager_name": "all_teams",
            },
            managers=[
                ("all_teams", django.db.models.manager.Manager()),
            ],
        ),
        migrations.AddIndex(
            model_name="productbrief",
            index=models.Index(
                condition=models.Q(("status", "generating")),
                fields=["updated_at"],
                name="pulse_brief_generating_idx",
            ),
        ),
        migrations.AddConstraint(
            model_name="opportunity",
            constraint=models.UniqueConstraint(fields=("team", "fingerprint"), name="pulse_opp_team_fp_unique"),
        ),
    ]