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.

3.8 KB
Raw Blame
# Generated by Django 5.2.14 on 2026-06-03 20:15

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 = [
        (
            "experiments",
            "0016_teamexperimentsconfig_default_sequential_testing_enabled_and_more",
        ),
        ("posthog", "1207_migrate_ai_observability_models"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="ExperimentMetricsRecalculation",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=posthog.models.utils.uuid7,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending", "Pending"),
                            ("in_progress", "In Progress"),
                            ("completed", "Completed"),
                            ("failed", "Failed"),
                        ],
                        default="pending",
                        max_length=20,
                    ),
                ),
                ("total_metrics", models.PositiveIntegerField(default=0)),
                ("metric_errors", models.JSONField(default=dict)),
                ("metric_uuids", models.JSONField(default=list)),
                ("query_to", models.DateTimeField(blank=True, null=True)),
                (
                    "trigger",
                    models.CharField(
                        choices=[
                            ("manual", "Manual"),
                            ("experiment_launch", "Experiment Launch"),
                            ("experiment_stop", "Experiment Stop"),
                            ("experiment_update", "Experiment Update"),
                        ],
                        default="manual",
                        max_length=30,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("started_at", models.DateTimeField(blank=True, null=True)),
                ("completed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "experiment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="experiments.experiment",
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
                ),
            ],
            options={
                "db_table": "posthog_experimentmetricsrecalculation",
                "indexes": [
                    models.Index(
                        fields=["experiment", "status"],
                        name="posthog_exp_experim_54da5b_idx",
                    ),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        condition=models.Q(("status__in", ["pending", "in_progress"])),
                        fields=("experiment",),
                        name="unique_active_metrics_recalculation_per_experiment",
                    )
                ],
            },
        ),
    ]