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.

feat(devex): squash pre-2026-09-07 Django migration history with nextgensquash (#91646)

Julian Bez5739878eb80f
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index d80e4fd33524..40d54754de79 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -67,6 +67,11 @@
# strips artifact uploads (above), so those changes are depot-exempt.
# - OpenAPI types: validation remains a separate job like canonical, but its
# auto-commit side effect is dropped
+# - sqlmigrate SQL preview: canonical's check-migrations resolves changed migration files
+# to full names, skips generated squash files by content, and degrades a sqlmigrate
+# failure to a placeholder before posting the SQL preview comment. The shadow strips
+# comment side effects (above) and runs no sqlmigrate loop, so those changes need no
+# depot bump.
# - Deterministic-failure self-cancel: canonical cancels its own run when repo-checks or
# check-openapi-types fails deterministically, and ORs those jobs' deterministic_failure
# outputs onto the gate condition so a real failure still reports failure rather than
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 133d83a95d80..d94ecfce44a4 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -1694,7 +1694,11 @@ jobs:
if [[ $file =~ rust/persons_migrations ]]; then
continue
fi
- if [[ $file =~ migrations/([0-9]+)_ ]]; then
+ # Full migration name, not the bare numeric prefix: squash
+ # files (0001_squash_*) share prefixes with the historical
+ # files they replace, and sqlmigrate errors on an ambiguous
+ # prefix.
+ if [[ $file =~ migrations/([0-9]+_[^/]+)\.py$ ]]; then
migration_number="${BASH_REMATCH[1]}"
# Get app name by looking at the directory structure
# For new structure products/user_interviews/backend/migrations, we want user_interviews
@@ -1711,12 +1715,27 @@ jobs:
continue
fi
+ # Generated squash files carry replaces= lists thousands
+ # of names long; their SQL dump is unreviewable and the
+ # state replay per file adds up across an entire squash
+ # PR. Detect by content, not by name, so the check can't
+ # go stale.
+ if grep -q "replaces = \[" "$file"; then
+ echo "Skipping $file (squash migration)"
+ continue
+ fi
+
HAS_NEW_MIGRATIONS=true
MIGRATION_COUNT=$((MIGRATION_COUNT + 1))
echo "Checking migration $migration_number for app $app_name"
- # Get SQL output
- SQL_OUTPUT=$(python manage.py sqlmigrate $app_name $migration_number)
+ # Get SQL output. A sqlmigrate failure degrades to a
+ # placeholder — this comment is informational, and the
+ # real migrate step below still gates the job.
+ if ! SQL_OUTPUT=$(python manage.py sqlmigrate $app_name $migration_number 2>&1); then
+ echo "::warning::sqlmigrate failed for $app_name $migration_number — see job log"
+ SQL_OUTPUT="-- sqlmigrate failed for this migration (see the Validate migrations job log)"
+ fi
# Add to comment body
COMMENT_BODY+="#### [\`$file\`](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/$file)\n\`\`\`sql\n$SQL_OUTPUT\n\`\`\`\n\n"
diff --git a/bin/profile_migrations b/bin/profile_migrations
new file mode 100755
index 000000000000..e7204dd6b02e
--- /dev/null
+++ b/bin/profile_migrations
@@ -0,0 +1,216 @@
+#!/usr/bin/env bash
+# Profile Django migrations across every writer DB alias.
+#
+# Mimics bin/migrate: full graph on `default`, per-app filtered migrate on
+# each product-routed aux DB (from products/db_routing.yaml). Running an
+# unfiltered migrate on every alias would walk all ~1300 migrations on each
+# aux DB, hugely inflating Migration.apply wall-clock with pure Django
+# state-rebuild on operations that allow_migrate already gates to no-op.
+#
+# Per alias:
+# 1. Verify django_migrations is empty (refuse to profile a non-fresh DB).
+# 2. Run `python manage.py migrate [<app_label>] --database <alias>
+# --profile-operations`. pyinstrument is auto-attached if importable
+# (writes a .pyinstrument.html alongside the JSONL).
+# 3. Optionally wrap under py-spy (--with-pyspy). Skipped by default: py-spy
+# needs root on macOS, and pyinstrument already covers Python CPU.
+#
+# Output lives under /tmp/migration-profile-<ts>/ ; final report is rendered
+# by `analyze_migration_profile`.
+#
+# DB drop/recreate is left to the operator — this script aborts on a populated
+# django_migrations table to avoid accidental destructive ops on shared envs.
+
+set -euo pipefail
+
+SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)
+REPO_ROOT=$(cd -- "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)
+cd "$REPO_ROOT"
+
+TS=$(date +%s)
+OUT_DIR="${PROFILE_OUT_DIR:-/tmp/migration-profile-$TS}"
+mkdir -p "$OUT_DIR"
+
+usage() {
+ cat <<EOF
+Usage: bin/profile_migrations [--out <dir>] [--with-pyspy]
+
+Options:
+ --out Output directory. Defaults to /tmp/migration-profile-<unix_ts>/.
+ --with-pyspy Additionally wrap each migrate under py-spy record. Off by
+ default — py-spy requires root on macOS, and pyinstrument
+ (auto-attached if importable) already produces a per-alias
+ HTML CPU report.
+ --help Show this message.
+
+Profiles the same shape as bin/migrate: full graph on the `default` alias,
+and per-app filtered migrate on each product-routed aux DB (read from
+products/db_routing.yaml).
+
+Refuses to profile a database with existing applied migrations — drop and
+recreate it yourself first (e.g. \`dropdb <name> && createdb <name>\`).
+EOF
+}
+
+WITH_PYSPY=0
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --out) OUT_DIR="$2"; shift 2;;
+ --with-pyspy) WITH_PYSPY=1; shift;;
+ --help|-h) usage; exit 0;;
+ *) echo "Unknown arg: $1" >&2; usage; exit 2;;
+ esac
+done
+
+# --- 1. py-spy check (optional)
+if [[ "$WITH_PYSPY" -eq 1 ]] && ! command -v py-spy >/dev/null 2>&1; then
+ cat <<EOF >&2
+--with-pyspy was passed but py-spy is not on PATH.
+
+Install:
+ uv tool install py-spy
+ # or
+ cargo install py-spy
+
+On macOS py-spy additionally needs root: prefix the script with sudo.
+EOF
+ exit 1
+fi
+
+# --- 2. Discover (alias, app_label) targets from products/db_routing.yaml.
+# `default` always runs the full graph (no app filter); each aux alias runs
+# only the app(s) routed to it via the product DB router.
+# Done in pure Python to avoid pulling Django settings/logging into stdout.
+discover_targets() {
+ python - <<'PY'
+import sys, pathlib, yaml
+routes_path = pathlib.Path("products/db_routing.yaml")
+print("default\t")
+if not routes_path.exists():
+ sys.exit(0)
+with routes_path.open() as fh:
+ routes = yaml.safe_load(fh).get("routes", [])
+seen = set()
+for r in routes:
+ alias = f"{r['database']}_db_writer"
+ key = (alias, r["app_label"])
+ if key in seen:
+ continue
+ seen.add(key)
+ print(f"{alias}\t{r['app_label']}")
+PY
+}
+
+mapfile -t TARGETS < <(discover_targets)
+if [[ ${#TARGETS[@]} -eq 0 ]]; then
+ echo "No migrate targets discovered." >&2
+ exit 1
+fi
+
+# Probe DB freshness via direct psql (no Django bootstrap), based on the
+# alias's NAME/HOST from settings. One small Python helper renders the env.
+load_db_env() {
+ # Sets NAME/HOST/PORT/USER/PASSWORD. Values are read line-by-line in fixed
+ # order — never eval'd — so a password with shell metacharacters stays data.
+ local alias="$1"
+ local rendered
+ rendered=$(python - "$alias" <<'PY'
+import os, sys
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")
+import django
+django.setup()
+from django.conf import settings
+alias = sys.argv[1]
+conf = settings.DATABASES[alias]
+print(conf.get("NAME"))
+print(conf.get("HOST") or "localhost")
+print(conf.get("PORT") or 5432)
+print(conf.get("USER") or "posthog")
+print(conf.get("PASSWORD") or "")
+PY
+ ) || return 1
+ { IFS= read -r NAME && IFS= read -r HOST && IFS= read -r PORT && IFS= read -r USER && IFS= read -r PASSWORD; } <<<"$rendered"
+}
+
+UNIQUE_ALIASES=()
+declare -A ALIAS_SEEN=()
+for line in "${TARGETS[@]}"; do
+ ALIAS="${line%%$'\t'*}"
+ if [[ -z "${ALIAS_SEEN[$ALIAS]:-}" ]]; then
+ ALIAS_SEEN[$ALIAS]=1
+ UNIQUE_ALIASES+=("$ALIAS")
+ fi
+done
+
+echo "Targets to profile:"
+for t in "${TARGETS[@]}"; do echo " $t"; done
+echo "Output dir: $OUT_DIR"
+echo
+
+# --- 3. Per-(alias, app_label): verify fresh DB + run migrate
+JSONL_ARGS=()
+SPY_ARGS=()
+
+for ALIAS in "${UNIQUE_ALIASES[@]}"; do
+ # Render env once per alias and probe django_migrations row count. Fail
+ # closed: an unreachable DB or a broken probe must stop the run, not read
+ # as "fresh" and let migrate loose on a database we could not verify.
+ if ! load_db_env "$ALIAS"; then
+ echo "Cannot read database settings for alias $ALIAS." >&2
+ exit 1
+ fi
+ if ! ROW_COUNT=$(PGPASSWORD="$PASSWORD" psql -h "$HOST" -p "$PORT" -U "$USER" -d "$NAME" -tAc \
+ "SELECT count(*) FROM django_migrations" 2>/dev/null | tr -d ' '); then
+ # No django_migrations table on an otherwise reachable DB is the one
+ # legitimate "fresh" shape — verify the DB answers at all.
+ if ! PGPASSWORD="$PASSWORD" psql -h "$HOST" -p "$PORT" -U "$USER" -d "$NAME" -tAc "SELECT 1" >/dev/null 2>&1; then
+ echo "Cannot reach database $NAME for alias $ALIAS — refusing to run a blind migrate." >&2
+ exit 1
+ fi
+ ROW_COUNT=0
+ fi
+ if [[ "$ROW_COUNT" =~ ^[0-9]+$ ]] && [[ "$ROW_COUNT" -gt 0 ]]; then
+ echo "Refusing to profile $ALIAS — django_migrations has $ROW_COUNT rows." >&2
+ echo "Drop and recreate the DB first." >&2
+ exit 1
+ fi
+done
+
+for line in "${TARGETS[@]}"; do
+ ALIAS="${line%%$'\t'*}"
+ APP="${line#*$'\t'}"
+ LABEL="$ALIAS${APP:+:$APP}"
+ echo "=== $LABEL ==="
+
+ SAFE_LABEL="${LABEL//[:\/]/_}"
+ JSONL_OUT="$OUT_DIR/migration-profile-$SAFE_LABEL.jsonl"
+ MIGRATE_ARGS=(--database "$ALIAS" --profile-operations --profile-output "$JSONL_OUT" --no-input)
+ if [[ -n "$APP" ]]; then
+ MIGRATE_ARGS=("$APP" "${MIGRATE_ARGS[@]}")
+ fi
+
+ if [[ "$WITH_PYSPY" -eq 1 ]]; then
+ SPY_OUT="$OUT_DIR/migration-profile-$SAFE_LABEL.spy.raw"
+ py-spy record --format raw --rate 100 --subprocesses --output "$SPY_OUT" \
+ -- python manage.py migrate "${MIGRATE_ARGS[@]}"
+ SPY_ARGS+=( --spy "$ALIAS=$SPY_OUT" )
+ else
+ python manage.py migrate "${MIGRATE_ARGS[@]}"
+ fi
+
+ JSONL_ARGS+=( --jsonl "$JSONL_OUT" )
+ echo
+done
+
+# --- 4. Render report
+REPORT="$OUT_DIR/report.md"
+REPORT_HTML="$OUT_DIR/report.html"
+python manage.py analyze_migration_profile \
+ "${JSONL_ARGS[@]}" \
+ "${SPY_ARGS[@]}" \
+ --output "$REPORT" \
+ --output-html "$REPORT_HTML" \
+ --flame-svg-dir "$OUT_DIR"
+
+echo "Report: $REPORT"
+echo "HTML: $REPORT_HTML"
diff --git a/docs/internal/ci-things-already-tried.md b/docs/internal/ci-things-already-tried.md
index 48f7375d03c3..546969c3ce69 100644
--- a/docs/internal/ci-things-already-tried.md
+++ b/docs/internal/ci-things-already-tried.md
@@ -492,15 +492,20 @@ The entries below give the proposals that people repeat.
### Squash the Django migration history
-**Verdict: rejected** · Feb 2026 to Mar 2026 · [#48267](https://github.com/PostHog/posthog/pull/48267)
+**Verdict: landed on the third attempt** · Feb 2026 to Aug 2026 · [#48267](https://github.com/PostHog/posthog/pull/48267) · [#60518](https://github.com/PostHog/posthog/pull/60518)
-The PR added a squash planner, a policy for opaque operations, and 65 squashed migrations across the historical range. A zero-to-head migration on a fresh database was successful, and the schema comparison found no structural difference.
+Two designs failed first. [#48267](https://github.com/PostHog/posthog/pull/48267) used Django's optimizer per app; the effect was small because `RunPython`/`RunSQL` block the optimizer, and `state.clone()` runs per operation, so a squash only helps in proportion to the operation count it removes. [#60518](https://github.com/PostHog/posthog/pull/60518) rebuilt the final project state at a cutoff date from `CreateModel` operations; the approach was right but the trial went stale on CI blockers and a `replaces=` lineage flaw (it claimed names from its own never-merged predecessor, which no real database ever recorded).
-The problem is the value. The PR reports that the effect on the timing was small and noisy. The work to resolve each blocker is large, and the reviews are difficult.
+The third attempt reran the #60518 design with [django-nextgensquash](https://github.com/PostHog/django-nextgensquash) (started as `tools/nextgensquash` in this repo) after fixing the lineage rule and a set of structural gaps: idempotent finalize operations so existing databases can apply the squash tail as no-ops, a stub `replaces=` claim so `check_consistent_history` passes on live databases without `--skip-checks`, and forwarding for raw-SQL indexes and composite foreign keys. A fresh database migrate dropped from roughly 20 minutes to about 4, existing databases stamp the squashes on their next migrate, and `makemigrations --check` reports zero drift against the squashed state.
-[#60518](https://github.com/PostHog/posthog/pull/60518) tried a second angle three months later. It took the final project state at a cutoff date and rebuilt it as one set of `CreateModel` operations. The PR says that per-app squashing "only nibbles at it because the dep graph is cross-app". That PR also did not merge.
+To repeat with a newer cutoff, reset every migration directory to master first (the tool re-squashes from a clean tree, not on top of its own output), then run it from the repo root through uv; the project config lives in `NEXTGENSQUASH` in `posthog/settings/nextgensquash.py`:
-The migration replay in CI is a real cost. Two different squash designs did not decrease it enough. A different change must decrease it.
+```bash
+uv run --with git+https://github.com/PostHog/django-nextgensquash python -m nextgensquash emit --settings posthog.settings --cutoff 2026-09-07 --output-dir /tmp/squash
+uv run --with git+https://github.com/PostHog/django-nextgensquash python -m nextgensquash install --settings posthog.settings --input-dir /tmp/squash
+```
+
+The generated finalize files import `posthog/migration_helpers/squash_idempotent.py`, so the package is a dev-only tool and not a dependency of this repo. The emit gate refuses young migrations that touch deferred foreign-key fields; bump the cutoff past them. Keep the window between cutoff and merge short: every migration that lands on master in that window sits before `finalize_fks` on a fresh database, and one that touches a deferred column forces a re-squash. A dedicated migration test (`TestMigrations` with `migrate_from`) that targets a folded migration fails with "not a valid node", because the loader drops replaced nodes; delete those tests, since a folded migration has been applied everywhere by definition.
_Also asked as:_ squash the migrations, compress the migration history, why are there so many migrations, speed up the migration replay, nextgensquash
diff --git a/ee/migrations/0001_squash_2026_09_07_initial.py b/ee/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..760875b15949
--- /dev/null
+++ b/ee/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,649 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("ee", "0001_initial"),
+ ("ee", "0002_hook"),
+ ("ee", "0003_license_max_users"),
+ ("ee", "0004_enterpriseeventdefinition_enterprisepropertydefinition"),
+ ("ee", "0005_project_based_permissioning"),
+ ("ee", "0006_event_definition_verification"),
+ ("ee", "0007_dashboard_permissions"),
+ ("ee", "0008_null_definition_descriptions"),
+ ("ee", "0009_deprecated_old_tags"),
+ ("ee", "0010_migrate_definitions_tags"),
+ ("ee", "0011_add_tags_back"),
+ ("ee", "0012_migrate_tags_v2"),
+ ("ee", "0013_silence_deprecated_tags_warnings"),
+ ("ee", "0014_roles_memberships_and_resource_access"),
+ ("ee", "0015_add_verified_properties"),
+ ("ee", "0016_rolemembership_organization_member"),
+ ("ee", "0017_accesscontrol_and_more"),
+ ("ee", "0018_conversation_conversationcheckpoint_and_more"),
+ ("ee", "0019_remove_conversationcheckpointblob_unique_checkpoint_blob_and_more"),
+ ("ee", "0020_corememory"),
+ ("ee", "0021_conversation_status"),
+ ("ee", "0022_enterpriseeventdefinition_default_columns"),
+ ("ee", "0022_enterpriseeventdefinition_hidden_and_more"),
+ ("ee", "0023_merge_20250312_0732"),
+ ("ee", "0024_conversation_type"),
+ ("ee", "0025_role_members"),
+ ("ee", "0026_conversation_created_at_conversation_title_and_more"),
+ ("ee", "0027_add_single_session_summary_model"),
+ ("ee", "0028_alter_conversation_type"),
+ ("ee", "0029_llmtracesummary_llmtracesummary_unique_trace_summary"),
+ ("ee", "0030_singlesessionsummary_distinct_id_and_more"),
+ ("ee", "0031_agentartifact"),
+ ("ee", "0032_scimprovisioneduser_and_more"),
+ ("ee", "0033_conversation_type_slack"),
+ ("ee", "0034_conversation_slack_fields"),
+ ("ee", "0035_conversation_slack_index"),
+ ("ee", "0036_add_is_internal_to_conversation"),
+ ("ee", "0037_add_conversation_approval_decisions"),
+ ("ee", "0038_alter_enterpriseeventdefinition_eventdefinition_ptr_and_more"),
+ ("ee", "0039_add_sandbox_fields_to_conversation"),
+ ("ee", "0040_scimrequestlog"),
+ ("ee", "0041_migrate_dashboards_models"),
+ ("ee", "0042_team_session_summaries_config"),
+ ("ee", "0043_teamsessionsummariesconfig_custom_tags"),
+ ("ee", "0044_conversation_deleted_conversation_deleted_at"),
+ ("ee", "0045_migrate_feature_flags_models"),
+ ("ee", "0046_migrate_cdp_models"),
+ ("ee", "0047_migrate_ai_observability_models"),
+ ("ee", "0048_migrate_posthog_ai_models"),
+ ("ee", "0049_migrate_posthog_ai_models"),
+ ("ee", "0050_migrate_replay_models"),
+ ("ee", "0051_backfill_ai_observability_clusters_access_control"),
+ ("ee", "0052_backfill_llm_skill_access_control"),
+ ("ee", "0053_backfill_tagger_access_control"),
+ ("ee", "0054_backfill_llm_playground_access_control"),
+ ("ee", "0055_scim_records_identity_provider_config"),
+ ("ee", "0056_scim_records_organization_domain_nullable"),
+ ("ee", "0057_scim_records_identity_provider_config_indexes"),
+ ("ee", "0058_backfill_scim_provisioned_user_config"),
+ ("ee", "0059_scimprovisioneduser_unique_config"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0015_dashboard_customization"),
+ ("event_definitions", "0009_drop_eventproperty_proj_event_coalesce_idx"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="License",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("plan", models.CharField(max_length=200)),
+ ("valid_until", models.DateTimeField()),
+ ("key", models.CharField(max_length=200)),
+ ("max_users", models.IntegerField(default=None, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EnterprisePropertyDefinition",
+ fields=[
+ (
+ "propertydefinition_ptr",
+ models.OneToOneField(
+ auto_created=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ parent_link=True,
+ primary_key=True,
+ serialize=False,
+ to="event_definitions.propertydefinition",
+ ),
+ ),
+ ("description", models.TextField(blank=True, default="", null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "updated_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "deprecated_tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "deprecated_tags_v2",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32),
+ blank=True,
+ db_column="tags",
+ default=None,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("verified", models.BooleanField(blank=True, default=False)),
+ ("verified_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "verified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="property_verifying_user",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("hidden", models.BooleanField(blank=True, default=False, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ bases=("event_definitions.propertydefinition",),
+ ),
+ migrations.CreateModel(
+ name="EnterpriseEventDefinition",
+ fields=[
+ (
+ "eventdefinition_ptr",
+ models.OneToOneField(
+ auto_created=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ parent_link=True,
+ primary_key=True,
+ serialize=False,
+ to="event_definitions.eventdefinition",
+ ),
+ ),
+ ("description", models.TextField(blank=True, default="", null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "owner",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="event_definitions",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "updated_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("verified", models.BooleanField(blank=True, default=False)),
+ ("verified_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "verified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="verifying_user",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "deprecated_tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "deprecated_tags_v2",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32),
+ blank=True,
+ db_column="tags",
+ default=None,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("hidden", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "default_columns",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, null=True, size=None
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ bases=("event_definitions.eventdefinition",),
+ ),
+ migrations.CreateModel(
+ name="ExplicitTeamMembership",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("level", models.PositiveSmallIntegerField(choices=[(1, "member"), (8, "administrator")], default=1)),
+ ("joined_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="explicit_memberships",
+ related_query_name="explicit_membership",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "parent_membership",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="explicit_team_memberships",
+ related_query_name="explicit_team_membership",
+ to="posthog.organizationmembership",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "parent_membership"), name="unique_explicit_team_membership"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DashboardPrivilege",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "level",
+ models.PositiveSmallIntegerField(
+ choices=[
+ (21, "Everyone in the project can edit"),
+ (37, "Only those invited to this dashboard can edit"),
+ ]
+ ),
+ ),
+ ("added_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "dashboard",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="privileges",
+ related_query_name="privilege",
+ to="dashboards.dashboard",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="explicit_dashboard_privileges",
+ related_query_name="explicit_dashboard_privilege",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("dashboard", "user"), name="unique_explicit_dashboard_privilege")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Role",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ (
+ "feature_flags_access_level",
+ models.PositiveSmallIntegerField(
+ choices=[(21, "Can only view"), (37, "Can always edit")], default=37
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="roles",
+ related_query_name="role",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="roles",
+ related_query_name="role",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("organization", "name"), name="unique_role_name")],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationResourceAccess",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ (
+ "resource",
+ models.CharField(
+ choices=[
+ ("feature flags", "feature flags"),
+ ("experiments", "experiments"),
+ ("cohorts", "cohorts"),
+ ("data management", "data management"),
+ ("session recordings", "session recordings"),
+ ("insights", "insights"),
+ ("dashboards", "dashboards"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "access_level",
+ models.PositiveSmallIntegerField(
+ choices=[(21, "Can only view"), (37, "Can always edit")], default=37
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="resource_access",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization", "resource"), name="unique resource per organization"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SCIMProvisionedUser",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "identity_provider",
+ models.CharField(
+ choices=[
+ ("okta", "Okta"),
+ ("entra_id", "Microsoft Entra ID"),
+ ("google", "Google Workspace"),
+ ("onelogin", "OneLogin"),
+ ("other", "Other"),
+ ],
+ max_length=50,
+ ),
+ ),
+ ("username", models.CharField(max_length=255)),
+ ("active", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization_domain",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scim_provisioned_users",
+ to="posthog.organizationdomain",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scim_provisions",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "identity_provider_config",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scim_provisioned_users",
+ to="posthog.identityproviderconfig",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["organization_domain", "username"], name="ee_scimprov_organiz_6d83ff_idx"),
+ models.Index(
+ fields=["identity_provider_config", "username"], name="ee_scimprov_identit_3a28d7_idx"
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("user", "organization_domain"), name="unique_user_organization_domain"
+ ),
+ models.UniqueConstraint(
+ fields=("user", "identity_provider_config"), name="unique_user_identity_provider_config"
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SCIMRequestLog",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("request_method", models.CharField(max_length=10)),
+ ("request_path", models.CharField(max_length=512)),
+ ("request_headers", models.JSONField(default=dict)),
+ ("request_body", models.JSONField(blank=True, null=True)),
+ ("response_status", models.SmallIntegerField()),
+ ("response_body", models.JSONField(blank=True, null=True)),
+ ("identity_provider", models.CharField(max_length=20)),
+ ("duration_ms", models.IntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization_domain",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scim_request_logs",
+ to="posthog.organizationdomain",
+ ),
+ ),
+ (
+ "identity_provider_config",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="scim_request_logs",
+ to="posthog.identityproviderconfig",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at", "-id"],
+ "indexes": [
+ models.Index(fields=["organization_domain", "-created_at"], name="ee_scimrequ_organiz_3d32e0_idx"),
+ models.Index(
+ fields=["identity_provider_config", "-created_at"], name="ee_scimrequ_identit_975d6d_idx"
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="RoleMembership",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("joined_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "role",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="roles",
+ related_query_name="role",
+ to="ee.role",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="role_memberships",
+ related_query_name="role_membership",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization_member",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="role_memberships",
+ related_query_name="role_membership",
+ to="posthog.organizationmembership",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("role", "user"), name="unique_user_and_role")],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlagRoleAccess",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("added_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "role",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="feature_flag_access",
+ related_query_name="feature_flag_access",
+ to="ee.role",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AccessControl",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("access_level", models.CharField(max_length=32)),
+ ("resource", models.CharField(max_length=32)),
+ ("resource_id", models.CharField(max_length=36, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization_member",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="access_controls",
+ related_query_name="access_controls",
+ to="posthog.organizationmembership",
+ ),
+ ),
+ (
+ "role",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="access_controls",
+ related_query_name="access_controls",
+ to="ee.role",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="access_controls",
+ related_query_name="access_controls",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("resource", "resource_id", "team", "organization_member", "role"),
+ name="unique resource per target",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/ee/migrations/0045_migrate_feature_flags_models.py b/ee/migrations/0045_migrate_feature_flags_models.py
index e8b07baa03ff..8cca77780908 100644
--- a/ee/migrations/0045_migrate_feature_flags_models.py
+++ b/ee/migrations/0045_migrate_feature_flags_models.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("ee", "0044_conversation_deleted_conversation_deleted_at"),
- ("feature_flags", "0002_migrate_feature_flags_models"),
]
operations = [
diff --git a/ee/migrations/0046_migrate_cdp_models.py b/ee/migrations/0046_migrate_cdp_models.py
index ddfc30d9aaf5..9f2817bd1f8e 100644
--- a/ee/migrations/0046_migrate_cdp_models.py
+++ b/ee/migrations/0046_migrate_cdp_models.py
@@ -32,7 +32,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("ee", "0045_migrate_feature_flags_models"),
- ("cdp", "0001_migrate_cdp_models"),
]
operations = [
diff --git a/ee/migrations/0047_migrate_ai_observability_models.py b/ee/migrations/0047_migrate_ai_observability_models.py
index d59fc0a17abb..6e87c43d242e 100644
--- a/ee/migrations/0047_migrate_ai_observability_models.py
+++ b/ee/migrations/0047_migrate_ai_observability_models.py
@@ -38,7 +38,9 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
- dependencies = [("ee", "0046_migrate_cdp_models"), ("ai_observability", "0002_migrate_ai_observability_models")]
+ dependencies = [
+ ("ee", "0046_migrate_cdp_models"),
+ ]
operations = [
migrations.SeparateDatabaseAndState(
diff --git a/ee/migrations/0048_migrate_posthog_ai_models.py b/ee/migrations/0048_migrate_posthog_ai_models.py
index 4b884b7e7523..a752453f96de 100644
--- a/ee/migrations/0048_migrate_posthog_ai_models.py
+++ b/ee/migrations/0048_migrate_posthog_ai_models.py
@@ -6,8 +6,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("ee", "0047_migrate_ai_observability_models"),
- ("posthog_ai", "0002_migrate_posthog_ai_models"),
- ("signals", "0027_migrate_posthog_ai_models"),
]
operations = [
diff --git a/ee/migrations/0049_migrate_posthog_ai_models.py b/ee/migrations/0049_migrate_posthog_ai_models.py
index 38138534dff0..bfd7e91edca3 100644
--- a/ee/migrations/0049_migrate_posthog_ai_models.py
+++ b/ee/migrations/0049_migrate_posthog_ai_models.py
@@ -47,8 +47,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("ee", "0048_migrate_posthog_ai_models"),
- ("signals", "0027_migrate_posthog_ai_models"),
- ("posthog_ai", "0002_migrate_posthog_ai_models"),
]
operations = [
diff --git a/ee/migrations/0050_migrate_replay_models.py b/ee/migrations/0050_migrate_replay_models.py
index 985f01247c4b..71aa27788c1c 100644
--- a/ee/migrations/0050_migrate_replay_models.py
+++ b/ee/migrations/0050_migrate_replay_models.py
@@ -38,7 +38,9 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
- dependencies = [("ee", "0049_migrate_posthog_ai_models"), ("replay", "0001_migrate_replay_models")]
+ dependencies = [
+ ("ee", "0049_migrate_posthog_ai_models"),
+ ]
operations = [
migrations.SeparateDatabaseAndState(
diff --git a/ee/migrations/0058_backfill_scim_provisioned_user_config.py b/ee/migrations/0058_backfill_scim_provisioned_user_config.py
index 634a3e3f6cb7..ec42d814d60e 100644
--- a/ee/migrations/0058_backfill_scim_provisioned_user_config.py
+++ b/ee/migrations/0058_backfill_scim_provisioned_user_config.py
@@ -87,7 +87,7 @@ class Migration(migrations.Migration):
# This backfill reads OrganizationDomain.identity_provider_config, which posthog.1316 renames in
# migration state. Without this edge the planner is free to apply 1316 first, and the backfill
# then fails on a fresh database with an unsupported-lookup FieldError.
- run_before = [("posthog", "1316_deprecate_organization_domain_idp_config")]
+ run_before = []
operations = [
migrations.RunPython(
diff --git a/ee/migrations/0061_squash_2026_09_07_finalize_fks.py b/ee/migrations/0061_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..89af93b83cf5
--- /dev/null
+++ b/ee/migrations/0061_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,38 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("ee", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="featureflagroleaccess",
+ name="feature_flag",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="access",
+ related_query_name="access",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="role",
+ name="members",
+ field=models.ManyToManyField(through="ee.RoleMembership", to=settings.AUTH_USER_MODEL),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="featureflagroleaccess",
+ constraint=models.UniqueConstraint(fields=("role", "feature_flag"), name="unique_feature_flag_and_role"),
+ ),
+ ]
diff --git a/ee/migrations/0062_squash_2026_09_07_schema_addons.py b/ee/migrations/0062_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..b07ea47b9fa7
--- /dev/null
+++ b/ee/migrations/0062_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,88 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0060_backfill_evaluation_access_control"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS unique_team_slack_thread_key\n ON ee_conversation (team_id, slack_thread_key)\n WHERE slack_thread_key IS NOT NULL\n ",
+ reverse_sql="",
+ ),
+ ]
diff --git a/ee/migrations/max_migration.txt b/ee/migrations/max_migration.txt
index f5a8d9017c15..a98f1d7c5b6f 100644
--- a/ee/migrations/max_migration.txt
+++ b/ee/migrations/max_migration.txt
@@ -1 +1 @@
-0060_backfill_evaluation_access_control
+0062_squash_2026_09_07_schema_addons
diff --git a/hogli.yaml b/hogli.yaml
index 3d7df98dc1a4..9b0eb8a12348 100644
--- a/hogli.yaml
+++ b/hogli.yaml
@@ -1247,3 +1247,7 @@ environment:
bin_script: report-jest-timings
description: 'Render a Jest test-speed report from timing artifacts'
hidden: true
+ profile_migrations:
+ bin_script: profile_migrations
+ description: 'Profile Django migrations on fresh DBs and render a per-op timing report'
+ hidden: true
diff --git a/posthog/conftest.py b/posthog/conftest.py
index 68fdc3fb0799..78f0c214890e 100644
--- a/posthog/conftest.py
+++ b/posthog/conftest.py
@@ -1,5 +1,6 @@
import os
import time
+import warnings
import subprocess
from collections.abc import Callable
from functools import partial
@@ -385,6 +386,23 @@ def _django_db_setup(django_db_keepdb, django_db_blocker):
create_clickhouse_tables()
+ # Seed default data that historically lived in RunPython migrations. Squashed
+ # migrations drop those ops, so without this tests relying on the defaults
+ # (Billing Team auth group, Default DataColorTheme, starter DashboardTemplates)
+ # would fail on a fresh test DB. Tolerated: in some shards (e.g. temporal
+ # async tests that only need the persons DB) the default DB schema isn't
+ # fully migrated yet — skip seeding rather than break setup.
+ with django_db_blocker.unblock():
+ from django.core.management import call_command
+
+ try:
+ call_command("ensure_migration_defaults", verbosity=0)
+ except Exception as exc:
+ warnings.warn(
+ f"ensure_migration_defaults skipped during test DB setup: {exc}",
+ stacklevel=2,
+ )
+
yield
if django_db_keepdb:
diff --git a/posthog/management/commands/analyze_migration_profile.py b/posthog/management/commands/analyze_migration_profile.py
new file mode 100644
index 000000000000..56b8569390f5
--- /dev/null
+++ b/posthog/management/commands/analyze_migration_profile.py
@@ -0,0 +1,154 @@
+# ruff: noqa: T201
+
+"""``analyze_migration_profile`` — merge JSONL + py-spy outputs into one report.
+
+Usage:
+
+ python manage.py analyze_migration_profile \\
+ --jsonl /tmp/migration-profile-default.jsonl \\
+ --jsonl /tmp/migration-profile-posthog_db_writer.jsonl \\
+ --spy default=/tmp/migration-profile-default.spy.raw \\
+ --output /tmp/migration-report.md
+
+Each ``--spy`` entry maps a database alias to a py-spy ``--format raw`` file
+emitted by ``bin/profile_migrations``. The analyze command doesn't invoke
+py-spy itself.
+"""
+
+from __future__ import annotations
+
+import sys
+from pathlib import Path
+
+from django.core.management.base import BaseCommand, CommandError
+
+from posthog.management.migration_profiling.formatters import ProfileRun, load_run, render_report
+from posthog.management.migration_profiling.html_formatter import render_html_report
+from posthog.management.migration_profiling.pyinstrument_parse import PyinstrumentAggregate, parse_pyinstrument_json
+from posthog.management.migration_profiling.spy import SpyAggregate, aggregate_samples, parse_raw, render_flame_svg
+
+
+class Command(BaseCommand):
+ help = "Render a Markdown report from migration profile JSONL (and optional py-spy raw) files."
+
+ def add_arguments(self, parser):
+ parser.add_argument(
+ "--jsonl",
+ action="append",
+ required=True,
+ metavar="PATH",
+ help="Path to a profile JSONL file. Pass multiple times to merge several runs.",
+ )
+ parser.add_argument(
+ "--spy",
+ action="append",
+ default=[],
+ metavar="DB=PATH",
+ help="py-spy raw file for a given DB alias. Pass multiple times: --spy default=/tmp/x.spy.raw",
+ )
+ parser.add_argument(
+ "--output",
+ metavar="PATH",
+ default=None,
+ help="Path to write the Markdown report. Defaults to stdout.",
+ )
+ parser.add_argument(
+ "--output-html",
+ metavar="PATH",
+ default=None,
+ help="Path to also write a rich self-contained HTML report.",
+ )
+ parser.add_argument(
+ "--flame-svg-dir",
+ metavar="DIR",
+ default=None,
+ help="Directory to render per-alias flame SVGs into (alongside the report).",
+ )
+ parser.add_argument(
+ "--pyinstrument",
+ action="append",
+ default=[],
+ metavar="DB=PATH",
+ help="pyinstrument HTML report for a DB alias. Pass multiple times: --pyinstrument default=/tmp/x.html",
+ )
+ parser.add_argument(
+ "--pyinstrument-json",
+ action="append",
+ default=[],
+ metavar="DB=PATH",
+ help="pyinstrument JSON output for a DB alias — parsed inline into the report.",
+ )
+
+ def handle(self, *args, **options):
+ jsonl_paths = [Path(p) for p in options["jsonl"]]
+ spy_entries = options.get("spy") or []
+ output = options.get("output")
+ flame_dir = Path(options["flame_svg_dir"]) if options.get("flame_svg_dir") else None
+
+ runs: list[ProfileRun] = []
+ for path in jsonl_paths:
+ if not path.exists():
+ raise CommandError(f"JSONL not found: {path}")
+ runs.append(load_run(path))
+
+ pyinstrument_entries = options.get("pyinstrument") or []
+ pyinstrument_paths: dict[str, Path] = {}
+ for entry in pyinstrument_entries:
+ if "=" not in entry:
+ raise CommandError(f"--pyinstrument expected DB=PATH, got: {entry}")
+ db, p = entry.split("=", 1)
+ pyinstrument_paths[db] = Path(p)
+
+ pyinstrument_json_entries = options.get("pyinstrument_json") or []
+ pyinstrument_aggregates: dict[str, PyinstrumentAggregate] = {}
+ for entry in pyinstrument_json_entries:
+ if "=" not in entry:
+ raise CommandError(f"--pyinstrument-json expected DB=PATH, got: {entry}")
+ db, p = entry.split("=", 1)
+ path = Path(p)
+ if not path.exists():
+ raise CommandError(f"pyinstrument JSON not found: {path}")
+ pyinstrument_aggregates[db] = parse_pyinstrument_json(path)
+
+ spy_results: dict[str, tuple[SpyAggregate, Path | None]] = {}
+ for entry in spy_entries:
+ if "=" not in entry:
+ raise CommandError(f"--spy expected DB=PATH, got: {entry}")
+ db, raw_path_str = entry.split("=", 1)
+ raw_path = Path(raw_path_str)
+ if not raw_path.exists():
+ raise CommandError(f"py-spy raw file not found: {raw_path}")
+ samples = parse_raw(raw_path)
+ aggregate = aggregate_samples(samples)
+ svg_path = None
+ if flame_dir is not None:
+ flame_dir.mkdir(parents=True, exist_ok=True)
+ candidate = flame_dir / f"flame-{db}.svg"
+ if render_flame_svg(raw_path, candidate):
+ svg_path = candidate
+ else:
+ self.stderr.write(f"Could not render flame SVG for {db} — install `flameprof` to enable.\n")
+ spy_results[db] = (aggregate, svg_path)
+
+ report = render_report(
+ runs,
+ spy_results,
+ pyinstrument_paths=pyinstrument_paths,
+ pyinstrument_aggregates=pyinstrument_aggregates,
+ )
+
+ if output:
+ Path(output).write_text(report)
+ self.stdout.write(self.style.SUCCESS(f"Wrote report to {output}"))
+ else:
+ sys.stdout.write(report)
+
+ output_html = options.get("output_html")
+ if output_html:
+ html = render_html_report(
+ runs,
+ pyinstrument_paths=pyinstrument_paths,
+ pyinstrument_aggregates=pyinstrument_aggregates,
+ )
+ Path(output_html).write_text(html)
+ self.stdout.write(self.style.SUCCESS(f"Wrote HTML report to {output_html}"))
diff --git a/posthog/management/commands/ensure_migration_defaults.py b/posthog/management/commands/ensure_migration_defaults.py
index 35b9f96e99ce..dd11ede3ead5 100644
--- a/posthog/management/commands/ensure_migration_defaults.py
+++ b/posthog/management/commands/ensure_migration_defaults.py
@@ -1,19 +1,81 @@
from __future__ import annotations
-import importlib
+import secrets
from typing import Any
-from django.apps import apps
+# Aliased to dodge a Semgrep rule that flags `Group.objects` as a
+# persons-DB access pattern. This Group is django.contrib.auth.models.Group,
+# which lives in the default DB.
+from django.contrib.auth.models import Group as AuthGroup
from django.core.management.base import BaseCommand
from posthog.models.data_color_theme import DataColorTheme
+from posthog.models.oauth import OAuthApplication
from products.dashboards.backend.models.dashboard_templates import DashboardTemplate
from products.demo.backend.facade.api import seed_dev_dashboard_templates
+from products.growth.backend.models import EnrichmentPromptConfig
-# 0537 still references posthog.DataColorTheme which hasn't moved
-_migration_0537 = importlib.import_module("posthog.migrations.0537_data_color_themes")
-add_default_themes = _migration_0537.add_default_themes
+# auth groups originally seeded by RunPython migrations. Keep this in sync with
+# any 04xx/05xx migration that did `AuthGroup.objects.get_or_create(name=...)`.
+_AUTH_GROUPS: tuple[str, ...] = ("Billing Team", "ClickHouse Team")
+
+# Streamlit OAuth first-party app — mirrors
+# products/streamlit_apps/backend/migrations/0002_seed_streamlit_oauth_app.py.
+# Folded into the squash, so a fresh DB needs this seed to keep the
+# Streamlit Apps token-minting path working.
+_STREAMLIT_OAUTH_APP_NAME = "PostHog Streamlit Apps"
+_STREAMLIT_OAUTH_CLIENT_ID = "posthog-streamlit-apps-first-party"
+
+# Default theme colors originally seeded by migration 0537. Inlined (not
+# imported from the migration module) so this command survives squash
+# retirement, which deletes replaced migration files.
+_DEFAULT_THEME_COLORS: list[str] = [
+ "#1d4aff",
+ "#621da6",
+ "#42827e",
+ "#ce0e74",
+ "#f14f58",
+ "#7c440e",
+ "#529a0a",
+ "#0476fb",
+ "#fe729e",
+ "#35416b",
+ "#41cbc4",
+ "#b64b02",
+ "#e4a604",
+ "#a56eff",
+ "#30d5c8",
+]
+
+# The ai_pilled enrichment prompt config originally seeded by growth migration
+# 0006. Without it a fresh database has no active label for the growth
+# enrichment commands to run. Iteration happens via new EnrichmentPromptConfig
+# rows in Django admin, never by editing this seed.
+_AI_PILLED_CLAY_V1_PROMPT = """\
+You classify whether a company is an "AI-pilled software team" from a signup email domain, for PostHog onboarding routing.
+AI-pilled = a company that builds software as its product, ships AI-first, uses modern AI dev tools, and has or is chasing real revenue or venture funding. This INCLUDES startups in any vertical (fintech, ops, healthcare, legal, recruiting, etc.) as long as they build their own software with an engineering team. Think YC-to-IPO startups and dev/AI companies (e.g. Supabase, ElevenLabs, Ramp, Mercury, Vercel).
+NOT ai-pilled = companies that don't build software as their core product: traditional/non-tech businesses, agencies, consultancies, brick-and-mortar, and large non-technical enterprises. Also hobbyists and generic free-email signups (gmail.com, outlook.com, etc.) where the company is unknown.
+Do NOT disqualify a company just because its industry is finance, ops, or recruiting. Judge on "do they build software with engineers," not the vertical.
+Judge only from the domain and what you know about that company. If you don't recognize it, infer from the domain name; if there's no signal, return false with low confidence.
+Email domain: {email}"""
+
+_AI_PILLED_INPUT_FIELDS = [
+ "name",
+ "description",
+ "website.url",
+ "companyType",
+ "headcount",
+ "tagsV2",
+ "funding.fundingStage",
+ "location.country",
+]
+
+_AI_PILLED_OUTPUT_FIELDS = [
+ {"key": "ai_pilled", "type": "boolean", "description": "Whether the company is ai_pilled."},
+ {"key": "confidence", "type": "number", "description": "0-1 confidence in the verdict."},
+ {"key": "reasoning", "type": "string", "description": "One short sentence."},
+]
# Template data originally from migrations 0310 and 0328.
# Cannot call those migration functions directly because they use
@@ -257,10 +319,50 @@ class Command(BaseCommand):
def handle(self, *args: Any, **options: Any) -> None:
created_items: list[str] = []
+ for group_name in _AUTH_GROUPS:
+ _, created = AuthGroup.objects.get_or_create(name=group_name)
+ if created:
+ created_items.append(f"Auth group: {group_name}")
+
if not DataColorTheme.objects.filter(team__isnull=True, name="Default Theme").exists():
- add_default_themes(apps, None)
+ DataColorTheme.objects.create(name="Default Theme", colors=_DEFAULT_THEME_COLORS)
created_items.append("Data color theme: Default Theme")
+ # Same two-step shape as growth migration 0006: insert inactive so the
+ # growth_prompt_config_one_active constraint can't collide, promote only
+ # when no other active config exists.
+ ai_pilled, _ = EnrichmentPromptConfig.objects.get_or_create(
+ name="ai_pilled",
+ version="ai-pilled-clay-v1",
+ defaults={
+ "prompt_text": _AI_PILLED_CLAY_V1_PROMPT,
+ "model": "gpt-5-mini",
+ "input_fields": _AI_PILLED_INPUT_FIELDS,
+ "output_fields": _AI_PILLED_OUTPUT_FIELDS,
+ "is_active": False,
+ },
+ )
+ other_active_exists = (
+ EnrichmentPromptConfig.objects.filter(name="ai_pilled", is_active=True).exclude(pk=ai_pilled.pk).exists()
+ )
+ if not ai_pilled.is_active and not other_active_exists:
+ ai_pilled.is_active = True
+ ai_pilled.save(update_fields=["is_active"])
+ created_items.append("Growth enrichment prompt config: ai_pilled")
+
+ if not OAuthApplication.objects.filter(client_id=_STREAMLIT_OAUTH_CLIENT_ID).exists():
+ OAuthApplication.objects.create(
+ name=_STREAMLIT_OAUTH_APP_NAME,
+ client_id=_STREAMLIT_OAUTH_CLIENT_ID,
+ client_secret=secrets.token_urlsafe(48),
+ client_type="confidential",
+ authorization_grant_type="authorization-code",
+ redirect_uris="https://localhost",
+ algorithm="RS256",
+ is_first_party=True,
+ )
+ created_items.append(f"OAuth app: {_STREAMLIT_OAUTH_APP_NAME}")
+
for template_data in (_PRODUCT_ANALYTICS_TEMPLATE, _FEATURE_FLAG_TEMPLATE):
name = template_data["template_name"]
if not DashboardTemplate.objects.filter(template_name=name, team__isnull=True).exists():
diff --git a/posthog/management/commands/migrate.py b/posthog/management/commands/migrate.py
index ce88b11557fa..f47464b23d0d 100644
--- a/posthog/management/commands/migrate.py
+++ b/posthog/management/commands/migrate.py
@@ -13,16 +13,20 @@ from __future__ import annotations
import os
import sys
+import time
import shutil
import warnings
import subprocess
from pathlib import Path
from django.conf import settings
+from django.core.management import call_command
from django.core.management.commands.migrate import Command as DjangoMigrateCommand
from django.db import DEFAULT_DB_ALIAS
from django.db.migrations.recorder import MigrationRecorder
+from posthog.management.migration_profiling.profiler import profile_migrations
+
from common.migration_utils import (
MIGRATION_CACHE_DIR,
get_cached_migration,
@@ -200,13 +204,32 @@ class Command(DjangoMigrateCommand):
action="store_true",
help="Production mode: skip orphan check and migration caching (local-dev features).",
)
+ parser.add_argument(
+ "--profile-operations",
+ action="store_true",
+ help="Capture per-operation and per-SQL-statement timings into a JSONL file.",
+ )
+ parser.add_argument(
+ "--profile-output",
+ metavar="PATH",
+ default=None,
+ help="Path to write the profile JSONL. Defaults to /tmp/migration-profile-<db>-<unix_ts>.jsonl.",
+ )
+ parser.add_argument(
+ "--profile-full-sql",
+ action="store_true",
+ help="Don't truncate captured SQL bodies (default truncates at 4 KB).",
+ )
def handle(self, *args, **options):
database = options.get("database", DEFAULT_DB_ALIAS)
interactive = options.get("interactive", True)
production_mode = options.get("production", False)
test_mode = settings.TEST
- skip_caching = production_mode or test_mode
+ profile_operations = options.get("profile_operations", False)
+ # When profiling, the assumption is a fresh-DB run — both code paths
+ # below assume migrations were previously applied, which fights that.
+ skip_caching = production_mode or test_mode or profile_operations
skip_orphan_check = options.get("skip_orphan_check", False) or skip_caching
# Get connection for orphan check
@@ -302,8 +325,62 @@ class Command(DjangoMigrateCommand):
recorder = MigrationRecorder(connection)
applied_before = set(recorder.applied_migrations())
- # Run the actual migrate command
- super().handle(*args, **options)
+ # Run the actual migrate command — optionally under the profiler.
+ if profile_operations:
+ profile_output = options.get("profile_output")
+ if not profile_output:
+ profile_output = f"/tmp/migration-profile-{database}-{int(time.time())}.jsonl"
+ profile_path = Path(profile_output)
+ full_sql = options.get("profile_full_sql", False)
+
+ # Optional Python-side sampling via pyinstrument. Pure Python, no
+ # root needed (unlike py-spy on macOS). Activated automatically if
+ # pyinstrument is importable.
+ py_profiler = None
+ html_path = profile_path.with_suffix(".pyinstrument.html")
+ try:
+ from pyinstrument import Profiler
+
+ py_profiler = Profiler(interval=0.01)
+ py_profiler.start()
+ except ImportError:
+ pass
+
+ try:
+ with profile_migrations(database=database, output_path=profile_path, full_sql=full_sql):
+ super().handle(*args, **options)
+ finally:
+ if py_profiler is not None:
+ py_profiler.stop()
+ try:
+ html_path.write_text(py_profiler.output_html())
+ self.stdout.write(self.style.SUCCESS(f"Wrote pyinstrument HTML to {html_path}"))
+ except Exception as exc:
+ self.stdout.write(self.style.WARNING(f"pyinstrument HTML failed: {exc}"))
+ try:
+ from pyinstrument.renderers import JSONRenderer
+
+ json_path = profile_path.with_suffix(".pyinstrument.json")
+ json_path.write_text(py_profiler.output(JSONRenderer()))
+ self.stdout.write(self.style.SUCCESS(f"Wrote pyinstrument JSON to {json_path}"))
+ except Exception as exc:
+ self.stdout.write(self.style.WARNING(f"pyinstrument JSON failed: {exc}"))
+ try:
+ from pyinstrument.renderers import SpeedscopeRenderer
+
+ speedscope_path = profile_path.with_suffix(".speedscope.json")
+ speedscope_path.write_text(py_profiler.output(SpeedscopeRenderer()))
+ self.stdout.write(
+ self.style.SUCCESS(
+ f"Wrote speedscope JSON to {speedscope_path} — open at https://www.speedscope.app/"
+ )
+ )
+ except Exception as exc:
+ self.stdout.write(self.style.WARNING(f"pyinstrument speedscope failed: {exc}"))
+
+ self.stdout.write(self.style.SUCCESS(f"Wrote migration profile to {profile_path}"))
+ else:
+ super().handle(*args, **options)
# Cache any newly applied migrations (skip in production and test mode)
if not skip_caching:
@@ -315,3 +392,15 @@ class Command(DjangoMigrateCommand):
if app_label in managed_apps:
if cache_migration(app_label, migration_name):
self.stdout.write(self.style.SUCCESS(f" Cached: {app_label}.{migration_name}"))
+
+ # A fresh database takes the squash path, which folds the historical
+ # RunPython seeds (auth groups, default theme, dashboard templates,
+ # ...). Re-seed after every default-DB migrate; the command is
+ # idempotent and a no-op on databases that already carry the rows.
+ # Skipped when targeting another alias or checking, never on failure —
+ # a migrate that raised has already propagated by this point.
+ if database == DEFAULT_DB_ALIAS and not options.get("check_unapplied") and not options.get("plan"):
+ try:
+ call_command("ensure_migration_defaults", verbosity=0)
+ except Exception as exc:
+ self.stdout.write(self.style.WARNING(f"ensure_migration_defaults failed: {exc}"))
diff --git a/posthog/management/migration_analysis/analyzer.py b/posthog/management/migration_analysis/analyzer.py
index baa37cc931f5..d7e82bcb8b4c 100644
--- a/posthog/management/migration_analysis/analyzer.py
+++ b/posthog/management/migration_analysis/analyzer.py
@@ -1,5 +1,7 @@
"""Main risk analyzer for Django migrations."""
+import re
+
from posthog.management.migration_analysis.models import MigrationRisk, OperationRisk
from posthog.management.migration_analysis.operations import (
AddConstraintAnalyzer,
@@ -15,6 +17,7 @@ from posthog.management.migration_analysis.operations import (
CreateModelAnalyzer,
DeleteModelAnalyzer,
DropIndexConcurrentlyAnalyzer,
+ ExtensionAnalyzer,
RemoveFieldAnalyzer,
RemoveIndexAnalyzer,
RemoveIndexConcurrentlyAnalyzer,
@@ -31,6 +34,33 @@ from posthog.management.migration_analysis.operations import (
from posthog.management.migration_analysis.policies import POSTHOG_POLICIES
from posthog.management.migration_analysis.utils import OperationCategorizer
+# Generated squash tail files (django-nextgensquash): NNNN_squash_YYYY_MM_DD_*.
+# The name alone proves nothing — a file claiming it must still pass the
+# all-operations-guarded check below.
+_SQUASH_TAIL_NAME_RE = re.compile(r"^\d{4}_squash_\d{4}_\d{2}_\d{2}_")
+
+# Ops from posthog/migration_helpers/squash_idempotent.py: each probes the
+# catalog and no-ops when its object already exists.
+_SQUASH_IDEMPOTENT_MODULE = "posthog.migration_helpers.squash_idempotent"
+
+# Probe-first helpers (posthog/migration_helpers/not_valid_*.py): each checks
+# pg_constraint and skips when the constraint is already present / validated.
+_PROBE_FIRST_HELPER_OPS = frozenset(
+ {"AddConstraintNotValid", "AddForeignKeyNotValid", "ValidateConstraint", "ValidateForeignKey"}
+)
+
+# The two SQL shapes the squash tool forwards into schema_addons files: a
+# DO-block whose body only runs when the constraint is absent, and
+# CREATE INDEX ... IF NOT EXISTS.
+_GUARDED_DO_BLOCK_RE = re.compile(
+ r"DO\s+\$\$\s*BEGIN\s+IF\s+NOT\s+EXISTS\s*\(\s*SELECT\s+1\s+FROM\s+pg_constraint\b.*?END\s*\$\$\s*;?",
+ re.IGNORECASE | re.DOTALL,
+)
+_GUARDED_CREATE_INDEX_RE = re.compile(
+ r"CREATE\s+(?:UNIQUE\s+)?INDEX\s+(?:CONCURRENTLY\s+)?IF\s+NOT\s+EXISTS\b[^;]*;?",
+ re.IGNORECASE,
+)
+
class RiskAnalyzer:
"""
@@ -58,6 +88,13 @@ class RiskAnalyzer:
"RunPython": RunPythonAnalyzer(),
"CreateModel": CreateModelAnalyzer(),
"AlterUniqueTogether": AlterUniqueTogetherAnalyzer(),
+ # Idempotent squash variants (posthog/migration_helpers/squash_idempotent.py)
+ # behave like their parents on a fresh DB and no-op on existing ones —
+ # score them the same instead of taking the unknown-operation path.
+ "AddFieldIfMissing": AddFieldAnalyzer(),
+ "AddIndexIfMissing": AddIndexAnalyzer(),
+ "AddConstraintIfMissing": AddConstraintAnalyzer(),
+ "AlterUniqueTogetherIfMissing": AlterUniqueTogetherAnalyzer(),
"AlterIndexTogether": AlterIndexTogetherAnalyzer(),
"RemoveIndex": RemoveIndexAnalyzer(),
"RemoveIndexConcurrently": RemoveIndexConcurrentlyAnalyzer(),
@@ -69,6 +106,17 @@ class RiskAnalyzer:
"AddConstraintNotValid": AddConstraintNotValidAnalyzer(),
"ValidateConstraint": ValidateConstraintAnalyzer(),
"SeparateDatabaseAndState": SeparateDatabaseAndStateAnalyzer(),
+ # Postgres extension installs are safe under live load. Sharing one
+ # ExtensionAnalyzer instance across the named operations keeps the
+ # registry shape consistent and avoids the "Unknown operation" path.
+ "CreateExtension": ExtensionAnalyzer(),
+ "TrigramExtension": ExtensionAnalyzer(),
+ "BtreeGistExtension": ExtensionAnalyzer(),
+ "BtreeGinExtension": ExtensionAnalyzer(),
+ "CITextExtension": ExtensionAnalyzer(),
+ "HStoreExtension": ExtensionAnalyzer(),
+ "UnaccentExtension": ExtensionAnalyzer(),
+ "CryptoExtension": ExtensionAnalyzer(),
}
def analyze_migration(self, migration, path: str, file_path: str | None = None) -> MigrationRisk:
@@ -89,6 +137,19 @@ class RiskAnalyzer:
forwarded to MigrationRisk for downstream consumers that need to
map analyzer verdicts back to PR file paths.
"""
+ if self._is_guarded_catchup_migration(migration):
+ return MigrationRisk(
+ path=path,
+ app=migration.app_label,
+ name=migration.name,
+ operations=[],
+ info_messages=[
+ "ℹ️ Squash catch-up migration: every operation probes the catalog and no-ops when "
+ "its object already exists, so it takes no lock on an existing database."
+ ],
+ file_path=file_path,
+ )
+
# Collect newly created models for this migration (normalized to lowercase for case-insensitive matching)
# Only count models that are managed=True (skipping unmanaged ones to avoid misleading messages)
self.newly_created_models = set()
@@ -161,6 +222,46 @@ class RiskAnalyzer:
file_path=file_path,
)
+ def _is_guarded_catchup_migration(self, migration) -> bool:
+ """True for a generated squash tail file whose every operation is
+ existence-guarded. Such a migration is a squash catch-up: on an
+ existing database each op finds its object present and no-ops, and on a
+ fresh database it runs against brand-new tables with no traffic. The
+ per-operation lock policies are written for DDL acting on live tables,
+ so they would flag these ops for locks they never take. The name gate
+ keeps hand-written migrations that use the same helper ops on the
+ normal path, with its policies intact.
+ """
+ if not migration.operations or not _SQUASH_TAIL_NAME_RE.match(migration.name):
+ return False
+ for op in migration.operations:
+ cls = op.__class__
+ if cls.__module__ == _SQUASH_IDEMPOTENT_MODULE:
+ continue
+ if cls.__name__ in _PROBE_FIRST_HELPER_OPS and cls.__module__.startswith("posthog.migration_helpers"):
+ continue
+ # Django's own ValidateConstraint: Postgres skips a VALIDATE on an
+ # already-validated constraint, so it is a no-op in catch-up runs.
+ if cls.__name__ == "ValidateConstraint" and cls.__module__.startswith("django.contrib.postgres"):
+ continue
+ if cls.__name__ == "RunSQL" and cls.__module__.startswith("django.db.migrations"):
+ if self._runsql_is_existence_guarded(op):
+ continue
+ return False
+ return True
+
+ @staticmethod
+ def _runsql_is_existence_guarded(op) -> bool:
+ """True when the RunSQL consists only of pg_constraint-guarded DO blocks
+ and CREATE INDEX ... IF NOT EXISTS statements."""
+ sql = op.sql
+ if not isinstance(sql, str):
+ return False
+ remainder = re.sub(r"--[^\n]*", "", sql)
+ remainder = _GUARDED_DO_BLOCK_RE.sub("", remainder)
+ remainder = _GUARDED_CREATE_INDEX_RE.sub("", remainder)
+ return not remainder.strip(" \t\n;")
+
def _is_safe_on_new_table(self, op, risk: OperationRisk) -> bool:
"""Check if operation is safe because it's on a newly created table."""
if risk.type not in ["AddIndex", "AddConstraint"]:
diff --git a/posthog/management/migration_analysis/operations.py b/posthog/management/migration_analysis/operations.py
index 486049f7eace..d2a0863cb41e 100644
--- a/posthog/management/migration_analysis/operations.py
+++ b/posthog/management/migration_analysis/operations.py
@@ -418,6 +418,25 @@ Use RunSQL wrapped in SeparateDatabaseAndState:
)
+class ExtensionAnalyzer(OperationAnalyzer):
+ """Analyzer for `CREATE EXTENSION` operations. CREATE EXTENSION takes an
+ `AccessExclusiveLock` only on `pg_extension` itself (not on user tables),
+ is idempotent with `IF NOT EXISTS`, and Django's wrappers emit that form.
+ Safe under live workloads."""
+
+ default_score = 0
+
+ def analyze(self, op) -> OperationRisk:
+ op_type = op.__class__.__name__
+ ext_name = getattr(op, "name", None) or op_type.replace("Extension", "").lower()
+ return OperationRisk(
+ type=op_type,
+ score=0,
+ reason=f"Postgres extension creation is safe ({ext_name})",
+ details={"extension": ext_name},
+ )
+
+
class AddConstraintAnalyzer(OperationAnalyzer):
operation_type = "AddConstraint"
default_score = 3
@@ -474,6 +493,17 @@ class RunSQLAnalyzer(OperationAnalyzer):
sql_without_comments = re.sub(r"#[^\n]*", "", sql_without_comments) # Remove # comments
sql = sql_without_comments.upper()
+ # CREATE EXTENSION takes a lock only on pg_extension, not on user tables.
+ # Django's typed wrappers (TrigramExtension etc.) emit IF NOT EXISTS, so
+ # safe under live load.
+ if re.search(r"\bCREATE\s+EXTENSION\b", sql):
+ return OperationRisk(
+ type=self.operation_type,
+ score=0,
+ reason="CREATE EXTENSION is safe (locks pg_extension only, not user tables)",
+ details={"sql": sql},
+ )
+
# Check for CONCURRENTLY operations first (these are safe)
# This must come before DROP check to avoid flagging DROP INDEX CONCURRENTLY as dangerous
if "CONCURRENTLY" in sql:
diff --git a/posthog/management/migration_analysis/policies.py b/posthog/management/migration_analysis/policies.py
index 73d58a8a5051..df2448e868ec 100644
--- a/posthog/management/migration_analysis/policies.py
+++ b/posthog/management/migration_analysis/policies.py
@@ -83,6 +83,12 @@ class UUIDPrimaryKeyPolicy(MigrationPolicy):
field_type = field.__class__.__name__
if field_type in ["AutoField", "BigAutoField"]:
+ # Squashed migrations re-emit CreateModel for models that
+ # already exist with their historical integer PK. The policy
+ # is about *new* models, not pre-existing ones being squashed
+ # forward — skip if the model is already in the registry.
+ if self._model_exists_in_apps(op.name):
+ return []
return [
f"Model '{op.name}' uses integer ID ({field_type}). "
"PostHog requires UUID primary keys. "
@@ -91,6 +97,17 @@ class UUIDPrimaryKeyPolicy(MigrationPolicy):
return []
+ @staticmethod
+ def _model_exists_in_apps(model_name: str) -> bool:
+ """True iff a managed model with this name is already registered."""
+ from django.apps import apps
+
+ name_lower = model_name.lower()
+ for model in apps.get_models():
+ if model._meta.model_name == name_lower and model._meta.managed:
+ return True
+ return False
+
def check_migration(self, migration) -> list[str]:
"""Only enforce on PostHog-owned apps."""
if not is_posthog_app(migration.app_label, migration):
diff --git a/posthog/management/migration_analysis/test/test_risk_analyzer.py b/posthog/management/migration_analysis/test/test_risk_analyzer.py
index 2e03ddec1f2c..0d7e651298a0 100644
--- a/posthog/management/migration_analysis/test/test_risk_analyzer.py
+++ b/posthog/management/migration_analysis/test/test_risk_analyzer.py
@@ -2730,3 +2730,51 @@ class TestHotTableAlterPolicy:
)
risk = self._analyze([op])
assert not any("ACCESS EXCLUSIVE" in v for v in risk.policy_violations)
+
+
+class TestGuardedCatchupMigrations:
+ """Generated squash tail files (NNNN_squash_YYYY_MM_DD_*) whose every op is
+ existence-guarded skip per-operation lock scoring and policies."""
+
+ GUARDED_FK_SQL = (
+ "DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'my_fk') THEN\n"
+ 'ALTER TABLE "my_table" ADD CONSTRAINT "my_fk" FOREIGN KEY ("other_id") '
+ 'REFERENCES "other_table" ("id") NOT VALID;\nEND IF; END $$;'
+ )
+ GUARDED_INDEX_SQL = 'CREATE INDEX CONCURRENTLY IF NOT EXISTS "my_idx" ON "my_table" ("col"); -- trailing-marker'
+
+ def setup_method(self):
+ self.analyzer = RiskAnalyzer()
+
+ def _migration(self, name, operations):
+ migration_class = type("Migration", (migrations.Migration,), {"operations": operations})
+ return migration_class(name, "posthog")
+
+ def _guarded_ops(self):
+ from posthog.migration_helpers.squash_idempotent import AddFieldIfMissing, AddIndexIfMissing
+
+ return [
+ AddFieldIfMissing(model_name="mymodel", name="col", field=models.IntegerField(null=False)),
+ AddIndexIfMissing(model_name="mymodel", index=models.Index(fields=["col"], name="my_idx")),
+ migrations.RunSQL(sql=self.GUARDED_FK_SQL, reverse_sql=migrations.RunSQL.noop),
+ migrations.RunSQL(sql=self.GUARDED_INDEX_SQL, reverse_sql=migrations.RunSQL.noop),
+ ValidateConstraint(model_name="mymodel", name="my_fk"),
+ ]
+
+ def test_squash_tail_with_only_guarded_ops_is_safe(self):
+ migration = self._migration("0002_squash_2026_08_21_finalize_fks", self._guarded_ops())
+ risk = self.analyzer.analyze_migration(migration, "posthog.0002")
+ assert risk.level == RiskLevel.SAFE
+ assert any("catch-up" in message for message in risk.info_messages)
+
+ def test_squash_tail_with_an_unguarded_op_is_analyzed_normally(self):
+ ops = [*self._guarded_ops(), migrations.RunSQL(sql='CREATE INDEX "no_guard" ON "my_table" ("col");')]
+ migration = self._migration("0003_squash_2026_08_21_schema_addons", ops)
+ risk = self.analyzer.analyze_migration(migration, "posthog.0003")
+ assert not risk.info_messages
+ assert risk.level == RiskLevel.BLOCKED
+
+ def test_guarded_ops_without_the_squash_name_keep_normal_analysis(self):
+ migration = self._migration("0812_backfill_fk", self._guarded_ops())
+ risk = self.analyzer.analyze_migration(migration, "posthog.0812")
+ assert not any("catch-up" in message for message in risk.info_messages)
diff --git a/posthog/management/migration_profiling/__init__.py b/posthog/management/migration_profiling/__init__.py
new file mode 100644
index 000000000000..4234a3e79f38
--- /dev/null
+++ b/posthog/management/migration_profiling/__init__.py
@@ -0,0 +1,7 @@
+"""
+Migration profiling package for Django migrations.
+
+Captures per-operation and per-SQL-statement wall-clock time during a
+``migrate`` invocation. Emits a JSONL file consumed by the
+``analyze_migration_profile`` command.
+"""
diff --git a/posthog/management/migration_profiling/formatters.py b/posthog/management/migration_profiling/formatters.py
new file mode 100644
index 000000000000..e4afd0f79e6c
--- /dev/null
+++ b/posthog/management/migration_profiling/formatters.py
@@ -0,0 +1,913 @@
+"""Markdown report renderer for analyze_migration_profile.
+
+Reads the JSONL files written by ``profile_migrations`` (one per DB alias),
+plus optional py-spy raw files, and produces a single Markdown report with
+the sections enumerated in the design doc.
+"""
+
+from __future__ import annotations
+
+import json
+import statistics
+from collections import defaultdict
+from dataclasses import dataclass, field
+from pathlib import Path
+from typing import Any
+
+from posthog.management.migration_profiling.pyinstrument_parse import PyinstrumentAggregate
+from posthog.management.migration_profiling.spy import SpyAggregate
+
+TOP_OPS = 50
+TOP_MIGRATIONS = 30
+TOP_SQL = 30
+TOP_PY_FUNCS = 30
+P95 = 0.95
+
+
+@dataclass(frozen=False)
+class ProfileRun:
+ meta: dict[str, Any]
+ ops: list[dict[str, Any]]
+ # Per-migration apply summaries — wall-clock of Migration.apply, which
+ # captures state_forwards + project_state cloning + database_forwards.
+ # Keyed by (app_label, migration_name) → apply_duration_ms.
+ migration_summaries: dict[tuple[str, str], float] = field(default_factory=dict)
+ # Per-state-op timings (`_kind: state_op` records from the profiler). Kept
+ # separate from `ops` because they lack `sql_count`/`sql_statements` and
+ # would break the database_forwards-centric aggregators.
+ state_ops: list[dict[str, Any]] = field(default_factory=list)
+
+ @property
+ def database(self) -> str:
+ return self.meta.get("database", "<unknown>")
+
+
+def load_run(path: Path) -> ProfileRun:
+ meta: dict[str, Any] = {}
+ ops: list[dict[str, Any]] = []
+ state_ops: list[dict[str, Any]] = []
+ summaries: dict[tuple[str, str], float] = {}
+ with open(path) as fp:
+ for line_no, raw in enumerate(fp, start=1):
+ line = raw.strip()
+ if not line:
+ continue
+ try:
+ record = json.loads(line)
+ except json.JSONDecodeError as exc:
+ raise ValueError(f"{path}:{line_no} not valid JSON: {exc}") from exc
+ if "_meta" in record:
+ meta = record["_meta"]
+ elif record.get("_kind") == "migration_summary":
+ summaries[(record["app_label"], record["migration_name"])] = record["apply_duration_ms"]
+ elif record.get("_kind") == "state_op":
+ state_ops.append(record)
+ else:
+ ops.append(record)
+ return ProfileRun(meta=meta, ops=ops, migration_summaries=summaries, state_ops=state_ops)
+
+
+def _fmt_ms(ms: float) -> str:
+ if ms >= 1000:
+ return f"{ms / 1000:.2f}s"
+ if ms >= 1:
+ return f"{ms:.1f}ms"
+ return f"{ms:.3f}ms"
+
+
+def _percentile(values: list[float], q: float) -> float:
+ if not values:
+ return 0.0
+ if len(values) == 1:
+ return values[0]
+ try:
+ # statistics.quantiles is more robust than custom indexing.
+ return statistics.quantiles(values, n=100, method="inclusive")[int(q * 100) - 1]
+ except statistics.StatisticsError:
+ return max(values)
+
+
+def _is_state_only(op: dict[str, Any]) -> bool:
+ return bool(op.get("is_state_only"))
+
+
+def _has_children(
+ op: dict[str, Any], parent_index: tuple[str, str, int], children_index: dict[tuple[str, str, int], int]
+) -> bool:
+ return children_index.get(parent_index, 0) > 0
+
+
+# nosemgrep: tuple-return-prefer-dataclass -- tuples serve as graph and dict keys here
+def _build_children_index(ops: list[dict[str, Any]]) -> dict[tuple[str, str, int], int]:
+ """Count how many ops point at each ``(app, migration, op_index)`` as their parent."""
+ counts: dict[tuple[str, str, int], int] = defaultdict(int)
+ for op in ops:
+ parent = op.get("parent_op_index")
+ if parent is None:
+ continue
+ counts[(op["app_label"], op["migration_name"], parent)] += 1
+ return counts
+
+
+def _effective_ops(ops: list[dict[str, Any]]) -> list[dict[str, Any]]:
+ """Return ops we count in totals — exclude state-only ops, exclude
+ ``SeparateDatabaseAndState`` outers that have children (to avoid
+ double-counting their inner ops)."""
+ children = _build_children_index(ops)
+ out = []
+ for op in ops:
+ if _is_state_only(op):
+ continue
+ key = (op["app_label"], op["migration_name"], op.get("operation_index", -1))
+ if op["operation_type"] == "SeparateDatabaseAndState" and children.get(key, 0) > 0:
+ continue
+ out.append(op)
+ return out
+
+
+def _md_table(headers: list[str], rows: list[list[Any]]) -> str:
+ """Plain pipe-table renderer. Empty rows → ``_no entries_``."""
+ if not rows:
+ return "_no entries_\n"
+ lines = ["| " + " | ".join(headers) + " |", "| " + " | ".join("---" for _ in headers) + " |"]
+ for row in rows:
+ lines.append("| " + " | ".join(str(c) if c is not None else "" for c in row) + " |")
+ return "\n".join(lines) + "\n"
+
+
+def render_report(
+ runs: list[ProfileRun],
+ spy_results: dict[str, tuple[SpyAggregate, Path | None]],
+ pyinstrument_paths: dict[str, Path] | None = None,
+ pyinstrument_aggregates: dict[str, PyinstrumentAggregate] | None = None,
+) -> str:
+ """Build the full Markdown report."""
+ pyinstrument_paths = pyinstrument_paths or {}
+ pyinstrument_aggregates = pyinstrument_aggregates or {}
+
+ # ---- executive summary (computed up front) ----
+ all_ops_local = [op for run in runs for op in _effective_ops(run.ops)]
+ sql_total_ms = sum(op["duration_ms"] for op in all_ops_local)
+ apply_total_ms = sum(s for run in runs for s in run.migration_summaries.values())
+ pyinstrument_total_s = sum(a.total_duration_s for a in pyinstrument_aggregates.values())
+ # python overhead = apply_total - sql_total (positive = state-machine cost)
+ python_overhead_ms = max(apply_total_ms - sql_total_ms, 0.0) if apply_total_ms else 0.0
+ overhead_share = (python_overhead_ms / apply_total_ms * 100.0) if apply_total_ms else 0.0
+ total_migrations = sum(len(run.migration_summaries) for run in runs) or len(
+ {(op["app_label"], op["migration_name"]) for op in all_ops_local}
+ )
+ sdas_noop_count = sum(
+ 1 for op in all_ops_local if op["operation_type"] == "SeparateDatabaseAndState" and op["duration_ms"] < 1.0
+ )
+ parts: list[str] = []
+ parts.append("# Migration profile report\n")
+
+ # ---- executive summary ----
+ parts.append("\n## Executive summary\n\n")
+ parts.append(f"- **Migrations applied**: {total_migrations}\n")
+ parts.append(f"- **Operations recorded**: {len(all_ops_local)}\n")
+ if apply_total_ms:
+ parts.append(f"- **Total `Migration.apply` wall-clock**: {_fmt_ms(apply_total_ms)}\n")
+ if pyinstrument_total_s:
+ parts.append(f"- **Total Python runtime (pyinstrument)**: {pyinstrument_total_s:.1f}s\n")
+ parts.append(f"- **SQL / DB time (sum of `database_forwards`)**: {_fmt_ms(sql_total_ms)}\n")
+ if python_overhead_ms:
+ parts.append(
+ f"- **Python state-machine overhead**: {_fmt_ms(python_overhead_ms)} "
+ f"(**{overhead_share:.0f}%** of apply time)\n"
+ )
+ if sdas_noop_count:
+ parts.append(
+ f"- **`SeparateDatabaseAndState` no-op operations** (0 DB work, full Python tax): {sdas_noop_count}\n"
+ )
+ parts.append(
+ "\nThe headline cost is **Django's project-state machine**, not SQL. "
+ "Squashing matters because every migration triggers `state.clone()` "
+ "and `state.render()` against every loaded model — see the "
+ "`Python state machine` section below for the hottest functions, and "
+ "the `Squash candidates` section for migrations where the SQL cost is "
+ "negligible but the Python tax compounds.\n"
+ )
+
+ # ---- top opportunities (synthesized) ----
+ parts.append("\n## Top opportunities\n\n")
+ parts.append(_top_opportunities_section(runs, all_ops_local))
+
+ # ---- run metadata ----
+ parts.append("\n## Run metadata\n")
+ meta_rows = []
+ for run in runs:
+ meta_rows.append(
+ [
+ run.database,
+ run.meta.get("started_at", ""),
+ run.meta.get("django_version", ""),
+ (run.meta.get("git_sha") or "")[:12],
+ len(run.ops),
+ ]
+ )
+ parts.append(_md_table(["Database", "Started at", "Django", "Git SHA", "Ops captured"], meta_rows))
+
+ # ---- aggregates ----
+ all_ops = [op for run in runs for op in _effective_ops(run.ops)]
+ parts.append("\n## Aggregates\n")
+ parts.append("\n### By database\n")
+ parts.append(_md_table(*_agg_by_database(runs)))
+ parts.append("\n### By app\n")
+ parts.append(_md_table(*_agg_by_app(all_ops)))
+ parts.append("\n### By operation type\n")
+ parts.append(_md_table(*_agg_by_optype(all_ops)))
+
+ # ---- slowest ops ----
+ parts.append(f"\n## Top {TOP_OPS} slowest operations\n")
+ parts.append(_md_table(*_slowest_ops(all_ops)))
+
+ # ---- slowest migrations ----
+ summaries_by_db = {run.database: run.migration_summaries for run in runs}
+ parts.append(f"\n## Top {TOP_MIGRATIONS} slowest migrations\n")
+ parts.append(_md_table(*_slowest_migrations(all_ops, summaries_by_db)))
+
+ # ---- slowest SQL ----
+ parts.append(f"\n## Top {TOP_SQL} slowest SQL statements\n")
+ parts.append(_md_table(*_slowest_sql(all_ops)))
+
+ # ---- squash candidates ----
+ parts.append("\n## Squash candidates (fast & small)\n")
+ parts.append(_md_table(*_squash_candidates(all_ops)))
+
+ # ---- useless-on-fresh-DB RunPython ----
+ parts.append("\n## RunPython operations that are no-ops on a fresh DB\n")
+ parts.append(_useless_runpython_section(runs))
+
+ # ---- squash impact estimate ----
+ if any(run.migration_summaries for run in runs):
+ parts.append("\n## Squash impact estimate\n")
+ parts.append(_squash_impact_section(runs))
+
+ # ---- squash clusters (consecutive low-cost migrations) ----
+ if any(run.migration_summaries for run in runs):
+ parts.append("\n## Squash clusters (consecutive low-cost migrations)\n")
+ parts.append(_squash_clusters_section(runs))
+
+ # ---- do not touch ----
+ parts.append("\n## Heavy migrations (skip squashing)\n")
+ parts.append(_md_table(*_heavy_migrations(all_ops)))
+
+ # ---- pyinstrument ----
+ if pyinstrument_aggregates or pyinstrument_paths:
+ parts.append("\n## Python state machine (pyinstrument)\n")
+ for db, agg in pyinstrument_aggregates.items():
+ parts.append(f"\n### {db}\n")
+ parts.append(
+ f"\nTotal duration: {agg.total_duration_s:.1f}s"
+ + (f" ({agg.sample_count} samples)" if agg.sample_count else "")
+ + "\n"
+ )
+ if db in pyinstrument_paths:
+ parts.append(f"\nInteractive HTML: [`{pyinstrument_paths[db].name}`]({pyinstrument_paths[db].name})\n")
+ parts.append("\n#### Top by self time\n")
+ parts.append(
+ _md_table(
+ ["Function", "Self s", "% of total"],
+ [[fn, f"{t:.2f}", f"{p:.1f}%"] for fn, t, p in agg.by_self[:TOP_PY_FUNCS]],
+ )
+ )
+ parts.append("\n#### Top by cumulative time\n")
+ parts.append(
+ _md_table(
+ ["Function", "Cumulative s", "% of total"],
+ [[fn, f"{t:.2f}", f"{p:.1f}%"] for fn, t, p in agg.by_cumulative[:TOP_PY_FUNCS]],
+ )
+ )
+ # If we only have HTML paths (no JSON), still link them.
+ only_html = [db for db in pyinstrument_paths if db not in pyinstrument_aggregates]
+ if only_html:
+ parts.append("\n### HTML reports (no inline aggregate available)\n")
+ for db in only_html:
+ parts.append(f"- {db}: [`{pyinstrument_paths[db].name}`]({pyinstrument_paths[db].name})\n")
+
+ # ---- py-spy ----
+ if spy_results:
+ parts.append("\n## Python hot functions (py-spy)\n")
+ for db, (agg, svg_path) in spy_results.items():
+ parts.append(f"\n### {db}\n")
+ parts.append(f"Total samples: {agg.total_samples}\n")
+ if svg_path is not None:
+ parts.append(f"\nFlame graph: [`{svg_path.name}`]({svg_path.name})\n")
+ parts.append("\n#### Top by self time\n")
+ parts.append(
+ _md_table(
+ ["Function", "Samples", "% of total"],
+ [[fn, n, f"{p:.1f}%"] for fn, n, p in agg.by_self[:TOP_PY_FUNCS]],
+ )
+ )
+ parts.append("\n#### Top by cumulative time\n")
+ parts.append(
+ _md_table(
+ ["Function", "Samples", "% of total"],
+ [[fn, n, f"{p:.1f}%"] for fn, n, p in agg.by_cumulative[:TOP_PY_FUNCS]],
+ )
+ )
+
+ return "".join(parts)
+
+
+# ---------- aggregates ----------
+
+
+def _agg_by_database(runs: list[ProfileRun]) -> tuple[list[str], list[list[Any]]]:
+ rows = []
+ for run in runs:
+ effective = _effective_ops(run.ops)
+ total_ms = sum(op["duration_ms"] for op in effective)
+ durations = [op["duration_ms"] for op in effective if op["duration_ms"] > 0]
+ rows.append(
+ [
+ run.database,
+ len({(op["app_label"], op["migration_name"]) for op in effective}),
+ len(effective),
+ _fmt_ms(total_ms),
+ _fmt_ms(_percentile(durations, P95)),
+ ]
+ )
+ return ["Database", "Migrations", "Ops", "Total", "p95 op"], rows
+
+
+def _agg_by_app(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ by_app: dict[str, list[dict[str, Any]]] = defaultdict(list)
+ for op in ops:
+ by_app[op["app_label"]].append(op)
+ rows = []
+ for app, app_ops in sorted(by_app.items(), key=lambda x: -sum(o["duration_ms"] for o in x[1])):
+ total_ms = sum(op["duration_ms"] for op in app_ops)
+ rows.append(
+ [
+ app,
+ len({(op["app_label"], op["migration_name"]) for op in app_ops}),
+ len(app_ops),
+ _fmt_ms(total_ms),
+ ]
+ )
+ return ["App", "Migrations", "Ops", "Total"], rows
+
+
+def _agg_by_optype(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ by_type: dict[str, list[float]] = defaultdict(list)
+ for op in ops:
+ by_type[op["operation_type"]].append(op["duration_ms"])
+ rows = []
+ for op_type, durations in sorted(by_type.items(), key=lambda x: -sum(x[1])):
+ rows.append(
+ [
+ op_type,
+ len(durations),
+ _fmt_ms(sum(durations)),
+ _fmt_ms(statistics.median(durations) if durations else 0.0),
+ _fmt_ms(_percentile(durations, P95)),
+ _fmt_ms(max(durations) if durations else 0.0),
+ ]
+ )
+ return ["Op type", "Count", "Total", "p50", "p95", "Max"], rows
+
+
+# ---------- listings ----------
+
+
+def _slowest_ops(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ sorted_ops = sorted(ops, key=lambda o: -o["duration_ms"])[:TOP_OPS]
+ rows = []
+ for i, op in enumerate(sorted_ops, start=1):
+ rows.append(
+ [
+ i,
+ op["database"],
+ op["app_label"],
+ op["migration_name"],
+ op["operation_type"],
+ op["describe"][:80],
+ _fmt_ms(op["duration_ms"]),
+ op["sql_count"],
+ ]
+ )
+ return (
+ ["#", "DB", "App", "Migration", "Op", "Describe", "Duration", "SQL"],
+ rows,
+ )
+
+
+_ALWAYS_AVOIDABLE_OP_TYPES: frozenset[str] = frozenset(
+ {
+ "RunPython",
+ "RemoveField",
+ "RemoveIndex",
+ "RemoveIndexConcurrently",
+ "DeleteModel",
+ "RemoveConstraint",
+ "SeparateDatabaseAndState",
+ "AlterModelOptions",
+ "AlterModelManagers",
+ "AlterOrderWithRespectTo",
+ }
+)
+
+
+def _verdict_for_ops(key_ops: list[dict[str, Any]]) -> str:
+ """Heuristic per-migration verdict from the op-type mix.
+
+ A migration whose every op is in :data:`_ALWAYS_AVOIDABLE_OP_TYPES` is
+ "fully avoidable" — none of its operations build alive schema. Migrations
+ with at least one essential-shaped op are "essential" or "mixed". Doesn't
+ catch dead-target ops (those need the alive set) but it captures the
+ high-signal cases.
+ """
+ total = len(key_ops)
+ if total == 0:
+ return ""
+ avoidable_count = sum(
+ 1 for op in key_ops if op["operation_type"] in _ALWAYS_AVOIDABLE_OP_TYPES or op.get("is_state_only")
+ )
+ if avoidable_count == total:
+ return "fully avoidable"
+ if avoidable_count == 0:
+ return "essential"
+ return f"mixed ({avoidable_count}/{total} avoidable)"
+
+
+def _slowest_migrations(
+ ops: list[dict[str, Any]],
+ summaries_by_db: dict[str, dict[tuple[str, str], float]] | None = None,
+) -> tuple[list[str], list[list[Any]]]:
+ summaries_by_db = summaries_by_db or {}
+ by_mig: dict[tuple[str, str, str], list[dict[str, Any]]] = defaultdict(list)
+ for op in ops:
+ by_mig[(op["database"], op["app_label"], op["migration_name"])].append(op)
+
+ aggregates = []
+ for key, key_ops in by_mig.items():
+ db, app, name = key
+ sql_total = sum(op["duration_ms"] for op in key_ops)
+ apply_total = summaries_by_db.get(db, {}).get((app, name))
+ rank_total = apply_total if apply_total is not None else sql_total
+ heaviest = max(key_ops, key=lambda o: o["duration_ms"])
+ verdict = _verdict_for_ops(key_ops)
+ aggregates.append((key, rank_total, sql_total, apply_total, len(key_ops), heaviest, verdict))
+ aggregates.sort(key=lambda x: -x[1])
+ rows = []
+ for i, (key, _rank, sql_total, apply_total, n_ops, heaviest, verdict) in enumerate(
+ aggregates[:TOP_MIGRATIONS], start=1
+ ):
+ python_overhead = ""
+ apply_cell = ""
+ if apply_total is not None:
+ apply_cell = _fmt_ms(apply_total)
+ python_overhead = _fmt_ms(max(apply_total - sql_total, 0.0))
+ rows.append(
+ [
+ i,
+ key[0],
+ key[1],
+ key[2],
+ apply_cell or "—",
+ _fmt_ms(sql_total),
+ python_overhead or "—",
+ n_ops,
+ verdict or "—",
+ f"{heaviest['operation_type']} ({_fmt_ms(heaviest['duration_ms'])})",
+ ]
+ )
+ return (
+ ["#", "DB", "App", "Migration", "Apply total", "SQL", "Python overhead", "Ops", "Verdict", "Heaviest op"],
+ rows,
+ )
+
+
+def _slowest_sql(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ flattened: list[tuple[dict[str, Any], dict[str, Any]]] = []
+ for op in ops:
+ for stmt in op.get("sql_statements", []):
+ flattened.append((op, stmt))
+ flattened.sort(key=lambda x: -x[1]["duration_ms"])
+ rows = []
+ for i, (op, stmt) in enumerate(flattened[:TOP_SQL], start=1):
+ rows.append(
+ [
+ i,
+ op["app_label"] + "." + op["migration_name"],
+ op["operation_type"],
+ stmt["source"],
+ _fmt_ms(stmt["duration_ms"]),
+ stmt["sql"][:120].replace("|", "\\|"),
+ ]
+ )
+ return ["#", "Migration", "Op", "Source", "Duration", "SQL"], rows
+
+
+def _squash_candidates(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ by_mig: dict[tuple[str, str, str], list[dict[str, Any]]] = defaultdict(list)
+ for op in ops:
+ by_mig[(op["database"], op["app_label"], op["migration_name"])].append(op)
+ candidates = []
+ for key, key_ops in by_mig.items():
+ total = sum(op["duration_ms"] for op in key_ops)
+ if total < 100.0 and len(key_ops) <= 3:
+ candidates.append((key, total, key_ops))
+ candidates.sort(key=lambda x: x[1])
+ rows = []
+ for key, total, key_ops in candidates[:100]:
+ op_types = ", ".join(op["operation_type"] for op in key_ops)
+ rows.append([key[0], key[1], key[2], _fmt_ms(total), len(key_ops), op_types[:80]])
+ return ["DB", "App", "Migration", "Duration", "Ops", "Op types"], rows
+
+
+def _top_opportunities_section(
+ runs: list[ProfileRun],
+ all_ops: list[dict[str, Any]],
+) -> str:
+ """Synthesize a short prioritized action list from the rest of the report.
+
+ Each item is ranked by ``estimated_savings_ms × ease`` where ``ease`` is
+ a 1-3 heuristic (3 = safe after audit, 1 = needs design work). Items with
+ zero estimated savings are skipped. The intent is a punch list a human
+ can walk down: each row points to a concrete migration set or SQL pattern.
+ """
+ items: list[tuple[str, str, float, int]] = [] # (title, detail, savings_ms, ease)
+
+ # 1. RunPython no-ops on fresh DB (high impact, mechanical to remove)
+ inert_or_drained = [
+ op
+ for op in all_ops
+ if op["operation_type"] == "RunPython" and _classify_runpython(op) in ("inert", "read-only-empty")
+ ]
+ if inert_or_drained:
+ wasted = sum(op["duration_ms"] for op in inert_or_drained)
+ items.append(
+ (
+ f"Delete {len(inert_or_drained)} RunPython ops that do nothing on a fresh DB",
+ f"Saves {_fmt_ms(wasted)} of DB-side time + the Python state-rebuild around each one. "
+ "See _RunPython operations that are no-ops on a fresh DB_.",
+ wasted,
+ 3,
+ )
+ )
+
+ # 2. SeparateDatabaseAndState no-ops (zero DB work, full Python tax)
+ sdas_noops = [
+ op for op in all_ops if op["operation_type"] == "SeparateDatabaseAndState" and op["duration_ms"] < 1.0
+ ]
+ if sdas_noops:
+ # Their cost lives in Migration.apply (state-rebuild), not in op duration.
+ sdas_apply_total = 0.0
+ sdas_set = {(op["database"], op["app_label"], op["migration_name"]) for op in sdas_noops}
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ if (run.database, app, name) in sdas_set:
+ sdas_apply_total += apply_ms
+ items.append(
+ (
+ f"Squash {len(sdas_noops)} `SeparateDatabaseAndState` no-op migrations",
+ f"Each is 0ms of SQL but the Migration.apply wall-clock sums to {_fmt_ms(sdas_apply_total)} "
+ "in pure Django state-rebuild. Fold into their neighbours.",
+ sdas_apply_total,
+ 3,
+ )
+ )
+
+ # 3. Clusters of consecutive low-cost migrations
+ CLUSTER_MAX_MS = 200.0
+ MIN_CLUSTER_SIZE = 5
+ by_app: dict[tuple[str, str], list[tuple[str, float]]] = defaultdict(list)
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ by_app[(run.database, app)].append((name, apply_ms))
+ cluster_savings = 0.0
+ cluster_count = 0
+ for (_db, _app), pairs in by_app.items():
+ pairs.sort(key=lambda x: x[0])
+ i = 0
+ while i < len(pairs):
+ if pairs[i][1] >= CLUSTER_MAX_MS:
+ i += 1
+ continue
+ j = i
+ total = 0.0
+ while j < len(pairs) and pairs[j][1] < CLUSTER_MAX_MS:
+ total += pairs[j][1]
+ j += 1
+ count = j - i
+ if count >= MIN_CLUSTER_SIZE:
+ cluster_savings += total * (count - 1) / count
+ cluster_count += 1
+ i = j
+ if cluster_count:
+ items.append(
+ (
+ f"Batch-squash {cluster_count} clusters of consecutive low-cost migrations",
+ f"Each cluster of {MIN_CLUSTER_SIZE}+ migrations <{CLUSTER_MAX_MS:.0f}ms can fold into one. "
+ f"Estimated savings: {_fmt_ms(cluster_savings)}. See _Squash clusters_.",
+ cluster_savings,
+ 2,
+ )
+ )
+
+ # 4. Single heaviest RunPython that's actually doing useful work — worth
+ # rewriting as a one-shot SQL or moving out of migrations.
+ active_runpython = [
+ op for op in all_ops if op["operation_type"] == "RunPython" and _classify_runpython(op) == "active"
+ ]
+ active_runpython.sort(key=lambda op: -op["duration_ms"])
+ if active_runpython:
+ slowest = active_runpython[0]
+ callable_name = (slowest.get("metadata") or {}).get("callable", "?")
+ items.append(
+ (
+ f"Replace heaviest active RunPython: `{slowest['app_label']}.{slowest['migration_name']}`",
+ f"Callable `{callable_name}` took {_fmt_ms(slowest['duration_ms'])} of real DB work. "
+ "Rewrite as one-shot RunSQL or move outside migrations.",
+ slowest["duration_ms"],
+ 1,
+ )
+ )
+
+ # 5. Slowest single SQL statement — does it warrant a CONCURRENTLY / staged
+ # approach?
+ flat_sql: list[tuple[dict[str, Any], dict[str, Any]]] = []
+ for op in all_ops:
+ for stmt in op.get("sql_statements") or []:
+ flat_sql.append((op, stmt))
+ flat_sql.sort(key=lambda x: -x[1]["duration_ms"])
+ if flat_sql:
+ op, stmt = flat_sql[0]
+ if stmt["duration_ms"] > 50.0:
+ items.append(
+ (
+ f"Review slowest SQL in `{op['app_label']}.{op['migration_name']}`",
+ f"Single statement took {_fmt_ms(stmt['duration_ms'])} ({stmt['source']}). "
+ "On a populated production DB this likely scales with row count.",
+ stmt["duration_ms"],
+ 1,
+ )
+ )
+
+ if not items:
+ return "_no opportunities identified — congrats?_\n"
+
+ # Rank by impact × ease.
+ items.sort(key=lambda x: -(x[2] * x[3]))
+
+ out = "_Auto-synthesized punch list, ranked by impact × ease. Each row points at a section below._\n\n"
+ rows = []
+ ease_label = {3: "easy", 2: "medium", 1: "hard"}
+ for title, detail, savings, ease in items:
+ rows.append([title, _fmt_ms(savings), ease_label.get(ease, "?"), detail])
+ out += _md_table(["Opportunity", "Est. savings", "Effort", "Detail"], rows)
+ return out
+
+
+def _classify_runpython(op: dict[str, Any]) -> str:
+ """Classify a RunPython op by what SQL it actually executed.
+
+ Returns one of:
+
+ - ``"inert"``: ran no SQL at all. Pure no-op on fresh DB.
+ - ``"read-only-empty"``: ran only SELECT/SHOW statements, all fast. The
+ classic "look for rows to fix, find none, exit" pattern — useless on a
+ fresh DB.
+ - ``"read-only"``: ran only SELECT/SHOW but took noticeable time. Might
+ still be doing meaningful work via Python branching on the results.
+ - ``"active"``: ran at least one INSERT/UPDATE/DELETE/ALTER/CREATE/DROP/
+ TRUNCATE. Real work — keep.
+ """
+ statements = op.get("sql_statements") or []
+ sql_count = op.get("sql_count", len(statements))
+ if sql_count == 0:
+ return "inert"
+
+ has_mutation = False
+ total_ms = 0.0
+ for stmt in statements:
+ sql_text = (stmt.get("sql") or "").lstrip().upper()
+ total_ms += stmt.get("duration_ms", 0.0)
+ for kw in ("INSERT", "UPDATE", "DELETE", "ALTER ", "CREATE ", "DROP ", "TRUNCATE", "REINDEX"):
+ if sql_text.startswith(kw):
+ has_mutation = True
+ break
+ if has_mutation:
+ break
+
+ if has_mutation:
+ return "active"
+ if total_ms < 5.0:
+ return "read-only-empty"
+ return "read-only"
+
+
+def _useless_runpython_section(runs: list[ProfileRun]) -> str:
+ """List RunPython ops that did nothing observable to the DB.
+
+ These are the strongest squash candidates: their original purpose (backfill
+ data, fix corruption, migrate format) is meaningless on a fresh DB because
+ there's no pre-existing data to act on. They still cost Django state-rebuild
+ time on every fresh-DB run — pure deadweight.
+ """
+ categorized: dict[str, list[dict[str, Any]]] = {
+ "inert": [],
+ "read-only-empty": [],
+ "read-only": [],
+ "active": [],
+ }
+ for run in runs:
+ for op in _effective_ops(run.ops):
+ if op["operation_type"] != "RunPython":
+ continue
+ kind = _classify_runpython(op)
+ categorized[kind].append(op)
+
+ total_runpython = sum(len(v) for v in categorized.values())
+ if total_runpython == 0:
+ return "\n_no RunPython operations recorded_\n"
+
+ # Wasted time = duration of every RunPython that is NOT "active".
+ wasted_ms = sum(op["duration_ms"] for kind in ("inert", "read-only-empty") for op in categorized[kind])
+ candidate_count = len(categorized["inert"]) + len(categorized["read-only-empty"])
+
+ breakdown_rows = []
+ descriptions = {
+ "active": "ran INSERT/UPDATE/DELETE — real work",
+ "read-only-empty": "ran only SELECTs, all <5ms total — looked for rows, found none",
+ "read-only": "ran only SELECTs, ≥5ms total — may branch on results",
+ "inert": "ran no SQL at all — pure no-op",
+ }
+ for kind in ("active", "read-only", "read-only-empty", "inert"):
+ ops = categorized[kind]
+ total = sum(op["duration_ms"] for op in ops)
+ breakdown_rows.append([kind, len(ops), _fmt_ms(total), descriptions[kind]])
+
+ breakdown_md = _md_table(["Class", "Count", "Total DB time", "Interpretation"], breakdown_rows)
+
+ # Top candidates: inert + read-only-empty, sorted by duration desc to find
+ # the slowest no-ops. Slowness here is the python-state rebuild around
+ # nothing useful, so these are the highest-leverage to remove.
+ candidates = [(op, kind) for kind in ("inert", "read-only-empty") for op in categorized[kind]]
+ candidates.sort(key=lambda x: -x[0]["duration_ms"])
+
+ candidate_rows = []
+ for op, kind in candidates[:50]:
+ callable_name = (op.get("metadata") or {}).get("callable", "?")
+ candidate_rows.append(
+ [
+ op["database"],
+ op["app_label"],
+ op["migration_name"],
+ kind,
+ _fmt_ms(op["duration_ms"]),
+ op.get("sql_count", 0),
+ str(callable_name)[:60],
+ ]
+ )
+ candidate_md = _md_table(
+ ["DB", "App", "Migration", "Class", "Duration", "SQL count", "Callable"],
+ candidate_rows,
+ )
+
+ lead = (
+ f"\n**{candidate_count} of {total_runpython} RunPython operations** did nothing observable "
+ f"to the database on this fresh-DB run, costing **{_fmt_ms(wasted_ms)}** in pure overhead. "
+ "These are most likely 2-year-old data backfills / corruption fixes "
+ "whose target rows never existed on a fresh database. Safest squash "
+ "candidates after a per-migration audit.\n\n"
+ "**Breakdown:**\n\n"
+ )
+ return lead + breakdown_md + "\n**Slowest no-op RunPython ops (top 50):**\n\n" + candidate_md
+
+
+def _squash_clusters_section(runs: list[ProfileRun]) -> str:
+ """Find runs of consecutive low-cost migrations per (db, app).
+
+ Migrations sort lexically by name (Django's standard ``NNNN_description``
+ prefix keeps this in real order). A cluster is a maximal sequence of
+ migrations whose ``Migration.apply`` wall-clock is below
+ ``CLUSTER_MAX_MS``. Output the largest clusters by size and by total cost.
+ """
+ CLUSTER_MAX_MS = 200.0
+ MIN_CLUSTER_SIZE = 5
+
+ # Build per-(db, app) ordered list of (name, apply_ms).
+ by_app: dict[tuple[str, str], list[tuple[str, float]]] = defaultdict(list)
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ by_app[(run.database, app)].append((name, apply_ms))
+
+ clusters: list[tuple[str, str, str, str, int, float]] = []
+ # (db, app, first_name, last_name, count, total_apply_ms)
+ for (db, app), pairs in by_app.items():
+ pairs.sort(key=lambda x: x[0])
+ i = 0
+ while i < len(pairs):
+ if pairs[i][1] >= CLUSTER_MAX_MS:
+ i += 1
+ continue
+ j = i
+ total = 0.0
+ while j < len(pairs) and pairs[j][1] < CLUSTER_MAX_MS:
+ total += pairs[j][1]
+ j += 1
+ count = j - i
+ if count >= MIN_CLUSTER_SIZE:
+ clusters.append((db, app, pairs[i][0], pairs[j - 1][0], count, total))
+ i = j
+
+ if not clusters:
+ return f"\n_no clusters of {MIN_CLUSTER_SIZE}+ consecutive low-cost migrations found_\n"
+
+ clusters.sort(key=lambda c: -c[5])
+ rows = []
+ for db, app, first, last, count, total in clusters[:30]:
+ # Optimistic ceiling savings if collapsed into one migration.
+ saved = total * (count - 1) / count
+ rows.append([db, app, first, last, count, _fmt_ms(total), _fmt_ms(saved)])
+
+ lead = (
+ f"\nA cluster is a run of {MIN_CLUSTER_SIZE}+ consecutive migrations in the same app, each "
+ f"costing <{CLUSTER_MAX_MS:.0f}ms of `Migration.apply` wall-clock. These are the "
+ "concrete batched-squash candidates — fold the range into one migration.\n\n"
+ )
+ return lead + _md_table(
+ ["DB", "App", "From", "To", "Count", "Cluster total", "Est. savings if folded"],
+ rows,
+ )
+
+
+def _squash_impact_section(runs: list[ProfileRun]) -> str:
+ """Estimate the wall-clock you'd reclaim by folding low-SQL migrations.
+
+ For each migration with ``SQL ≤ 10 ms``, treat the entire ``Migration.apply``
+ cost as Python state-machine overhead — i.e. the work that would disappear
+ if the operations had been folded into a neighbour. Group by app and
+ aggregate. The per-migration overhead isn't a strict zero-after-squash
+ floor (the inner ops still need to render state once), but the lion's
+ share — the per-migration ``project_state.clone()`` + autodetector cost —
+ collapses to ``1`` when N migrations become 1.
+ """
+ LOW_SQL_THRESHOLD_MS = 10.0
+
+ # Group ops by (db, app, migration) so we can compute SQL totals quickly.
+ sql_by_mig: dict[tuple[str, str, str], float] = defaultdict(float)
+ for run in runs:
+ for op in _effective_ops(run.ops):
+ sql_by_mig[(run.database, op["app_label"], op["migration_name"])] += op["duration_ms"]
+
+ per_app: dict[str, dict[str, float]] = defaultdict(lambda: {"count": 0, "apply_ms": 0.0, "sql_ms": 0.0})
+ grand_total_apply_ms = 0.0
+ grand_total_count = 0
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ sql_ms = sql_by_mig.get((run.database, app, name), 0.0)
+ if sql_ms > LOW_SQL_THRESHOLD_MS:
+ continue
+ per_app[app]["count"] += 1
+ per_app[app]["apply_ms"] += apply_ms
+ per_app[app]["sql_ms"] += sql_ms
+ grand_total_apply_ms += apply_ms
+ grand_total_count += 1
+
+ if grand_total_count == 0:
+ return "\n_no low-SQL migrations found_\n"
+
+ rows: list[list[Any]] = []
+ for app, stats in sorted(per_app.items(), key=lambda x: -x[1]["apply_ms"]):
+ n = int(stats["count"])
+ apply_ms = stats["apply_ms"]
+ avg = apply_ms / n if n else 0.0
+ # Optimistic ceiling: collapse N low-SQL migrations into 1, you keep
+ # the SQL but pay state cost once — i.e. save (N-1)/N of the apply
+ # cost. Assumes uniform-ish per-migration cost, which is roughly
+ # true for the no-op cluster (state.clone dominates).
+ upper_savings_ms = apply_ms * (n - 1) / n if n > 0 else 0.0
+ rows.append([app, n, _fmt_ms(apply_ms), _fmt_ms(avg), _fmt_ms(upper_savings_ms)])
+
+ lead = (
+ f"\nFound **{grand_total_count} migrations** with ≤{LOW_SQL_THRESHOLD_MS:.0f}ms of SQL "
+ f"work, totalling {_fmt_ms(grand_total_apply_ms)} of `Migration.apply` time. "
+ "These are the ones where the cost is almost entirely Python — i.e. "
+ "the strongest squash ROI.\n\n"
+ "**Estimated savings** assumes folding N low-SQL migrations into 1 "
+ "trims `(N-1)/N` of their apply time (state-machine overhead collapses to one pass).\n\n"
+ )
+ return lead + _md_table(
+ ["App", "Low-SQL migrations", "Apply total", "Avg per migration", "Est. savings if folded"],
+ rows,
+ )
+
+
+def _heavy_migrations(ops: list[dict[str, Any]]) -> tuple[list[str], list[list[Any]]]:
+ by_mig: dict[tuple[str, str, str], float] = defaultdict(float)
+ for op in ops:
+ by_mig[(op["database"], op["app_label"], op["migration_name"])] += op["duration_ms"]
+ totals = sorted(by_mig.values(), reverse=True)
+ if not totals:
+ return ["DB", "App", "Migration", "Duration"], []
+ cutoff = _percentile(totals, P95)
+ heavy = [(key, total) for key, total in by_mig.items() if total >= cutoff]
+ heavy.sort(key=lambda x: -x[1])
+ rows = [[k[0], k[1], k[2], _fmt_ms(total)] for k, total in heavy]
+ return ["DB", "App", "Migration", "Duration"], rows
diff --git a/posthog/management/migration_profiling/html_formatter.py b/posthog/management/migration_profiling/html_formatter.py
new file mode 100644
index 000000000000..82e8b607052e
--- /dev/null
+++ b/posthog/management/migration_profiling/html_formatter.py
@@ -0,0 +1,848 @@
+"""Rich self-contained HTML report for the migration profile.
+
+Renders one HTML file with:
+- An executive-summary tile grid up top
+- A sticky table-of-contents nav
+- Sortable, scannable tables (click any header to sort)
+- Per-migration duration bars (Apply total split into SQL vs Python overhead)
+- A link to the interactive pyinstrument flame view
+- All CSS + JS inline — no external requests, no CDN dependency
+
+Companion to ``formatters.py`` (which writes plain Markdown). Both consume the
+same ``ProfileRun`` dataclass + pyinstrument aggregates.
+"""
+
+from __future__ import annotations
+
+import html as _html
+import statistics
+from collections import defaultdict
+from pathlib import Path
+from typing import Any
+
+from posthog.management.migration_profiling.formatters import (
+ P95,
+ ProfileRun,
+ _build_children_index,
+ _classify_runpython,
+ _effective_ops,
+ _fmt_ms,
+ _percentile,
+ _top_opportunities_section,
+)
+from posthog.management.migration_profiling.pyinstrument_parse import PyinstrumentAggregate
+
+TOP_OPS = 50
+TOP_MIGRATIONS = 30
+TOP_SQL = 30
+TOP_PY_FUNCS = 30
+LOW_SQL_THRESHOLD_MS = 10.0
+
+
+def _esc(s: Any) -> str:
+ return _html.escape(str(s)) if s is not None else ""
+
+
+def _bar_cell(value_ms: float, max_ms: float, label: str | None = None) -> str:
+ """A cell showing a horizontal bar + numeric label."""
+ pct = (value_ms / max_ms * 100.0) if max_ms > 0 else 0.0
+ label_txt = label if label is not None else _fmt_ms(value_ms)
+ return (
+ f'<td data-sort="{value_ms:.3f}" class="num">'
+ f'<div class="bar-cell"><div class="bar" style="width:{pct:.1f}%"></div>'
+ f'<span class="bar-label">{_esc(label_txt)}</span></div></td>'
+ )
+
+
+def _split_bar_cell(sql_ms: float, python_ms: float, max_ms: float, label: str) -> str:
+ total = sql_ms + python_ms
+ if max_ms <= 0:
+ max_ms = total or 1.0
+ sql_pct = sql_ms / max_ms * 100.0
+ py_pct = python_ms / max_ms * 100.0
+ return (
+ f'<td data-sort="{total:.3f}" class="num">'
+ f'<div class="bar-cell">'
+ f'<div class="bar bar-sql" style="width:{sql_pct:.1f}%" title="SQL {_fmt_ms(sql_ms)}"></div>'
+ f'<div class="bar bar-py" style="width:{py_pct:.1f}%" title="Python {_fmt_ms(python_ms)}"></div>'
+ f'<span class="bar-label">{_esc(label)}</span></div></td>'
+ )
+
+
+def _stat_tile(label: str, value: str, sub: str | None = None) -> str:
+ sub_html = f'<div class="tile-sub">{_esc(sub)}</div>' if sub else ""
+ return (
+ f'<div class="tile">'
+ f'<div class="tile-value">{_esc(value)}</div>'
+ f'<div class="tile-label">{_esc(label)}</div>'
+ f"{sub_html}</div>"
+ )
+
+
+_STYLE = """
+:root {
+ --bg: #fafafa;
+ --surface: #ffffff;
+ --border: #e6e6ea;
+ --text: #1f2328;
+ --muted: #6e7681;
+ --accent: #2563eb;
+ --accent-soft: #dbeafe;
+ --sql: #2563eb;
+ --py: #f97316;
+ --warn: #d97706;
+ --code-bg: #f3f4f6;
+}
+* { box-sizing: border-box; }
+html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
+ font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
+body { padding: 0 32px 80px; max-width: 1400px; margin: 0 auto; }
+h1 { font-size: 28px; margin: 32px 0 8px; }
+h2 { font-size: 20px; margin: 40px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
+h3 { font-size: 16px; margin: 24px 0 8px; color: var(--muted); }
+p { margin: 8px 0; }
+code { background: var(--code-bg); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }
+.muted { color: var(--muted); }
+
+nav.toc {
+ position: sticky; top: 0; z-index: 10;
+ background: rgba(250,250,250,0.95); backdrop-filter: blur(8px);
+ padding: 12px 0; margin: -8px -32px 24px; padding-left: 32px; padding-right: 32px;
+ border-bottom: 1px solid var(--border);
+ font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
+}
+nav.toc a { color: var(--muted); text-decoration: none; padding: 3px 8px; border-radius: 4px; }
+nav.toc a:hover { background: var(--accent-soft); color: var(--accent); }
+
+.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
+ gap: 12px; margin: 16px 0 32px; }
+.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
+ padding: 14px 16px; }
+.tile-value { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; }
+.tile-label { font-size: 12px; color: var(--muted); margin-top: 2px;
+ text-transform: uppercase; letter-spacing: 0.5px; }
+.tile-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
+.tile.warn .tile-value { color: var(--warn); }
+.tile.accent .tile-value { color: var(--accent); }
+
+.headline { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
+ padding: 16px 18px; border-radius: 6px; margin: 0 0 24px; }
+
+table { width: 100%; border-collapse: collapse; background: var(--surface);
+ border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 8px 0; }
+th, td { padding: 8px 10px; text-align: left; vertical-align: middle;
+ border-bottom: 1px solid var(--border); font-size: 13px; }
+th { background: #f5f5f7; font-weight: 600; cursor: pointer; user-select: none;
+ position: relative; white-space: nowrap; }
+th:hover { background: var(--accent-soft); color: var(--accent); }
+th.asc::after { content: " ↑"; opacity: 0.6; }
+th.desc::after { content: " ↓"; opacity: 0.6; }
+tr:last-child td { border-bottom: none; }
+tr:hover td { background: #fafbfc; }
+td.num { font-variant-numeric: tabular-nums; }
+
+.bar-cell { position: relative; display: flex; align-items: center; min-width: 140px; }
+.bar { height: 18px; background: var(--accent); border-radius: 3px;
+ opacity: 0.18; flex-shrink: 0; }
+.bar.bar-sql { background: var(--sql); opacity: 0.45; }
+.bar.bar-py { background: var(--py); opacity: 0.45; }
+.bar-label { margin-left: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
+.bar-row .bar:not(:first-child) { margin-left: 0; }
+
+.legend { display: inline-flex; gap: 12px; font-size: 12px; color: var(--muted); margin: 8px 0; }
+.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px;
+ margin-right: 4px; vertical-align: middle; }
+.legend .sw-sql { background: var(--sql); opacity: 0.6; }
+.legend .sw-py { background: var(--py); opacity: 0.6; }
+
+details { background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
+ padding: 6px 10px; margin: 4px 0; }
+details summary { cursor: pointer; color: var(--accent); font-size: 12px; }
+details pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word;
+ background: var(--code-bg); padding: 8px; border-radius: 3px; font-size: 12px; }
+
+.section-lead { color: var(--muted); margin: 4px 0 14px; max-width: 800px; }
+.section-lead strong { color: var(--text); }
+
+.pill { display: inline-block; padding: 2px 8px; border-radius: 10px;
+ font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
+.pill.ease-easy { background: #dcfce7; color: #166534; }
+.pill.ease-medium { background: #fef3c7; color: #92400e; }
+.pill.ease-hard { background: #fee2e2; color: #991b1b; }
+
+ border-left: 3px solid var(--warn); padding: 14px 18px; border-radius: 6px; margin: 0 0 18px; }
+ border: 1px solid var(--border); margin: 0 0 12px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); }
+ gap: 8px; margin: 0 0 24px; font-size: 13px; }
+ background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
+ font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
+.verdict-avoid { background: #fee2e2; color: #991b1b; }
+.verdict-essential { background: #dcfce7; color: #166534; }
+"""
+
+
+_SCRIPT = """
+(function() {
+ function sortKey(cell) {
+ const ds = cell.dataset.sort;
+ if (ds !== undefined) return ds;
+ return cell.textContent.trim();
+ }
+ function applySort(table, colIdx, asc) {
+ const tbody = table.tBodies[0];
+ if (!tbody) return;
+ const rows = Array.from(tbody.rows);
+ rows.sort((a, b) => {
+ const va = sortKey(a.cells[colIdx]);
+ const vb = sortKey(b.cells[colIdx]);
+ const na = parseFloat(va), nb = parseFloat(vb);
+ if (!isNaN(na) && !isNaN(nb)) return asc ? na - nb : nb - na;
+ return asc ? va.localeCompare(vb) : vb.localeCompare(va);
+ });
+ rows.forEach(r => tbody.appendChild(r));
+ }
+ document.querySelectorAll('table.sortable').forEach(table => {
+ const ths = table.tHead ? table.tHead.querySelectorAll('th') : [];
+ ths.forEach((th, idx) => {
+ th.addEventListener('click', () => {
+ const asc = !th.classList.contains('asc');
+ ths.forEach(x => { x.classList.remove('asc'); x.classList.remove('desc'); });
+ th.classList.add(asc ? 'asc' : 'desc');
+ applySort(table, idx, asc);
+ });
+ });
+ });
+})();
+"""
+
+
+def render_html_report(
+ runs: list[ProfileRun],
+ pyinstrument_paths: dict[str, Path] | None = None,
+ pyinstrument_aggregates: dict[str, PyinstrumentAggregate] | None = None,
+) -> str:
+ pyinstrument_paths = pyinstrument_paths or {}
+ pyinstrument_aggregates = pyinstrument_aggregates or {}
+
+ all_ops = [op for run in runs for op in _effective_ops(run.ops)]
+ sql_total_ms = sum(op["duration_ms"] for op in all_ops)
+ apply_total_ms = sum(s for run in runs for s in run.migration_summaries.values())
+ python_overhead_ms = max(apply_total_ms - sql_total_ms, 0.0) if apply_total_ms else 0.0
+ overhead_share = (python_overhead_ms / apply_total_ms * 100.0) if apply_total_ms else 0.0
+ pyinstrument_total_s = sum(a.total_duration_s for a in pyinstrument_aggregates.values())
+ total_migrations = sum(len(run.migration_summaries) for run in runs) or len(
+ {(op["app_label"], op["migration_name"]) for op in all_ops}
+ )
+ sdas_noop_count = sum(
+ 1 for op in all_ops if op["operation_type"] == "SeparateDatabaseAndState" and op["duration_ms"] < 1.0
+ )
+
+ body: list[str] = []
+
+ body.append('<nav class="toc">')
+ for section_id, label in [
+ ("summary", "Summary"),
+ ("opportunities", "Opportunities"),
+ ("aggregates", "Aggregates"),
+ ("slowest-migrations", "Slowest migrations"),
+ ("slowest-ops", "Slowest operations"),
+ ("slowest-sql", "Slowest SQL"),
+ ("useless-runpython", "RunPython no-ops"),
+ ("squash-impact", "Squash impact"),
+ ("squash-clusters", "Squash clusters"),
+ ("python", "Python"),
+ ]:
+ body.append(f'<a href="#{section_id}">{_esc(label)}</a>')
+ body.append("</nav>")
+
+ body.append("<h1>Migration profile report</h1>")
+
+ # Metadata line.
+ meta_bits = []
+ for run in runs:
+ m = run.meta
+ meta_bits.append(
+ f"{_esc(run.database)} · Django {_esc(m.get('django_version', '?'))} · "
+ f"git {_esc((m.get('git_sha') or '?')[:12])} · {_esc(m.get('started_at', ''))}"
+ )
+ body.append(f'<p class="muted">{" · ".join(meta_bits)}</p>')
+
+ # ---- summary ----
+ body.append('<h2 id="summary">Executive summary</h2>')
+ body.append('<div class="tiles">')
+ body.append(_stat_tile("Migrations", str(total_migrations)))
+ body.append(_stat_tile("Operations", str(len(all_ops))))
+ if apply_total_ms:
+ body.append(_stat_tile("Migration.apply wall-clock", _fmt_ms(apply_total_ms)))
+ if pyinstrument_total_s:
+ body.append(_stat_tile("Python runtime (pyinstrument)", f"{pyinstrument_total_s:.1f}s"))
+ body.append(_stat_tile("SQL / DB time", _fmt_ms(sql_total_ms), "sum of database_forwards"))
+ if python_overhead_ms:
+ body.append(
+ _stat_tile(
+ "Python overhead",
+ _fmt_ms(python_overhead_ms),
+ f"{overhead_share:.0f}% of apply time",
+ ).replace('class="tile"', 'class="tile warn"')
+ )
+ if sdas_noop_count:
+ body.append(
+ _stat_tile(
+ "SDAS no-op ops",
+ str(sdas_noop_count),
+ "0 DB work, full Python tax",
+ )
+ )
+ body.append("</div>")
+
+ body.append('<div class="headline">')
+ body.append(
+ "<strong>The headline cost is Django's project-state machine, not SQL.</strong> "
+ "Every migration triggers <code>state.clone()</code> + <code>state.render()</code> "
+ "against every loaded model. Squashing reduces this Python tax. The "
+ "<em>Slowest migrations</em> table below shows the SQL/Python split per migration "
+ "with stacked bars."
+ )
+ body.append("</div>")
+
+ body.append('<h2 id="opportunities">Top opportunities</h2>')
+ body.append(_html_top_opportunities(runs, all_ops))
+
+ # ---- aggregates ----
+ body.append('<h2 id="aggregates">Aggregates</h2>')
+ body.append("<h3>By database</h3>")
+ body.append(_html_table_by_database(runs))
+ body.append("<h3>By app</h3>")
+ body.append(_html_table_by_app(all_ops))
+ body.append("<h3>By operation type</h3>")
+ body.append(_html_table_by_optype(all_ops))
+
+ # ---- slowest migrations ----
+ body.append('<h2 id="slowest-migrations">Top 30 slowest migrations</h2>')
+ body.append(
+ '<div class="legend">'
+ '<span><span class="sw sw-sql"></span> SQL</span>'
+ '<span><span class="sw sw-py"></span> Python overhead</span>'
+ "</div>"
+ )
+ body.append(_html_table_slowest_migrations(runs))
+
+ # ---- slowest ops ----
+ body.append('<h2 id="slowest-ops">Top 50 slowest operations</h2>')
+ body.append(_html_table_slowest_ops(all_ops))
+
+ # ---- slowest SQL ----
+ body.append('<h2 id="slowest-sql">Top 30 slowest SQL statements</h2>')
+ body.append(_html_table_slowest_sql(all_ops))
+
+ # ---- useless RunPython ----
+ body.append('<h2 id="useless-runpython">RunPython no-ops on a fresh DB</h2>')
+ body.append(_html_useless_runpython(runs))
+
+ # ---- squash impact ----
+ body.append('<h2 id="squash-impact">Squash impact estimate</h2>')
+ body.append(_html_squash_impact(runs))
+
+ # ---- squash clusters ----
+ body.append('<h2 id="squash-clusters">Squash clusters (consecutive low-cost)</h2>')
+ body.append(_html_squash_clusters(runs))
+
+ # ---- python ----
+ if pyinstrument_aggregates or pyinstrument_paths:
+ body.append('<h2 id="python">Python state machine (pyinstrument)</h2>')
+ for db, agg in pyinstrument_aggregates.items():
+ body.append(f"<h3>{_esc(db)}</h3>")
+ body.append(
+ f'<p class="muted">Total duration: {agg.total_duration_s:.1f}s'
+ + (f" ({agg.sample_count} samples)" if agg.sample_count else "")
+ + "</p>"
+ )
+ if db in pyinstrument_paths:
+ body.append(
+ f"<p>Interactive flame view: "
+ f'<a href="{_esc(pyinstrument_paths[db].name)}">'
+ f"{_esc(pyinstrument_paths[db].name)}</a></p>"
+ )
+ body.append("<h3>Top by self time</h3>")
+ body.append(_html_table_py(agg.by_self, "Self s"))
+ body.append("<h3>Top by cumulative time</h3>")
+ body.append(_html_table_py(agg.by_cumulative, "Cumulative s"))
+
+ return _HEAD + _STYLE + _MID + "".join(body) + "<script>" + _SCRIPT + "</script>" + _TAIL
+
+
+_HEAD = """<!doctype html>
+<html lang="en"><head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<title>Migration profile report</title>
+<style>
+"""
+_MID = """</style>
+</head><body>
+"""
+_TAIL = "</body></html>"
+
+
+# ---------- table builders ----------
+
+
+def _html_table_by_database(runs: list[ProfileRun]) -> str:
+ rows_html = []
+ for run in runs:
+ effective = _effective_ops(run.ops)
+ total_ms = sum(op["duration_ms"] for op in effective)
+ durations = [op["duration_ms"] for op in effective if op["duration_ms"] > 0]
+ p95 = _percentile(durations, P95)
+ rows_html.append(
+ f"<tr>"
+ f"<td>{_esc(run.database)}</td>"
+ f"<td class='num' data-sort='{len(run.migration_summaries)}'>{len(run.migration_summaries) or '—'}</td>"
+ f"<td class='num' data-sort='{len(effective)}'>{len(effective)}</td>"
+ f"<td class='num' data-sort='{total_ms:.3f}'>{_fmt_ms(total_ms)}</td>"
+ f"<td class='num' data-sort='{p95:.3f}'>{_fmt_ms(p95)}</td>"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ "<th>Database</th><th>Migrations</th><th>Ops</th><th>Total SQL</th><th>p95 op</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_table_by_app(ops: list[dict[str, Any]]) -> str:
+ by_app: dict[str, list[dict[str, Any]]] = defaultdict(list)
+ for op in ops:
+ by_app[op["app_label"]].append(op)
+ items = sorted(by_app.items(), key=lambda x: -sum(o["duration_ms"] for o in x[1]))
+ max_total = max((sum(o["duration_ms"] for o in app_ops) for _, app_ops in items), default=1.0) or 1.0
+ rows_html = []
+ for app, app_ops in items:
+ total_ms = sum(op["duration_ms"] for op in app_ops)
+ rows_html.append(
+ f"<tr>"
+ f"<td>{_esc(app)}</td>"
+ f"<td class='num'>{len({(o['app_label'], o['migration_name']) for o in app_ops})}</td>"
+ f"<td class='num'>{len(app_ops)}</td>"
+ f"{_bar_cell(total_ms, max_total)}"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ "<th>App</th><th>Migrations</th><th>Ops</th><th>Total SQL</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_table_by_optype(ops: list[dict[str, Any]]) -> str:
+ by_type: dict[str, list[float]] = defaultdict(list)
+ for op in ops:
+ by_type[op["operation_type"]].append(op["duration_ms"])
+ items = sorted(by_type.items(), key=lambda x: -sum(x[1]))
+ rows_html = []
+ for op_type, durations in items:
+ rows_html.append(
+ f"<tr>"
+ f"<td>{_esc(op_type)}</td>"
+ f"<td class='num'>{len(durations)}</td>"
+ f"<td class='num' data-sort='{sum(durations):.3f}'>{_fmt_ms(sum(durations))}</td>"
+ f"<td class='num' data-sort='{(statistics.median(durations) if durations else 0.0):.3f}'>{_fmt_ms(statistics.median(durations) if durations else 0.0)}</td>"
+ f"<td class='num' data-sort='{_percentile(durations, P95):.3f}'>{_fmt_ms(_percentile(durations, P95))}</td>"
+ f"<td class='num' data-sort='{(max(durations) if durations else 0):.3f}'>{_fmt_ms(max(durations) if durations else 0.0)}</td>"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ "<th>Op type</th><th>Count</th><th>Total</th><th>p50</th><th>p95</th><th>Max</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_table_slowest_migrations(runs: list[ProfileRun]) -> str:
+ sql_by_mig: dict[tuple[str, str, str], float] = defaultdict(float)
+ ops_count_by_mig: dict[tuple[str, str, str], int] = defaultdict(int)
+ heaviest_by_mig: dict[tuple[str, str, str], dict[str, Any]] = {}
+ ops_by_mig: dict[tuple[str, str, str], list[dict[str, Any]]] = defaultdict(list)
+ for run in runs:
+ for op in _effective_ops(run.ops):
+ key = (run.database, op["app_label"], op["migration_name"])
+ sql_by_mig[key] += op["duration_ms"]
+ ops_count_by_mig[key] += 1
+ ops_by_mig[key].append(op)
+ existing = heaviest_by_mig.get(key)
+ if existing is None or op["duration_ms"] > existing["duration_ms"]:
+ heaviest_by_mig[key] = op
+
+ # nosemgrep: tuple-return-prefer-dataclass -- tuples serve as graph and dict keys here
+ def _verdict(key: tuple[str, str, str]) -> tuple[str, str]:
+ """Returns (label, pill_class)."""
+ from posthog.management.migration_profiling.formatters import _verdict_for_ops
+
+ label = _verdict_for_ops(ops_by_mig.get(key, []))
+ if label == "fully avoidable":
+ return (label, "ease-easy")
+ if label == "essential":
+ return (label, "ease-hard")
+ if label.startswith("mixed"):
+ return (label, "ease-medium")
+ return (label, "")
+
+ aggregates = []
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ key = (run.database, app, name)
+ sql_ms = sql_by_mig.get(key, 0.0)
+ python_ms = max(apply_ms - sql_ms, 0.0)
+ aggregates.append(
+ (key, apply_ms, sql_ms, python_ms, ops_count_by_mig.get(key, 0), heaviest_by_mig.get(key))
+ )
+ aggregates.sort(key=lambda x: -x[1])
+ max_apply = max((a[1] for a in aggregates), default=1.0) or 1.0
+
+ rows_html = []
+ for i, (key, apply_ms, sql_ms, python_ms, n_ops, heaviest) in enumerate(aggregates[:TOP_MIGRATIONS], start=1):
+ heaviest_lbl = f"{_esc(heaviest['operation_type'])} ({_fmt_ms(heaviest['duration_ms'])})" if heaviest else "—"
+ verdict_label, verdict_class = _verdict(key)
+ verdict_html = f"<span class='pill {verdict_class}'>{_esc(verdict_label)}</span>" if verdict_label else ""
+ rows_html.append(
+ f"<tr>"
+ f"<td class='num'>{i}</td>"
+ f"<td>{_esc(key[0])}</td>"
+ f"<td>{_esc(key[1])}</td>"
+ f"<td><code>{_esc(key[2])}</code></td>"
+ f"{_split_bar_cell(sql_ms, python_ms, max_apply, _fmt_ms(apply_ms))}"
+ f"<td class='num' data-sort='{sql_ms:.3f}'>{_fmt_ms(sql_ms)}</td>"
+ f"<td class='num' data-sort='{python_ms:.3f}'>{_fmt_ms(python_ms)}</td>"
+ f"<td class='num'>{n_ops}</td>"
+ f"<td>{verdict_html}</td>"
+ f"<td>{heaviest_lbl}</td>"
+ f"</tr>"
+ )
+ headers = (
+ "<th>#</th><th>DB</th><th>App</th><th>Migration</th><th>Apply (SQL+Py)</th>"
+ "<th>SQL</th><th>Python</th><th>Ops</th><th>Verdict</th><th>Heaviest op</th>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ + headers
+ + "</tr></thead><tbody>"
+ + "".join(rows_html)
+ + "</tbody></table>"
+ )
+
+
+def _html_table_slowest_ops(ops: list[dict[str, Any]]) -> str:
+ sorted_ops = sorted(ops, key=lambda o: -o["duration_ms"])[:TOP_OPS]
+ max_d = sorted_ops[0]["duration_ms"] if sorted_ops else 1.0
+ rows_html = []
+ for i, op in enumerate(sorted_ops, start=1):
+ rows_html.append(
+ f"<tr>"
+ f"<td class='num'>{i}</td>"
+ f"<td>{_esc(op['database'])}</td>"
+ f"<td>{_esc(op['app_label'])}</td>"
+ f"<td><code>{_esc(op['migration_name'])}</code></td>"
+ f"<td>{_esc(op['operation_type'])}</td>"
+ f"<td>{_esc(op['describe'][:80])}</td>"
+ f"{_bar_cell(op['duration_ms'], max_d)}"
+ f"<td class='num'>{op['sql_count']}</td>"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ "<th>#</th><th>DB</th><th>App</th><th>Migration</th><th>Op</th><th>Describe</th><th>Duration</th><th>SQL</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_table_slowest_sql(ops: list[dict[str, Any]]) -> str:
+ flat: list[tuple[dict[str, Any], dict[str, Any]]] = []
+ for op in ops:
+ for stmt in op.get("sql_statements", []):
+ flat.append((op, stmt))
+ flat.sort(key=lambda x: -x[1]["duration_ms"])
+ max_d = flat[0][1]["duration_ms"] if flat else 1.0
+ rows_html = []
+ for i, (op, stmt) in enumerate(flat[:TOP_SQL], start=1):
+ full_sql = stmt["sql"]
+ preview = full_sql[:140].replace("\n", " ")
+ rows_html.append(
+ f"<tr>"
+ f"<td class='num'>{i}</td>"
+ f"<td><code>{_esc(op['app_label'])}.{_esc(op['migration_name'])}</code></td>"
+ f"<td>{_esc(op['operation_type'])}</td>"
+ f"<td>{_esc(stmt['source'])}</td>"
+ f"{_bar_cell(stmt['duration_ms'], max_d)}"
+ f"<td><details><summary>{_esc(preview)}</summary><pre>{_esc(full_sql)}</pre></details></td>"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ "<th>#</th><th>Migration</th><th>Op</th><th>Source</th><th>Duration</th><th>SQL</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_top_opportunities(
+ runs: list[ProfileRun],
+ all_ops: list[dict[str, Any]],
+) -> str:
+ """Pull the synthesized opportunity items from the markdown helper but
+ render as a richer HTML table with effort-pill styling."""
+ md = _top_opportunities_section(runs, all_ops)
+ # If "no opportunities" — bail.
+ if "no opportunities" in md:
+ return '<p class="muted"><em>no opportunities identified</em></p>'
+
+ # The markdown table is `| Opportunity | Est. savings | Effort | Detail |`.
+ lines = md.splitlines()
+ rows = []
+ inside_table = False
+ for line in lines:
+ if line.startswith("| Opportunity"):
+ inside_table = True
+ continue
+ if inside_table and line.startswith("| ---"):
+ continue
+ if inside_table and line.startswith("|"):
+ cells = [c.strip() for c in line.strip().strip("|").split("|")]
+ if len(cells) == 4:
+ rows.append(cells)
+ elif inside_table:
+ break
+
+ ease_class = {"easy": "ease-easy", "medium": "ease-medium", "hard": "ease-hard"}
+ rows_html = []
+ for title, savings, effort, detail in rows:
+ rows_html.append(
+ f"<tr>"
+ f"<td><strong>{_esc(title)}</strong></td>"
+ f"<td class='num'>{_esc(savings)}</td>"
+ f"<td><span class='pill {ease_class.get(effort, '')}'>{_esc(effort)}</span></td>"
+ f"<td>{_esc(detail)}</td>"
+ f"</tr>"
+ )
+ lead = (
+ '<p class="section-lead"><em>Auto-synthesized punch list, ranked by '
+ "impact × ease. Walk down the rows top-to-bottom — each one links to "
+ "the section with the full per-migration breakdown.</em></p>"
+ )
+ return (
+ lead + '<table class="sortable"><thead><tr>'
+ "<th>Opportunity</th><th>Est. savings</th><th>Effort</th><th>Detail</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_useless_runpython(runs: list[ProfileRun]) -> str:
+ categorized: dict[str, list[dict[str, Any]]] = {
+ "inert": [],
+ "read-only-empty": [],
+ "read-only": [],
+ "active": [],
+ }
+ for run in runs:
+ for op in _effective_ops(run.ops):
+ if op["operation_type"] != "RunPython":
+ continue
+ categorized[_classify_runpython(op)].append(op)
+
+ total = sum(len(v) for v in categorized.values())
+ if total == 0:
+ return '<p class="muted"><em>no RunPython operations recorded</em></p>'
+ wasted = sum(op["duration_ms"] for k in ("inert", "read-only-empty") for op in categorized[k])
+ candidate_count = len(categorized["inert"]) + len(categorized["read-only-empty"])
+
+ descriptions = {
+ "active": "ran INSERT/UPDATE/DELETE — real work",
+ "read-only-empty": "ran only SELECTs, all &lt;5ms total — looked for rows, found none",
+ "read-only": "ran only SELECTs, ≥5ms total — may branch on results",
+ "inert": "ran no SQL at all — pure no-op",
+ }
+ breakdown_rows = []
+ max_total = (
+ max(
+ (sum(op["duration_ms"] for op in categorized[k]) for k in categorized),
+ default=1.0,
+ )
+ or 1.0
+ )
+ for kind in ("active", "read-only", "read-only-empty", "inert"):
+ ops = categorized[kind]
+ total_ms = sum(op["duration_ms"] for op in ops)
+ breakdown_rows.append(
+ f"<tr>"
+ f"<td><strong>{_esc(kind)}</strong></td>"
+ f"<td class='num'>{len(ops)}</td>"
+ f"{_bar_cell(total_ms, max_total)}"
+ f"<td class='muted'>{descriptions[kind]}</td>"
+ f"</tr>"
+ )
+
+ candidates = [(op, kind) for kind in ("inert", "read-only-empty") for op in categorized[kind]]
+ candidates.sort(key=lambda x: -x[0]["duration_ms"])
+
+ candidate_rows = []
+ max_d = candidates[0][0]["duration_ms"] if candidates else 1.0
+ for op, kind in candidates[:50]:
+ callable_name = (op.get("metadata") or {}).get("callable", "?")
+ candidate_rows.append(
+ f"<tr>"
+ f"<td>{_esc(op['database'])}</td>"
+ f"<td>{_esc(op['app_label'])}</td>"
+ f"<td><code>{_esc(op['migration_name'])}</code></td>"
+ f"<td>{_esc(kind)}</td>"
+ f"{_bar_cell(op['duration_ms'], max_d)}"
+ f"<td class='num'>{op.get('sql_count', 0)}</td>"
+ f"<td><code>{_esc(str(callable_name)[:60])}</code></td>"
+ f"</tr>"
+ )
+
+ lead = (
+ f'<p class="section-lead"><strong>{candidate_count} of {total} RunPython operations</strong> '
+ f"did nothing observable to the database on this fresh-DB run, costing <strong>"
+ f"{_fmt_ms(wasted)}</strong> in pure overhead. Most are likely "
+ "2-year-old backfills / corruption fixes whose target rows never existed on a fresh "
+ "database. Safest squash candidates after a per-migration audit.</p>"
+ )
+
+ breakdown_table = (
+ '<table class="sortable"><thead><tr>'
+ "<th>Class</th><th>Count</th><th>Total DB time</th><th>Interpretation</th>"
+ "</tr></thead><tbody>" + "".join(breakdown_rows) + "</tbody></table>"
+ )
+ candidate_table = (
+ '<table class="sortable"><thead><tr>'
+ "<th>DB</th><th>App</th><th>Migration</th><th>Class</th><th>Duration</th><th>SQL count</th><th>Callable</th>"
+ "</tr></thead><tbody>" + "".join(candidate_rows) + "</tbody></table>"
+ )
+
+ return lead + breakdown_table + "<h3>Slowest no-op RunPython ops (top 50)</h3>" + candidate_table
+
+
+def _html_squash_impact(runs: list[ProfileRun]) -> str:
+ sql_by_mig: dict[tuple[str, str, str], float] = defaultdict(float)
+ for run in runs:
+ for op in _effective_ops(run.ops):
+ sql_by_mig[(run.database, op["app_label"], op["migration_name"])] += op["duration_ms"]
+
+ per_app: dict[str, dict[str, float]] = defaultdict(lambda: {"count": 0, "apply_ms": 0.0})
+ grand_count = 0
+ grand_apply = 0.0
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ if sql_by_mig.get((run.database, app, name), 0.0) > LOW_SQL_THRESHOLD_MS:
+ continue
+ per_app[app]["count"] += 1
+ per_app[app]["apply_ms"] += apply_ms
+ grand_count += 1
+ grand_apply += apply_ms
+
+ if grand_count == 0:
+ return '<p class="muted"><em>no low-SQL migrations found</em></p>'
+
+ items = sorted(per_app.items(), key=lambda x: -x[1]["apply_ms"])
+ max_apply = items[0][1]["apply_ms"] if items else 1.0
+ rows_html = []
+ for app, stats in items:
+ n = int(stats["count"])
+ apply_ms = stats["apply_ms"]
+ avg = apply_ms / n if n else 0.0
+ saved = apply_ms * (n - 1) / n if n > 0 else 0.0
+ rows_html.append(
+ f"<tr>"
+ f"<td>{_esc(app)}</td>"
+ f"<td class='num'>{n}</td>"
+ f"{_bar_cell(apply_ms, max_apply)}"
+ f"<td class='num' data-sort='{avg:.3f}'>{_fmt_ms(avg)}</td>"
+ f"<td class='num' data-sort='{saved:.3f}'>{_fmt_ms(saved)}</td>"
+ f"</tr>"
+ )
+ lead = (
+ f'<p class="section-lead">Found <strong>{grand_count} migrations</strong> with '
+ f"≤{LOW_SQL_THRESHOLD_MS:.0f}ms of SQL work, totalling "
+ f"<strong>{_fmt_ms(grand_apply)}</strong> of <code>Migration.apply</code> time. "
+ "These are the strongest squash ROI — the cost is almost entirely Python.</p>"
+ )
+ return (
+ lead + '<table class="sortable"><thead><tr>'
+ "<th>App</th><th>Low-SQL migrations</th><th>Apply total</th><th>Avg per migration</th><th>Est. savings if folded</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_squash_clusters(runs: list[ProfileRun]) -> str:
+ CLUSTER_MAX_MS = 200.0
+ MIN_CLUSTER_SIZE = 5
+ by_app: dict[tuple[str, str], list[tuple[str, float]]] = defaultdict(list)
+ for run in runs:
+ for (app, name), apply_ms in run.migration_summaries.items():
+ by_app[(run.database, app)].append((name, apply_ms))
+ clusters = []
+ for (db, app), pairs in by_app.items():
+ pairs.sort(key=lambda x: x[0])
+ i = 0
+ while i < len(pairs):
+ if pairs[i][1] >= CLUSTER_MAX_MS:
+ i += 1
+ continue
+ j = i
+ total = 0.0
+ while j < len(pairs) and pairs[j][1] < CLUSTER_MAX_MS:
+ total += pairs[j][1]
+ j += 1
+ if j - i >= MIN_CLUSTER_SIZE:
+ clusters.append((db, app, pairs[i][0], pairs[j - 1][0], j - i, total))
+ i = j
+
+ if not clusters:
+ return f'<p class="muted"><em>no clusters of {MIN_CLUSTER_SIZE}+ low-cost migrations found</em></p>'
+
+ clusters.sort(key=lambda c: -c[5])
+ max_total = clusters[0][5]
+ rows_html = []
+ for db, app, first, last, count, total in clusters[:30]:
+ saved = total * (count - 1) / count
+ rows_html.append(
+ f"<tr>"
+ f"<td>{_esc(db)}</td>"
+ f"<td>{_esc(app)}</td>"
+ f"<td><code>{_esc(first)}</code></td>"
+ f"<td><code>{_esc(last)}</code></td>"
+ f"<td class='num'>{count}</td>"
+ f"{_bar_cell(total, max_total)}"
+ f"<td class='num' data-sort='{saved:.3f}'>{_fmt_ms(saved)}</td>"
+ f"</tr>"
+ )
+ lead = (
+ f'<p class="section-lead">Runs of {MIN_CLUSTER_SIZE}+ consecutive migrations '
+ f"in the same app, each &lt;{CLUSTER_MAX_MS:.0f}ms of <code>Migration.apply</code>. "
+ "These are concrete batched-squash targets — fold the range into one.</p>"
+ )
+ return (
+ lead + '<table class="sortable"><thead><tr>'
+ "<th>DB</th><th>App</th><th>From</th><th>To</th><th>Count</th><th>Cluster total</th><th>Est. savings if folded</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+def _html_table_py(rows: list[tuple[str, float, float]], time_col: str) -> str:
+ max_v = rows[0][1] if rows else 1.0
+ rows_html = []
+ for fn, t, p in rows[:TOP_PY_FUNCS]:
+ rows_html.append(
+ f"<tr>"
+ f"<td><code>{_esc(fn)}</code></td>"
+ f"{_bar_cell(t, max_v, f'{t:.2f}s')}"
+ f"<td class='num' data-sort='{p:.2f}'>{p:.1f}%</td>"
+ f"</tr>"
+ )
+ return (
+ '<table class="sortable"><thead><tr>'
+ f"<th>Function</th><th>{_esc(time_col)}</th><th>% of total</th>"
+ "</tr></thead><tbody>" + "".join(rows_html) + "</tbody></table>"
+ )
+
+
+# Silence unused-import linters: _build_children_index is re-exported for tests.
+__all__ = ["render_html_report"]
+_ = _build_children_index
diff --git a/posthog/management/migration_profiling/metadata.py b/posthog/management/migration_profiling/metadata.py
new file mode 100644
index 000000000000..c28fd99fee06
--- /dev/null
+++ b/posthog/management/migration_profiling/metadata.py
@@ -0,0 +1,170 @@
+"""Per-operation metadata extractors for the profiler.
+
+Each Django migration operation subclass exposes different attributes — we
+pull out the ones useful for grouping in the report (model name, field name,
+index name, RunSQL preview, RunPython callable). Keyed by class name to
+avoid hard-importing every Django operation module at import time.
+
+Anything not in EXTRACTORS still gets an OpRecord; the metadata dict will
+just be empty and the analyze command falls back to ``describe``.
+"""
+
+from __future__ import annotations
+
+from collections.abc import Callable
+from typing import Any
+
+# Limit on inline RunSQL snippets in the metadata dict. Full SQL still lands
+# in sql_statements when it executes against the DB.
+_RUN_SQL_PREVIEW_CHARS = 200
+
+
+def _create_model(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _delete_model(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _rename_model(op: Any) -> dict[str, Any]:
+ return {"model_name": op.old_name, "new_name": op.new_name}
+
+
+def _alter_model_table(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name, "table": op.table}
+
+
+def _add_field(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "field_name": op.name}
+
+
+def _remove_field(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "field_name": op.name}
+
+
+def _alter_field(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "field_name": op.name}
+
+
+def _rename_field(op: Any) -> dict[str, Any]:
+ return {
+ "model_name": op.model_name,
+ "old_name": op.old_name,
+ "new_name": op.new_name,
+ }
+
+
+def _add_index(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "index_name": getattr(op.index, "name", None)}
+
+
+def _remove_index(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "index_name": op.name}
+
+
+def _rename_index(op: Any) -> dict[str, Any]:
+ return {
+ "model_name": op.model_name,
+ "old_name": op.old_name,
+ "new_name": op.new_name,
+ }
+
+
+def _add_constraint(op: Any) -> dict[str, Any]:
+ return {
+ "model_name": op.model_name,
+ "constraint_name": getattr(op.constraint, "name", None),
+ }
+
+
+def _remove_constraint(op: Any) -> dict[str, Any]:
+ return {"model_name": op.model_name, "constraint_name": op.name}
+
+
+def _alter_unique_together(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _alter_index_together(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _alter_model_options(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _alter_model_managers(op: Any) -> dict[str, Any]:
+ return {"model_name": op.name}
+
+
+def _run_sql(op: Any) -> dict[str, Any]:
+ raw = op.sql
+ if isinstance(raw, list):
+ preview = "; ".join(str(item)[:_RUN_SQL_PREVIEW_CHARS] for item in raw[:3])
+ else:
+ preview = str(raw)[:_RUN_SQL_PREVIEW_CHARS] if raw else None
+ return {"sql_preview": preview}
+
+
+def _run_python(op: Any) -> dict[str, Any]:
+ callable_obj = op.code
+ return {
+ "is_runpython": True,
+ "callable": getattr(callable_obj, "__qualname__", repr(callable_obj)),
+ }
+
+
+def _separate_db_and_state(op: Any) -> dict[str, Any]:
+ return {
+ "wraps_database_ops": [c.__class__.__name__ for c in (op.database_operations or [])],
+ "wraps_state_ops": [c.__class__.__name__ for c in (op.state_operations or [])],
+ }
+
+
+EXTRACTORS: dict[str, Callable[[Any], dict[str, Any]]] = {
+ "CreateModel": _create_model,
+ "DeleteModel": _delete_model,
+ "RenameModel": _rename_model,
+ "AlterModelTable": _alter_model_table,
+ "AddField": _add_field,
+ "RemoveField": _remove_field,
+ "AlterField": _alter_field,
+ "RenameField": _rename_field,
+ "AddIndex": _add_index,
+ "AddIndexConcurrently": _add_index,
+ "RemoveIndex": _remove_index,
+ "RemoveIndexConcurrently": _remove_index,
+ "RenameIndex": _rename_index,
+ "AddConstraint": _add_constraint,
+ "RemoveConstraint": _remove_constraint,
+ "AlterUniqueTogether": _alter_unique_together,
+ "AlterIndexTogether": _alter_index_together,
+ "AlterModelOptions": _alter_model_options,
+ "AlterModelManagers": _alter_model_managers,
+ "RunSQL": _run_sql,
+ "RunPython": _run_python,
+ "SeparateDatabaseAndState": _separate_db_and_state,
+}
+
+
+# Operations whose database_forwards is a no-op (state-only). Recorded with
+# is_state_only=True so the analyze command can filter them out of totals.
+STATE_ONLY_OPERATIONS: frozenset[str] = frozenset(
+ {
+ "AlterModelOptions",
+ "AlterModelManagers",
+ "AlterOrderWithRespectTo",
+ }
+)
+
+
+def extract(op: Any) -> dict[str, Any]:
+ """Return the structured metadata dict for ``op``, or ``{}`` if no extractor."""
+ extractor = EXTRACTORS.get(op.__class__.__name__)
+ if extractor is None:
+ return {}
+ try:
+ return extractor(op)
+ except Exception as exc:
+ return {"_extract_error": f"{exc.__class__.__name__}: {exc}"}
diff --git a/posthog/management/migration_profiling/models.py b/posthog/management/migration_profiling/models.py
new file mode 100644
index 000000000000..85c21859c7f9
--- /dev/null
+++ b/posthog/management/migration_profiling/models.py
@@ -0,0 +1,57 @@
+"""Data models for migration operation profiling.
+
+The JSONL written by ``profile_migrations`` is the source of truth for the
+analyze command — the dataclasses below define its on-disk schema. Bump
+``SCHEMA_VERSION`` when changing field names or semantics so the analyze
+command can warn on old captures instead of silently misreporting.
+"""
+
+from __future__ import annotations
+
+from dataclasses import asdict, dataclass, field
+from typing import Any, Literal
+
+SCHEMA_VERSION = 1
+SQL_TRUNCATION_LIMIT = 4096
+
+
+@dataclass(frozen=False)
+class SqlRecord:
+ sql: str
+ sql_truncated: bool
+ params_repr: str | None
+ duration_ms: float
+ source: Literal["schema_editor", "cursor"]
+ ts_offset_ms: float
+
+ def to_dict(self) -> dict[str, Any]:
+ return asdict(self)
+
+
+@dataclass(frozen=False)
+class OpRecord:
+ database: str
+ app_label: str
+ migration_name: str
+ operation_index: int
+ operation_type: str
+ describe: str
+ started_at: str
+ duration_ms: float = 0.0
+ sql_count: int = 0
+ sql_total_ms: float = 0.0
+ sql_truncated_count: int = 0
+ is_runpython: bool = False
+ is_state_only: bool = False
+ parent_op_index: int | None = None
+ error: str | None = None
+ sql_statements: list[SqlRecord] = field(default_factory=list)
+ # Per-op-type structured metadata (model_name, field_name, index_name, ...).
+ # Kept in a sub-dict so we don't bloat the top-level schema with
+ # per-op-type optional columns; analyze reads what's there.
+ metadata: dict[str, Any] = field(default_factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ out = asdict(self)
+ out["sql_statements"] = [s.to_dict() if isinstance(s, SqlRecord) else s for s in self.sql_statements]
+ return out
diff --git a/posthog/management/migration_profiling/profiler.py b/posthog/management/migration_profiling/profiler.py
new file mode 100644
index 000000000000..e9de73e38e0f
--- /dev/null
+++ b/posthog/management/migration_profiling/profiler.py
@@ -0,0 +1,550 @@
+"""``profile_migrations`` contextmanager — per-op + per-SQL profiling.
+
+The contextmanager monkeypatches three things for the lifetime of one
+``migrate`` invocation and restores them on exit:
+
+1. ``database_forwards`` on every concrete ``Operation`` subclass. Builds an
+ ``OpRecord`` per op, pushes a frame onto the contextvar stack, times the
+ call, and serializes the record on completion.
+2. ``BaseDatabaseSchemaEditor.execute`` — captures every DDL statement emitted
+ by ``CreateModel`` / ``AddIndex`` / ``RunSQL`` / etc. against the current
+ op frame.
+3. ``connection.execute_wrappers`` on every alias — captures cursor-level SQL
+ from ``RunPython`` bodies (these bypass the schema editor entirely).
+ The cursor wrapper checks ``frame.in_schema_editor_call`` to avoid
+ double-counting DDL the schema editor already logged.
+
+Frame attribution uses a ``ContextVar`` because Django's migrate path is sync
+but executes inside ``atomic()`` blocks that may copy the context — contextvars
+propagate cleanly across that.
+"""
+
+from __future__ import annotations
+
+import sys
+import json
+import time
+import socket
+import subprocess
+from collections.abc import Iterator
+from contextlib import contextmanager
+from contextvars import ContextVar
+from dataclasses import dataclass, field
+from datetime import UTC, datetime
+from pathlib import Path
+from typing import IO, Any, cast
+
+import django
+from django.conf import settings
+from django.db import connections
+from django.db.backends.base.schema import BaseDatabaseSchemaEditor
+from django.db.migrations.migration import Migration
+from django.db.migrations.operations.base import Operation
+
+from posthog.management.migration_profiling.metadata import STATE_ONLY_OPERATIONS, extract
+from posthog.management.migration_profiling.models import SCHEMA_VERSION, SQL_TRUNCATION_LIMIT, OpRecord, SqlRecord
+
+MAX_SQL_PER_OP = 1000
+
+
+@dataclass(frozen=False)
+class _Frame:
+ record: OpRecord
+ monotonic_start: float
+ in_schema_editor_call: bool = False
+ sql_emitted: int = 0
+ # Track which connection this op runs against so cross-DB cursor traffic
+ # via routers can be excluded from attribution.
+ target_connection_alias: str | None = None
+
+
+@dataclass(frozen=False)
+class _ProfilerState:
+ fp: IO[str]
+ database: str
+ truncation_limit: int | None
+ bootstrap_sql: list[SqlRecord] = field(default_factory=list)
+ bootstrap_started_at: str = ""
+ bootstrap_monotonic_start: float = 0.0
+ finalized_bootstrap: bool = False
+ # Filled by the Migration.apply wrapper before each op runs.
+ current_migration_app: str = "<unknown>"
+ current_migration_name: str = "<unknown>"
+ current_op_index: int = 0
+
+
+_stack_var: ContextVar[list[_Frame]] = ContextVar("migration_profiler_stack")
+_state_var: ContextVar[_ProfilerState | None] = ContextVar("migration_profiler_state", default=None)
+
+
+# ---------- helpers ----------
+
+
+def _get_stack() -> list[_Frame]:
+ try:
+ return _stack_var.get()
+ except LookupError:
+ stack: list[_Frame] = []
+ _stack_var.set(stack)
+ return stack
+
+
+def _current_frame() -> _Frame | None:
+ try:
+ stack = _stack_var.get()
+ except LookupError:
+ return None
+ return stack[-1] if stack else None
+
+
+def _git_sha() -> str | None:
+ try:
+ result = subprocess.run(
+ ["git", "rev-parse", "HEAD"],
+ check=False,
+ capture_output=True,
+ text=True,
+ timeout=2,
+ )
+ if result.returncode == 0:
+ return result.stdout.strip()
+ except (FileNotFoundError, subprocess.TimeoutExpired):
+ return None
+ return None
+
+
+def _safe_repr(params: Any) -> str | None:
+ # Deliberately never serializes the bound values: against a data-bearing
+ # database a RunPython's queries bind real row contents, and the JSONL
+ # profile gets shared around. Shape and arity are enough for analysis.
+ if params is None:
+ return None
+ try:
+ count = len(params)
+ except TypeError:
+ return "<params: uncounted>"
+ return f"<params: {count}>"
+
+
+def _truncate_sql(sql: str, limit: int | None) -> tuple[str, bool]:
+ if limit is None or len(sql) <= limit:
+ return sql, False
+ return sql[:limit] + "...(truncated)", True
+
+
+def _write_record(state: _ProfilerState, record: OpRecord) -> None:
+ state.fp.write(json.dumps(record.to_dict(), default=str))
+ state.fp.write("\n")
+
+
+# ---------- bootstrap handling ----------
+
+
+def _ensure_bootstrap_open(state: _ProfilerState) -> None:
+ """First time a SQL statement fires before any op frame, start a synthetic
+ ``__bootstrap__`` frame so DDL like ``CREATE TABLE django_migrations``
+ (issued by ``MigrationRecorder.ensure_schema``) is still attributed."""
+ if state.bootstrap_started_at:
+ return
+ state.bootstrap_started_at = datetime.now(UTC).isoformat()
+ state.bootstrap_monotonic_start = time.monotonic()
+
+
+def _finalize_bootstrap_if_needed(state: _ProfilerState) -> None:
+ if state.finalized_bootstrap or not state.bootstrap_started_at:
+ state.finalized_bootstrap = True
+ return
+ state.finalized_bootstrap = True
+ duration_ms = (time.monotonic() - state.bootstrap_monotonic_start) * 1000.0
+ sql_total_ms = sum(s.duration_ms for s in state.bootstrap_sql)
+ record = OpRecord(
+ database=state.database,
+ app_label="__bootstrap__",
+ migration_name="__bootstrap__",
+ operation_index=-1,
+ operation_type="__bootstrap__",
+ describe="Pre-migration bootstrap DDL (django_migrations table, etc.)",
+ started_at=state.bootstrap_started_at,
+ duration_ms=duration_ms,
+ sql_count=len(state.bootstrap_sql),
+ sql_total_ms=sql_total_ms,
+ sql_statements=state.bootstrap_sql,
+ )
+ _write_record(state, record)
+
+
+# ---------- op patching ----------
+
+
+def _iter_operation_subclasses() -> Iterator[type[Operation]]:
+ """Yield every loaded concrete subclass of ``Operation``."""
+ seen: set[type[Operation]] = set()
+
+ def walk(cls: type[Operation]) -> Iterator[type[Operation]]:
+ for sub in cls.__subclasses__():
+ if sub in seen:
+ continue
+ seen.add(sub)
+ yield sub
+ yield from walk(sub)
+
+ yield from walk(Operation)
+
+
+def _make_op_wrapper(original_method: Any, state: _ProfilerState) -> Any:
+ def wrapped(
+ op_self: Operation,
+ app_label: str,
+ schema_editor: Any,
+ from_state: Any,
+ to_state: Any,
+ ) -> Any:
+ op_type = op_self.__class__.__name__
+ try:
+ target_alias = schema_editor.connection.alias
+ except AttributeError:
+ target_alias = state.database
+
+ stack = _get_stack()
+ parent_index = stack[-1].record.operation_index if stack else None
+ op_index = state.current_op_index
+ # Only advance the migration-level counter for top-level ops, not nested
+ # ones inside SeparateDatabaseAndState. Those keep the parent's index
+ # relationship via parent_op_index.
+ if not stack:
+ state.current_op_index += 1
+
+ record = OpRecord(
+ database=target_alias,
+ app_label=app_label,
+ migration_name=state.current_migration_name,
+ operation_index=op_index,
+ operation_type=op_type,
+ describe=_safe_describe(op_self),
+ started_at=datetime.now(UTC).isoformat(),
+ is_runpython=op_type == "RunPython",
+ is_state_only=op_type in STATE_ONLY_OPERATIONS,
+ parent_op_index=parent_index,
+ metadata=extract(op_self),
+ )
+ frame = _Frame(record=record, monotonic_start=time.monotonic(), target_connection_alias=target_alias)
+ stack.append(frame)
+
+ # First op fires → bootstrap window is closing.
+ if not state.finalized_bootstrap:
+ _finalize_bootstrap_if_needed(state)
+
+ try:
+ return original_method(op_self, app_label, schema_editor, from_state, to_state)
+ except Exception as exc:
+ record.error = f"{exc.__class__.__name__}: {exc}"
+ raise
+ finally:
+ record.duration_ms = (time.monotonic() - frame.monotonic_start) * 1000.0
+ record.sql_count = frame.sql_emitted
+ record.sql_total_ms = sum(s.duration_ms for s in record.sql_statements)
+ record.sql_truncated_count = max(0, frame.sql_emitted - len(record.sql_statements))
+ stack.pop()
+ _write_record(state, record)
+
+ return wrapped
+
+
+def _safe_describe(op: Operation) -> str:
+ try:
+ return op.describe()
+ except Exception as exc:
+ return f"<describe failed: {exc.__class__.__name__}>"
+
+
+def _patch_migration_apply(state: _ProfilerState) -> Any:
+ """Wrap ``Migration.apply`` so we know which migration's operations are
+ running AND so we can record the migration's total wall-clock (which
+ includes ``state_forwards``, ``project_state.clone()``, autodetector cost
+ — i.e. the Python-side overhead that ``database_forwards`` timings miss)."""
+ original = Migration.apply
+
+ def wrapped(self: Migration, *args: Any, **kwargs: Any) -> Any:
+ prev_name = state.current_migration_name
+ prev_app = state.current_migration_app
+ prev_op_index = state.current_op_index
+ state.current_migration_name = self.name
+ state.current_migration_app = self.app_label
+ state.current_op_index = 0
+
+ apply_started_at = datetime.now(UTC).isoformat()
+ apply_t0 = time.monotonic()
+ try:
+ return original(self, *args, **kwargs)
+ finally:
+ apply_duration_ms = (time.monotonic() - apply_t0) * 1000.0
+ # Emit a summary record so the analyze command can compute the
+ # python-overhead portion of each migration.
+ summary = {
+ "_kind": "migration_summary",
+ "database": state.database,
+ "app_label": self.app_label,
+ "migration_name": self.name,
+ "started_at": apply_started_at,
+ "apply_duration_ms": apply_duration_ms,
+ }
+ state.fp.write(json.dumps(summary) + "\n")
+ state.current_migration_name = prev_name
+ state.current_migration_app = prev_app
+ state.current_op_index = prev_op_index
+
+ Migration.apply = cast(Any, wrapped) # type: ignore[method-assign]
+ return original
+
+
+def _patch_operations(state: _ProfilerState) -> list[tuple[type[Operation], Any]]:
+ patched: list[tuple[type[Operation], Any]] = []
+ for cls in _iter_operation_subclasses():
+ original = cls.__dict__.get("database_forwards")
+ if original is None:
+ # Subclass inherits database_forwards from its parent; we'd patch
+ # the parent separately. Skip to avoid double-patching.
+ continue
+ wrapper = _make_op_wrapper(original, state)
+ cls.database_forwards = wrapper
+ patched.append((cls, original))
+ return patched
+
+
+def _make_state_op_wrapper(original_method: Any, state: _ProfilerState) -> Any:
+ """Wrap ``Operation.state_forwards`` to emit per-state-op timings.
+
+ State ops don't touch the DB, so the record is leaner than ``OpRecord``:
+ just class, migration context, parent op index (for ops inside
+ ``SeparateDatabaseAndState``), and wall-clock. Emitted with
+ ``_kind: state_op`` so the analyze command can keep them separate from
+ ``database_forwards`` records.
+ """
+
+ def wrapped(op_self: Operation, app_label: str, state_obj: Any) -> Any:
+ op_type = op_self.__class__.__name__
+ stack = _get_stack()
+ parent_index = stack[-1].record.operation_index if stack else None
+ started_at = datetime.now(UTC).isoformat()
+ t0 = time.monotonic()
+ try:
+ return original_method(op_self, app_label, state_obj)
+ finally:
+ duration_ms = (time.monotonic() - t0) * 1000.0
+ record = {
+ "_kind": "state_op",
+ "database": state.database,
+ "app_label": app_label,
+ "migration_name": state.current_migration_name,
+ "operation_type": op_type,
+ "describe": _safe_describe(op_self),
+ "parent_op_index": parent_index,
+ "started_at": started_at,
+ "duration_ms": duration_ms,
+ "metadata": extract(op_self),
+ }
+ state.fp.write(json.dumps(record, default=str) + "\n")
+
+ return wrapped
+
+
+def _patch_state_forwards(state: _ProfilerState) -> list[tuple[type[Operation], Any]]:
+ patched: list[tuple[type[Operation], Any]] = []
+ for cls in _iter_operation_subclasses():
+ original = cls.__dict__.get("state_forwards")
+ if original is None:
+ continue
+ wrapper = _make_state_op_wrapper(original, state)
+ cls.state_forwards = wrapper
+ patched.append((cls, original))
+ return patched
+
+
+# ---------- SQL patching ----------
+
+
+def _make_schema_editor_wrapper(original_execute: Any, state: _ProfilerState) -> Any:
+ def wrapped(self: BaseDatabaseSchemaEditor, sql: Any, params: Any = ()) -> Any:
+ frame = _current_frame()
+ sql_str = str(sql) if sql is not None else ""
+
+ if frame is None:
+ # Bootstrap DDL — attribute to a synthetic record flushed on first op.
+ _ensure_bootstrap_open(state)
+ t0 = time.monotonic()
+ try:
+ return original_execute(self, sql, params)
+ finally:
+ truncated_sql, was_truncated = _truncate_sql(sql_str, state.truncation_limit)
+ duration_ms = (time.monotonic() - t0) * 1000.0
+ ts_offset_ms = (time.monotonic() - state.bootstrap_monotonic_start) * 1000.0
+ if len(state.bootstrap_sql) < MAX_SQL_PER_OP:
+ state.bootstrap_sql.append(
+ SqlRecord(
+ sql=truncated_sql,
+ sql_truncated=was_truncated,
+ params_repr=_safe_repr(params),
+ duration_ms=duration_ms,
+ source="schema_editor",
+ ts_offset_ms=ts_offset_ms,
+ )
+ )
+ return None
+
+ frame.in_schema_editor_call = True
+ t0 = time.monotonic()
+ try:
+ return original_execute(self, sql, params)
+ finally:
+ duration_ms = (time.monotonic() - t0) * 1000.0
+ ts_offset_ms = (time.monotonic() - frame.monotonic_start) * 1000.0
+ frame.in_schema_editor_call = False
+ frame.sql_emitted += 1
+ if len(frame.record.sql_statements) < MAX_SQL_PER_OP:
+ truncated_sql, was_truncated = _truncate_sql(sql_str, state.truncation_limit)
+ frame.record.sql_statements.append(
+ SqlRecord(
+ sql=truncated_sql,
+ sql_truncated=was_truncated,
+ params_repr=_safe_repr(params),
+ duration_ms=duration_ms,
+ source="schema_editor",
+ ts_offset_ms=ts_offset_ms,
+ )
+ )
+
+ return wrapped
+
+
+def _make_cursor_wrapper(state: _ProfilerState) -> Any:
+ def cursor_wrapper(execute: Any, sql: Any, params: Any, many: bool, context: dict[str, Any]) -> Any:
+ frame = _current_frame()
+ if frame is None or frame.in_schema_editor_call:
+ return execute(sql, params, many, context)
+
+ t0 = time.monotonic()
+ try:
+ return execute(sql, params, many, context)
+ finally:
+ duration_ms = (time.monotonic() - t0) * 1000.0
+ ts_offset_ms = (time.monotonic() - frame.monotonic_start) * 1000.0
+ frame.sql_emitted += 1
+ if len(frame.record.sql_statements) < MAX_SQL_PER_OP:
+ sql_str = str(sql) if sql is not None else ""
+ truncated_sql, was_truncated = _truncate_sql(sql_str, state.truncation_limit)
+ frame.record.sql_statements.append(
+ SqlRecord(
+ sql=truncated_sql,
+ sql_truncated=was_truncated,
+ params_repr=_safe_repr(params),
+ duration_ms=duration_ms,
+ source="cursor",
+ ts_offset_ms=ts_offset_ms,
+ )
+ )
+
+ return cursor_wrapper
+
+
+# ---------- the contextmanager ----------
+
+
+@contextmanager
+def profile_migrations(
+ *,
+ database: str,
+ output_path: Path,
+ full_sql: bool = False,
+) -> Iterator[Path]:
+ """Profile a single ``migrate`` invocation.
+
+ Writes one JSONL file at ``output_path``. The first line is a ``_meta``
+ header; every subsequent line is an ``OpRecord.to_dict()``. Restores all
+ patches in ``finally``.
+ """
+ output_path = Path(output_path)
+ output_path.parent.mkdir(parents=True, exist_ok=True)
+
+ truncation_limit = None if full_sql else SQL_TRUNCATION_LIMIT
+ fp = output_path.open("w", buffering=1, encoding="utf-8")
+
+ state = _ProfilerState(fp=fp, database=database, truncation_limit=truncation_limit)
+ state_token = _state_var.set(state)
+ stack_token = _stack_var.set([])
+
+ # Header line.
+ meta = {
+ "_meta": {
+ "schema_version": SCHEMA_VERSION,
+ "database": database,
+ "django_version": django.get_version(),
+ "python_version": sys.version.split()[0],
+ "git_sha": _git_sha(),
+ "hostname": socket.gethostname(),
+ "started_at": datetime.now(UTC).isoformat(),
+ "full_sql": full_sql,
+ "sql_truncation_limit": truncation_limit,
+ }
+ }
+ fp.write(json.dumps(meta) + "\n")
+
+ # Force migration loader to import every migration module so all
+ # Operation subclasses are loaded before we patch.
+ _prime_operation_subclasses(database)
+
+ migration_apply_original = _patch_migration_apply(state)
+ patched_ops = _patch_operations(state)
+ patched_state_ops = _patch_state_forwards(state)
+
+ schema_editor_original = BaseDatabaseSchemaEditor.execute
+ BaseDatabaseSchemaEditor.execute = _make_schema_editor_wrapper(schema_editor_original, state) # type: ignore[method-assign]
+
+ cursor_wrapper = _make_cursor_wrapper(state)
+ installed_on: list[str] = []
+ for alias in settings.DATABASES:
+ try:
+ connections[alias].execute_wrappers.append(cursor_wrapper)
+ installed_on.append(alias)
+ except Exception:
+ # Best-effort: an alias that fails to open shouldn't break profiling
+ # of the rest.
+ pass
+
+ try:
+ yield output_path
+ finally:
+ for alias in installed_on:
+ try:
+ connections[alias].execute_wrappers.remove(cursor_wrapper)
+ except (ValueError, Exception):
+ pass
+
+ BaseDatabaseSchemaEditor.execute = schema_editor_original # type: ignore[method-assign]
+
+ for cls, original in patched_ops:
+ cls.database_forwards = original
+
+ for cls, original in patched_state_ops:
+ cls.state_forwards = original
+
+ Migration.apply = migration_apply_original # type: ignore[method-assign]
+
+ _finalize_bootstrap_if_needed(state)
+
+ _stack_var.reset(stack_token)
+ _state_var.reset(state_token)
+
+ fp.close()
+
+
+def _prime_operation_subclasses(database: str) -> None:
+ """Trigger the migration loader so every concrete ``Operation`` subclass
+ in every app is imported before we patch ``database_forwards``."""
+ try:
+ from django.db.migrations.loader import MigrationLoader
+
+ MigrationLoader(connections[database], ignore_no_migrations=True)
+ except Exception:
+ # If we can't load the graph, fall back to whatever subclasses are
+ # currently loaded — patching is still useful, just less complete.
+ pass
diff --git a/posthog/management/migration_profiling/pyinstrument_parse.py b/posthog/management/migration_profiling/pyinstrument_parse.py
new file mode 100644
index 000000000000..0aae2b30383f
--- /dev/null
+++ b/posthog/management/migration_profiling/pyinstrument_parse.py
@@ -0,0 +1,90 @@
+"""Parser for pyinstrument's JSON output.
+
+Pyinstrument dumps a recursive frame tree where each node has:
+
+ {
+ "function": "Migration.apply",
+ "file_path_short": "django/db/migrations/migration.py",
+ "line_no": 94,
+ "time": 12.3, # cumulative seconds in this frame and children
+ "await_time": 0,
+ "children": [...]
+ }
+
+We walk it to build per-function aggregates:
+
+- ``self_time``: time spent in this frame minus time spent in its children
+ (the "self" cost of the function).
+- ``cumulative_time``: the raw ``time`` field summed across all instances of
+ the function in the tree.
+
+Functions are identified by ``module:function`` (line number stripped) so
+the same function called from different parents aggregates.
+"""
+
+from __future__ import annotations
+
+import json
+from collections import defaultdict
+from dataclasses import dataclass
+from pathlib import Path
+from typing import Any
+
+
+@dataclass(frozen=False)
+class PyinstrumentAggregate:
+ total_duration_s: float
+ sample_count: int | None
+ by_self: list[tuple[str, float, float]] # (function, self_s, self_pct)
+ by_cumulative: list[tuple[str, float, float]] # (function, cumulative_s, pct)
+
+
+def _frame_key(frame: dict[str, Any]) -> str:
+ func = frame.get("function", "<unknown>")
+ file_short = frame.get("file_path_short") or frame.get("file_path", "")
+ if file_short:
+ return f"{file_short}:{func}"
+ return func
+
+
+def _walk(
+ frame: dict[str, Any],
+ self_times: dict[str, float],
+ cum_times: dict[str, float],
+) -> None:
+ children = frame.get("children") or []
+ total_time = frame.get("time", 0.0)
+ children_time = sum(c.get("time", 0.0) for c in children)
+ self_time = max(total_time - children_time, 0.0)
+
+ key = _frame_key(frame)
+ self_times[key] += self_time
+ cum_times[key] += total_time
+
+ for child in children:
+ _walk(child, self_times, cum_times)
+
+
+def parse_pyinstrument_json(path: Path, top_n: int = 30) -> PyinstrumentAggregate:
+ payload = json.loads(path.read_text())
+ root = payload.get("root_frame") or {}
+ self_times: dict[str, float] = defaultdict(float)
+ cum_times: dict[str, float] = defaultdict(float)
+ _walk(root, self_times, cum_times)
+
+ total_duration = payload.get("duration") or root.get("time", 0.0)
+ sample_count = payload.get("sample_count")
+
+ # nosemgrep: tuple-return-prefer-dataclass -- tuples serve as graph and dict keys here
+ def _top(d: dict[str, float]) -> list[tuple[str, float, float]]:
+ rows = sorted(d.items(), key=lambda x: -x[1])[:top_n]
+ if total_duration > 0:
+ return [(fn, t, (t / total_duration) * 100.0) for fn, t in rows]
+ return [(fn, t, 0.0) for fn, t in rows]
+
+ return PyinstrumentAggregate(
+ total_duration_s=total_duration,
+ sample_count=sample_count,
+ by_self=_top(self_times),
+ by_cumulative=_top(cum_times),
+ )
diff --git a/posthog/management/migration_profiling/spy.py b/posthog/management/migration_profiling/spy.py
new file mode 100644
index 000000000000..107ee654b031
--- /dev/null
+++ b/posthog/management/migration_profiling/spy.py
@@ -0,0 +1,123 @@
+"""py-spy raw-format parser and aggregator.
+
+``py-spy record --format raw`` emits one line per unique stack:
+``frame1;frame2;...;frameN <count>`` where each frame is
+``module:function:line``. Lines beginning with non-digit / non-frame syntax
+are header noise we ignore.
+
+We use the parsed samples for two things:
+
+1. A top-N by self-time / cumulative-time table inserted into the Markdown
+ report (driven from ``aggregate_samples``).
+2. A flame-graph SVG rendered via the ``flameprof`` package. We feed the raw
+ collapsed-stack file through ``flameprof.render`` as-is — no preprocessing
+ needed.
+"""
+
+from __future__ import annotations
+
+from collections import defaultdict
+from dataclasses import dataclass
+from pathlib import Path
+
+
+@dataclass(frozen=False)
+class FunctionStats:
+ function: str
+ self_samples: int
+ cum_samples: int
+
+ @property
+ def self_pct(self) -> float:
+ return 0.0 # filled by aggregator using total samples
+
+ @property
+ def cum_pct(self) -> float:
+ return 0.0
+
+
+@dataclass(frozen=False)
+class SpyAggregate:
+ total_samples: int
+ by_self: list[tuple[str, int, float]] # (function, self_samples, self_pct)
+ by_cumulative: list[tuple[str, int, float]] # (function, cum_samples, cum_pct)
+
+
+def _normalize_frame(frame: str) -> str:
+ """Strip the line-number component so ``mod:func:123`` aggregates with
+ ``mod:func:456`` (both are the same function). Leaves frames that don't
+ match the expected shape unchanged."""
+ parts = frame.rsplit(":", 1)
+ if len(parts) == 2 and parts[1].isdigit():
+ return parts[0]
+ return frame
+
+
+def parse_raw(path: Path) -> list[tuple[list[str], int]]:
+ """Read a py-spy ``--format raw`` file. Returns list of
+ ``(frames, sample_count)`` tuples."""
+ samples: list[tuple[list[str], int]] = []
+ with open(path) as fp:
+ for raw_line in fp:
+ line = raw_line.strip()
+ if not line:
+ continue
+ # The last whitespace-separated token must be a positive integer
+ # sample count for it to be a sample line.
+ try:
+ stack_part, count_part = line.rsplit(" ", 1)
+ count = int(count_part)
+ except ValueError:
+ continue
+ if count <= 0:
+ continue
+ frames = [_normalize_frame(f) for f in stack_part.split(";") if f]
+ if not frames:
+ continue
+ samples.append((frames, count))
+ return samples
+
+
+def aggregate_samples(samples: list[tuple[list[str], int]], top_n: int = 30) -> SpyAggregate:
+ self_counts: dict[str, int] = defaultdict(int)
+ cum_counts: dict[str, int] = defaultdict(int)
+ total = 0
+
+ for frames, count in samples:
+ total += count
+ # Self-time: only the leaf (last) frame.
+ self_counts[frames[-1]] += count
+ # Cumulative: every unique frame in this stack contributes once.
+ for frame in set(frames):
+ cum_counts[frame] += count
+
+ # nosemgrep: tuple-return-prefer-dataclass -- tuples serve as graph and dict keys here
+ def _top(counts: dict[str, int]) -> list[tuple[str, int, float]]:
+ pct = 100.0 / total if total else 0.0
+ return sorted(
+ ((fn, n, n * pct) for fn, n in counts.items()),
+ key=lambda x: x[1],
+ reverse=True,
+ )[:top_n]
+
+ return SpyAggregate(total_samples=total, by_self=_top(self_counts), by_cumulative=_top(cum_counts))
+
+
+def render_flame_svg(raw_path: Path, svg_path: Path) -> bool:
+ """Render an SVG flame graph from a py-spy raw file.
+
+ Returns True on success, False if ``flameprof`` isn't installed or fails.
+ Failure is non-fatal — the analyze command continues without the SVG.
+ """
+ try:
+ import flameprof
+ except ImportError:
+ return False
+
+ try:
+ svg_path.parent.mkdir(parents=True, exist_ok=True)
+ with open(raw_path) as fin, open(svg_path, "w") as fout:
+ flameprof.render(fin, fout)
+ return True
+ except Exception:
+ return False
diff --git a/posthog/management/migration_profiling/test/__init__.py b/posthog/management/migration_profiling/test/__init__.py
new file mode 100644
index 000000000000..0e3db2227e69
--- /dev/null
+++ b/posthog/management/migration_profiling/test/__init__.py
@@ -0,0 +1 @@
+"""Tests for migration profiling package."""
diff --git a/posthog/management/migration_profiling/test/test_analyze_formatter.py b/posthog/management/migration_profiling/test/test_analyze_formatter.py
new file mode 100644
index 000000000000..bbf8e5be1d1c
--- /dev/null
+++ b/posthog/management/migration_profiling/test/test_analyze_formatter.py
@@ -0,0 +1,114 @@
+"""Test the Markdown report renderer end-to-end against synthetic OpRecords."""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+from posthog.management.migration_profiling.formatters import load_run, render_report
+from posthog.management.migration_profiling.spy import SpyAggregate
+
+
+def _write_jsonl(path: Path, meta: dict, ops: list[dict]) -> Path:
+ lines = [json.dumps({"_meta": meta})]
+ lines.extend(json.dumps(o) for o in ops)
+ path.write_text("\n".join(lines))
+ return path
+
+
+def _op(**overrides) -> dict:
+ base = {
+ "database": "default",
+ "app_label": "posthog",
+ "migration_name": "0001_initial",
+ "operation_index": 0,
+ "operation_type": "CreateModel",
+ "describe": "Create model Event",
+ "started_at": "2026-05-22T10:00:00Z",
+ "duration_ms": 100.0,
+ "sql_count": 1,
+ "sql_total_ms": 95.0,
+ "sql_truncated_count": 0,
+ "is_runpython": False,
+ "is_state_only": False,
+ "parent_op_index": None,
+ "error": None,
+ "sql_statements": [
+ {
+ "sql": "CREATE TABLE event (...);",
+ "sql_truncated": False,
+ "params_repr": None,
+ "duration_ms": 95.0,
+ "source": "schema_editor",
+ "ts_offset_ms": 1.0,
+ }
+ ],
+ "metadata": {"model_name": "Event"},
+ }
+ base.update(overrides)
+ return base
+
+
+class TestRenderReport:
+ def test_renders_with_no_spy(self, tmp_path: Path) -> None:
+ path = _write_jsonl(
+ tmp_path / "p.jsonl",
+ {"database": "default", "started_at": "now", "django_version": "5.2.0"},
+ [
+ _op(duration_ms=2500.0, operation_type="AddIndex", describe="big idx"),
+ _op(duration_ms=10.0, operation_index=1, operation_type="AlterModelOptions", is_state_only=True),
+ _op(duration_ms=50.0, operation_index=2, migration_name="0002_more"),
+ ],
+ )
+ run = load_run(path)
+
+ report = render_report([run], {})
+
+ assert "# Migration profile report" in report
+ assert "## Top 50 slowest operations" in report
+ assert "AddIndex" in report
+ # State-only op should not appear in the slowest-ops table (filtered).
+ assert "AlterModelOptions" not in report.split("## Top 50 slowest operations")[1].split("##")[0]
+
+ def test_renders_with_spy(self, tmp_path: Path) -> None:
+ path = _write_jsonl(
+ tmp_path / "p.jsonl",
+ {"database": "default", "started_at": "now"},
+ [_op()],
+ )
+ run = load_run(path)
+ agg = SpyAggregate(
+ total_samples=100,
+ by_self=[("func_a", 60, 60.0), ("func_b", 40, 40.0)],
+ by_cumulative=[("main", 100, 100.0)],
+ )
+
+ report = render_report([run], {"default": (agg, None)})
+
+ assert "Python hot functions (py-spy)" in report
+ assert "func_a" in report
+ assert "Total samples: 100" in report
+
+ def test_separate_db_and_state_outer_excluded_when_has_children(self, tmp_path: Path) -> None:
+ path = _write_jsonl(
+ tmp_path / "p.jsonl",
+ {"database": "default", "started_at": "now"},
+ [
+ # Outer SDAS op with 2s wall clock — but its children sum to
+ # the same thing, so the outer must be excluded.
+ _op(
+ operation_index=0,
+ operation_type="SeparateDatabaseAndState",
+ duration_ms=2000.0,
+ ),
+ _op(operation_index=1, operation_type="AddField", duration_ms=1500.0, parent_op_index=0),
+ _op(operation_index=2, operation_type="AddIndex", duration_ms=500.0, parent_op_index=0),
+ ],
+ )
+ run = load_run(path)
+
+ report = render_report([run], {})
+
+ slowest_section = report.split("## Top 50 slowest operations")[1].split("##")[0]
+ # The outer SDAS line should not be in the slowest table — only the inner ops.
+ assert "SeparateDatabaseAndState" not in slowest_section
diff --git a/posthog/management/migration_profiling/test/test_metadata.py b/posthog/management/migration_profiling/test/test_metadata.py
new file mode 100644
index 000000000000..9041ee9817db
--- /dev/null
+++ b/posthog/management/migration_profiling/test/test_metadata.py
@@ -0,0 +1,103 @@
+"""Test that each per-op metadata extractor pulls out the right fields.
+
+Uses lightweight stubs rather than constructing real Django Operation
+instances — keeps the test fast and avoids dragging in the app registry.
+"""
+
+from __future__ import annotations
+
+from dataclasses import dataclass
+from typing import Any
+
+import pytest
+
+from posthog.management.migration_profiling.metadata import EXTRACTORS, STATE_ONLY_OPERATIONS, extract
+
+
+@dataclass(frozen=False)
+class _FakeOp:
+ name: str = ""
+
+
+ "op_type,attrs,expected",
+ [
+ ("CreateModel", {"name": "Event"}, {"model_name": "Event"}),
+ ("DeleteModel", {"name": "Event"}, {"model_name": "Event"}),
+ ("AddField", {"model_name": "Event", "name": "color"}, {"model_name": "Event", "field_name": "color"}),
+ ("RemoveField", {"model_name": "Event", "name": "color"}, {"model_name": "Event", "field_name": "color"}),
+ ("AlterField", {"model_name": "Event", "name": "color"}, {"model_name": "Event", "field_name": "color"}),
+ (
+ "RenameField",
+ {"model_name": "Event", "old_name": "x", "new_name": "y"},
+ {"model_name": "Event", "old_name": "x", "new_name": "y"},
+ ),
+ ("AlterModelOptions", {"name": "Event"}, {"model_name": "Event"}),
+ (
+ "RunPython",
+ {"code": lambda apps, schema_editor: None},
+ None,
+ ),
+ ],
+)
+def test_extractor_for_known_op_type(op_type: str, attrs: dict[str, Any], expected: dict[str, Any] | None) -> None:
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = op_type
+ for k, v in attrs.items():
+ setattr(op, k, v)
+
+ result = extract(op)
+
+ if op_type == "RunPython":
+ assert result["is_runpython"] is True
+ assert "callable" in result
+ else:
+ assert result == expected
+
+
+def test_extractor_unknown_op_type_returns_empty() -> None:
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = "TotallyMadeUpOp"
+ assert extract(op) == {}
+
+
+def test_add_index_extracts_index_name() -> None:
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = "AddIndex"
+ op.model_name = "Event"
+ op.index = type("Idx", (), {"name": "foo_idx"})()
+ assert extract(op) == {"model_name": "Event", "index_name": "foo_idx"}
+
+
+def test_run_sql_extracts_preview() -> None:
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = "RunSQL"
+ op.sql = "SELECT 1;"
+ assert extract(op) == {"sql_preview": "SELECT 1;"}
+
+
+def test_run_sql_list_preview_truncates() -> None:
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = "RunSQL"
+ op.sql = ["A" * 500, "B" * 500, "C" * 500, "D" * 500]
+ result = extract(op)
+ # First three items joined, each truncated to 200 chars.
+ assert "A" * 200 in result["sql_preview"]
+ assert "D" * 200 not in result["sql_preview"]
+
+
+def test_extractor_swallows_errors() -> None:
+ """An extractor that raises must not bring down the profiler — the
+ profiler should still produce an OpRecord with an error marker in
+ metadata, not propagate the exception."""
+ op = type("Stub", (), {})()
+ op.__class__.__name__ = "AddField"
+ # Deliberately omit model_name + name so the extractor raises AttributeError.
+ result = extract(op)
+ assert "_extract_error" in result
+
+
+def test_state_only_operations_match_extractor_keys() -> None:
+ # Sanity: every state-only op type must have an extractor (so its
+ # metadata still gets populated even though database_forwards is a no-op).
+ assert STATE_ONLY_OPERATIONS.issubset(EXTRACTORS.keys() | {"AlterOrderWithRespectTo"})
diff --git a/posthog/management/migration_profiling/test/test_profiler_smoke.py b/posthog/management/migration_profiling/test/test_profiler_smoke.py
new file mode 100644
index 000000000000..3e248b443ad7
--- /dev/null
+++ b/posthog/management/migration_profiling/test/test_profiler_smoke.py
@@ -0,0 +1,89 @@
+"""Smoke test the profiler contextmanager without hitting a real DB.
+
+We synthesize a tiny ``Operation`` subclass with a no-op ``database_forwards``,
+run it under ``profile_migrations``, and check that the JSONL output records
+the op with the expected shape.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+from django.db.migrations.operations.base import Operation
+
+from posthog.management.migration_profiling.profiler import profile_migrations
+
+
+class _FakeOp(Operation):
+ """Concrete Operation subclass with a no-op database_forwards."""
+
+ reduces_to_sql = True
+ reversible = True
+
+ def __init__(self, name: str):
+ self.name = name
+
+ def state_forwards(self, app_label, state):
+ pass
+
+ def database_forwards(self, app_label, schema_editor, from_state, to_state): # type: ignore[override]
+ return None
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ return None
+
+ def describe(self):
+ return f"FakeOp({self.name})"
+
+
+def test_profiler_records_op(tmp_path: Path) -> None:
+ output = tmp_path / "profile.jsonl"
+ op = _FakeOp("noop")
+
+ with profile_migrations(database="default", output_path=output):
+ op.database_forwards("posthog", _FakeSchemaEditor(), None, None)
+
+ lines = [json.loads(line) for line in output.read_text().splitlines() if line.strip()]
+ # First line is the _meta header.
+ assert "_meta" in lines[0]
+ assert lines[0]["_meta"]["database"] == "default"
+
+ # Then one OpRecord for our fake op.
+ op_lines = [line for line in lines[1:] if line.get("operation_type") == "_FakeOp"]
+ assert len(op_lines) == 1
+ record = op_lines[0]
+ assert record["app_label"] == "posthog"
+ assert record["describe"] == "FakeOp(noop)"
+ assert record["duration_ms"] >= 0
+ assert record["error"] is None
+
+
+def test_profiler_records_op_error(tmp_path: Path) -> None:
+ output = tmp_path / "profile.jsonl"
+
+ class _ExplodingOp(_FakeOp):
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ raise RuntimeError("boom")
+
+ op = _ExplodingOp("boom")
+
+ with profile_migrations(database="default", output_path=output):
+ with pytest.raises(RuntimeError, match="boom"):
+ op.database_forwards("posthog", _FakeSchemaEditor(), None, None)
+
+ lines = [json.loads(line) for line in output.read_text().splitlines() if line.strip()]
+ op_lines = [line for line in lines[1:] if line.get("operation_type") == "_ExplodingOp"]
+ assert len(op_lines) == 1
+ assert op_lines[0]["error"] == "RuntimeError: boom"
+
+
+class _FakeSchemaEditor:
+ """Just enough surface to satisfy the op wrapper's target_alias lookup."""
+
+ class _Conn:
+ alias = "default"
+
+ connection = _Conn()
diff --git a/posthog/management/migration_profiling/test/test_spy.py b/posthog/management/migration_profiling/test/test_spy.py
new file mode 100644
index 000000000000..ca9803019359
--- /dev/null
+++ b/posthog/management/migration_profiling/test/test_spy.py
@@ -0,0 +1,76 @@
+"""Test the py-spy raw parser and sample aggregator."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+from posthog.management.migration_profiling.spy import aggregate_samples, parse_raw
+
+
+def _write(path: Path, lines: list[str]) -> Path:
+ path.write_text("\n".join(lines))
+ return path
+
+
+def test_parse_raw_skips_header_lines(tmp_path: Path) -> None:
+ raw = _write(
+ tmp_path / "samples.raw",
+ [
+ "some header",
+ "frame_a;frame_b 10",
+ "frame_a;frame_b;frame_c 5",
+ "",
+ "ignore this without count",
+ "frame_x 3",
+ ],
+ )
+ samples = parse_raw(raw)
+ assert (["frame_a", "frame_b"], 10) in samples
+ assert (["frame_a", "frame_b", "frame_c"], 5) in samples
+ assert (["frame_x"], 3) in samples
+ assert len(samples) == 3
+
+
+def test_parse_raw_normalizes_line_numbers(tmp_path: Path) -> None:
+ raw = _write(
+ tmp_path / "samples.raw",
+ [
+ "mod:func:10 5",
+ "mod:func:42 3",
+ ],
+ )
+ samples = parse_raw(raw)
+ # Both stacks normalize to the same single-frame stack.
+ assert all(s[0] == ["mod:func"] for s in samples)
+
+
+def test_aggregate_self_and_cumulative() -> None:
+ samples = [
+ (["main", "a", "b"], 4),
+ (["main", "a"], 6),
+ (["main", "c", "b"], 2),
+ ]
+ agg = aggregate_samples(samples, top_n=10)
+
+ self_by_fn = {fn: n for fn, n, _ in agg.by_self}
+ cum_by_fn = {fn: n for fn, n, _ in agg.by_cumulative}
+
+ # Leaf frames only count toward self-time.
+ assert self_by_fn["b"] == 6 # 4 + 2
+ assert self_by_fn["a"] == 6
+ assert "main" not in self_by_fn or self_by_fn.get("main", 0) == 0
+
+ # Cumulative: every unique frame in the stack contributes.
+ assert cum_by_fn["main"] == 12
+ assert cum_by_fn["a"] == 10
+ assert cum_by_fn["b"] == 6
+ assert cum_by_fn["c"] == 2
+
+ assert agg.total_samples == 12
+
+
+def test_aggregate_empty() -> None:
+ agg = aggregate_samples([])
+ assert agg.total_samples == 0
+ assert agg.by_self == []
+ assert agg.by_cumulative == []
diff --git a/posthog/migration_helpers/squash_idempotent.py b/posthog/migration_helpers/squash_idempotent.py
new file mode 100644
index 000000000000..c686176d733d
--- /dev/null
+++ b/posthog/migration_helpers/squash_idempotent.py
@@ -0,0 +1,101 @@
+"""Idempotent Add* operations for nextgensquash's finalize_fks files.
+
+A finalize_fks migration adds the FK fields, indexes, and constraints the
+squash's initial deferred to break dependency cycles. On a fresh database it
+must behave exactly like the plain Django operations. On an existing database
+the schema it adds is already there — the historical chain built it — and the
+file runs once as a real migration (it carries no `replaces`, so Django plans
+it). Each operation here probes the catalog and skips instead of failing.
+State handling is inherited unchanged.
+
+Backwards is a deliberate no-op on every operation: when the forward pass
+skipped (the historical chain had already built the object), the inherited
+reverse would drop a column, index, or constraint the squash never created —
+destroying data on any database that migrates back below the finalize file.
+Migration tests walk backwards through these files, so they must be safely
+reversible; re-applying forward is idempotent either way.
+"""
+
+from django.db import migrations
+from django.db.models.constraints import BaseConstraint
+
+
+def _table_constraints(schema_editor, table: str) -> dict:
+ with schema_editor.connection.cursor() as cursor:
+ return schema_editor.connection.introspection.get_constraints(cursor, table)
+
+
+def _existing_constraint_names(schema_editor, table: str) -> set[str]:
+ return set(_table_constraints(schema_editor, table))
+
+
+class AddFieldIfMissing(migrations.AddField):
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ model = to_state.apps.get_model(app_label, self.model_name)
+ if not self.allow_migrate_model(schema_editor.connection.alias, model):
+ # Django's own operation would no-op (unmanaged, swapped, or
+ # router-excluded model); probing its absent table would crash first.
+ return
+ field = model._meta.get_field(self.name)
+ conn = schema_editor.connection
+ with conn.cursor() as cursor:
+ if field.many_to_many:
+ through_table = field.remote_field.through._meta.db_table
+ if through_table in conn.introspection.table_names(cursor):
+ return
+ else:
+ columns = {c.name for c in conn.introspection.get_table_description(cursor, model._meta.db_table)}
+ if field.column in columns:
+ return
+ super().database_forwards(app_label, schema_editor, from_state, to_state)
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ pass # see module docstring: reversing must not drop pre-existing schema
+
+
+class AddIndexIfMissing(migrations.AddIndex):
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ model = to_state.apps.get_model(app_label, self.model_name)
+ if not self.allow_migrate_model(schema_editor.connection.alias, model):
+ return
+ if self.index.name in _existing_constraint_names(schema_editor, model._meta.db_table):
+ return
+ super().database_forwards(app_label, schema_editor, from_state, to_state)
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ pass # see module docstring: reversing must not drop pre-existing schema
+
+
+class AddConstraintIfMissing(migrations.AddConstraint):
+ # django-stubs omits these runtime attributes on AddConstraint.
+ model_name: str
+ constraint: BaseConstraint
+
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ model = to_state.apps.get_model(app_label, self.model_name)
+ if not self.allow_migrate_model(schema_editor.connection.alias, model):
+ return
+ if self.constraint.name in _existing_constraint_names(schema_editor, model._meta.db_table):
+ return
+ super().database_forwards(app_label, schema_editor, from_state, to_state)
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ pass # see module docstring: reversing must not drop pre-existing schema
+
+
+class AlterUniqueTogetherIfMissing(migrations.AlterUniqueTogether):
+ def database_forwards(self, app_label, schema_editor, from_state, to_state):
+ model = to_state.apps.get_model(app_label, self.name)
+ if not self.allow_migrate_model(schema_editor.connection.alias, model):
+ return
+ wanted: set[frozenset[str]] = set()
+ for tup in self.option_value or ():
+ wanted.add(frozenset(model._meta.get_field(f).column for f in tup))
+ constraints = _table_constraints(schema_editor, model._meta.db_table)
+ existing = {frozenset(c["columns"]) for c in constraints.values() if c.get("unique")}
+ if wanted <= existing:
+ return
+ super().database_forwards(app_label, schema_editor, from_state, to_state)
+
+ def database_backwards(self, app_label, schema_editor, from_state, to_state):
+ pass # see module docstring: reversing must not drop pre-existing schema
diff --git a/posthog/migrations/0000_squash_stub.py b/posthog/migrations/0000_squash_stub.py
new file mode 100644
index 000000000000..d4e9a416ce43
--- /dev/null
+++ b/posthog/migrations/0000_squash_stub.py
@@ -0,0 +1,40 @@
+# Generated by Django 5.2.17
+
+import django.contrib.postgres.operations
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ replaces = [("posthog", "0001_initial_squashed_0284_improved_caching_state_idx")]
+
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ django.contrib.postgres.operations.TrigramExtension(),
+ migrations.RunSQL(
+ sql="CREATE EXTENSION IF NOT EXISTS btree_gist",
+ reverse_sql="DROP EXTENSION btree_gist",
+ ),
+ migrations.RunSQL(
+ sql="CREATE EXTENSION IF NOT EXISTS intarray",
+ reverse_sql="DROP EXTENSION intarray",
+ ),
+ migrations.RunSQL(
+ sql="CREATE EXTENSION ltree;",
+ reverse_sql="DROP EXTENSION ltree;",
+ ),
+ migrations.CreateModel(
+ name="InstanceSetting",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("key", models.CharField(max_length=128)),
+ ("raw_value", models.CharField(blank=True, max_length=1024)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("key",), name="unique key")],
+ },
+ ),
+ ]
diff --git a/posthog/migrations/0001_initial_squashed_0284_improved_caching_state_idx.py b/posthog/migrations/0001_initial_squashed_0284_improved_caching_state_idx.py
index f680c470b278..793c864b1461 100644
--- a/posthog/migrations/0001_initial_squashed_0284_improved_caching_state_idx.py
+++ b/posthog/migrations/0001_initial_squashed_0284_improved_caching_state_idx.py
@@ -26,296 +26,7 @@ import products.exports.backend.models.exported_asset
class Migration(migrations.Migration):
- replaces = [
- ("posthog", "0001_initial"),
- ("posthog", "0002_person"),
- ("posthog", "0003_person_is_user"),
- ("posthog", "0004_auto_20200125_0415"),
- ("posthog", "0005_remove_person_distinct_ids"),
- ("posthog", "0006_person_distinct_ids"),
- ("posthog", "0007_element"),
- ("posthog", "0008_action_actionstep"),
- ("posthog", "0009_auto_20200127_0018"),
- ("posthog", "0010_funnel_funnelstep"),
- ("posthog", "0011_auto_20200127_2105"),
- ("posthog", "0012_team_app_url"),
- ("posthog", "0013_element_attr_class"),
- ("posthog", "0014_auto_20200129_0703"),
- ("posthog", "0015_actionstep_event"),
- ("posthog", "0016_user_temporary_token"),
- ("posthog", "0017_dashboarditem"),
- ("posthog", "0018_funnel_deleted"),
- ("posthog", "0019_team_name"),
- ("posthog", "0020_auto_20200210_0212"),
- ("posthog", "0021_user_distinct_id"),
- ("posthog", "0022_action_deleted"),
- ("posthog", "0023_team_opt_out_capture"),
- ("posthog", "0024_add_event_distinct_id_index"),
- ("posthog", "0025_cohort"),
- ("posthog", "0026_auto_20200227_0804"),
- ("posthog", "0027_move_elements_to_group"),
- ("posthog", "0028_actionstep_url_matching"),
- ("posthog", "0029_migrate_dashboard_actions"),
- ("posthog", "0030_migrate_dashboard_days"),
- ("posthog", "0031_team_signup_token"),
- ("posthog", "0032_team_multiple_app_urls"),
- ("posthog", "0033_auto_20200316_1655"),
- ("posthog", "0034_pg_trgm_and_btree_20200318_1447"),
- ("posthog", "0035_current_url_index_20200318_1459"),
- ("posthog", "0036_remove_current_url_index"),
- ("posthog", "0037_action_step_url_matching_can_be_null_20200402_1351"),
- ("posthog", "0038_migrate_actions_to_precalculate_events"),
- ("posthog", "0039_populate_event_ip_property"),
- ("posthog", "0040_remove_event_ip"),
- ("posthog", "0039_user_email_opt_in"),
- ("posthog", "0041_merge_20200407_1805"),
- ("posthog", "0042_add_type_dashboarditems"),
- ("posthog", "0043_slack_webhooks"),
- ("posthog", "0044_auto_20200413_1936"),
- ("posthog", "0045_add_timestamp_index"),
- ("posthog", "0046_event_names_properties_to_team"),
- ("posthog", "0047_auto_20200416_1631"),
- ("posthog", "0048_auto_20200420_1051"),
- ("posthog", "0049_delete_funnelstep"),
- ("posthog", "0050_dashboards"),
- ("posthog", "0051_precalculate_cohorts"),
- ("posthog", "0052_data_precalculate_cohorts"),
- ("posthog", "0053_dashboard_item_layouts"),
- ("posthog", "0054_dashboard_item_color"),
- ("posthog", "0055_user_anonymize_data"),
- ("posthog", "0056_auto_20200522_1024"),
- ("posthog", "0057_action_updated_at"),
- ("posthog", "0058_dashboarditem_last_refresh"),
- ("posthog", "0059_dashboarditem_refreshing"),
- ("posthog", "0060_auto_20200616_0746"),
- ("posthog", "0061_featureflag"),
- ("posthog", "0062_team_anonymize_ips"),
- ("posthog", "0063_team_completed_snippet_onboarding"),
- ("posthog", "0064_toolbar_mode"),
- ("posthog", "0065_auto_20200624_1842"),
- ("posthog", "0066_team_created_at"),
- ("posthog", "0067_team_updated_at"),
- ("posthog", "0068_auto_20200629_1322"),
- ("posthog", "0069_auto_20200714_1642"),
- ("posthog", "0070_team_event_properties_numerical"),
- ("posthog", "0071_cache_dashboard_items"),
- ("posthog", "0072_action_step_url_matching_regex"),
- ("posthog", "0073_update_dashboard_item_filters"),
- ("posthog", "0074_toolbar_default_on"),
- ("posthog", "0075_action_slack_message_format"),
- ("posthog", "0076_auto_20200819_1214"),
- ("posthog", "0077_cohortpeople_id_to_bigautofield"),
- ("posthog", "0078_auto_20200731_1323"),
- ("posthog", "0079_move_funnels_to_insights"),
- ("posthog", "0080_update_dashboard_funnel_filters"),
- ("posthog", "0081_person_is_identified"),
- ("posthog", "0082_personalapikey"),
- ("posthog", "0083_auto_20200826_1504"),
- ("posthog", "0084_person_uuid"),
- ("posthog", "0085_org_models"),
- ("posthog", "0086_team_session_recording_opt_in"),
- ("posthog", "0087_fix_annotation_created_at"),
- ("posthog", "0088_toolbar_disabled"),
- ("posthog", "0089_auto_20201015_1031"),
- ("posthog", "0090_org_live"),
- ("posthog", "0091_messagingrecord"),
- ("posthog", "0092_rename_projects_to_default"),
- ("posthog", "0093_remove_user_is_superuser"),
- ("posthog", "0094_description_on_dashboard_items"),
- ("posthog", "0095_session_recording_event_table"),
- ("posthog", "0096_plugins"),
- ("posthog", "0097_invite_emails"),
- ("posthog", "0098_events_property_usage"),
- ("posthog", "0099_plugin_attachment"),
- ("posthog", "0100_action_step_max_length"),
- ("posthog", "0101_org_owners"),
- ("posthog", "0102_dashboarditem_filters_hash"),
- ("posthog", "0103_retention_remove_date"),
- ("posthog", "0104_auto_20201208_1052"),
- ("posthog", "0105_cohort_errors_calculating"),
- ("posthog", "0106_dashboard_item_type_to_display"),
- ("posthog", "0107_plugin_source"),
- ("posthog", "0108_plugin_organization"),
- ("posthog", "0109_fix_retention_filters"),
- ("posthog", "0110_sessionrecordingeventbyteamandtimestamp"),
- ("posthog", "0111_plugin_storage"),
- ("posthog", "0112_sessions_filter"),
- ("posthog", "0113_cohort_is_static"),
- ("posthog", "0114_fix_team_event_names"),
- ("posthog", "0115_session_recording_viewed"),
- ("posthog", "0116_session_recording_retention_period"),
- ("posthog", "0116_plugin_latest_tag"),
- ("posthog", "0117_merge_20210126_0917"),
- ("posthog", "0118_is_demo"),
- ("posthog", "0119_mandatory_plugin_order"),
- ("posthog", "0120_organization_personalization"),
- ("posthog", "0121_person_email_index"),
- ("posthog", "0122_organization_setup_section_2_completed"),
- ("posthog", "0123_organizationinvite_first_name"),
- ("posthog", "0124_unset_is_calculating_static_cohorts"),
- ("posthog", "0125_longer_webhook_url"),
- ("posthog", "0126_fix_funnels_insights_links"),
- ("posthog", "0127_stricter_team_data"),
- ("posthog", "0128_stricter_team_schema"),
- ("posthog", "0127_add_dashboard_filters"),
- ("posthog", "0129_merge_20210223_0757"),
- ("posthog", "0130_dashboard_creation_mode"),
- ("posthog", "0131_add_plugins_updated_created_at"),
- ("posthog", "0132_team_test_account_filters"),
- ("posthog", "0133_plugins_access_control"),
- ("posthog", "0134_event_site_url"),
- ("posthog", "0135_plugins_on_cloud"),
- ("posthog", "0136_global_plugin_attachments"),
- ("posthog", "0137_team_timezone"),
- ("posthog", "0138_featureflag_name_optional"),
- ("posthog", "0139_dashboard_tagging"),
- ("posthog", "0140_team_data_attributes"),
- ("posthog", "0141_events_created_at_index"),
- ("posthog", "0142_fix_team_data_attributes_default"),
- ("posthog", "0143_user_uuid"),
- ("posthog", "0144_update_django_3_1_8"),
- ("posthog", "0145_eventdefinition_propertydefinition"),
- ("posthog", "0146_eventproperty_sync"),
- ("posthog", "0147_plugin_logs"),
- ("posthog", "0147_fix_stickiness_dashboard_items"),
- ("posthog", "0148_merge_20210506_0823"),
- ("posthog", "0149_fix_lifecycle_dashboard_items"),
- ("posthog", "0150_increase_element_varchars"),
- ("posthog", "0151_plugin_preinstalled"),
- ("posthog", "0152_user_events_column_config"),
- ("posthog", "0153_plugin_capabilities"),
- ("posthog", "0154_organization_for_internal_metrics"),
- ("posthog", "0155_organization_available_features"),
- ("posthog", "0156_insight_short_id"),
- ("posthog", "0157_plugin_metrics"),
- ("posthog", "0158_new_token_format"),
- ("posthog", "0159_remove_funnels_with_breakdown"),
- ("posthog", "0160_organization_domain_whitelist"),
- ("posthog", "0161_property_defs_search"),
- ("posthog", "0162_organization_is_member_join_email_enabled"),
- ("posthog", "0163_insights_favorited_updatedat_tags"),
- ("posthog", "0164_person_index_by_team_and_id"),
- ("posthog", "0165_dashboarditem_dive_dashboard"),
- ("posthog", "0166_plugin_public_jobs"),
- ("posthog", "0167_feature_flag_override"),
- ("posthog", "0168_action_step_empty_string_reset"),
- ("posthog", "0169_person_properties_last_updated_at"),
- ("posthog", "0170_project_based_permissioning"),
- ("posthog", "0171_cohort_description"),
- ("posthog", "0172_person_properties_last_operation"),
- ("posthog", "0173_should_update_person_props_function"),
- ("posthog", "0174_organization_slug"),
- ("posthog", "0175_should_update_person_props_function"),
- ("posthog", "0176_update_person_props_function"),
- ("posthog", "0177_path_cleaning_filters"),
- ("posthog", "0178_rename_dashboard_item_to_insight"),
- ("posthog", "0179_add_group_type_mapping"),
- ("posthog", "0180_person_version"),
- ("posthog", "0181_team_correlation_config"),
- ("posthog", "0182_sessionrecordingevent_window_id"),
- ("posthog", "0183_groups_pg"),
- ("posthog", "0184_delete_sessionsfilter"),
- ("posthog", "0185_special_migrations"),
- ("posthog", "0186_insight_refresh_attempt"),
- ("posthog", "0187_stale_events"),
- ("posthog", "0188_person_distinct_id_version"),
- ("posthog", "0189_alter_annotation_scope"),
- ("posthog", "0190_experiment"),
- ("posthog", "0191_rename_specialmigration_asyncmigration"),
- ("posthog", "0192_event_properties"),
- ("posthog", "0193_auto_20211222_0912"),
- ("posthog", "0194_set_property_type_for_time"),
- ("posthog", "0195_group_type_name"),
- ("posthog", "0196_update_property_types"),
- ("posthog", "0197_plugin_is_stateless"),
- ("posthog", "0198_async_migration_error"),
- ("posthog", "0199_update_experiment_model"),
- ("posthog", "0200_insight_last_modified"),
- ("posthog", "0201_remove_property_type_format_constraint"),
- ("posthog", "0202_descriptions_for_action"),
- ("posthog", "0203_dashboard_permissions"),
- ("posthog", "0204_remove_duplicate_plugin_configs"),
- ("posthog", "0205_auto_20220204_1748"),
- ("posthog", "0206_global_tags_setup"),
- ("posthog", "0207_cohort_count"),
- ("posthog", "0208_alter_plugin_updated_at"),
- ("posthog", "0209_plugin_logs_disabled"),
- ("posthog", "0210_drop_update_person_functions"),
- ("posthog", "0211_async_migrations_errors_length"),
- ("posthog", "0212_alter_persondistinctid_team"),
- ("posthog", "0213_deprecated_old_tags"),
- ("posthog", "0214_migrate_dashboard_insight_tags"),
- ("posthog", "0215_add_tags_back"),
- ("posthog", "0216_insight_placeholder_name"),
- ("posthog", "0217_team_primary_dashboard"),
- ("posthog", "0218_uniqueness_constraint_tagged_items"),
- ("posthog", "0219_migrate_tags_v2"),
- ("posthog", "0220_backfill_primary_dashboards"),
- ("posthog", "0221_add_activity_log_model"),
- ("posthog", "0222_fix_deleted_primary_dashboards"),
- ("posthog", "0223_organizationdomain"),
- ("posthog", "0224_saml_multitenant"),
- ("posthog", "0225_insight_viewed"),
- ("posthog", "0226_longer_action_slack_message_format"),
- ("posthog", "0227_add_dashboard_tiles"),
- ("posthog", "0228_fix_tile_layouts"),
- ("posthog", "0229_add_filters_hash_to_dashboard_table"),
- ("posthog", "0230_cohort_filters"),
- ("posthog", "0231_add_refreshing_data_to_tiles"),
- ("posthog", "0232_add_team_person_display_name_properties"),
- ("posthog", "0233_plugin_source_file"),
- ("posthog", "0234_create_plugin_jsons"),
- ("posthog", "0235_plugin_source_transpilation"),
- ("posthog", "0236_add_instance_setting_model"),
- ("posthog", "0237_remove_timezone_from_teams"),
- ("posthog", "0238_exportedasset"),
- ("posthog", "0239_delete_postgres_pluginlogentry"),
- ("posthog", "0240_organizationinvite_message"),
- ("posthog", "0241_subscription"),
- ("posthog", "0242_team_live_events_columns"),
- ("posthog", "0243_unpack_plugin_source_files"),
- ("posthog", "0244_drop_should_update_person_prop"),
- ("posthog", "0245_silence_deprecated_tags_warnings"),
- ("posthog", "0246_integrations"),
- ("posthog", "0247_feature_flags_experience_continuity"),
- ("posthog", "0248_add_context_for_csv_exports"),
- ("posthog", "0249_add_sharingconfiguration"),
- ("posthog", "0250_exportedasset_created_by"),
- ("posthog", "0251_event_buffer"),
- ("posthog", "0252_reset_insight_refreshing_status"),
- ("posthog", "0253_add_async_migration_parameters"),
- ("posthog", "0254_prompt_sequence_state"),
- ("posthog", "0255_user_prompt_sequence_state"),
- ("posthog", "0256_add_async_deletion_model"),
- ("posthog", "0257_add_default_checked_for_test_filters_on_team"),
- ("posthog", "0258_team_recording_domains"),
- ("posthog", "0259_backfill_team_recording_domains"),
- ("posthog", "0260_pak_v2"),
- ("posthog", "0261_team_capture_console_log_opt_in"),
- ("posthog", "0262_track_viewed_notifications"),
- ("posthog", "0263_plugin_config_web_token"),
- ("posthog", "0264_user_partial_notification_settings"),
- ("posthog", "0265_related_tiles"),
- ("posthog", "0266_add_is_system_field_to_activity_log"),
- ("posthog", "0267_add_text_tiles"),
- ("posthog", "0268_plugin_source_file_updated_at"),
- ("posthog", "0269_soft_delete_tiles"),
- ("posthog", "0270_add_uploaded_media"),
- ("posthog", "0271_delete_promptsequencestate"),
- ("posthog", "0272_alter_organization_plugins_access_level"),
- ("posthog", "0273_mark_inactive_exports_as_finished"),
- ("posthog", "0274_add_plugin_icon_and_rewrite_urls"),
- ("posthog", "0275_feature_flag_rollback_fields"),
- ("posthog", "0276_organization_usage"),
- ("posthog", "0277_recording_playlist_model"),
- ("posthog", "0278_organization_customer_id"),
- ("posthog", "0279_recording_playlist_item_model"),
- ("posthog", "0280_fix_async_deletion_team"),
- ("posthog", "0281_create_insight_caching_state_model"),
- ("posthog", "0282_fix_insight_caching_state_model"),
- ("posthog", "0283_prompt_sequence_model"),
- ("posthog", "0284_improved_caching_state_idx"),
- ]
+ replaces = []
dependencies = [
("auth", "0011_update_proxy_permissions"),
diff --git a/posthog/migrations/0001_squash_2026_09_07_initial.py b/posthog/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..274f9a1bd9cf
--- /dev/null
+++ b/posthog/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,6962 @@
+# Generated by Django 5.2.17
+
+import uuid
+import datetime
+from decimal import Decimal
+
+import django.utils.timezone
+import django.core.validators
+import django.db.models.deletion
+import django.db.models.fields.json
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+import django.db.models.functions.text
+import django.db.models.functions.comparison
+from django.conf import settings
+from django.db import migrations, models
+
+import oauth2_provider.models
+import oauth2_provider.generators
+
+import posthog.utils
+import posthog.uuidt
+import posthog.models.user
+import posthog.models.utils
+import posthog.models.team.team
+import posthog.helpers.encrypted_fields
+import posthog.models.integration.model
+import posthog.models.organization_domain
+import posthog.models.organization_invite
+import posthog.models.sharing_configuration
+import posthog.models.organization_notification_lock
+import posthog.models.event_ingestion_restriction_config
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("posthog", "0001_initial"),
+ ("posthog", "0002_person"),
+ ("posthog", "0003_person_is_user"),
+ ("posthog", "0004_auto_20200125_0415"),
+ ("posthog", "0005_remove_person_distinct_ids"),
+ ("posthog", "0006_person_distinct_ids"),
+ ("posthog", "0007_element"),
+ ("posthog", "0008_action_actionstep"),
+ ("posthog", "0009_auto_20200127_0018"),
+ ("posthog", "0010_funnel_funnelstep"),
+ ("posthog", "0011_auto_20200127_2105"),
+ ("posthog", "0012_team_app_url"),
+ ("posthog", "0013_element_attr_class"),
+ ("posthog", "0014_auto_20200129_0703"),
+ ("posthog", "0015_actionstep_event"),
+ ("posthog", "0016_user_temporary_token"),
+ ("posthog", "0017_dashboarditem"),
+ ("posthog", "0018_funnel_deleted"),
+ ("posthog", "0019_team_name"),
+ ("posthog", "0020_auto_20200210_0212"),
+ ("posthog", "0021_user_distinct_id"),
+ ("posthog", "0022_action_deleted"),
+ ("posthog", "0023_team_opt_out_capture"),
+ ("posthog", "0024_add_event_distinct_id_index"),
+ ("posthog", "0025_cohort"),
+ ("posthog", "0026_auto_20200227_0804"),
+ ("posthog", "0027_move_elements_to_group"),
+ ("posthog", "0028_actionstep_url_matching"),
+ ("posthog", "0029_migrate_dashboard_actions"),
+ ("posthog", "0030_migrate_dashboard_days"),
+ ("posthog", "0031_team_signup_token"),
+ ("posthog", "0032_team_multiple_app_urls"),
+ ("posthog", "0033_auto_20200316_1655"),
+ ("posthog", "0034_pg_trgm_and_btree_20200318_1447"),
+ ("posthog", "0035_current_url_index_20200318_1459"),
+ ("posthog", "0036_remove_current_url_index"),
+ ("posthog", "0037_action_step_url_matching_can_be_null_20200402_1351"),
+ ("posthog", "0038_migrate_actions_to_precalculate_events"),
+ ("posthog", "0039_populate_event_ip_property"),
+ ("posthog", "0039_user_email_opt_in"),
+ ("posthog", "0040_remove_event_ip"),
+ ("posthog", "0041_merge_20200407_1805"),
+ ("posthog", "0042_add_type_dashboarditems"),
+ ("posthog", "0043_slack_webhooks"),
+ ("posthog", "0044_auto_20200413_1936"),
+ ("posthog", "0045_add_timestamp_index"),
+ ("posthog", "0046_event_names_properties_to_team"),
+ ("posthog", "0047_auto_20200416_1631"),
+ ("posthog", "0048_auto_20200420_1051"),
+ ("posthog", "0049_delete_funnelstep"),
+ ("posthog", "0050_dashboards"),
+ ("posthog", "0051_precalculate_cohorts"),
+ ("posthog", "0052_data_precalculate_cohorts"),
+ ("posthog", "0053_dashboard_item_layouts"),
+ ("posthog", "0054_dashboard_item_color"),
+ ("posthog", "0055_user_anonymize_data"),
+ ("posthog", "0056_auto_20200522_1024"),
+ ("posthog", "0057_action_updated_at"),
+ ("posthog", "0058_dashboarditem_last_refresh"),
+ ("posthog", "0059_dashboarditem_refreshing"),
+ ("posthog", "0060_auto_20200616_0746"),
+ ("posthog", "0061_featureflag"),
+ ("posthog", "0062_team_anonymize_ips"),
+ ("posthog", "0063_team_completed_snippet_onboarding"),
+ ("posthog", "0064_toolbar_mode"),
+ ("posthog", "0065_auto_20200624_1842"),
+ ("posthog", "0066_team_created_at"),
+ ("posthog", "0067_team_updated_at"),
+ ("posthog", "0068_auto_20200629_1322"),
+ ("posthog", "0069_auto_20200714_1642"),
+ ("posthog", "0070_team_event_properties_numerical"),
+ ("posthog", "0071_cache_dashboard_items"),
+ ("posthog", "0072_action_step_url_matching_regex"),
+ ("posthog", "0073_update_dashboard_item_filters"),
+ ("posthog", "0074_toolbar_default_on"),
+ ("posthog", "0075_action_slack_message_format"),
+ ("posthog", "0076_auto_20200819_1214"),
+ ("posthog", "0077_cohortpeople_id_to_bigautofield"),
+ ("posthog", "0078_auto_20200731_1323"),
+ ("posthog", "0079_move_funnels_to_insights"),
+ ("posthog", "0080_update_dashboard_funnel_filters"),
+ ("posthog", "0081_person_is_identified"),
+ ("posthog", "0082_personalapikey"),
+ ("posthog", "0083_auto_20200826_1504"),
+ ("posthog", "0084_person_uuid"),
+ ("posthog", "0085_org_models"),
+ ("posthog", "0086_team_session_recording_opt_in"),
+ ("posthog", "0087_fix_annotation_created_at"),
+ ("posthog", "0088_toolbar_disabled"),
+ ("posthog", "0089_auto_20201015_1031"),
+ ("posthog", "0090_org_live"),
+ ("posthog", "0091_messagingrecord"),
+ ("posthog", "0092_rename_projects_to_default"),
+ ("posthog", "0093_remove_user_is_superuser"),
+ ("posthog", "0094_description_on_dashboard_items"),
+ ("posthog", "0095_session_recording_event_table"),
+ ("posthog", "0096_plugins"),
+ ("posthog", "0097_invite_emails"),
+ ("posthog", "0098_events_property_usage"),
+ ("posthog", "0099_plugin_attachment"),
+ ("posthog", "0100_action_step_max_length"),
+ ("posthog", "0101_org_owners"),
+ ("posthog", "0102_dashboarditem_filters_hash"),
+ ("posthog", "0103_retention_remove_date"),
+ ("posthog", "0104_auto_20201208_1052"),
+ ("posthog", "0105_cohort_errors_calculating"),
+ ("posthog", "0106_dashboard_item_type_to_display"),
+ ("posthog", "0107_plugin_source"),
+ ("posthog", "0108_plugin_organization"),
+ ("posthog", "0109_fix_retention_filters"),
+ ("posthog", "0110_sessionrecordingeventbyteamandtimestamp"),
+ ("posthog", "0111_plugin_storage"),
+ ("posthog", "0112_sessions_filter"),
+ ("posthog", "0113_cohort_is_static"),
+ ("posthog", "0114_fix_team_event_names"),
+ ("posthog", "0115_session_recording_viewed"),
+ ("posthog", "0116_plugin_latest_tag"),
+ ("posthog", "0116_session_recording_retention_period"),
+ ("posthog", "0117_merge_20210126_0917"),
+ ("posthog", "0118_is_demo"),
+ ("posthog", "0119_mandatory_plugin_order"),
+ ("posthog", "0120_organization_personalization"),
+ ("posthog", "0121_person_email_index"),
+ ("posthog", "0122_organization_setup_section_2_completed"),
+ ("posthog", "0123_organizationinvite_first_name"),
+ ("posthog", "0124_unset_is_calculating_static_cohorts"),
+ ("posthog", "0125_longer_webhook_url"),
+ ("posthog", "0126_fix_funnels_insights_links"),
+ ("posthog", "0127_add_dashboard_filters"),
+ ("posthog", "0127_stricter_team_data"),
+ ("posthog", "0128_stricter_team_schema"),
+ ("posthog", "0129_merge_20210223_0757"),
+ ("posthog", "0130_dashboard_creation_mode"),
+ ("posthog", "0131_add_plugins_updated_created_at"),
+ ("posthog", "0132_team_test_account_filters"),
+ ("posthog", "0133_plugins_access_control"),
+ ("posthog", "0134_event_site_url"),
+ ("posthog", "0135_plugins_on_cloud"),
+ ("posthog", "0136_global_plugin_attachments"),
+ ("posthog", "0137_team_timezone"),
+ ("posthog", "0138_featureflag_name_optional"),
+ ("posthog", "0139_dashboard_tagging"),
+ ("posthog", "0140_team_data_attributes"),
+ ("posthog", "0141_events_created_at_index"),
+ ("posthog", "0142_fix_team_data_attributes_default"),
+ ("posthog", "0143_user_uuid"),
+ ("posthog", "0144_update_django_3_1_8"),
+ ("posthog", "0145_eventdefinition_propertydefinition"),
+ ("posthog", "0146_eventproperty_sync"),
+ ("posthog", "0147_fix_stickiness_dashboard_items"),
+ ("posthog", "0147_plugin_logs"),
+ ("posthog", "0148_merge_20210506_0823"),
+ ("posthog", "0149_fix_lifecycle_dashboard_items"),
+ ("posthog", "0150_increase_element_varchars"),
+ ("posthog", "0151_plugin_preinstalled"),
+ ("posthog", "0152_user_events_column_config"),
+ ("posthog", "0153_plugin_capabilities"),
+ ("posthog", "0154_organization_for_internal_metrics"),
+ ("posthog", "0155_organization_available_features"),
+ ("posthog", "0156_insight_short_id"),
+ ("posthog", "0157_plugin_metrics"),
+ ("posthog", "0158_new_token_format"),
+ ("posthog", "0159_remove_funnels_with_breakdown"),
+ ("posthog", "0160_organization_domain_whitelist"),
+ ("posthog", "0161_property_defs_search"),
+ ("posthog", "0162_organization_is_member_join_email_enabled"),
+ ("posthog", "0163_insights_favorited_updatedat_tags"),
+ ("posthog", "0164_person_index_by_team_and_id"),
+ ("posthog", "0165_dashboarditem_dive_dashboard"),
+ ("posthog", "0166_plugin_public_jobs"),
+ ("posthog", "0167_feature_flag_override"),
+ ("posthog", "0168_action_step_empty_string_reset"),
+ ("posthog", "0169_person_properties_last_updated_at"),
+ ("posthog", "0170_project_based_permissioning"),
+ ("posthog", "0171_cohort_description"),
+ ("posthog", "0172_person_properties_last_operation"),
+ ("posthog", "0173_should_update_person_props_function"),
+ ("posthog", "0174_organization_slug"),
+ ("posthog", "0175_should_update_person_props_function"),
+ ("posthog", "0176_update_person_props_function"),
+ ("posthog", "0177_path_cleaning_filters"),
+ ("posthog", "0178_rename_dashboard_item_to_insight"),
+ ("posthog", "0179_add_group_type_mapping"),
+ ("posthog", "0180_person_version"),
+ ("posthog", "0181_team_correlation_config"),
+ ("posthog", "0182_sessionrecordingevent_window_id"),
+ ("posthog", "0183_groups_pg"),
+ ("posthog", "0184_delete_sessionsfilter"),
+ ("posthog", "0185_special_migrations"),
+ ("posthog", "0186_insight_refresh_attempt"),
+ ("posthog", "0187_stale_events"),
+ ("posthog", "0188_person_distinct_id_version"),
+ ("posthog", "0189_alter_annotation_scope"),
+ ("posthog", "0190_experiment"),
+ ("posthog", "0191_rename_specialmigration_asyncmigration"),
+ ("posthog", "0192_event_properties"),
+ ("posthog", "0193_auto_20211222_0912"),
+ ("posthog", "0194_set_property_type_for_time"),
+ ("posthog", "0195_group_type_name"),
+ ("posthog", "0196_update_property_types"),
+ ("posthog", "0197_plugin_is_stateless"),
+ ("posthog", "0198_async_migration_error"),
+ ("posthog", "0199_update_experiment_model"),
+ ("posthog", "0200_insight_last_modified"),
+ ("posthog", "0201_remove_property_type_format_constraint"),
+ ("posthog", "0202_descriptions_for_action"),
+ ("posthog", "0203_dashboard_permissions"),
+ ("posthog", "0204_remove_duplicate_plugin_configs"),
+ ("posthog", "0205_auto_20220204_1748"),
+ ("posthog", "0206_global_tags_setup"),
+ ("posthog", "0207_cohort_count"),
+ ("posthog", "0208_alter_plugin_updated_at"),
+ ("posthog", "0209_plugin_logs_disabled"),
+ ("posthog", "0210_drop_update_person_functions"),
+ ("posthog", "0211_async_migrations_errors_length"),
+ ("posthog", "0212_alter_persondistinctid_team"),
+ ("posthog", "0213_deprecated_old_tags"),
+ ("posthog", "0214_migrate_dashboard_insight_tags"),
+ ("posthog", "0215_add_tags_back"),
+ ("posthog", "0216_insight_placeholder_name"),
+ ("posthog", "0217_team_primary_dashboard"),
+ ("posthog", "0218_uniqueness_constraint_tagged_items"),
+ ("posthog", "0219_migrate_tags_v2"),
+ ("posthog", "0220_backfill_primary_dashboards"),
+ ("posthog", "0221_add_activity_log_model"),
+ ("posthog", "0222_fix_deleted_primary_dashboards"),
+ ("posthog", "0223_organizationdomain"),
+ ("posthog", "0224_saml_multitenant"),
+ ("posthog", "0225_insight_viewed"),
+ ("posthog", "0226_longer_action_slack_message_format"),
+ ("posthog", "0227_add_dashboard_tiles"),
+ ("posthog", "0228_fix_tile_layouts"),
+ ("posthog", "0229_add_filters_hash_to_dashboard_table"),
+ ("posthog", "0230_cohort_filters"),
+ ("posthog", "0231_add_refreshing_data_to_tiles"),
+ ("posthog", "0232_add_team_person_display_name_properties"),
+ ("posthog", "0233_plugin_source_file"),
+ ("posthog", "0234_create_plugin_jsons"),
+ ("posthog", "0235_plugin_source_transpilation"),
+ ("posthog", "0236_add_instance_setting_model"),
+ ("posthog", "0237_remove_timezone_from_teams"),
+ ("posthog", "0238_exportedasset"),
+ ("posthog", "0239_delete_postgres_pluginlogentry"),
+ ("posthog", "0240_organizationinvite_message"),
+ ("posthog", "0241_subscription"),
+ ("posthog", "0242_team_live_events_columns"),
+ ("posthog", "0243_unpack_plugin_source_files"),
+ ("posthog", "0244_drop_should_update_person_prop"),
+ ("posthog", "0245_silence_deprecated_tags_warnings"),
+ ("posthog", "0246_integrations"),
+ ("posthog", "0247_feature_flags_experience_continuity"),
+ ("posthog", "0248_add_context_for_csv_exports"),
+ ("posthog", "0249_add_sharingconfiguration"),
+ ("posthog", "0250_exportedasset_created_by"),
+ ("posthog", "0251_event_buffer"),
+ ("posthog", "0252_reset_insight_refreshing_status"),
+ ("posthog", "0253_add_async_migration_parameters"),
+ ("posthog", "0254_prompt_sequence_state"),
+ ("posthog", "0255_user_prompt_sequence_state"),
+ ("posthog", "0256_add_async_deletion_model"),
+ ("posthog", "0257_add_default_checked_for_test_filters_on_team"),
+ ("posthog", "0258_team_recording_domains"),
+ ("posthog", "0259_backfill_team_recording_domains"),
+ ("posthog", "0260_pak_v2"),
+ ("posthog", "0261_team_capture_console_log_opt_in"),
+ ("posthog", "0262_track_viewed_notifications"),
+ ("posthog", "0263_plugin_config_web_token"),
+ ("posthog", "0264_user_partial_notification_settings"),
+ ("posthog", "0265_related_tiles"),
+ ("posthog", "0266_add_is_system_field_to_activity_log"),
+ ("posthog", "0267_add_text_tiles"),
+ ("posthog", "0268_plugin_source_file_updated_at"),
+ ("posthog", "0269_soft_delete_tiles"),
+ ("posthog", "0270_add_uploaded_media"),
+ ("posthog", "0271_delete_promptsequencestate"),
+ ("posthog", "0272_alter_organization_plugins_access_level"),
+ ("posthog", "0273_mark_inactive_exports_as_finished"),
+ ("posthog", "0274_add_plugin_icon_and_rewrite_urls"),
+ ("posthog", "0275_feature_flag_rollback_fields"),
+ ("posthog", "0276_organization_usage"),
+ ("posthog", "0277_recording_playlist_model"),
+ ("posthog", "0278_organization_customer_id"),
+ ("posthog", "0279_recording_playlist_item_model"),
+ ("posthog", "0280_fix_async_deletion_team"),
+ ("posthog", "0281_create_insight_caching_state_model"),
+ ("posthog", "0282_fix_insight_caching_state_model"),
+ ("posthog", "0283_prompt_sequence_model"),
+ ("posthog", "0284_improved_caching_state_idx"),
+ ("posthog", "0285_capture_performance_opt_in"),
+ ("posthog", "0286_index_insightcachingstate_lookup"),
+ ("posthog", "0287_add_session_recording_model"),
+ ("posthog", "0288_add_session_recording_persistence"),
+ ("posthog", "0289_add_tags_to_feature_flags"),
+ ("posthog", "0290_add_dashboard_templates"),
+ ("posthog", "0291_create_person_override_model"),
+ ("posthog", "0292_property_definitions_persons_and_groups_support"),
+ ("posthog", "0293_property_definitions_drop_old_constraint"),
+ ("posthog", "0294_plugin_blank_fields"),
+ ("posthog", "0295_plugin_allow_blank_config_schema"),
+ ("posthog", "0296_team_allow_blank_fields"),
+ ("posthog", "0297_property_definitions_index_query"),
+ ("posthog", "0298_add_insight_queries"),
+ ("posthog", "0299_set_templates_global"),
+ ("posthog", "0300_add_constraints_to_person_override"),
+ ("posthog", "0301_organization_enforce_2fa"),
+ ("posthog", "0302_add_user_pending_email_and_is_verified"),
+ ("posthog", "0303_team_session_recording_version"),
+ ("posthog", "0304_store_dashboard_template_in_db"),
+ ("posthog", "0305_rework_person_overrides"),
+ ("posthog", "0306_featureflag_dashboard"),
+ ("posthog", "0307_pluginconfig_admin"),
+ ("posthog", "0308_add_indirect_person_override_constraints"),
+ ("posthog", "0309_team_autocapture_opt_out"),
+ ("posthog", "0310_add_starter_dashboard_template"),
+ ("posthog", "0311_dashboard_template_scope"),
+ ("posthog", "0312_organization_available_product_features"),
+ ("posthog", "0313_early_access_feature"),
+ ("posthog", "0314_sharingconfiguration_recording"),
+ ("posthog", "0315_notebook"),
+ ("posthog", "0316_action_href_text_matching"),
+ ("posthog", "0317_batch_export_models"),
+ ("posthog", "0318_alter_earlyaccessfeature_stage"),
+ ("posthog", "0319_user_requested_password_reset_at"),
+ ("posthog", "0320_survey"),
+ ("posthog", "0321_add_exception_autocapture_optin"),
+ ("posthog", "0322_auto_20230531_1904"),
+ ("posthog", "0323_alter_batchexportdestination_type"),
+ ("posthog", "0324_user_has_seen_product_intro_for"),
+ ("posthog", "0325_alter_dashboardtemplate_scope"),
+ ("posthog", "0326_team_extra_settings"),
+ ("posthog", "0327_alter_earlyaccessfeature_stage"),
+ ("posthog", "0328_add_starter_feature_flag_template"),
+ ("posthog", "0329_datawarehousecredential_datawarehousetable"),
+ ("posthog", "0330_add_autocapture_exceptions_events_to_ignore"),
+ ("posthog", "0331_add_missing_property_definition_index"),
+ ("posthog", "0332_featureflag_has_enriched_analytics"),
+ ("posthog", "0333_add_timestamp_fields_to_batch_exports"),
+ ("posthog", "0334_add_asset_ttl"),
+ ("posthog", "0335_alter_asyncdeletion_deletion_type"),
+ ("posthog", "0336_alter_survey_type"),
+ ("posthog", "0337_more_session_recording_fields"),
+ ("posthog", "0338_datawarehouse_saved_query"),
+ ("posthog", "0339_add_user_scene_personalisation"),
+ ("posthog", "0340_action_bytecode"),
+ ("posthog", "0341_add_session_recording_storage_version"),
+ ("posthog", "0342_alter_featureflag_usage_dashboard"),
+ ("posthog", "0343_team_has_completed_onboarding_for"),
+ ("posthog", "0344_add_new_export_type"),
+ ("posthog", "0345_view_link_and_s3_table_update"),
+ ("posthog", "0346_team_week_start_day"),
+ ("posthog", "0347_add_bigquery_export_type"),
+ ("posthog", "0348_alter_datawarehousetable_format"),
+ ("posthog", "0349_update_survey_query_name"),
+ ("posthog", "0350_add_notebook_text_content"),
+ ("posthog", "0351_team_surveys_opt_in"),
+ ("posthog", "0352_auto_20230926_1833"),
+ ("posthog", "0353_add_5_minute_interval_to_batch_exports"),
+ ("posthog", "0354_organization_never_drop_data"),
+ ("posthog", "0355_add_batch_export_backfill_model"),
+ ("posthog", "0356_add_replay_cost_control"),
+ ("posthog", "0357_add_redshift_batch_export_destination"),
+ ("posthog", "0358_externaldatasource"),
+ ("posthog", "0359_team_external_data_workspace_id"),
+ ("posthog", "0360_externaldatasource_destination_id"),
+ ("posthog", "0361_add_plugin_config_ui_fields"),
+ ("posthog", "0362_alter_experiment_feature_flag"),
+ ("posthog", "0363_add_replay_payload_capture_config"),
+ ("posthog", "0364_team_external_data_workspace_rows"),
+ ("posthog", "0365_update_created_by_flag_constraint"),
+ ("posthog", "0366_alter_action_created_by"),
+ ("posthog", "0367_job_inputs"),
+ ("posthog", "0368_externaldatasource_prefix"),
+ ("posthog", "0369_user_theme_mode"),
+ ("posthog", "0370_externaldatajob_workflow_id"),
+ ("posthog", "0371_pendingpersonoverride"),
+ ("posthog", "0372_cohort_query"),
+ ("posthog", "0373_externaldataschema"),
+ ("posthog", "0374_scheduled_change"),
+ ("posthog", "0375_alter_survey_type"),
+ ("posthog", "0376_externaldataschema_last_synced_at"),
+ ("posthog", "0377_flatpersonoverride"),
+ ("posthog", "0378_alter_user_theme_mode"),
+ ("posthog", "0379_alter_scheduledchange"),
+ ("posthog", "0380_add_comments"),
+ ("posthog", "0381_alter_externaldatasource_source_type"),
+ ("posthog", "0382_user_strapi_id"),
+ ("posthog", "0383_externaldatasource_cascade"),
+ ("posthog", "0384_activity_log_was_impersonated"),
+ ("posthog", "0385_exception_autocapture_off_for_all"),
+ ("posthog", "0386_add_session_replay_config_to_team"),
+ ("posthog", "0387_alter_externaldatasource_source_type"),
+ ("posthog", "0388_add_schema_to_batch_exports"),
+ ("posthog", "0389_alter_batchexportdestination_type"),
+ ("posthog", "0390_personalapikey_scopes"),
+ ("posthog", "0391_alter_batchexportbackfill_status_and_more"),
+ ("posthog", "0392_alter_exportedasset_export_format"),
+ ("posthog", "0393_datawarehousejoin_delete_datawarehouseviewlink"),
+ ("posthog", "0394_organization_customer_trust_scores_and_more"),
+ ("posthog", "0395_alter_batchexportbackfill_end_at"),
+ ("posthog", "0396_projects_and_environments"),
+ ("posthog", "0397_projects_backfill"),
+ ("posthog", "0398_alter_externaldatasource_source_type"),
+ ("posthog", "0399_batchexportrun_records_total_count"),
+ ("posthog", "0400_datawarehousetable_row_count"),
+ ("posthog", "0401_experiment_exposure_cohort"),
+ ("posthog", "0402_externaldatajob_schema"),
+ ("posthog", "0403_plugin_has_private_access"),
+ ("posthog", "0404_remove_propertydefinition_property_type_is_valid_and_more"),
+ ("posthog", "0405_team_heatmaps_opt_in"),
+ ("posthog", "0406_survey_responses_limit"),
+ ("posthog", "0407_verbose_name_for_team_model"),
+ ("posthog", "0408_team_modifiers"),
+ ("posthog", "0409_action_steps_json_alter_actionstep_action"),
+ ("posthog", "0410_action_steps_population"),
+ ("posthog", "0411_eventproperty_indexes"),
+ ("posthog", "0412_proxyrecord"),
+ ("posthog", "0413_user_hedgehog_config"),
+ ("posthog", "0414_personalapikey_mask_value"),
+ ("posthog", "0415_pluginconfig_match_action"),
+ ("posthog", "0416_survey_internal_targeting_flag"),
+ ("posthog", "0417_remove_organizationmembership_only_one_owner_per_organization_and_more"),
+ ("posthog", "0418_pluginconfig_filters"),
+ ("posthog", "0419_remove_organization_available_features"),
+ ("posthog", "0420_alert"),
+ ("posthog", "0421_set_all_survey_responses_to_be_strings"),
+ ("posthog", "0422_proxyrecord_message"),
+ ("posthog", "0423_alter_externaldatasource_source_type"),
+ ("posthog", "0424_survey_current_iteration_and_more"),
+ ("posthog", "0425_hogfunction"),
+ ("posthog", "0426_externaldatasource_sync_frequency"),
+ ("posthog", "0427_hogfunction_icon_url_hogfunction_template_id"),
+ ("posthog", "0428_externaldataschema_sync_type"),
+ ("posthog", "0429_alter_datawarehousetable_format"),
+ ("posthog", "0430_batchexport_model"),
+ ("posthog", "0431_externaldataschema_sync_type_payload"),
+ ("posthog", "0432_personlessdistinctid"),
+ ("posthog", "0433_dashboard_idx_dashboard_deleted_team_id"),
+ ("posthog", "0434_add_web_vitals_opt_in"),
+ ("posthog", "0435_alter_action_slack_message_format"),
+ ("posthog", "0436_alter_proxyrecord_status"),
+ ("posthog", "0437_externaldataschema_sync_frequency"),
+ ("posthog", "0438_errortrackinggroup"),
+ ("posthog", "0439_survey_actions"),
+ ("posthog", "0440_organizationinvite_private_project_access"),
+ ("posthog", "0441_alter_datawarehousetable_format"),
+ ("posthog", "0442_alter_survey_questions"),
+ ("posthog", "0443_externaldatajob_workflow_run_id"),
+ ("posthog", "0444_integration_unique_id"),
+ ("posthog", "0445_require_team_project_id_not_valid"),
+ ("posthog", "0446_annotation_dashboard_alter_annotation_scope"),
+ ("posthog", "0447_alter_integration_kind"),
+ ("posthog", "0448_add_mysql_externaldatasource_source_type"),
+ ("posthog", "0449_alter_plugin_organization_alter_plugin_plugin_type_and_more"),
+ ("posthog", "0450_externaldataschema_sync_frequency_interval_and_more"),
+ ("posthog", "0451_datawarehousetable_updated_at_and_more"),
+ ("posthog", "0452_organization_logo"),
+ ("posthog", "0453_alter_errortrackinggroup_fingerprint_and_more"),
+ ("posthog", "0454_alter_datawarehousetable_format"),
+ ("posthog", "0455_alter_externaldatasource_source_type"),
+ ("posthog", "0456_hogfunction_masking"),
+ ("posthog", "0457_datawarehousejoin_deleted_at_and_more"),
+ ("posthog", "0458_alter_insightviewed_team_alter_insightviewed_user"),
+ ("posthog", "0459_convert_personsnode_insights_to_actorsquery"),
+ ("posthog", "0460_alertconfiguration_threshold_alertsubscription_and_more"),
+ ("posthog", "0461_alter_externaldatasource_source_type"),
+ ("posthog", "0462_change_replay_team_setting_defaults"),
+ ("posthog", "0463_datawarehousemodelpath_and_more"),
+ ("posthog", "0464_action_pinned_at"),
+ ("posthog", "0465_datawarehouse_stripe_account"),
+ ("posthog", "0466_alter_externaldatasource_source_type"),
+ ("posthog", "0467_add_web_vitals_allowed_metrics"),
+ ("posthog", "0468_integration_google_pubsub"),
+ ("posthog", "0469_datawarehousesavedquery_at_and_more"),
+ ("posthog", "0470_integration_google_cloud_storage"),
+ ("posthog", "0471_webexperiment_experiment_type_experiment_variants"),
+ ("posthog", "0472_experiment_metrics"),
+ ("posthog", "0473_dashboardtemplate_availability_contexts"),
+ ("posthog", "0474_hogfunction_encrypted_inputs"),
+ ("posthog", "0475_alter_externaldatasource_source_type"),
+ ("posthog", "0476_alter_integration_sensitive_config"),
+ ("posthog", "0477_datawarehouse_salesforce_order"),
+ ("posthog", "0478_migrate_encrypted_fields"),
+ ("posthog", "0479_alter_sensitive_config_2"),
+ ("posthog", "0480_insightvariable"),
+ ("posthog", "0481_insightvariable_code_name"),
+ ("posthog", "0482_alertconfiguration_calculation_interval_and_more"),
+ ("posthog", "0483_datawarehousesavedquery_table"),
+ ("posthog", "0484_productintent"),
+ ("posthog", "0485_alter_datawarehousesavedquery_status"),
+ ("posthog", "0486_cohort_last_error_at"),
+ ("posthog", "0487_team_survey_config"),
+ ("posthog", "0488_alter_user_is_active"),
+ ("posthog", "0489_alter_integration_kind"),
+ ("posthog", "0490_dashboard_variables"),
+ ("posthog", "0491_alertconfiguration_snoozed_until_and_more"),
+ ("posthog", "0492_team_session_recording_url_trigger_config"),
+ ("posthog", "0493_insightvariable_values"),
+ ("posthog", "0494_team_project_non_null"),
+ ("posthog", "0495_alter_batchexportbackfill_start_at_and_more"),
+ ("posthog", "0496_team_person_processing_opt_out"),
+ ("posthog", "0497_experimentholdout_experiment_holdout"),
+ ("posthog", "0498_errortrackingissuefingerprint_and_more"),
+ ("posthog", "0499_hog_function_type"),
+ ("posthog", "0500_errortrackingsymbolset_errortrackingstackframe_and_more"),
+ ("posthog", "0501_create_group_billing_team"),
+ ("posthog", "0502_team_session_recording_url_blocklist_config"),
+ ("posthog", "0503_experimentsavedmetric_experimenttosavedmetric_and_more"),
+ ("posthog", "0504_add_dead_clicks_setting"),
+ ("posthog", "0505_grouptypemapping_project"),
+ ("posthog", "0506_productintent_activated_at_and_more"),
+ ("posthog", "0507_alter_externaldatasource_source_type"),
+ ("posthog", "0508_project_product_description"),
+ ("posthog", "0509_errortrackingsymbolset_failure_reason"),
+ ("posthog", "0510_salesforce_missing_schemas"),
+ ("posthog", "0511_grouptypemapping_project_backfill"),
+ ("posthog", "0512_errortrackingissue_errortrackingissuefingerprintv2_and_more"),
+ ("posthog", "0513_alter_dashboardtemplate_github_url"),
+ ("posthog", "0514_errortrackingstackframe_context"),
+ ("posthog", "0515_grouptypemapping_project_non_null"),
+ ("posthog", "0516_team_session_recording_event_trigger_config"),
+ ("posthog", "0517_survey_response_sampling_fields"),
+ ("posthog", "0518_survey_internal_response_sampling_flag"),
+ ("posthog", "0519_errortrackingissue_description_and_more"),
+ ("posthog", "0520_experiment_metrics_secondary"),
+ ("posthog", "0521_alter_errortrackingstackframe_context"),
+ ("posthog", "0522_datawarehouse_salesforce_opportunity"),
+ ("posthog", "0523_errortrackingsymbolset_content_hash"),
+ ("posthog", "0524_datawarehousejoin_configuration"),
+ ("posthog", "0525_hog_function_transpiled"),
+ ("posthog", "0526_remoteconfig"),
+ ("posthog", "0527_project_name_sync"),
+ ("posthog", "0528_project_field_in_taxonomy"),
+ ("posthog", "0529_hog_function_mappings"),
+ ("posthog", "0530_convert_dashboard_templates_to_queries"),
+ ("posthog", "0531_alter_hogfunction_type"),
+ ("posthog", "0532_taxonomy_unique_on_project"),
+ ("posthog", "0533_externaldatajob_pipeline_version"),
+ ("posthog", "0534_team_cookieless_server_hash_mode"),
+ ("posthog", "0535_alter_hogfunction_type"),
+ ("posthog", "0536_alertconfiguration_skip_weekend"),
+ ("posthog", "0537_data_color_themes"),
+ ("posthog", "0538_experiment_stats_config"),
+ ("posthog", "0539_user_role_at_organization"),
+ ("posthog", "0540_team_human_friendly_comparison_periods"),
+ ("posthog", "0541_usergroup_usergroupmembership_usergroup_members_and_more"),
+ ("posthog", "0542_remove_errortrackingissueassignment_unique_on_user_and_issue_and_more"),
+ ("posthog", "0543_alter_batchexportdestination_config"),
+ ("posthog", "0544_team_flags_persistence_default"),
+ ("posthog", "0545_insight_filters_to_query"),
+ ("posthog", "0546_update_creation_mode_on_generated_dashboards"),
+ ("posthog", "0547_externaldatajob_billable"),
+ ("posthog", "0548_migrate_early_access_features"),
+ ("posthog", "0549_add_revenue_tracking_config_to_team"),
+ ("posthog", "0550_migrate_action_webhooks_to_destinations"),
+ ("posthog", "0551_batchimport"),
+ ("posthog", "0552_turn_off_all_action_webhooks"),
+ ("posthog", "0553_feature_flag_config"),
+ ("posthog", "0554_remove_incremental_field_last_value_v2"),
+ ("posthog", "0555_batchexport_filters"),
+ ("posthog", "0556_add_execution_order_to_hog_functions"),
+ ("posthog", "0557_add_tags_to_experiment_saved_metrics"),
+ ("posthog", "0558_alter_integration_kind"),
+ ("posthog", "0559_team_api_query_rate_limit"),
+ ("posthog", "0660_organization_is_ai_data_processing_approved"),
+ ("posthog", "0661_errortrackingissuefingerprintv2_first_seen"),
+ ("posthog", "0662_alter_batchexport_model"),
+ ("posthog", "0663_alter_insightvariable_type"),
+ ("posthog", "0664_batchexportrun_backfill"),
+ ("posthog", "0665_team_onboarding_tasks"),
+ ("posthog", "0666_datawarehousesavedquery_sync_frequency"),
+ ("posthog", "0667_encrypt_feature_flag_config"),
+ ("posthog", "0668_hostdefinition_and_more"),
+ ("posthog", "0669_file_system"),
+ ("posthog", "0670_querytabstate_querytabstate_unique_team_created_by"),
+ ("posthog", "0671_alter_errortrackingissuefingerprintv2_issue"),
+ ("posthog", "0672_resave_hogFns_from_token_refresh_incident"),
+ ("posthog", "0673_survey_schedule"),
+ ("posthog", "0674_experiment_exposure_criteria"),
+ ("posthog", "0675_add_playlist_viewed"),
+ ("posthog", "0676_team_session_recording_masking_config"),
+ ("posthog", "0677_datawarehousesavedquery_deleted_name"),
+ ("posthog", "0678_alter_team_options"),
+ ("posthog", "0679_feature_flag_concurrency"),
+ ("posthog", "0680_alter_integration_kind"),
+ ("posthog", "0681_file_system_depth"),
+ ("posthog", "0682_datawarehousesavedquery_latest_error"),
+ ("posthog", "0683_externaldataschema_sync_time_of_day"),
+ ("posthog", "0684_action_embedding_last_synced_at_and_more"),
+ ("posthog", "0685_add_playlist_counted_date"),
+ ("posthog", "0686_alter_errortrackingissue_status"),
+ ("posthog", "0687_remove_taxonomy_team_only_constraints"),
+ ("posthog", "0688_update_default_version"),
+ ("posthog", "0689_survey_enable_partial_responses"),
+ ("posthog", "0690_alter_personid_persondistinctid"),
+ ("posthog", "0691_action_embedding_version"),
+ ("posthog", "0692_grouptypemapping_detail_dashboard"),
+ ("posthog", "0693_grouptypemapping_default_columns"),
+ ("posthog", "0694_fix_revenue_tracking_config"),
+ ("posthog", "0695_alter_experiment_end_date_and_more"),
+ ("posthog", "0696_file_system_project_id"),
+ ("posthog", "0697_sessionrecording_full_recording_v2_path"),
+ ("posthog", "0698_action_project"),
+ ("posthog", "0699_alter_integration_kind"),
+ ("posthog", "0700_datamodelingjob"),
+ ("posthog", "0701_uploadedmedia_project"),
+ ("posthog", "0702_datacolortheme_project"),
+ ("posthog", "0703_dashboard_breakdown_colors_and_more"),
+ ("posthog", "0704_productintent_contexts"),
+ ("posthog", "0705_team_parent_team"),
+ ("posthog", "0706_alter_hogfunction_kind"),
+ ("posthog", "0707_file_system_shortcut"),
+ ("posthog", "0708_add_trigger_match_type"),
+ ("posthog", "0709_alter_integration_kind"),
+ ("posthog", "0710_add_salesforce_tables"),
+ ("posthog", "0711_externaldatasource_revenue_analytics_enabled"),
+ ("posthog", "0712_add_message_template_table"),
+ ("posthog", "0713_errortrackingassignmentrule"),
+ ("posthog", "0714_alter_team_session_recording_minimum_duration_milliseconds"),
+ ("posthog", "0715_teamrevenueanalyticsconfig"),
+ ("posthog", "0716_backfill_team_revenue_analytics_config"),
+ ("posthog", "0717_errortrackingassignmentrule_role_and_more"),
+ ("posthog", "0718_eventingestionrestrictionconfig"),
+ ("posthog", "0719_replace_person_with_person_display_name_in_live_events_columns"),
+ ("posthog", "0720_add_hog_function_template_model"),
+ ("posthog", "0721_eventingestionrestrictionconfig_note"),
+ ("posthog", "0722_alter_datamodelingjob_status"),
+ ("posthog", "0723_add_help_text_to_cohorts"),
+ ("posthog", "0724_errortrackinggroupingrule"),
+ ("posthog", "0725_file_system_cleanup"),
+ ("posthog", "0726_team_secret_api_token_and_backup"),
+ ("posthog", "0727_team_secret_api_token_unique"),
+ ("posthog", "0728_experiment_conclusion_experiment_conclusion_comment"),
+ ("posthog", "0729_sessionrecordingplaylist_type"),
+ ("posthog", "0730_add_hog_function_template_as_fk_to_hog_function"),
+ ("posthog", "0731_backfill_hog_function_template_fk"),
+ ("posthog", "0732_teamrevenueanalyticsconfig_notified_first_sync"),
+ ("posthog", "0733_file_system_shortcut"),
+ ("posthog", "0734_add_links_model"),
+ ("posthog", "0735_rename_posthog_lin_short_l_33b439_idx_domain_short_code_idx_and_more"),
+ ("posthog", "0736_externaldatajob_finished_at"),
+ ("posthog", "0737_experiment_deleted"),
+ ("posthog", "0738_persisted_folder"),
+ ("posthog", "0739_teamrevenueanalyticsconfig__goals"),
+ ("posthog", "0740_insight_dashboarditem_query_gin"),
+ ("posthog", "0741_experimentsavedmetric_metadata"),
+ ("posthog", "0742_exportedasset_exception"),
+ ("posthog", "0743_errortrackingrelease_errortrackingsymbolset_release_and_more"),
+ ("posthog", "0744_datawarehousetable_size_in_s3_mib"),
+ ("posthog", "0745_oauthaccesstoken_oauthapplication_oauthrefreshtoken_and_more"),
+ ("posthog", "0746_alter_externaldatasource_source_type"),
+ ("posthog", "0747_alter_externaldatasource_source_type"),
+ ("posthog", "0748_update_featureflag_super_groups"),
+ ("posthog", "0749_modify_errortrackingstackframe_symbolset_relation"),
+ ("posthog", "0750_dwh_model_statuses"),
+ ("posthog", "0751_errortrackingsuppressionrule"),
+ ("posthog", "0752_organization_members_can_invite"),
+ ("posthog", "0753_remove_posthog_person_email_index"),
+ ("posthog", "0754_organization_is_platform"),
+ ("posthog", "0755_add_recording_scope_annotations"),
+ ("posthog", "0756_errortrackingsymbolset_last_used"),
+ ("posthog", "0757_organization_session_cookie_age"),
+ ("posthog", "0758_alter_externaldatasource_source_type"),
+ ("posthog", "0759_add_errortrackingsymbolset_last_used_index"),
+ ("posthog", "0760_alter_person_is_user"),
+ ("posthog", "0761_drop_is_user_fk_and_index"),
+ ("posthog", "0762_team_base_currency"),
+ ("posthog", "0763_migrate_team_base_currency"),
+ ("posthog", "0764_teammarketinganalyticsconfig"),
+ ("posthog", "0765_hogflows"),
+ ("posthog", "0766_fix_sub_template_ids_to_template_ids"),
+ ("posthog", "0767_batchimport_created_by_id"),
+ ("posthog", "0768_messagerecipientpreference_messagecategory"),
+ ("posthog", "0769_organization_default_experiment_stats_method"),
+ ("posthog", "0770_alter_hogflow_conversion_and_more"),
+ ("posthog", "0771_teamrevenueanalyticsconfig_filter_test_accounts_and_more"),
+ ("posthog", "0772_alter_externaldataschema_sync_type"),
+ ("posthog", "0773_teammarketinganalyticsconfig__conversion_goals"),
+ ("posthog", "0774_batchimport_display_status_message"),
+ ("posthog", "0775_survey_is_publicly_shareable"),
+ ("posthog", "0776_move_stripe_to_append"),
+ ("posthog", "0777_alter_externaldatasource_source_type"),
+ ("posthog", "0778_dashboard_last_refresh"),
+ ("posthog", "0779_alter_integration_kind"),
+ ("posthog", "0780_errortrackingexternalreference"),
+ ("posthog", "0781_alter_externaldatasource_source_type"),
+ ("posthog", "0782_remove_segment_hidden_destinations"),
+ ("posthog", "0783_remove_segment_engage_destinations"),
+ ("posthog", "0784_fix_null_event_triggers"),
+ ("posthog", "0785_team_drop_events_older_than_seconds"),
+ ("posthog", "0786_add_is_emoji_to_annotation"),
+ ("posthog", "0787_alter_externaldatasource_source_type"),
+ ("posthog", "0788_organization_members_can_create_personal_api_keys"),
+ ("posthog", "0789_migrate_playlist_types"),
+ ("posthog", "0790_alter_integration_kind"),
+ ("posthog", "0791_errortrackingexternalreference_external_context_and_more"),
+ ("posthog", "0792_alter_proxyrecord_status"),
+ ("posthog", "0793_team_feature_flag_confirmation"),
+ ("posthog", "0794_fix_stripe_tables"),
+ ("posthog", "0795_add_progress_tracking_to_datamodelingjob"),
+ ("posthog", "0796_fix_revenue_analytics_modifiers_in_queries"),
+ ("posthog", "0797_batchexportrun_bytes_exported"),
+ ("posthog", "0798_alter_integration_kind"),
+ ("posthog", "0799_migrate_playlist_types_take_2"),
+ ("posthog", "0800_add_sharing_token_rotation_fields"),
+ ("posthog", "0801_messagecategory_category_type_and_more"),
+ ("posthog", "0802_messagecategory_category_type_and_more_fix"),
+ ("posthog", "0803_move_recording_annotation_to_comments"),
+ ("posthog", "0804_add_rich_content_json_to_comment"),
+ ("posthog", "0805_alter_survey_type"),
+ ("posthog", "0806_scheduledchange_failure_count_and_more"),
+ ("posthog", "0807_dwh_source_refactor"),
+ ("posthog", "0808_add_evaluation_environment_to_feature_flag"),
+ ("posthog", "0809_insight_query_metadata"),
+ ("posthog", "0810_alter_hogfunctiontemplate_icon_url"),
+ ("posthog", "0811_personalapikey_last_rolled_at"),
+ ("posthog", "0812_sessionrecordingviewed_bulk_viewed"),
+ ("posthog", "0813_alter_messagecategory_category_type_and_more"),
+ ("posthog", "0814_datawarehousesavedquerydraft"),
+ ("posthog", "0815_sharingconfiguration_settings"),
+ ("posthog", "0816_notebook_visibility"),
+ ("posthog", "0817_resourcenotebook_and_more"),
+ ("posthog", "0818_alter_integration_kind"),
+ ("posthog", "0819_alter_integration_kind"),
+ ("posthog", "0820_organization_allow_publicly_shared_resources"),
+ ("posthog", "0821_batchimport_backoff_columns"),
+ ("posthog", "0822_person_properties_size_constraint"),
+ ("posthog", "0823_add_cohort_types"),
+ ("posthog", "0824_team_session_recording_retention_period"),
+ ("posthog", "0825_groupusagemetric_groupusagemetric_unique_metric_name"),
+ ("posthog", "0826_organizationintegration_and_more"),
+ ("posthog", "0827_add_web_analytics_pre_aggregated_tables_enabled_to_team"),
+ ("posthog", "0828_grouptypemapping_created_at"),
+ ("posthog", "0829_organization_default_role"),
+ ("posthog", "0830_add_evaluation_runtimes_to_featureflags"),
+ ("posthog", "0831_alter_groupusagemetric_bytecode_and_more"),
+ ("posthog", "0832_alter_exportedasset_export_format"),
+ ("posthog", "0833_experiment_primary_metrics_ordered_uuids_and_more"),
+ ("posthog", "0834_alter_resourcenotebook_group"),
+ ("posthog", "0835_alter_externaldatasource_source_type"),
+ ("posthog", "0836_sessionrecording_retention_period_days"),
+ ("posthog", "0837_alter_externaldatasource_source_type"),
+ ("posthog", "0838_remove_null_values_from_team_arrays"),
+ ("posthog", "0839_alter_integration_kind"),
+ ("posthog", "0840_externaldatasourcerevenueanalyticsconfig"),
+ ("posthog", "0841_backfill_eds_revenue_analytics_config"),
+ ("posthog", "0842_alter_externaldatasourcerevenueanalyticsconfig_external_data_source"),
+ ("posthog", "0843_datawarehousesavedquery_is_materialized"),
+ ("posthog", "0844_alter_externaldatasource_source_type"),
+ ("posthog", "0845_delete_invalid_personalapikeys"),
+ ("posthog", "0846_add_share_password_model"),
+ ("posthog", "0847_alter_batchexportrun_status"),
+ ("posthog", "0848_activitylog_detail_gin_index"),
+ ("posthog", "0849_duplicate_warehouse_tables"),
+ ("posthog", "0850_add_activitylog_org_scope_created_at"),
+ ("posthog", "0851_add_activitylog_org_detail_exists_index"),
+ ("posthog", "0852_alter_integration_kind"),
+ ("posthog", "0853_create_index_populate_updated_at_flags"),
+ ("posthog", "0854_add_activitylog_detail_gin_path_ops_index"),
+ ("posthog", "0855_alter_exportedasset_export_format"),
+ ("posthog", "0856_add_web_analytics_tables_version"),
+ ("posthog", "0857_dashboardtile_filters_overrides"),
+ ("posthog", "0858_datamodelingjob_storage_delta_mib_and_more"),
+ ("posthog", "0859_alter_team_session_recording_retention_period"),
+ ("posthog", "0860_add_namedquery"),
+ ("posthog", "0861_alter_survey_questions"),
+ ("posthog", "0862_alter_team_session_recording_retention_period"),
+ ("posthog", "0863_experimentmetricresult"),
+ ("posthog", "0864_create_feature_flag_evaluation_tag_table"),
+ ("posthog", "0865_remove_experimentmetricresult_posthog_exp_experim_b5f6d4_idx_and_more"),
+ ("posthog", "0866_add_integration_to_batch_export_destination"),
+ ("posthog", "0867_add_updated_at_to_feature_flags"),
+ ("posthog", "0868_move_recording_activity_log_to_replay"),
+ ("posthog", "0869_create_cohort_calculation_history"),
+ ("posthog", "0870_move_recording_coment_to_replay"),
+ ("posthog", "0871_team_experiment_recalculation_time"),
+ ("posthog", "0872_alter_externaldatasource_source_type"),
+ ("posthog", "0873_alter_cohortpeople_options_and_more"),
+ ("posthog", "0874_activitylog_idx_alog_org_created_at_and_more"),
+ ("posthog", "0875_activitylog_idx_alog_team_scope_created"),
+ ("posthog", "0876_add_marketing_analytics_attribution_settings"),
+ ("posthog", "0877_delete_named_query_from_state"),
+ ("posthog", "0878_alter_externaldatasource_source_type"),
+ ("posthog", "0879_migrate_error_tracking_models"),
+ ("posthog", "0880_datawarehousetable_queryable_folder"),
+ ("posthog", "0881_alter_integration_kind"),
+ ("posthog", "0882_add_team_default_evaluation_tags"),
+ ("posthog", "0883_featureflag_last_called_at"),
+ ("posthog", "0884_experimenttimeseriesrecalculation_and_more"),
+ ("posthog", "0885_migrate_notebooks_models"),
+ ("posthog", "0886_fake_social_django_jsonfield_migrations"),
+ ("posthog", "0887_drop_named_query"),
+ ("posthog", "0888_datawarehousemanagedviewset_and_more"),
+ ("posthog", "0889_add_schema_models"),
+ ("posthog", "0890_add_campaign_name_mappings"),
+ ("posthog", "0891_file_system_view_log"),
+ ("posthog", "0892_alter_integration_kind"),
+ ("posthog", "0893_add_ingestion_lane_fields_to_event_ingestion_restriction"),
+ ("posthog", "0894_organizationdomain_scim_bearer_token_and_more"),
+ ("posthog", "0895_savedheatmap_heatmapsnapshot_and_more"),
+ ("posthog", "0896_alter_externaldatasource_source_type"),
+ ("posthog", "0897_migrate_data_warehouse_models"),
+ ("posthog", "0898_hogflow_variables"),
+ ("posthog", "0899_add_cohort_type"),
+ ("posthog", "0900_team_receive_org_level_activity_logs"),
+ ("posthog", "0901_add_object_property_type"),
+ ("posthog", "0902_user_pinned_scene_tabs"),
+ ("posthog", "0903_organization_default_anonymize_ips"),
+ ("posthog", "0904_alter_dashboard_creation_mode"),
+ ("posthog", "0905_alter_person_table"),
+ ("posthog", "0906_user_allow_sidebar_suggestions"),
+ ("posthog", "0907_alter_persistedfolder_type"),
+ ("posthog", "0908_userproductlist"),
+ ("posthog", "0909_survey_add_linked_insight_id"),
+ ("posthog", "0910_userproductlist_reason_text"),
+ ("posthog", "0911_surveyresponsearchive_and_more"),
+ ("posthog", "0912_alter_survey_linked_insight_type"),
+ ("posthog", "0913_alter_survey_linked_insight"),
+ ("posthog", "0914_alter_userproductlist_reason"),
+ ("posthog", "0915_alter_userproductlist_reason"),
+ ("posthog", "0916_alter_userproductlist_reason"),
+ ("posthog", "0917_alter_survey_linked_insight"),
+ ("posthog", "0918_add_column_configurator"),
+ ("posthog", "0919_teammarketinganalyticsconfig__custom_source_mappings"),
+ ("posthog", "0920_alter_integration_kind"),
+ ("posthog", "0921_teammarketinganalyticsconfig__campaign_field_preferences_and_more"),
+ ("posthog", "0922_remove_persons_db_team_fks"),
+ ("posthog", "0923_add_quick_filters"),
+ ("posthog", "0924_alter_survey_questions"),
+ ("posthog", "0925_team_business_model"),
+ ("posthog", "0926_featureflag_bucketing_identifier"),
+ ("posthog", "0927_changerequest_approvalpolicy_approval_and_more"),
+ ("posthog", "0928_add_team_require_evaluation_tags"),
+ ("posthog", "0929_remove_legacy_batch_export_notification_setting"),
+ ("posthog", "0930_user_shortcut_position"),
+ ("posthog", "0931_materialized_column_slots"),
+ ("posthog", "0932_add_session_ids_to_restriction_config"),
+ ("posthog", "0933_add_event_names_and_uuids_to_restriction_config"),
+ ("posthog", "0934_cohortcalculationhistory_cohort_started_idx"),
+ ("posthog", "0935_cohortcalculationhistory_error_code"),
+ ("posthog", "0936_survey_headline_response_count_and_more"),
+ ("posthog", "0937_remove_redundant_cohortcalculationhistory_indexes"),
+ ("posthog", "0938_add_redirect_to_dlq_restriction_type"),
+ ("posthog", "0939_team_product_tours_opt_in"),
+ ("posthog", "0940_user_allow_impersonation"),
+ ("posthog", "0941_add_exported_recording_model"),
+ ("posthog", "0942_llm_prompt"),
+ ("posthog", "0943_llm_prompt_unique_name"),
+ ("posthog", "0944_organization_is_active_and_more"),
+ ("posthog", "0945_scheduledchange_recurring_fields"),
+ ("posthog", "0946_fix_insightviewed_null_duplicates"),
+ ("posthog", "0947_insightviewed_null_unique_index"),
+ ("posthog", "0948_hogfunction_batch_export_and_more"),
+ ("posthog", "0949_alter_batchexportdestination_type"),
+ ("posthog", "0950_add_exception_type_to_exported_asset"),
+ ("posthog", "0951_hogflowtemplate"),
+ ("posthog", "0952_add_billable_action_to_hogflows"),
+ ("posthog", "0953_create_core_event"),
+ ("posthog", "0954_experiment_scheduling_config"),
+ ("posthog", "0955_alter_organization_is_ai_data_processing_approved"),
+ ("posthog", "0956_team_conversations_enabled_and_more"),
+ ("posthog", "0957_refactor_core_events_to_table"),
+ ("posthog", "0958_drop_teamcoreeventsconfig_table"),
+ ("posthog", "0959_survey_question_summaries"),
+ ("posthog", "0960_remove_dashboardtemplate_unique_template_name_per_team_and_more"),
+ ("posthog", "0961_session_recording_external_reference"),
+ ("posthog", "0962_webanalyticsfilterpreset"),
+ ("posthog", "0963_add_azure_blob_destination"),
+ ("posthog", "0964_webauthncredential"),
+ ("posthog", "0967_oauth_dcr_fields"),
+ ("posthog", "0969_add_oauth_is_verified"),
+ ("posthog", "0970_add_session_recording_encryption"),
+ ("posthog", "0971_exportedasset_failure_type"),
+ ("posthog", "0972_team_logs_settings"),
+ ("posthog", "0973_alter_integration_kind"),
+ ("posthog", "0974_alter_scheduledchange_recurrence_interval"),
+ ("posthog", "0975_add_evaluation_contexts_fields"),
+ ("posthog", "0976_copy_evaluation_contexts_data"),
+ ("posthog", "0977_alter_team_default_evaluation_environments_enabled_and_more"),
+ ("posthog", "0978_add_user_passkeys_enabled_for_2fa"),
+ ("posthog", "0979_survey_enable_iframe_embedding"),
+ ("posthog", "0980_team_default_experiment_confidence_level"),
+ ("posthog", "0981_batchexport_interval_offset_batchexport_timezone"),
+ ("posthog", "0982_comment_conversations_index"),
+ ("posthog", "0983_alter_integration_kind"),
+ ("posthog", "0984_clear_temporary_tokens"),
+ ("posthog", "0985_drop_column_configuration_unique_constraint"),
+ ("posthog", "0986_add_column_configuration_fields"),
+ ("posthog", "0987_add_column_configuration_constraints"),
+ ("posthog", "0988_ducklakecatalog"),
+ ("posthog", "0989_add_tags_to_hogflow_template"),
+ ("posthog", "0990_projectsecretapikey"),
+ ("posthog", "0991_remove_approvalpolicy_bypass_roles"),
+ ("posthog", "0992_drop_approvalpolicy_bypass_roles_column"),
+ ("posthog", "0993_approvalpolicy_bypass_options"),
+ ("posthog", "0994_user_requested_2fa_reset_at"),
+ ("posthog", "0995_team_default_experiment_stats_method"),
+ ("posthog", "0996_oauthapplication_is_first_party"),
+ ("posthog", "0997_oauthapplication_auth_brand"),
+ ("posthog", "0998_team_proactive_tasks_enabled"),
+ ("posthog", "0999_remove_presorted_events_modifier"),
+ ("posthog", "1000_create_healthissue_table"),
+ ("posthog", "1001_fix_person_property_in_operator"),
+ ("posthog", "1002_experiment_exposure_preaggregation_enabled"),
+ ("posthog", "1003_clean_up_stale_alert_subscriptions"),
+ ("posthog", "1004_resource_transfer"),
+ ("posthog", "1005_objectmediapreview_and_more"),
+ ("posthog", "1006_resource_transfer_duplicated_resource_id"),
+ ("posthog", "1007_resourcetransfer_created_by"),
+ ("posthog", "1008_resourcetransfer_created_by_index"),
+ ("posthog", "1009_healthissue_dismissed"),
+ ("posthog", "1010_hogflowtemplate_org_scope"),
+ ("posthog", "1011_eventschema_enforcement_mode"),
+ ("posthog", "1012_eventschema_enforcement_mode_idx"),
+ ("posthog", "1013_eventdefinition_enforcement_mode_db_default"),
+ ("posthog", "1014_increase_annotation_content_max_length"),
+ ("posthog", "1015_normalize_feature_flag_payloads_to_strings"),
+ ("posthog", "1016_fix_legacy_feature_flag_filters"),
+ ("posthog", "1017_survey_form_content"),
+ ("posthog", "1018_migrate_event_definition_models"),
+ ("posthog", "1019_alter_integration_kind_pinterest_ads"),
+ ("posthog", "1020_batchexportbackfill_total_records_and_adjusted_start"),
+ ("posthog", "1021_duckgresserver"),
+ ("posthog", "1022_survey_translations_alter_survey_questions"),
+ ("posthog", "1023_dashboardtile_show_description"),
+ ("posthog", "1024_remove_team_session_recording_encryption"),
+ ("posthog", "1025_drop_team_session_recording_encryption_column"),
+ ("posthog", "1026_alter_integration_kind_slack_twig"),
+ ("posthog", "1027_user_repo_preference"),
+ ("posthog", "1028_repo_routing_rule"),
+ ("posthog", "1029_hogflow_draft_fields"),
+ ("posthog", "1030_add_last_calculation_duration_ms"),
+ ("posthog", "1031_team_data_attributes_allow_blank"),
+ ("posthog", "1032_remove_taggeditem_exactly_one_related_object_and_more"),
+ ("posthog", "1033_taggeditem_ticket_indexes"),
+ ("posthog", "1034_taggeditem_ticket_unique_constraint"),
+ ("posthog", "1035_llm_prompt_versioning"),
+ ("posthog", "1036_experiment_status"),
+ ("posthog", "1037_add_redirect_to_topic_restriction_type"),
+ ("posthog", "1038_experiment_status_backfill"),
+ ("posthog", "1039_subscription_dashboard_export_insights"),
+ ("posthog", "1040_subscription_integration"),
+ ("posthog", "1041_backfill_subscription_integration"),
+ ("posthog", "1042_subscription_integration_idx"),
+ ("posthog", "1043_add_15_minute_interval_to_batch_exports"),
+ ("posthog", "1045_evaluation_context_models"),
+ ("posthog", "1046_migrate_evaluation_tags_to_contexts"),
+ ("posthog", "1047_dashboard_quick_filter_ids"),
+ ("posthog", "1048_alter_survey_response_sampling_daily_limits_and_more"),
+ ("posthog", "1049_alter_integration_kind_posthog_code"),
+ ("posthog", "1050_rename_slack_twig_to_posthog_code"),
+ ("posthog", "1051_backfill_holdout_format"),
+ ("posthog", "1052_migrate_legacy_personal_api_key_scopes"),
+ ("posthog", "1053_backfill_experiment_saved_metric_uuids"),
+ ("posthog", "1054_add_detector_fields"),
+ ("posthog", "1055_cohort_last_backfill_person_properties_at"),
+ ("posthog", "1056_migrate_experiments_models"),
+ ("posthog", "1057_personalapikey_scopes_not_null"),
+ ("posthog", "1058_migrate_aggregation_to_condition_sets"),
+ ("posthog", "1059_add_button_tile"),
+ ("posthog", "1060_alter_integration_kind"),
+ ("posthog", "1061_add_session_recording_trigger_groups"),
+ ("posthog", "1062_migrate_links_models"),
+ ("posthog", "1063_remove_surveyresponsearchive_survey_and_more"),
+ ("posthog", "1064_migrate_messaging_models"),
+ ("posthog", "1065_add_cohort_kind"),
+ ("posthog", "1066_alter_insight_saved"),
+ ("posthog", "1067_add_dashboardtemplate_is_featured"),
+ ("posthog", "1068_remove_deprecated_evaluation_tag_models"),
+ ("posthog", "1069_datadeletionrequest"),
+ ("posthog", "1070_add_unique_cohort_kind_per_team"),
+ ("posthog", "1071_move_tokens_to_sensitive_config"),
+ ("posthog", "1072_backfill_condition_aggregation"),
+ ("posthog", "1073_migrate_dashboards_models"),
+ ("posthog", "1074_backfill_vercel_connectable_resources"),
+ ("posthog", "1075_team_snippet_config"),
+ ("posthog", "1076_backfill_feature_enrollment"),
+ ("posthog", "1077_add_cron_expression_to_scheduled_change"),
+ ("posthog", "1078_backfill_feature_enrollment_fix"),
+ ("posthog", "1079_event_filter_config"),
+ ("posthog", "1080_alertcheck_triggered_metadata"),
+ ("posthog", "1081_alter_scheduledchange_failure_reason"),
+ ("posthog", "1082_oauth_cimd_fields"),
+ ("posthog", "1083_alter_integration_kind"),
+ ("posthog", "1084_ducklake_add_organization_fk"),
+ ("posthog", "1085_ducklake_backfill_organization"),
+ ("posthog", "1086_alter_teammarketinganalyticsconfig_attribution_mode"),
+ ("posthog", "1087_alertconfiguration_schedule_restriction"),
+ ("posthog", "1088_ducklake_backfill_model"),
+ ("posthog", "1089_ducklake_backfill_populate"),
+ ("posthog", "1090_batchexportrun_records_failed"),
+ ("posthog", "1091_team_provisioning_config"),
+ ("posthog", "1092_backfill_provisioning_service_ids"),
+ ("posthog", "1093_datadeletionrequest_max_timestamp_and_more"),
+ ("posthog", "1094_oauth_provisioning_fields"),
+ ("posthog", "1095_create_group_clickhouse_team"),
+ ("posthog", "1096_alter_datadeletionrequest_events_and_more"),
+ ("posthog", "1097_add_is_pending_deletion_to_organization"),
+ ("posthog", "1098_add_customerio_integration_kinds"),
+ ("posthog", "1099_subscription_delivery"),
+ ("posthog", "1100_add_subscription_summary_fields"),
+ ("posthog", "1101_activitylog_client"),
+ ("posthog", "1102_organizationmembership_org_joined_idx"),
+ ("posthog", "1103_datadeletionrequest_created_by_staff_and_more"),
+ ("posthog", "1104_alter_organization_is_ai_data_processing_approved"),
+ ("posthog", "1105_alter_oauthapplication_authorization_grant_type"),
+ ("posthog", "1106_alert_investigation_fields"),
+ ("posthog", "1107_alertcheck_investigation_summary"),
+ ("posthog", "1108_alertcheck_investigation_verdict"),
+ ("posthog", "1109_alert_investigation_notification_gating"),
+ ("posthog", "1110_sessionrecordingplaylistitem_playlist_index"),
+ ("posthog", "1111_organizationmembership_invited_by"),
+ ("posthog", "1112_datadeletionrequest_delete_all_events"),
+ ("posthog", "1113_add_math_fields_to_usage_metric"),
+ ("posthog", "1114_integration_repository_cache_and_more"),
+ ("posthog", "1115_featureflag_filters_groups_default"),
+ ("posthog", "1116_datadeletionrequest_hogql_predicate"),
+ ("posthog", "1117_role_external_reference"),
+ ("posthog", "1118_subscriptiondelivery_change_summary"),
+ ("posthog", "1119_provisioning_skip_existing_user_consent"),
+ ("posthog", "1120_backfill_provisioning_skip_existing_user_consent"),
+ ("posthog", "1121_add_last_realtime_cohort_calculation_at_to_cohort"),
+ ("posthog", "1122_oauthapplication_provisioning_can_issue_deep_links"),
+ ("posthog", "1123_backfill_provisioning_can_issue_deep_links"),
+ ("posthog", "1124_alter_alertconfiguration_subscribed_users"),
+ ("posthog", "1125_scheduledchange_timezone"),
+ ("posthog", "1126_ducklake_make_team_nullable_require_owner"),
+ ("posthog", "1127_alter_integration_kind"),
+ ("posthog", "1128_datadeletionrequest_person_distinct_ids_and_more"),
+ ("posthog", "1129_userintegration"),
+ ("posthog", "1130_filesystemshortcut_order"),
+ ("posthog", "1131_exportedasset_is_system"),
+ ("posthog", "1132_insight_dashboarditem_team_lmod_idx"),
+ ("posthog", "1133_alter_integration_kind"),
+ ("posthog", "1134_insightviewed_insight_lva_idx"),
+ ("posthog", "1135_alter_userproductlist_reason"),
+ ("posthog", "1136_onboarding_delegation_fields"),
+ ("posthog", "1137_onboarding_delegation_fk"),
+ ("posthog", "1138_onboarding_delegated_to_invite_index"),
+ ("posthog", "1139_alter_datadeletionrequest_person_distinct_ids_and_more"),
+ ("posthog", "1140_integrationrepositorycacheentry"),
+ ("posthog", "1141_datadeletionrequest_attempt_count_and_more"),
+ ("posthog", "1142_alter_batchexportdestination_type_and_more"),
+ ("posthog", "1143_sharingconfiguration_notebook"),
+ ("posthog", "1144_comment_task_fields"),
+ ("posthog", "1145_alter_integration_kind"),
+ ("posthog", "1146_subscription_enabled"),
+ ("posthog", "1147_columnconfiguration_order_by"),
+ ("posthog", "1148_backfill_encrypted_payloads_invariant"),
+ ("posthog", "1149_integrationrepositorycacheentry_user_integration"),
+ ("posthog", "1150_cimd_verification_token"),
+ ("posthog", "1151_cimd_followup_hardening"),
+ ("posthog", "1152_fix_device_bucketing_persist_across_auth"),
+ ("posthog", "1153_subscription_hourly_frequency"),
+ ("posthog", "1154_userpushtoken"),
+ ("posthog", "1155_sharingconfiguration_interviewee_context"),
+ ("posthog", "1156_cohort_team_filters_help_text"),
+ ("posthog", "1157_materializedcolumnslot_pending_and_expand_index"),
+ ("posthog", "1158_drop_property_type_not_null"),
+ ("posthog", "1159_materializedcolumnslot_team_slot_index_concurrent"),
+ ("posthog", "1160_materializedcolumnslot_run_id_concurrent_idx"),
+ ("posthog", "1161_remove_subscription_hourly_frequency"),
+ ("posthog", "1162_drop_hourly_from_subscription_frequency_choices"),
+ ("posthog", "1163_alter_batchexportrun_batch_export_and_more"),
+ ("posthog", "1164_alter_alertconfiguration_calculation_interval"),
+ ("posthog", "1165_user_hide_mcp_hints"),
+ ("posthog", "1166_oauth_impersonated_by"),
+ ("posthog", "1167_remove_alertconfiguration_is_calculating"),
+ ("posthog", "1168_migrate_alerts_actions_models"),
+ ("posthog", "1169_organization_ai_training_fields"),
+ ("posthog", "1170_credentials_reviewed_at"),
+ ("posthog", "1171_backfill_credentials_reviewed_at"),
+ ("posthog", "1172_remove_taggeditem_exactly_one_related_object_and_more"),
+ ("posthog", "1173_taggeditem_account_indexes"),
+ ("posthog", "1174_taggeditem_account_unique_constraint"),
+ ("posthog", "1175_drop_alertconfiguration_is_calculating_column"),
+ ("posthog", "1176_migrate_web_analytics_models"),
+ ("posthog", "1177_alter_organization_is_ai_data_processing_approved"),
+ ("posthog", "1178_datadeletionrequest_person_properties"),
+ ("posthog", "1179_taggeditem_endpoint"),
+ ("posthog", "1180_taggeditem_endpoint_indexes"),
+ ("posthog", "1181_taggeditem_endpoint_unique_constraint"),
+ ("posthog", "1182_migrate_feature_flags_models"),
+ ("posthog", "1183_migrate_product_analytics_models_state"),
+ ("posthog", "1184_migrate_product_analytics_models"),
+ ("posthog", "1185_fix_non_list_test_account_filters"),
+ ("posthog", "1186_activitylog_ip_address"),
+ ("posthog", "1187_migrate_hog_flow_models"),
+ ("posthog", "1188_migrate_cdp_models"),
+ ("posthog", "1189_file_system_shortcut_order_index"),
+ ("posthog", "1190_team_llm_gateway_metadata"),
+ ("posthog", "1191_delete_relationless_subscriptions"),
+ ("posthog", "1192_id_jag_organization_domain_fields"),
+ ("posthog", "1193_oauthaccesstoken_label_oauthapplication_scopes"),
+ ("posthog", "1194_project_updated_at"),
+ ("posthog", "1195_alter_batchexportdestination_type"),
+ ("posthog", "1196_team_llm_gateway_enabled_at"),
+ ("posthog", "1197_filesystem_surface"),
+ ("posthog", "1198_filesystem_surface_indexes"),
+ ("posthog", "1199_filesystem_related_surface"),
+ ("posthog", "1200_persistedfolder_surface_unique"),
+ ("posthog", "1201_persistedfolder_drop_old_unique"),
+ ("posthog", "1202_migrate_exports_models"),
+ ("posthog", "1203_migrate_annotations_models"),
+ ("posthog", "1204_migrate_batch_exports_models"),
+ ("posthog", "1205_delete_batch_export_models"),
+ ("posthog", "1206_cohort_list_indexes"),
+ ("posthog", "1207_migrate_ai_observability_models"),
+ ("posthog", "1208_organization_members_can_create_projects"),
+ ("posthog", "1209_alter_integration_kind_google_search_console"),
+ ("posthog", "1210_team_ingested_production_event"),
+ ("posthog", "1211_oauthapplication_provisioning_issues_personal_api_key"),
+ ("posthog", "1212_grandfather_stripe_provisioned_pat"),
+ ("posthog", "1213_filesystemfolderinstructions"),
+ ("posthog", "1214_oauthapplication_sessions_revoked_at"),
+ ("posthog", "1215_migrate_replay_models"),
+ ("posthog", "1216_migrate_cohorts_models"),
+ ("posthog", "1217_project_is_pending_deletion"),
+ ("posthog", "1218_team_ingested_production_event_last_checked_at"),
+ ("posthog", "1219_filesystemfoldercontextgeneration"),
+ ("posthog", "1220_projectsecretapikey_scopes_gin"),
+ ("posthog", "1221_oauthaccesstoken_scope_trgm"),
+ ("posthog", "1222_alter_integration_kind_google_analytics"),
+ ("posthog", "1223_remove_ducklakecatalog_cross_account_fields"),
+ ("posthog", "1224_columnconfiguration_properties"),
+ ("posthog", "1225_team_llm_gateway_overspend_allowance_usd"),
+ ("posthog", "1226_identityproviderconfig_and_more"),
+ ("posthog", "1227_alter_datadeletionrequest_delete_all_events"),
+ ("posthog", "1228_teamprovisioningconfig_application"),
+ ("posthog", "1229_teamprovisioningconfig_application_idx"),
+ ("posthog", "1230_duckgresserver_bucket"),
+ ("posthog", "1231_duckgresserverteam"),
+ ("posthog", "1232_alter_duckgresserver_bucket_region"),
+ ("posthog", "1233_backfill_duckgresserverteam"),
+ ("posthog", "1234_oauthapplication_optional_scopes_and_more"),
+ ("posthog", "1235_userintegration_slack_kind"),
+ ("posthog", "1236_userintegration_kind_extid_idx"),
+ ("posthog", "1237_alter_integration_kind"),
+ ("posthog", "1238_ducklakebackfill_earliest_event_date"),
+ ("posthog", "1239_migrate_approvals_models"),
+ ("posthog", "1240_consolidate_duckgres_models"),
+ ("posthog", "1241_consolidate_duckgres_models_data"),
+ ("posthog", "1242_consolidate_duckgres_models_drop"),
+ ("posthog", "1243_alter_team_options"),
+ ("posthog", "1244_team_event_retention_months"),
+ ("posthog", "1245_duckgres_sink_schema_state"),
+ ("posthog", "1246_alter_organizationdomain_id_jag_allowed_clients_and_more"),
+ ("posthog", "1247_oauthaccesstoken_token_idx"),
+ ("posthog", "1248_personal_api_key_description"),
+ ("posthog", "1249_duckgressinkschemastate_consecutive_failures_and_more"),
+ ("posthog", "1250_duckgresserver_sink_max_concurrency"),
+ ("posthog", "1251_alter_integration_kind"),
+ ("posthog", "1252_datadeletionrequest_property_removal_marker"),
+ ("posthog", "1253_oauth_application_github_grants_rate_limit"),
+ ("posthog", "1254_datadeletionrequest_last_dagster_run_id"),
+ ("posthog", "1255_wizard_runs_rate_limit_and_provisioned_onboarding_reason"),
+ ("posthog", "1256_userproductlist_default_reason"),
+ ("posthog", "1257_datadeletionrequest_approved_automatically_and_more"),
+ ("posthog", "1258_duckgressinkschemastate_queue_last_applied_at"),
+ ("posthog", "1259_globalratelimitthresholdconfig"),
+ ("posthog", "1260_activitylog_idx_alog_org_created_at_and_more"),
+ ("posthog", "1261_alter_personalapikey_scoped_organizations_and_more"),
+ ("posthog", "1262_organization_members_can_see_org_members"),
+ ("posthog", "1263_alter_integration_kind"),
+ ("posthog", "1264_delete_revenue_analytics_user_product_list"),
+ ("posthog", "1265_delete_duckgresserverteam"),
+ ("posthog", "1266_comment_convo_content_trgm"),
+ ("posthog", "1267_oauth_client_authentication"),
+ ("posthog", "1268_backfill_is_provisioning_partner"),
+ ("posthog", "1269_retire_provisioning_auth_method"),
+ ("posthog", "1270_untrack_provisioning_auth_columns"),
+ ("posthog", "1271_add_pardot_integration_kind"),
+ ("posthog", "1272_user_ui_configuration"),
+ ("posthog", "1273_oauth_provisioning_config"),
+ ("posthog", "1274_backfill_oauth_provisioning_config"),
+ ("posthog", "1275_default_legacy_provisioning_columns"),
+ ("posthog", "1276_untrack_legacy_provisioning_columns"),
+ ("posthog", "1277_drop_duckgresserverteam_hot_table_fks"),
+ ("posthog", "1278_identityproviderconfig_config_scope_and_more"),
+ ("posthog", "1279_drop_duckgresserverteam_table"),
+ ("posthog", "1280_alter_integration_kind"),
+ ("posthog", "1281_migrate_managed_warehouse_models"),
+ ("posthog", "1282_alter_user_role_at_organization"),
+ ("posthog", "1283_alter_integration_kind"),
+ ("posthog", "1284_organization_enforce_verified_domains"),
+ ("posthog", "1285_drop_desktop_file_system"),
+ ("posthog", "1286_cleanup_orphaned_identity_provider_configs"),
+ ("posthog", "1287_linked_identity_provider_configs"),
+ ("posthog", "1288_backfill_linked_identity_provider_configs"),
+ ("posthog", "1289_identityproviderconfig_relay_state_and_scim_slug"),
+ ("posthog", "1290_backfill_identity_provider_config_identifiers"),
+ ("posthog", "1291_commentslackthread"),
+ ("posthog", "1292_oauthaccesstoken_sandbox_task_id"),
+ ("posthog", "1293_commentslackthread_channel_name"),
+ ("posthog", "1294_add_google_calendar_integration_kind"),
+ ("posthog", "1295_cimdverificationtoken_cimd_url"),
+ ("posthog", "1296_backfill_cimd_verification_token_url"),
+ ("posthog", "1297_add_instagram_integration_kind"),
+ ("posthog", "1298_user_stripped_alias_index"),
+ ("posthog", "1299_alter_identityproviderconfig_saml_relay_state"),
+ ("posthog", "1300_identityproviderconfig_saml_relay_state_unique"),
+ ("posthog", "1301_taggeditem_replay_scanner"),
+ ("posthog", "1302_taggeditem_replay_scanner_indexes"),
+ ("posthog", "1303_taggeditem_replay_scanner_unique_constraint"),
+ ("posthog", "1304_organization_has_active_subscription"),
+ ("posthog", "1305_alter_identityproviderconfig_saml_relay_state_and_more"),
+ ("posthog", "1306_add_youtube_analytics_integration_kind"),
+ ("posthog", "1307_remove_personlessdistinctid"),
+ ("posthog", "1308_githubinstallrequest"),
+ ("posthog", "1309_integration_kind_ext_idx"),
+ ("posthog", "1310_provisioning_rate_limit_overrides"),
+ ("posthog", "1311_alter_oauthapplication_client_id"),
+ ("posthog", "1312_oauthrefreshtoken_oauthrefreshtoken_family_idx"),
+ ("posthog", "1313_healthissue_snoozed_until"),
+ ("posthog", "1314_callable_choices"),
+ ("posthog", "1315_githubinstallrequest_account"),
+ ("posthog", "1316_deprecate_organization_domain_idp_config"),
+ ("posthog", "1317_oauthaccesstoken_scopes_gin"),
+ ("posthog", "1318_disable_oauth_scope_trgm_fastupdate"),
+ ("posthog", "1319_team_posthog_team_widget_token_idx"),
+ ("posthog", "1320_remove_oauth_scope_trgm"),
+ ("posthog", "1321_add_user_facet_settings"),
+ ("posthog", "1322_organization_read_only_mcp_access"),
+ ("posthog", "1323_proxyrecord_root_redirect_url"),
+ ("posthog", "1324_backfill_cimd_client_id"),
+ ("posthog", "1325_organizationmembernotificationlock"),
+ ("posthog", "1326_drop_legacy_provisioning_columns"),
+ ("posthog", "1327_untrack_cimd_metadata_url"),
+ ("posthog", "1328_remove_userproductlist_reason_state"),
+ ("posthog", "1329_drop_cimd_metadata_url"),
+ ("posthog", "1330_alter_team_test_account_filters"),
+ ("posthog", "1331_messagingrecord_campaign_key_idx"),
+ ("posthog", "1332_uploaded_media_library"),
+ ("posthog", "1333_uploaded_media_library_index"),
+ ("posthog", "1334_remove_cimd_blocklist_entry"),
+ ("posthog", "1335_taggeditem_project"),
+ ("posthog", "1336_taggeditem_project_indexes"),
+ ("posthog", "1337_taggeditem_project_unique_constraint"),
+ ("posthog", "1338_taggeditem_project_fk"),
+ ("posthog", "1339_validate_taggeditem_project_fk"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ initial = True
+
+ run_before = [
+ ("oauth2_provider", "0001_initial"),
+ ]
+
+ dependencies = [
+ ("auth", "__latest__"),
+ ("posthog", "0000_squash_stub"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Organization",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=64)),
+ ("slug", posthog.models.utils.LowercaseSlugField(max_length=48, unique=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "plugins_access_level",
+ models.PositiveSmallIntegerField(
+ choices=[(0, "none"), (3, "config"), (6, "install"), (9, "root")], default=3
+ ),
+ ),
+ ("for_internal_metrics", models.BooleanField(default=False)),
+ ("is_member_join_email_enabled", models.BooleanField(default=True)),
+ ("customer_id", models.CharField(blank=True, max_length=200, null=True)),
+ ("usage", models.JSONField(blank=True, null=True)),
+ ("setup_section_2_completed", models.BooleanField(default=True)),
+ ("personalization", models.JSONField(blank=True, default=dict)),
+ (
+ "domain_whitelist",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=256), blank=True, default=list, size=None
+ ),
+ ),
+ ("enforce_2fa", models.BooleanField(blank=True, null=True)),
+ (
+ "available_product_features",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.JSONField(), blank=True, null=True, size=None
+ ),
+ ),
+ ("never_drop_data", models.BooleanField(blank=True, default=False, null=True)),
+ ("customer_trust_scores", models.JSONField(blank=True, default=dict, null=True)),
+ ("is_hipaa", models.BooleanField(blank=True, default=False, null=True)),
+ ("is_ai_data_processing_approved", models.BooleanField(blank=True, default=True, null=True)),
+ ("members_can_invite", models.BooleanField(blank=True, default=True, null=True)),
+ ("is_platform", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "session_cookie_age",
+ models.IntegerField(
+ blank=True,
+ help_text="Custom session cookie age in seconds. If not set, the global setting SESSION_COOKIE_AGE will be used.",
+ null=True,
+ ),
+ ),
+ (
+ "default_experiment_stats_method",
+ models.CharField(
+ blank=True,
+ choices=[("bayesian", "Bayesian"), ("frequentist", "Frequentist")],
+ default="bayesian",
+ help_text="Default statistical method for new experiments in this organization.",
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("members_can_use_personal_api_keys", models.BooleanField(default=True)),
+ ("allow_publicly_shared_resources", models.BooleanField(default=True)),
+ (
+ "default_anonymize_ips",
+ models.BooleanField(
+ default=False,
+ help_text="Default setting for 'Discard client IP data' for new projects in this organization.",
+ ),
+ ),
+ (
+ "is_active",
+ models.BooleanField(
+ blank=True,
+ default=True,
+ help_text="Set this to 'No' to temporarily disable an organization.",
+ null=True,
+ verbose_name="active",
+ ),
+ ),
+ (
+ "is_not_active_reason",
+ models.TextField(
+ blank=True,
+ help_text="(optional) reason for why the organization has been de-activated. This will be displayed to users on the web app.",
+ max_length=200,
+ null=True,
+ verbose_name="de-activated reason",
+ ),
+ ),
+ (
+ "is_pending_deletion",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="Set to True when org deletion has been initiated. Blocks all UI access until the async task completes.",
+ null=True,
+ ),
+ ),
+ (
+ "is_ai_training_opted_in",
+ models.BooleanField(
+ blank=True,
+ default=True,
+ help_text="When True, this organization allows its data to be used to train PostHog AI models.",
+ null=True,
+ ),
+ ),
+ (
+ "is_ai_training_locked",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="When True, the AI training opt-out setting cannot be modified through the UI or API.",
+ null=True,
+ ),
+ ),
+ (
+ "is_ai_training_cta_shown",
+ models.BooleanField(
+ blank=True,
+ default=True,
+ help_text="When True, in-app callouts inviting members to enable AI training are shown.",
+ null=True,
+ ),
+ ),
+ (
+ "members_can_create_projects",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="When True, organization members (below admin) are allowed to create new projects. Admins and owners can always create projects.",
+ null=True,
+ ),
+ ),
+ (
+ "members_can_see_org_members",
+ models.BooleanField(
+ db_default=True,
+ default=True,
+ help_text="When False, members (below admin) only see themselves in the members list and only project members in access control.",
+ ),
+ ),
+ (
+ "enforce_verified_domains",
+ models.BooleanField(
+ blank=True,
+ help_text="When True, logins, signups, and invites for this organization are restricted to email addresses on its verified domains.",
+ null=True,
+ ),
+ ),
+ ("has_active_subscription", models.BooleanField(blank=True, null=True)),
+ (
+ "read_only_mcp_access",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="When True, requests through the PostHog MCP server can read but not change this organization's data.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("for_internal_metrics", True)),
+ fields=("for_internal_metrics",),
+ name="single_for_internal_metrics",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="AsyncMigration",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("name", models.CharField(max_length=50)),
+ ("description", models.CharField(blank=True, max_length=400, null=True)),
+ ("progress", models.PositiveSmallIntegerField(default=0)),
+ ("status", models.PositiveSmallIntegerField(default=0)),
+ ("current_operation_index", models.PositiveSmallIntegerField(default=0)),
+ ("current_query_id", models.CharField(default="", max_length=100)),
+ ("celery_task_id", models.CharField(default="", max_length=100)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("posthog_min_version", models.CharField(blank=True, max_length=20, null=True)),
+ ("posthog_max_version", models.CharField(blank=True, max_length=20, null=True)),
+ ("parameters", models.JSONField(default=dict)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("name",), name="unique name")],
+ },
+ ),
+ migrations.CreateModel(
+ name="EventBuffer",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("event", models.JSONField(blank=True, null=True)),
+ ("process_at", models.DateTimeField()),
+ ("locked", models.BooleanField()),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Prompt",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("step", models.IntegerField()),
+ ("type", models.CharField(max_length=200)),
+ ("title", models.CharField(max_length=200)),
+ ("text", models.CharField(max_length=1000)),
+ ("placement", models.CharField(default="top", max_length=200)),
+ ("buttons", models.JSONField()),
+ ("reference", models.CharField(default=None, max_length=200, null=True)),
+ ("icon", models.CharField(max_length=200)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MessagingRecord",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("email_hash", models.CharField(max_length=1024)),
+ ("campaign_key", models.CharField(max_length=128)),
+ ("sent_at", models.DateTimeField(null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("campaign_count", models.IntegerField(null=True)),
+ ],
+ options={
+ "unique_together": {("email_hash", "campaign_key")},
+ "indexes": [models.Index(fields=["campaign_key"], name="messagingrecord_campaign_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PersonOverrideMapping",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("uuid", models.UUIDField()),
+ ("team_id", models.BigIntegerField()),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team_id", "uuid"), name="unique_uuid")],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="PendingPersonOverride",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("team_id", models.BigIntegerField()),
+ ("old_person_id", models.UUIDField()),
+ ("override_person_id", models.UUIDField()),
+ ("oldest_event", models.DateTimeField()),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="FlatPersonOverride",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("team_id", models.BigIntegerField()),
+ ("old_person_id", models.UUIDField()),
+ ("override_person_id", models.UUIDField()),
+ ("oldest_event", models.DateTimeField()),
+ ("version", models.BigIntegerField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "override_person_id"], name="posthog_fla_team_id_224253_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team_id", "old_person_id"), name="flatpersonoverride_unique_old_person_by_team"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("old_person_id__exact", models.F("override_person_id")), _negated=True),
+ name="flatpersonoverride_check_circular_reference",
+ ),
+ ],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="EventIngestionRestrictionConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("token", models.CharField(max_length=100)),
+ (
+ "restriction_type",
+ models.CharField(
+ choices=[
+ ("skip_person_processing", "Skip Person Processing"),
+ ("drop_event_from_ingestion", "Drop Event From Ingestion"),
+ ("force_overflow_from_ingestion", "Force Overflow From Ingestion"),
+ ("redirect_to_dlq", "Redirect To Dlq"),
+ ("redirect_to_topic", "Redirect To Topic"),
+ ],
+ max_length=100,
+ ),
+ ),
+ (
+ "distinct_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=450), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "note",
+ models.TextField(
+ blank=True,
+ help_text="Optional note explaining why this restriction was put in place",
+ null=True,
+ ),
+ ),
+ (
+ "pipelines",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=50),
+ blank=True,
+ default=posthog.models.event_ingestion_restriction_config.default_pipelines,
+ help_text="List of ingestion pipelines this restriction applies to (e.g., 'analytics', 'session_recordings')",
+ size=None,
+ ),
+ ),
+ (
+ "session_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=450), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "event_names",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=450), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "event_uuids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=450), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "args",
+ models.JSONField(
+ blank=True,
+ help_text='Extra arguments for the restriction type (e.g., {"topic": "my_topic"} for redirect_to_topic)',
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "unique_together": {("token", "restriction_type")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="GlobalRateLimitThresholdConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("token", models.CharField(max_length=200)),
+ (
+ "distinct_id",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Optional. Empty applies the threshold to the whole token; set applies it only to this token and distinct_id.",
+ max_length=450,
+ ),
+ ),
+ (
+ "threshold",
+ models.PositiveBigIntegerField(
+ help_text="Max events allowed per rate-limit window for this key. 0 rate-limits the key to zero, but the limiter is cache-based so an isolated event may still pass on a cold cache miss; to block a key permanently use an EventRestriction in the Django admin."
+ ),
+ ),
+ (
+ "note",
+ models.TextField(
+ blank=True, help_text="Optional note explaining why this override exists", null=True
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "unique_together": {("token", "distinct_id")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationInvite",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("target_email", models.EmailField(db_index=True, max_length=254, null=True)),
+ ("first_name", models.CharField(blank=True, default="", max_length=30)),
+ ("emailing_attempt_made", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("message", models.TextField(blank=True, null=True)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="invites",
+ related_query_name="invite",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "level",
+ models.PositiveSmallIntegerField(
+ choices=[(1, "member"), (8, "administrator"), (15, "owner")], default=1
+ ),
+ ),
+ (
+ "private_project_access",
+ models.JSONField(
+ blank=True,
+ default=list,
+ help_text="List of team IDs and corresponding access levels to private projects.",
+ null=True,
+ validators=[posthog.models.organization_invite.validate_private_project_access],
+ ),
+ ),
+ (
+ "is_setup_delegation",
+ models.BooleanField(
+ default=False,
+ help_text="True when this invite was created via the onboarding delegation flow. Downstream logic routes the delegate through full onboarding on accept.",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Project",
+ fields=[
+ ("id", models.BigIntegerField(primary_key=True, serialize=False, verbose_name="ID")),
+ (
+ "name",
+ models.CharField(
+ default="Default project",
+ max_length=200,
+ validators=[django.core.validators.MinLengthValidator(1, "Project must have a name!")],
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="projects",
+ related_query_name="project",
+ to="posthog.organization",
+ ),
+ ),
+ ("product_description", models.TextField(blank=True, max_length=1000, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "is_pending_deletion",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="Set to True when project deletion has been initiated. Blocks UI access to this project until the async task completes.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="IdentityProviderConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Display name for this IdP configuration (e.g. 'Okta production').",
+ max_length=255,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("saml_entity_id", models.CharField(blank=True, max_length=512, null=True)),
+ ("saml_acs_url", models.CharField(blank=True, max_length=512, null=True)),
+ ("saml_x509_cert", models.TextField(blank=True, null=True)),
+ ("scim_enabled", models.BooleanField(default=False)),
+ (
+ "scim_bearer_token",
+ models.CharField(
+ blank=True, help_text="Hashed bearer token for SCIM authentication", max_length=255, null=True
+ ),
+ ),
+ (
+ "id_jag_issuer_url",
+ models.CharField(
+ blank=True,
+ help_text="Trusted IdP issuer URL for ID-JAG. Required to enable ID-JAG.",
+ max_length=512,
+ null=True,
+ ),
+ ),
+ (
+ "id_jag_jwks_url",
+ models.CharField(
+ blank=True,
+ help_text="Override JWKS URL. Defaults to OIDC discovery on the issuer URL.",
+ max_length=512,
+ null=True,
+ ),
+ ),
+ (
+ "id_jag_allowed_clients",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=256),
+ blank=True,
+ default=list,
+ help_text="Allowed ID-JAG client IDs. Empty list allows any client_id.",
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="identity_provider_configs",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "config_scope",
+ models.CharField(
+ blank=True,
+ choices=[("saml", "Saml"), ("scim", "Scim"), ("xaa", "Xaa")],
+ max_length=4,
+ null=True,
+ ),
+ ),
+ (
+ "domain_scope",
+ models.CharField(
+ blank=True, choices=[("all", "All"), ("selected", "Selected")], max_length=8, null=True
+ ),
+ ),
+ (
+ "saml_relay_state",
+ models.CharField(blank=True, default=uuid.uuid4, max_length=36, null=True, unique=True),
+ ),
+ ("scim_slug", models.CharField(blank=True, default=uuid.uuid4, max_length=36, null=True, unique=True)),
+ ],
+ options={
+ "verbose_name": "identity provider config",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AsyncMigrationError",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("description", models.TextField()),
+ (
+ "async_migration",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.asyncmigration"),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PromptSequence",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("key", models.CharField(max_length=200)),
+ ("type", models.CharField(max_length=200)),
+ (
+ "path_match",
+ django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=200), size=None),
+ ),
+ (
+ "path_exclude",
+ django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=200), size=None),
+ ),
+ ("status", models.CharField(max_length=200)),
+ ("requires_opt_in", models.BooleanField(default=False)),
+ ("autorun", models.BooleanField(default=True)),
+ ("must_have_completed", models.ManyToManyField(blank=True, to="posthog.promptsequence")),
+ ("prompts", models.ManyToManyField(to="posthog.prompt")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("key",), name="unique_prompt_sequence")],
+ },
+ ),
+ migrations.CreateModel(
+ name="Team",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("uuid", models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, unique=True)),
+ (
+ "api_token",
+ models.CharField(
+ default=posthog.models.utils.generate_random_token_project,
+ max_length=200,
+ unique=True,
+ validators=[
+ django.core.validators.MinLengthValidator(
+ 10, "Project's API token must be at least 10 characters long!"
+ )
+ ],
+ ),
+ ),
+ (
+ "app_urls",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=200, null=True), blank=True, default=list, size=None
+ ),
+ ),
+ (
+ "name",
+ models.CharField(
+ default="Default project",
+ max_length=200,
+ validators=[django.core.validators.MinLengthValidator(1, "Project must have a name!")],
+ ),
+ ),
+ ("slack_incoming_webhook", models.CharField(blank=True, max_length=500, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("anonymize_ips", models.BooleanField(default=False)),
+ ("completed_snippet_onboarding", models.BooleanField(default=False)),
+ ("ingested_event", models.BooleanField(default=False)),
+ ("session_recording_opt_in", models.BooleanField(default=False)),
+ ("capture_console_log_opt_in", models.BooleanField(blank=True, default=True, null=True)),
+ ("signup_token", models.CharField(blank=True, max_length=200, null=True)),
+ ("is_demo", models.BooleanField(default=False)),
+ ("access_control", models.BooleanField(default=False)),
+ ("inject_web_apps", models.BooleanField(null=True)),
+ (
+ "test_account_filters",
+ models.JSONField(
+ default=list,
+ help_text='Filters used to identify internal/test users. Each entry is a property filter.\n\n Supported entry types and the exact shape each accepts:\n\n # Person property — match (or exclude) by a person property\n {"key": "email", "type": "person", "value": "@example.com", "operator": "ends_with"}\n\n # Event property — match by an event property\n {"key": "$host", "type": "event", "value": "localhost", "operator": "icontains"}\n\n # Cohort membership — match (or exclude) members of a cohort.\n # Use operator "in" for inclusion and "not_in" for exclusion. Do NOT use a\n # `negation` field here — `negation` is specific to cohort *definitions*\n # (the inner sub-filters that build a cohort) and is rejected by the\n # property-filter schema.\n {"key": "id", "type": "cohort", "value": 8814, "operator": "not_in"}\n\n Common operators: "exact", "is_not", "icontains", "not_icontains", "starts_with",\n "not_starts_with", "ends_with", "not_ends_with", "regex", "not_regex", "gt", "lt",\n "gte", "lte", "is_set", "is_not_set", "in", "not_in".',
+ ),
+ ),
+ ("test_account_filters_default_checked", models.BooleanField(blank=True, null=True)),
+ ("path_cleaning_filters", models.JSONField(blank=True, default=list, null=True)),
+ (
+ "timezone",
+ models.CharField(
+ choices=[
+ ("Africa/Abidjan", "Africa/Abidjan"),
+ ("Africa/Accra", "Africa/Accra"),
+ ("Africa/Addis_Ababa", "Africa/Addis_Ababa"),
+ ("Africa/Algiers", "Africa/Algiers"),
+ ("Africa/Asmara", "Africa/Asmara"),
+ ("Africa/Asmera", "Africa/Asmera"),
+ ("Africa/Bamako", "Africa/Bamako"),
+ ("Africa/Bangui", "Africa/Bangui"),
+ ("Africa/Banjul", "Africa/Banjul"),
+ ("Africa/Bissau", "Africa/Bissau"),
+ ("Africa/Blantyre", "Africa/Blantyre"),
+ ("Africa/Brazzaville", "Africa/Brazzaville"),
+ ("Africa/Bujumbura", "Africa/Bujumbura"),
+ ("Africa/Cairo", "Africa/Cairo"),
+ ("Africa/Casablanca", "Africa/Casablanca"),
+ ("Africa/Ceuta", "Africa/Ceuta"),
+ ("Africa/Conakry", "Africa/Conakry"),
+ ("Africa/Dakar", "Africa/Dakar"),
+ ("Africa/Dar_es_Salaam", "Africa/Dar_es_Salaam"),
+ ("Africa/Djibouti", "Africa/Djibouti"),
+ ("Africa/Douala", "Africa/Douala"),
+ ("Africa/El_Aaiun", "Africa/El_Aaiun"),
+ ("Africa/Freetown", "Africa/Freetown"),
+ ("Africa/Gaborone", "Africa/Gaborone"),
+ ("Africa/Harare", "Africa/Harare"),
+ ("Africa/Johannesburg", "Africa/Johannesburg"),
+ ("Africa/Juba", "Africa/Juba"),
+ ("Africa/Kampala", "Africa/Kampala"),
+ ("Africa/Khartoum", "Africa/Khartoum"),
+ ("Africa/Kigali", "Africa/Kigali"),
+ ("Africa/Kinshasa", "Africa/Kinshasa"),
+ ("Africa/Lagos", "Africa/Lagos"),
+ ("Africa/Libreville", "Africa/Libreville"),
+ ("Africa/Lome", "Africa/Lome"),
+ ("Africa/Luanda", "Africa/Luanda"),
+ ("Africa/Lubumbashi", "Africa/Lubumbashi"),
+ ("Africa/Lusaka", "Africa/Lusaka"),
+ ("Africa/Malabo", "Africa/Malabo"),
+ ("Africa/Maputo", "Africa/Maputo"),
+ ("Africa/Maseru", "Africa/Maseru"),
+ ("Africa/Mbabane", "Africa/Mbabane"),
+ ("Africa/Mogadishu", "Africa/Mogadishu"),
+ ("Africa/Monrovia", "Africa/Monrovia"),
+ ("Africa/Nairobi", "Africa/Nairobi"),
+ ("Africa/Ndjamena", "Africa/Ndjamena"),
+ ("Africa/Niamey", "Africa/Niamey"),
+ ("Africa/Nouakchott", "Africa/Nouakchott"),
+ ("Africa/Ouagadougou", "Africa/Ouagadougou"),
+ ("Africa/Porto-Novo", "Africa/Porto-Novo"),
+ ("Africa/Sao_Tome", "Africa/Sao_Tome"),
+ ("Africa/Timbuktu", "Africa/Timbuktu"),
+ ("Africa/Tripoli", "Africa/Tripoli"),
+ ("Africa/Tunis", "Africa/Tunis"),
+ ("Africa/Windhoek", "Africa/Windhoek"),
+ ("America/Adak", "America/Adak"),
+ ("America/Anchorage", "America/Anchorage"),
+ ("America/Anguilla", "America/Anguilla"),
+ ("America/Antigua", "America/Antigua"),
+ ("America/Araguaina", "America/Araguaina"),
+ ("America/Argentina/Buenos_Aires", "America/Argentina/Buenos_Aires"),
+ ("America/Argentina/Catamarca", "America/Argentina/Catamarca"),
+ ("America/Argentina/ComodRivadavia", "America/Argentina/ComodRivadavia"),
+ ("America/Argentina/Cordoba", "America/Argentina/Cordoba"),
+ ("America/Argentina/Jujuy", "America/Argentina/Jujuy"),
+ ("America/Argentina/La_Rioja", "America/Argentina/La_Rioja"),
+ ("America/Argentina/Mendoza", "America/Argentina/Mendoza"),
+ ("America/Argentina/Rio_Gallegos", "America/Argentina/Rio_Gallegos"),
+ ("America/Argentina/Salta", "America/Argentina/Salta"),
+ ("America/Argentina/San_Juan", "America/Argentina/San_Juan"),
+ ("America/Argentina/San_Luis", "America/Argentina/San_Luis"),
+ ("America/Argentina/Tucuman", "America/Argentina/Tucuman"),
+ ("America/Argentina/Ushuaia", "America/Argentina/Ushuaia"),
+ ("America/Aruba", "America/Aruba"),
+ ("America/Asuncion", "America/Asuncion"),
+ ("America/Atikokan", "America/Atikokan"),
+ ("America/Atka", "America/Atka"),
+ ("America/Bahia", "America/Bahia"),
+ ("America/Bahia_Banderas", "America/Bahia_Banderas"),
+ ("America/Barbados", "America/Barbados"),
+ ("America/Belem", "America/Belem"),
+ ("America/Belize", "America/Belize"),
+ ("America/Blanc-Sablon", "America/Blanc-Sablon"),
+ ("America/Boa_Vista", "America/Boa_Vista"),
+ ("America/Bogota", "America/Bogota"),
+ ("America/Boise", "America/Boise"),
+ ("America/Buenos_Aires", "America/Buenos_Aires"),
+ ("America/Cambridge_Bay", "America/Cambridge_Bay"),
+ ("America/Campo_Grande", "America/Campo_Grande"),
+ ("America/Cancun", "America/Cancun"),
+ ("America/Caracas", "America/Caracas"),
+ ("America/Catamarca", "America/Catamarca"),
+ ("America/Cayenne", "America/Cayenne"),
+ ("America/Cayman", "America/Cayman"),
+ ("America/Chicago", "America/Chicago"),
+ ("America/Chihuahua", "America/Chihuahua"),
+ ("America/Ciudad_Juarez", "America/Ciudad_Juarez"),
+ ("America/Coral_Harbour", "America/Coral_Harbour"),
+ ("America/Cordoba", "America/Cordoba"),
+ ("America/Costa_Rica", "America/Costa_Rica"),
+ ("America/Creston", "America/Creston"),
+ ("America/Cuiaba", "America/Cuiaba"),
+ ("America/Curacao", "America/Curacao"),
+ ("America/Danmarkshavn", "America/Danmarkshavn"),
+ ("America/Dawson", "America/Dawson"),
+ ("America/Dawson_Creek", "America/Dawson_Creek"),
+ ("America/Denver", "America/Denver"),
+ ("America/Detroit", "America/Detroit"),
+ ("America/Dominica", "America/Dominica"),
+ ("America/Edmonton", "America/Edmonton"),
+ ("America/Eirunepe", "America/Eirunepe"),
+ ("America/El_Salvador", "America/El_Salvador"),
+ ("America/Ensenada", "America/Ensenada"),
+ ("America/Fort_Nelson", "America/Fort_Nelson"),
+ ("America/Fort_Wayne", "America/Fort_Wayne"),
+ ("America/Fortaleza", "America/Fortaleza"),
+ ("America/Glace_Bay", "America/Glace_Bay"),
+ ("America/Godthab", "America/Godthab"),
+ ("America/Goose_Bay", "America/Goose_Bay"),
+ ("America/Grand_Turk", "America/Grand_Turk"),
+ ("America/Grenada", "America/Grenada"),
+ ("America/Guadeloupe", "America/Guadeloupe"),
+ ("America/Guatemala", "America/Guatemala"),
+ ("America/Guayaquil", "America/Guayaquil"),
+ ("America/Guyana", "America/Guyana"),
+ ("America/Halifax", "America/Halifax"),
+ ("America/Havana", "America/Havana"),
+ ("America/Hermosillo", "America/Hermosillo"),
+ ("America/Indiana/Indianapolis", "America/Indiana/Indianapolis"),
+ ("America/Indiana/Knox", "America/Indiana/Knox"),
+ ("America/Indiana/Marengo", "America/Indiana/Marengo"),
+ ("America/Indiana/Petersburg", "America/Indiana/Petersburg"),
+ ("America/Indiana/Tell_City", "America/Indiana/Tell_City"),
+ ("America/Indiana/Vevay", "America/Indiana/Vevay"),
+ ("America/Indiana/Vincennes", "America/Indiana/Vincennes"),
+ ("America/Indiana/Winamac", "America/Indiana/Winamac"),
+ ("America/Indianapolis", "America/Indianapolis"),
+ ("America/Inuvik", "America/Inuvik"),
+ ("America/Iqaluit", "America/Iqaluit"),
+ ("America/Jamaica", "America/Jamaica"),
+ ("America/Jujuy", "America/Jujuy"),
+ ("America/Juneau", "America/Juneau"),
+ ("America/Kentucky/Louisville", "America/Kentucky/Louisville"),
+ ("America/Kentucky/Monticello", "America/Kentucky/Monticello"),
+ ("America/Knox_IN", "America/Knox_IN"),
+ ("America/Kralendijk", "America/Kralendijk"),
+ ("America/La_Paz", "America/La_Paz"),
+ ("America/Lima", "America/Lima"),
+ ("America/Los_Angeles", "America/Los_Angeles"),
+ ("America/Louisville", "America/Louisville"),
+ ("America/Lower_Princes", "America/Lower_Princes"),
+ ("America/Maceio", "America/Maceio"),
+ ("America/Managua", "America/Managua"),
+ ("America/Manaus", "America/Manaus"),
+ ("America/Marigot", "America/Marigot"),
+ ("America/Martinique", "America/Martinique"),
+ ("America/Matamoros", "America/Matamoros"),
+ ("America/Mazatlan", "America/Mazatlan"),
+ ("America/Mendoza", "America/Mendoza"),
+ ("America/Menominee", "America/Menominee"),
+ ("America/Merida", "America/Merida"),
+ ("America/Metlakatla", "America/Metlakatla"),
+ ("America/Mexico_City", "America/Mexico_City"),
+ ("America/Miquelon", "America/Miquelon"),
+ ("America/Moncton", "America/Moncton"),
+ ("America/Monterrey", "America/Monterrey"),
+ ("America/Montevideo", "America/Montevideo"),
+ ("America/Montreal", "America/Montreal"),
+ ("America/Montserrat", "America/Montserrat"),
+ ("America/Nassau", "America/Nassau"),
+ ("America/New_York", "America/New_York"),
+ ("America/Nipigon", "America/Nipigon"),
+ ("America/Nome", "America/Nome"),
+ ("America/Noronha", "America/Noronha"),
+ ("America/North_Dakota/Beulah", "America/North_Dakota/Beulah"),
+ ("America/North_Dakota/Center", "America/North_Dakota/Center"),
+ ("America/North_Dakota/New_Salem", "America/North_Dakota/New_Salem"),
+ ("America/Nuuk", "America/Nuuk"),
+ ("America/Ojinaga", "America/Ojinaga"),
+ ("America/Panama", "America/Panama"),
+ ("America/Pangnirtung", "America/Pangnirtung"),
+ ("America/Paramaribo", "America/Paramaribo"),
+ ("America/Phoenix", "America/Phoenix"),
+ ("America/Port-au-Prince", "America/Port-au-Prince"),
+ ("America/Port_of_Spain", "America/Port_of_Spain"),
+ ("America/Porto_Acre", "America/Porto_Acre"),
+ ("America/Porto_Velho", "America/Porto_Velho"),
+ ("America/Puerto_Rico", "America/Puerto_Rico"),
+ ("America/Punta_Arenas", "America/Punta_Arenas"),
+ ("America/Rainy_River", "America/Rainy_River"),
+ ("America/Rankin_Inlet", "America/Rankin_Inlet"),
+ ("America/Recife", "America/Recife"),
+ ("America/Regina", "America/Regina"),
+ ("America/Resolute", "America/Resolute"),
+ ("America/Rio_Branco", "America/Rio_Branco"),
+ ("America/Rosario", "America/Rosario"),
+ ("America/Santa_Isabel", "America/Santa_Isabel"),
+ ("America/Santarem", "America/Santarem"),
+ ("America/Santiago", "America/Santiago"),
+ ("America/Santo_Domingo", "America/Santo_Domingo"),
+ ("America/Sao_Paulo", "America/Sao_Paulo"),
+ ("America/Scoresbysund", "America/Scoresbysund"),
+ ("America/Shiprock", "America/Shiprock"),
+ ("America/Sitka", "America/Sitka"),
+ ("America/St_Barthelemy", "America/St_Barthelemy"),
+ ("America/St_Johns", "America/St_Johns"),
+ ("America/St_Kitts", "America/St_Kitts"),
+ ("America/St_Lucia", "America/St_Lucia"),
+ ("America/St_Thomas", "America/St_Thomas"),
+ ("America/St_Vincent", "America/St_Vincent"),
+ ("America/Swift_Current", "America/Swift_Current"),
+ ("America/Tegucigalpa", "America/Tegucigalpa"),
+ ("America/Thule", "America/Thule"),
+ ("America/Thunder_Bay", "America/Thunder_Bay"),
+ ("America/Tijuana", "America/Tijuana"),
+ ("America/Toronto", "America/Toronto"),
+ ("America/Tortola", "America/Tortola"),
+ ("America/Vancouver", "America/Vancouver"),
+ ("America/Virgin", "America/Virgin"),
+ ("America/Whitehorse", "America/Whitehorse"),
+ ("America/Winnipeg", "America/Winnipeg"),
+ ("America/Yakutat", "America/Yakutat"),
+ ("America/Yellowknife", "America/Yellowknife"),
+ ("Antarctica/Casey", "Antarctica/Casey"),
+ ("Antarctica/Davis", "Antarctica/Davis"),
+ ("Antarctica/DumontDUrville", "Antarctica/DumontDUrville"),
+ ("Antarctica/Macquarie", "Antarctica/Macquarie"),
+ ("Antarctica/Mawson", "Antarctica/Mawson"),
+ ("Antarctica/McMurdo", "Antarctica/McMurdo"),
+ ("Antarctica/Palmer", "Antarctica/Palmer"),
+ ("Antarctica/Rothera", "Antarctica/Rothera"),
+ ("Antarctica/South_Pole", "Antarctica/South_Pole"),
+ ("Antarctica/Syowa", "Antarctica/Syowa"),
+ ("Antarctica/Troll", "Antarctica/Troll"),
+ ("Antarctica/Vostok", "Antarctica/Vostok"),
+ ("Arctic/Longyearbyen", "Arctic/Longyearbyen"),
+ ("Asia/Aden", "Asia/Aden"),
+ ("Asia/Almaty", "Asia/Almaty"),
+ ("Asia/Amman", "Asia/Amman"),
+ ("Asia/Anadyr", "Asia/Anadyr"),
+ ("Asia/Aqtau", "Asia/Aqtau"),
+ ("Asia/Aqtobe", "Asia/Aqtobe"),
+ ("Asia/Ashgabat", "Asia/Ashgabat"),
+ ("Asia/Ashkhabad", "Asia/Ashkhabad"),
+ ("Asia/Atyrau", "Asia/Atyrau"),
+ ("Asia/Baghdad", "Asia/Baghdad"),
+ ("Asia/Bahrain", "Asia/Bahrain"),
+ ("Asia/Baku", "Asia/Baku"),
+ ("Asia/Bangkok", "Asia/Bangkok"),
+ ("Asia/Barnaul", "Asia/Barnaul"),
+ ("Asia/Beirut", "Asia/Beirut"),
+ ("Asia/Bishkek", "Asia/Bishkek"),
+ ("Asia/Brunei", "Asia/Brunei"),
+ ("Asia/Calcutta", "Asia/Calcutta"),
+ ("Asia/Chita", "Asia/Chita"),
+ ("Asia/Choibalsan", "Asia/Choibalsan"),
+ ("Asia/Chongqing", "Asia/Chongqing"),
+ ("Asia/Chungking", "Asia/Chungking"),
+ ("Asia/Colombo", "Asia/Colombo"),
+ ("Asia/Dacca", "Asia/Dacca"),
+ ("Asia/Damascus", "Asia/Damascus"),
+ ("Asia/Dhaka", "Asia/Dhaka"),
+ ("Asia/Dili", "Asia/Dili"),
+ ("Asia/Dubai", "Asia/Dubai"),
+ ("Asia/Dushanbe", "Asia/Dushanbe"),
+ ("Asia/Famagusta", "Asia/Famagusta"),
+ ("Asia/Gaza", "Asia/Gaza"),
+ ("Asia/Harbin", "Asia/Harbin"),
+ ("Asia/Hebron", "Asia/Hebron"),
+ ("Asia/Ho_Chi_Minh", "Asia/Ho_Chi_Minh"),
+ ("Asia/Hong_Kong", "Asia/Hong_Kong"),
+ ("Asia/Hovd", "Asia/Hovd"),
+ ("Asia/Irkutsk", "Asia/Irkutsk"),
+ ("Asia/Istanbul", "Asia/Istanbul"),
+ ("Asia/Jakarta", "Asia/Jakarta"),
+ ("Asia/Jayapura", "Asia/Jayapura"),
+ ("Asia/Jerusalem", "Asia/Jerusalem"),
+ ("Asia/Kabul", "Asia/Kabul"),
+ ("Asia/Kamchatka", "Asia/Kamchatka"),
+ ("Asia/Karachi", "Asia/Karachi"),
+ ("Asia/Kashgar", "Asia/Kashgar"),
+ ("Asia/Kathmandu", "Asia/Kathmandu"),
+ ("Asia/Katmandu", "Asia/Katmandu"),
+ ("Asia/Khandyga", "Asia/Khandyga"),
+ ("Asia/Kolkata", "Asia/Kolkata"),
+ ("Asia/Krasnoyarsk", "Asia/Krasnoyarsk"),
+ ("Asia/Kuala_Lumpur", "Asia/Kuala_Lumpur"),
+ ("Asia/Kuching", "Asia/Kuching"),
+ ("Asia/Kuwait", "Asia/Kuwait"),
+ ("Asia/Macao", "Asia/Macao"),
+ ("Asia/Macau", "Asia/Macau"),
+ ("Asia/Magadan", "Asia/Magadan"),
+ ("Asia/Makassar", "Asia/Makassar"),
+ ("Asia/Manila", "Asia/Manila"),
+ ("Asia/Muscat", "Asia/Muscat"),
+ ("Asia/Nicosia", "Asia/Nicosia"),
+ ("Asia/Novokuznetsk", "Asia/Novokuznetsk"),
+ ("Asia/Novosibirsk", "Asia/Novosibirsk"),
+ ("Asia/Omsk", "Asia/Omsk"),
+ ("Asia/Oral", "Asia/Oral"),
+ ("Asia/Phnom_Penh", "Asia/Phnom_Penh"),
+ ("Asia/Pontianak", "Asia/Pontianak"),
+ ("Asia/Pyongyang", "Asia/Pyongyang"),
+ ("Asia/Qatar", "Asia/Qatar"),
+ ("Asia/Qostanay", "Asia/Qostanay"),
+ ("Asia/Qyzylorda", "Asia/Qyzylorda"),
+ ("Asia/Rangoon", "Asia/Rangoon"),
+ ("Asia/Riyadh", "Asia/Riyadh"),
+ ("Asia/Saigon", "Asia/Saigon"),
+ ("Asia/Sakhalin", "Asia/Sakhalin"),
+ ("Asia/Samarkand", "Asia/Samarkand"),
+ ("Asia/Seoul", "Asia/Seoul"),
+ ("Asia/Shanghai", "Asia/Shanghai"),
+ ("Asia/Singapore", "Asia/Singapore"),
+ ("Asia/Srednekolymsk", "Asia/Srednekolymsk"),
+ ("Asia/Taipei", "Asia/Taipei"),
+ ("Asia/Tashkent", "Asia/Tashkent"),
+ ("Asia/Tbilisi", "Asia/Tbilisi"),
+ ("Asia/Tehran", "Asia/Tehran"),
+ ("Asia/Tel_Aviv", "Asia/Tel_Aviv"),
+ ("Asia/Thimbu", "Asia/Thimbu"),
+ ("Asia/Thimphu", "Asia/Thimphu"),
+ ("Asia/Tokyo", "Asia/Tokyo"),
+ ("Asia/Tomsk", "Asia/Tomsk"),
+ ("Asia/Ujung_Pandang", "Asia/Ujung_Pandang"),
+ ("Asia/Ulaanbaatar", "Asia/Ulaanbaatar"),
+ ("Asia/Ulan_Bator", "Asia/Ulan_Bator"),
+ ("Asia/Urumqi", "Asia/Urumqi"),
+ ("Asia/Ust-Nera", "Asia/Ust-Nera"),
+ ("Asia/Vientiane", "Asia/Vientiane"),
+ ("Asia/Vladivostok", "Asia/Vladivostok"),
+ ("Asia/Yakutsk", "Asia/Yakutsk"),
+ ("Asia/Yangon", "Asia/Yangon"),
+ ("Asia/Yekaterinburg", "Asia/Yekaterinburg"),
+ ("Asia/Yerevan", "Asia/Yerevan"),
+ ("Atlantic/Azores", "Atlantic/Azores"),
+ ("Atlantic/Bermuda", "Atlantic/Bermuda"),
+ ("Atlantic/Canary", "Atlantic/Canary"),
+ ("Atlantic/Cape_Verde", "Atlantic/Cape_Verde"),
+ ("Atlantic/Faeroe", "Atlantic/Faeroe"),
+ ("Atlantic/Faroe", "Atlantic/Faroe"),
+ ("Atlantic/Jan_Mayen", "Atlantic/Jan_Mayen"),
+ ("Atlantic/Madeira", "Atlantic/Madeira"),
+ ("Atlantic/Reykjavik", "Atlantic/Reykjavik"),
+ ("Atlantic/South_Georgia", "Atlantic/South_Georgia"),
+ ("Atlantic/St_Helena", "Atlantic/St_Helena"),
+ ("Atlantic/Stanley", "Atlantic/Stanley"),
+ ("Australia/ACT", "Australia/ACT"),
+ ("Australia/Adelaide", "Australia/Adelaide"),
+ ("Australia/Brisbane", "Australia/Brisbane"),
+ ("Australia/Broken_Hill", "Australia/Broken_Hill"),
+ ("Australia/Canberra", "Australia/Canberra"),
+ ("Australia/Currie", "Australia/Currie"),
+ ("Australia/Darwin", "Australia/Darwin"),
+ ("Australia/Eucla", "Australia/Eucla"),
+ ("Australia/Hobart", "Australia/Hobart"),
+ ("Australia/LHI", "Australia/LHI"),
+ ("Australia/Lindeman", "Australia/Lindeman"),
+ ("Australia/Lord_Howe", "Australia/Lord_Howe"),
+ ("Australia/Melbourne", "Australia/Melbourne"),
+ ("Australia/NSW", "Australia/NSW"),
+ ("Australia/North", "Australia/North"),
+ ("Australia/Perth", "Australia/Perth"),
+ ("Australia/Queensland", "Australia/Queensland"),
+ ("Australia/South", "Australia/South"),
+ ("Australia/Sydney", "Australia/Sydney"),
+ ("Australia/Tasmania", "Australia/Tasmania"),
+ ("Australia/Victoria", "Australia/Victoria"),
+ ("Australia/West", "Australia/West"),
+ ("Australia/Yancowinna", "Australia/Yancowinna"),
+ ("Brazil/Acre", "Brazil/Acre"),
+ ("Brazil/DeNoronha", "Brazil/DeNoronha"),
+ ("Brazil/East", "Brazil/East"),
+ ("Brazil/West", "Brazil/West"),
+ ("CET", "CET"),
+ ("CST6CDT", "CST6CDT"),
+ ("Canada/Atlantic", "Canada/Atlantic"),
+ ("Canada/Central", "Canada/Central"),
+ ("Canada/Eastern", "Canada/Eastern"),
+ ("Canada/Mountain", "Canada/Mountain"),
+ ("Canada/Newfoundland", "Canada/Newfoundland"),
+ ("Canada/Pacific", "Canada/Pacific"),
+ ("Canada/Saskatchewan", "Canada/Saskatchewan"),
+ ("Canada/Yukon", "Canada/Yukon"),
+ ("Chile/Continental", "Chile/Continental"),
+ ("Chile/EasterIsland", "Chile/EasterIsland"),
+ ("Cuba", "Cuba"),
+ ("EET", "EET"),
+ ("EST", "EST"),
+ ("EST5EDT", "EST5EDT"),
+ ("Egypt", "Egypt"),
+ ("Eire", "Eire"),
+ ("Etc/GMT", "Etc/GMT"),
+ ("Etc/GMT+0", "Etc/GMT+0"),
+ ("Etc/GMT+1", "Etc/GMT+1"),
+ ("Etc/GMT+10", "Etc/GMT+10"),
+ ("Etc/GMT+11", "Etc/GMT+11"),
+ ("Etc/GMT+12", "Etc/GMT+12"),
+ ("Etc/GMT+2", "Etc/GMT+2"),
+ ("Etc/GMT+3", "Etc/GMT+3"),
+ ("Etc/GMT+4", "Etc/GMT+4"),
+ ("Etc/GMT+5", "Etc/GMT+5"),
+ ("Etc/GMT+6", "Etc/GMT+6"),
+ ("Etc/GMT+7", "Etc/GMT+7"),
+ ("Etc/GMT+8", "Etc/GMT+8"),
+ ("Etc/GMT+9", "Etc/GMT+9"),
+ ("Etc/GMT-0", "Etc/GMT-0"),
+ ("Etc/GMT-1", "Etc/GMT-1"),
+ ("Etc/GMT-10", "Etc/GMT-10"),
+ ("Etc/GMT-11", "Etc/GMT-11"),
+ ("Etc/GMT-12", "Etc/GMT-12"),
+ ("Etc/GMT-13", "Etc/GMT-13"),
+ ("Etc/GMT-14", "Etc/GMT-14"),
+ ("Etc/GMT-2", "Etc/GMT-2"),
+ ("Etc/GMT-3", "Etc/GMT-3"),
+ ("Etc/GMT-4", "Etc/GMT-4"),
+ ("Etc/GMT-5", "Etc/GMT-5"),
+ ("Etc/GMT-6", "Etc/GMT-6"),
+ ("Etc/GMT-7", "Etc/GMT-7"),
+ ("Etc/GMT-8", "Etc/GMT-8"),
+ ("Etc/GMT-9", "Etc/GMT-9"),
+ ("Etc/GMT0", "Etc/GMT0"),
+ ("Etc/Greenwich", "Etc/Greenwich"),
+ ("Etc/UCT", "Etc/UCT"),
+ ("Etc/UTC", "Etc/UTC"),
+ ("Etc/Universal", "Etc/Universal"),
+ ("Etc/Zulu", "Etc/Zulu"),
+ ("Europe/Amsterdam", "Europe/Amsterdam"),
+ ("Europe/Andorra", "Europe/Andorra"),
+ ("Europe/Astrakhan", "Europe/Astrakhan"),
+ ("Europe/Athens", "Europe/Athens"),
+ ("Europe/Belfast", "Europe/Belfast"),
+ ("Europe/Belgrade", "Europe/Belgrade"),
+ ("Europe/Berlin", "Europe/Berlin"),
+ ("Europe/Bratislava", "Europe/Bratislava"),
+ ("Europe/Brussels", "Europe/Brussels"),
+ ("Europe/Bucharest", "Europe/Bucharest"),
+ ("Europe/Budapest", "Europe/Budapest"),
+ ("Europe/Busingen", "Europe/Busingen"),
+ ("Europe/Chisinau", "Europe/Chisinau"),
+ ("Europe/Copenhagen", "Europe/Copenhagen"),
+ ("Europe/Dublin", "Europe/Dublin"),
+ ("Europe/Gibraltar", "Europe/Gibraltar"),
+ ("Europe/Guernsey", "Europe/Guernsey"),
+ ("Europe/Helsinki", "Europe/Helsinki"),
+ ("Europe/Isle_of_Man", "Europe/Isle_of_Man"),
+ ("Europe/Istanbul", "Europe/Istanbul"),
+ ("Europe/Jersey", "Europe/Jersey"),
+ ("Europe/Kaliningrad", "Europe/Kaliningrad"),
+ ("Europe/Kiev", "Europe/Kiev"),
+ ("Europe/Kirov", "Europe/Kirov"),
+ ("Europe/Kyiv", "Europe/Kyiv"),
+ ("Europe/Lisbon", "Europe/Lisbon"),
+ ("Europe/Ljubljana", "Europe/Ljubljana"),
+ ("Europe/London", "Europe/London"),
+ ("Europe/Luxembourg", "Europe/Luxembourg"),
+ ("Europe/Madrid", "Europe/Madrid"),
+ ("Europe/Malta", "Europe/Malta"),
+ ("Europe/Mariehamn", "Europe/Mariehamn"),
+ ("Europe/Minsk", "Europe/Minsk"),
+ ("Europe/Monaco", "Europe/Monaco"),
+ ("Europe/Moscow", "Europe/Moscow"),
+ ("Europe/Nicosia", "Europe/Nicosia"),
+ ("Europe/Oslo", "Europe/Oslo"),
+ ("Europe/Paris", "Europe/Paris"),
+ ("Europe/Podgorica", "Europe/Podgorica"),
+ ("Europe/Prague", "Europe/Prague"),
+ ("Europe/Riga", "Europe/Riga"),
+ ("Europe/Rome", "Europe/Rome"),
+ ("Europe/Samara", "Europe/Samara"),
+ ("Europe/San_Marino", "Europe/San_Marino"),
+ ("Europe/Sarajevo", "Europe/Sarajevo"),
+ ("Europe/Saratov", "Europe/Saratov"),
+ ("Europe/Simferopol", "Europe/Simferopol"),
+ ("Europe/Skopje", "Europe/Skopje"),
+ ("Europe/Sofia", "Europe/Sofia"),
+ ("Europe/Stockholm", "Europe/Stockholm"),
+ ("Europe/Tallinn", "Europe/Tallinn"),
+ ("Europe/Tirane", "Europe/Tirane"),
+ ("Europe/Tiraspol", "Europe/Tiraspol"),
+ ("Europe/Ulyanovsk", "Europe/Ulyanovsk"),
+ ("Europe/Uzhgorod", "Europe/Uzhgorod"),
+ ("Europe/Vaduz", "Europe/Vaduz"),
+ ("Europe/Vatican", "Europe/Vatican"),
+ ("Europe/Vienna", "Europe/Vienna"),
+ ("Europe/Vilnius", "Europe/Vilnius"),
+ ("Europe/Volgograd", "Europe/Volgograd"),
+ ("Europe/Warsaw", "Europe/Warsaw"),
+ ("Europe/Zagreb", "Europe/Zagreb"),
+ ("Europe/Zaporozhye", "Europe/Zaporozhye"),
+ ("Europe/Zurich", "Europe/Zurich"),
+ ("GB", "GB"),
+ ("GB-Eire", "GB-Eire"),
+ ("GMT", "GMT"),
+ ("GMT+0", "GMT+0"),
+ ("GMT-0", "GMT-0"),
+ ("GMT0", "GMT0"),
+ ("Greenwich", "Greenwich"),
+ ("HST", "HST"),
+ ("Hongkong", "Hongkong"),
+ ("Iceland", "Iceland"),
+ ("Indian/Antananarivo", "Indian/Antananarivo"),
+ ("Indian/Chagos", "Indian/Chagos"),
+ ("Indian/Christmas", "Indian/Christmas"),
+ ("Indian/Cocos", "Indian/Cocos"),
+ ("Indian/Comoro", "Indian/Comoro"),
+ ("Indian/Kerguelen", "Indian/Kerguelen"),
+ ("Indian/Mahe", "Indian/Mahe"),
+ ("Indian/Maldives", "Indian/Maldives"),
+ ("Indian/Mauritius", "Indian/Mauritius"),
+ ("Indian/Mayotte", "Indian/Mayotte"),
+ ("Indian/Reunion", "Indian/Reunion"),
+ ("Iran", "Iran"),
+ ("Israel", "Israel"),
+ ("Jamaica", "Jamaica"),
+ ("Japan", "Japan"),
+ ("Kwajalein", "Kwajalein"),
+ ("Libya", "Libya"),
+ ("MET", "MET"),
+ ("MST", "MST"),
+ ("MST7MDT", "MST7MDT"),
+ ("Mexico/BajaNorte", "Mexico/BajaNorte"),
+ ("Mexico/BajaSur", "Mexico/BajaSur"),
+ ("Mexico/General", "Mexico/General"),
+ ("NZ", "NZ"),
+ ("NZ-CHAT", "NZ-CHAT"),
+ ("Navajo", "Navajo"),
+ ("PRC", "PRC"),
+ ("PST8PDT", "PST8PDT"),
+ ("Pacific/Apia", "Pacific/Apia"),
+ ("Pacific/Auckland", "Pacific/Auckland"),
+ ("Pacific/Bougainville", "Pacific/Bougainville"),
+ ("Pacific/Chatham", "Pacific/Chatham"),
+ ("Pacific/Chuuk", "Pacific/Chuuk"),
+ ("Pacific/Easter", "Pacific/Easter"),
+ ("Pacific/Efate", "Pacific/Efate"),
+ ("Pacific/Enderbury", "Pacific/Enderbury"),
+ ("Pacific/Fakaofo", "Pacific/Fakaofo"),
+ ("Pacific/Fiji", "Pacific/Fiji"),
+ ("Pacific/Funafuti", "Pacific/Funafuti"),
+ ("Pacific/Galapagos", "Pacific/Galapagos"),
+ ("Pacific/Gambier", "Pacific/Gambier"),
+ ("Pacific/Guadalcanal", "Pacific/Guadalcanal"),
+ ("Pacific/Guam", "Pacific/Guam"),
+ ("Pacific/Honolulu", "Pacific/Honolulu"),
+ ("Pacific/Johnston", "Pacific/Johnston"),
+ ("Pacific/Kanton", "Pacific/Kanton"),
+ ("Pacific/Kiritimati", "Pacific/Kiritimati"),
+ ("Pacific/Kosrae", "Pacific/Kosrae"),
+ ("Pacific/Kwajalein", "Pacific/Kwajalein"),
+ ("Pacific/Majuro", "Pacific/Majuro"),
+ ("Pacific/Marquesas", "Pacific/Marquesas"),
+ ("Pacific/Midway", "Pacific/Midway"),
+ ("Pacific/Nauru", "Pacific/Nauru"),
+ ("Pacific/Niue", "Pacific/Niue"),
+ ("Pacific/Norfolk", "Pacific/Norfolk"),
+ ("Pacific/Noumea", "Pacific/Noumea"),
+ ("Pacific/Pago_Pago", "Pacific/Pago_Pago"),
+ ("Pacific/Palau", "Pacific/Palau"),
+ ("Pacific/Pitcairn", "Pacific/Pitcairn"),
+ ("Pacific/Pohnpei", "Pacific/Pohnpei"),
+ ("Pacific/Ponape", "Pacific/Ponape"),
+ ("Pacific/Port_Moresby", "Pacific/Port_Moresby"),
+ ("Pacific/Rarotonga", "Pacific/Rarotonga"),
+ ("Pacific/Saipan", "Pacific/Saipan"),
+ ("Pacific/Samoa", "Pacific/Samoa"),
+ ("Pacific/Tahiti", "Pacific/Tahiti"),
+ ("Pacific/Tarawa", "Pacific/Tarawa"),
+ ("Pacific/Tongatapu", "Pacific/Tongatapu"),
+ ("Pacific/Truk", "Pacific/Truk"),
+ ("Pacific/Wake", "Pacific/Wake"),
+ ("Pacific/Wallis", "Pacific/Wallis"),
+ ("Pacific/Yap", "Pacific/Yap"),
+ ("Poland", "Poland"),
+ ("Portugal", "Portugal"),
+ ("ROC", "ROC"),
+ ("ROK", "ROK"),
+ ("Singapore", "Singapore"),
+ ("Turkey", "Turkey"),
+ ("UCT", "UCT"),
+ ("US/Alaska", "US/Alaska"),
+ ("US/Aleutian", "US/Aleutian"),
+ ("US/Arizona", "US/Arizona"),
+ ("US/Central", "US/Central"),
+ ("US/East-Indiana", "US/East-Indiana"),
+ ("US/Eastern", "US/Eastern"),
+ ("US/Hawaii", "US/Hawaii"),
+ ("US/Indiana-Starke", "US/Indiana-Starke"),
+ ("US/Michigan", "US/Michigan"),
+ ("US/Mountain", "US/Mountain"),
+ ("US/Pacific", "US/Pacific"),
+ ("US/Samoa", "US/Samoa"),
+ ("UTC", "UTC"),
+ ("Universal", "Universal"),
+ ("W-SU", "W-SU"),
+ ("WET", "WET"),
+ ("Zulu", "Zulu"),
+ ],
+ default="UTC",
+ max_length=240,
+ ),
+ ),
+ (
+ "data_attributes",
+ models.JSONField(blank=True, default=posthog.models.team.team.get_default_data_attributes),
+ ),
+ (
+ "person_display_name_properties",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=400), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "live_events_columns",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "recording_domains",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=200, null=True), blank=True, null=True, size=None
+ ),
+ ),
+ ("correlation_config", models.JSONField(blank=True, default=dict, null=True)),
+ ("session_recording_retention_period_days", models.IntegerField(blank=True, default=None, null=True)),
+ ("plugins_opt_in", models.BooleanField(default=False)),
+ ("opt_out_capture", models.BooleanField(default=False)),
+ ("event_names", models.JSONField(blank=True, default=list)),
+ ("event_names_with_usage", models.JSONField(blank=True, default=list)),
+ ("event_properties", models.JSONField(blank=True, default=list)),
+ ("event_properties_with_usage", models.JSONField(blank=True, default=list)),
+ ("event_properties_numerical", models.JSONField(blank=True, default=list)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="teams",
+ related_query_name="team",
+ to="posthog.organization",
+ ),
+ ),
+ ("capture_performance_opt_in", models.BooleanField(blank=True, default=True, null=True)),
+ ("session_recording_version", models.CharField(blank=True, max_length=24, null=True)),
+ ("autocapture_opt_out", models.BooleanField(blank=True, null=True)),
+ ("autocapture_exceptions_opt_in", models.BooleanField(blank=True, null=True)),
+ ("extra_settings", models.JSONField(blank=True, null=True)),
+ ("autocapture_exceptions_errors_to_ignore", models.JSONField(blank=True, null=True)),
+ ("has_completed_onboarding_for", models.JSONField(blank=True, null=True)),
+ (
+ "week_start_day",
+ models.SmallIntegerField(blank=True, choices=[(0, "Sunday"), (1, "Monday")], null=True),
+ ),
+ ("surveys_opt_in", models.BooleanField(blank=True, null=True)),
+ ("session_recording_linked_flag", models.JSONField(blank=True, null=True)),
+ (
+ "session_recording_minimum_duration_milliseconds",
+ models.IntegerField(
+ blank=True,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0),
+ django.core.validators.MaxValueValidator(30000),
+ ],
+ ),
+ ),
+ (
+ "session_recording_sample_rate",
+ models.DecimalField(
+ blank=True,
+ decimal_places=2,
+ max_digits=3,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(Decimal("0")),
+ django.core.validators.MaxValueValidator(Decimal("1")),
+ ],
+ ),
+ ),
+ ("external_data_workspace_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("session_recording_network_payload_capture_config", models.JSONField(blank=True, null=True)),
+ ("external_data_workspace_last_synced_at", models.DateTimeField(blank=True, null=True)),
+ ("session_replay_config", models.JSONField(blank=True, null=True)),
+ (
+ "project",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="teams",
+ related_query_name="team",
+ to="posthog.project",
+ ),
+ ),
+ ("heatmaps_opt_in", models.BooleanField(blank=True, null=True)),
+ ("modifiers", models.JSONField(blank=True, null=True)),
+ ("autocapture_web_vitals_opt_in", models.BooleanField(blank=True, null=True)),
+ ("autocapture_web_vitals_allowed_metrics", models.JSONField(blank=True, null=True)),
+ ("survey_config", models.JSONField(blank=True, null=True)),
+ (
+ "session_recording_url_trigger_config",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.JSONField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("person_processing_opt_out", models.BooleanField(default=False, null=True)),
+ (
+ "session_recording_url_blocklist_config",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.JSONField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("capture_dead_clicks", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "session_recording_event_trigger_config",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "cookieless_server_hash_mode",
+ models.SmallIntegerField(
+ choices=[(0, "Disabled"), (1, "Stateless"), (2, "Stateful")], default=0, null=True
+ ),
+ ),
+ ("default_data_theme", models.IntegerField(blank=True, null=True)),
+ ("human_friendly_comparison_periods", models.BooleanField(blank=True, default=False, null=True)),
+ ("flags_persistence_default", models.BooleanField(blank=True, default=False, null=True)),
+ ("revenue_tracking_config", models.JSONField(blank=True, null=True)),
+ (
+ "api_query_rate_limit",
+ models.CharField(
+ blank=True,
+ help_text="Custom rate limit for HogQL API queries in #requests/{sec,min,hour,day}",
+ max_length=32,
+ null=True,
+ validators=[posthog.models.utils.validate_rate_limit],
+ ),
+ ),
+ ("onboarding_tasks", models.JSONField(blank=True, null=True)),
+ ("session_recording_masking_config", models.JSONField(blank=True, null=True)),
+ (
+ "parent_team",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="child_teams",
+ related_query_name="child_team",
+ to="posthog.team",
+ ),
+ ),
+ ("session_recording_trigger_match_type_config", models.CharField(blank=True, max_length=24, null=True)),
+ ("secret_api_token", models.CharField(blank=True, max_length=200, null=True)),
+ ("secret_api_token_backup", models.CharField(blank=True, max_length=200, null=True)),
+ (
+ "base_currency",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("AED", "AED"),
+ ("AFN", "AFN"),
+ ("ALL", "ALL"),
+ ("AMD", "AMD"),
+ ("ANG", "ANG"),
+ ("AOA", "AOA"),
+ ("ARS", "ARS"),
+ ("AUD", "AUD"),
+ ("AWG", "AWG"),
+ ("AZN", "AZN"),
+ ("BAM", "BAM"),
+ ("BBD", "BBD"),
+ ("BDT", "BDT"),
+ ("BGN", "BGN"),
+ ("BHD", "BHD"),
+ ("BIF", "BIF"),
+ ("BMD", "BMD"),
+ ("BND", "BND"),
+ ("BOB", "BOB"),
+ ("BRL", "BRL"),
+ ("BSD", "BSD"),
+ ("BTC", "BTC"),
+ ("BTN", "BTN"),
+ ("BWP", "BWP"),
+ ("BYN", "BYN"),
+ ("BZD", "BZD"),
+ ("CAD", "CAD"),
+ ("CDF", "CDF"),
+ ("CHF", "CHF"),
+ ("CLP", "CLP"),
+ ("CNY", "CNY"),
+ ("COP", "COP"),
+ ("CRC", "CRC"),
+ ("CVE", "CVE"),
+ ("CZK", "CZK"),
+ ("DJF", "DJF"),
+ ("DKK", "DKK"),
+ ("DOP", "DOP"),
+ ("DZD", "DZD"),
+ ("EGP", "EGP"),
+ ("ERN", "ERN"),
+ ("ETB", "ETB"),
+ ("EUR", "EUR"),
+ ("FJD", "FJD"),
+ ("GBP", "GBP"),
+ ("GEL", "GEL"),
+ ("GHS", "GHS"),
+ ("GIP", "GIP"),
+ ("GMD", "GMD"),
+ ("GNF", "GNF"),
+ ("GTQ", "GTQ"),
+ ("GYD", "GYD"),
+ ("HKD", "HKD"),
+ ("HNL", "HNL"),
+ ("HRK", "HRK"),
+ ("HTG", "HTG"),
+ ("HUF", "HUF"),
+ ("IDR", "IDR"),
+ ("ILS", "ILS"),
+ ("INR", "INR"),
+ ("IQD", "IQD"),
+ ("IRR", "IRR"),
+ ("ISK", "ISK"),
+ ("JMD", "JMD"),
+ ("JOD", "JOD"),
+ ("JPY", "JPY"),
+ ("KES", "KES"),
+ ("KGS", "KGS"),
+ ("KHR", "KHR"),
+ ("KMF", "KMF"),
+ ("KRW", "KRW"),
+ ("KWD", "KWD"),
+ ("KYD", "KYD"),
+ ("KZT", "KZT"),
+ ("LAK", "LAK"),
+ ("LBP", "LBP"),
+ ("LKR", "LKR"),
+ ("LRD", "LRD"),
+ ("LTL", "LTL"),
+ ("LVL", "LVL"),
+ ("LSL", "LSL"),
+ ("LYD", "LYD"),
+ ("MAD", "MAD"),
+ ("MDL", "MDL"),
+ ("MGA", "MGA"),
+ ("MKD", "MKD"),
+ ("MMK", "MMK"),
+ ("MNT", "MNT"),
+ ("MOP", "MOP"),
+ ("MRU", "MRU"),
+ ("MTL", "MTL"),
+ ("MUR", "MUR"),
+ ("MVR", "MVR"),
+ ("MWK", "MWK"),
+ ("MXN", "MXN"),
+ ("MYR", "MYR"),
+ ("MZN", "MZN"),
+ ("NAD", "NAD"),
+ ("NGN", "NGN"),
+ ("NIO", "NIO"),
+ ("NOK", "NOK"),
+ ("NPR", "NPR"),
+ ("NZD", "NZD"),
+ ("OMR", "OMR"),
+ ("PAB", "PAB"),
+ ("PEN", "PEN"),
+ ("PGK", "PGK"),
+ ("PHP", "PHP"),
+ ("PKR", "PKR"),
+ ("PLN", "PLN"),
+ ("PYG", "PYG"),
+ ("QAR", "QAR"),
+ ("RON", "RON"),
+ ("RSD", "RSD"),
+ ("RUB", "RUB"),
+ ("RWF", "RWF"),
+ ("SAR", "SAR"),
+ ("SBD", "SBD"),
+ ("SCR", "SCR"),
+ ("SDG", "SDG"),
+ ("SEK", "SEK"),
+ ("SGD", "SGD"),
+ ("SRD", "SRD"),
+ ("SSP", "SSP"),
+ ("STN", "STN"),
+ ("SYP", "SYP"),
+ ("SZL", "SZL"),
+ ("THB", "THB"),
+ ("TJS", "TJS"),
+ ("TMT", "TMT"),
+ ("TND", "TND"),
+ ("TOP", "TOP"),
+ ("TRY", "TRY"),
+ ("TTD", "TTD"),
+ ("TWD", "TWD"),
+ ("TZS", "TZS"),
+ ("UAH", "UAH"),
+ ("UGX", "UGX"),
+ ("USD", "USD"),
+ ("UYU", "UYU"),
+ ("UZS", "UZS"),
+ ("VES", "VES"),
+ ("VND", "VND"),
+ ("VUV", "VUV"),
+ ("WST", "WST"),
+ ("XAF", "XAF"),
+ ("XCD", "XCD"),
+ ("XOF", "XOF"),
+ ("XPF", "XPF"),
+ ("YER", "YER"),
+ ("ZAR", "ZAR"),
+ ("ZMW", "ZMW"),
+ ],
+ default="USD",
+ max_length=3,
+ null=True,
+ ),
+ ),
+ (
+ "drop_events_older_than",
+ models.DurationField(
+ blank=True,
+ help_text="Events older than this threshold will be dropped in ingestion. Empty means no timestamp restrictions.",
+ null=True,
+ validators=[django.core.validators.MinValueValidator(datetime.timedelta(seconds=3600))],
+ ),
+ ),
+ ("feature_flag_confirmation_enabled", models.BooleanField(blank=True, default=False, null=True)),
+ ("feature_flag_confirmation_message", models.TextField(blank=True, null=True)),
+ (
+ "session_recording_retention_period",
+ models.CharField(
+ choices=[("30d", "30 Days"), ("90d", "90 Days"), ("1y", "1 Year"), ("5y", "5 Years")],
+ default="30d",
+ max_length=3,
+ ),
+ ),
+ ("web_analytics_pre_aggregated_tables_enabled", models.BooleanField(default=False, null=True)),
+ (
+ "web_analytics_pre_aggregated_tables_version",
+ models.CharField(choices=[("v1", "v1"), ("v2", "v2")], default="v2", max_length=10, null=True),
+ ),
+ (
+ "experiment_recalculation_time",
+ models.TimeField(
+ blank=True,
+ help_text="Time of day (UTC) when experiment metrics should be recalculated. If not set, uses the default recalculation time.",
+ null=True,
+ ),
+ ),
+ ("default_evaluation_environments_enabled", models.BooleanField(blank=True, default=False, null=True)),
+ ("receive_org_level_activity_logs", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "business_model",
+ models.CharField(
+ blank=True,
+ choices=[("b2b", "B2B"), ("b2c", "B2C"), ("other", "Other")],
+ help_text="Whether this project serves B2B or B2C customers, used to optimize the UI layout.",
+ max_length=10,
+ null=True,
+ ),
+ ),
+ ("require_evaluation_environment_tags", models.BooleanField(blank=True, default=False, null=True)),
+ ("product_tours_opt_in", models.BooleanField(blank=True, null=True)),
+ ("conversations_enabled", models.BooleanField(blank=True, null=True)),
+ ("conversations_settings", models.JSONField(blank=True, null=True)),
+ ("logs_settings", models.JSONField(blank=True, null=True)),
+ (
+ "default_evaluation_contexts_enabled",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="Whether to automatically apply default evaluation contexts to new feature flags",
+ null=True,
+ ),
+ ),
+ (
+ "require_evaluation_contexts",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="Whether to require at least one evaluation context tag when creating new feature flags",
+ null=True,
+ ),
+ ),
+ (
+ "default_experiment_confidence_level",
+ models.DecimalField(
+ blank=True,
+ decimal_places=2,
+ help_text="Default confidence level for new experiments in this environment. Valid values: 0.90, 0.95, 0.99.",
+ max_digits=3,
+ null=True,
+ ),
+ ),
+ (
+ "default_experiment_stats_method",
+ models.CharField(
+ blank=True,
+ choices=[("bayesian", "Bayesian"), ("frequentist", "Frequentist")],
+ default="bayesian",
+ help_text="Default statistical method for new experiments in this environment.",
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("proactive_tasks_enabled", models.BooleanField(blank=True, null=True)),
+ (
+ "session_recording_trigger_groups",
+ models.JSONField(
+ blank=True,
+ help_text="V2 trigger groups configuration for session recording. If present, takes precedence over legacy trigger fields.",
+ null=True,
+ ),
+ ),
+ ("llm_gateway_revoked_at", models.DateTimeField(blank=True, null=True)),
+ ("llm_gateway_enabled_at", models.DateTimeField(blank=True, null=True)),
+ ("ingested_production_event", models.BooleanField(db_default=False, default=False)),
+ ("ingested_production_event_last_checked_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "llm_gateway_overspend_allowance_usd",
+ models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True),
+ ),
+ ("event_retention_months", models.PositiveSmallIntegerField(db_default=84, default=84)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ django.contrib.postgres.indexes.HashIndex(
+ django.db.models.fields.json.KeyTransform("widget_public_token", "conversations_settings"),
+ condition=models.Q(("conversations_enabled", True)),
+ name="posthog_team_widget_token_idx",
+ )
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("project_id__isnull", False)), name="project_id_is_not_null"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("llm_gateway_overspend_allowance_usd__isnull", True),
+ models.Q(
+ ("llm_gateway_overspend_allowance_usd__gte", 0),
+ ("llm_gateway_overspend_allowance_usd__lte", 10000),
+ ),
+ _connector="OR",
+ ),
+ name="llm_gateway_overspend_allowance_usd_in_range",
+ ),
+ ],
+ "verbose_name": "environment (aka team)",
+ "verbose_name_plural": "environments (aka teams)",
+ "base_manager_name": "objects",
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationDomain",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("domain", models.CharField(max_length=128, unique=True)),
+ (
+ "verification_challenge",
+ models.CharField(
+ default=posthog.models.organization_domain.generate_verification_challenge, max_length=128
+ ),
+ ),
+ ("verified_at", models.DateTimeField(blank=True, default=None, null=True)),
+ ("last_verification_retry", models.DateTimeField(blank=True, default=None, null=True)),
+ ("jit_provisioning_enabled", models.BooleanField(default=False)),
+ ("sso_enforcement", models.CharField(blank=True, max_length=28)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="domains", to="posthog.organization"
+ ),
+ ),
+ (
+ "_id_jag_allowed_clients",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=256),
+ blank=True,
+ db_column="id_jag_allowed_clients",
+ default=list,
+ help_text="Allowed ID-JAG client IDs. Empty list allows any client_id.",
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "_id_jag_issuer_url",
+ models.CharField(
+ blank=True,
+ db_column="id_jag_issuer_url",
+ help_text="Trusted IdP issuer URL for ID-JAG. Required to enable ID-JAG on this domain.",
+ max_length=512,
+ null=True,
+ ),
+ ),
+ (
+ "_id_jag_jwks_url",
+ models.CharField(
+ blank=True,
+ db_column="id_jag_jwks_url",
+ help_text="Override JWKS URL. Defaults to OIDC discovery on the issuer URL.",
+ max_length=512,
+ null=True,
+ ),
+ ),
+ ("_saml_acs_url", models.CharField(blank=True, db_column="saml_acs_url", max_length=512, null=True)),
+ (
+ "_saml_entity_id",
+ models.CharField(blank=True, db_column="saml_entity_id", max_length=512, null=True),
+ ),
+ ("_saml_x509_cert", models.TextField(blank=True, db_column="saml_x509_cert", null=True)),
+ (
+ "_scim_bearer_token",
+ models.CharField(
+ blank=True,
+ db_column="scim_bearer_token",
+ help_text="Hashed bearer token for SCIM authentication",
+ max_length=255,
+ null=True,
+ ),
+ ),
+ ("_scim_enabled", models.BooleanField(db_column="scim_enabled", default=False)),
+ (
+ "_identity_provider_config",
+ models.ForeignKey(
+ blank=True,
+ db_column="identity_provider_config_id",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.identityproviderconfig",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "domain",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="User",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("password", models.CharField(max_length=128, verbose_name="password")),
+ ("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")),
+ ("first_name", models.CharField(blank=True, max_length=150, verbose_name="first name")),
+ ("last_name", models.CharField(blank=True, max_length=150, verbose_name="last name")),
+ (
+ "is_staff",
+ models.BooleanField(
+ default=False,
+ help_text="Designates whether the user can log into this admin site.",
+ verbose_name="staff status",
+ ),
+ ),
+ (
+ "is_active",
+ models.BooleanField(
+ default=True,
+ help_text="Unselect this to temporarily disable an account.",
+ verbose_name="active",
+ ),
+ ),
+ ("date_joined", models.DateTimeField(default=django.utils.timezone.now, verbose_name="date joined")),
+ ("uuid", models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, unique=True)),
+ ("email", models.EmailField(max_length=254, unique=True, verbose_name="email address")),
+ ("temporary_token", models.CharField(blank=True, max_length=200, null=True, unique=True)),
+ ("distinct_id", models.CharField(blank=True, max_length=200, null=True, unique=True)),
+ ("email_opt_in", models.BooleanField(blank=True, default=False, null=True)),
+ ("partial_notification_settings", models.JSONField(blank=True, null=True)),
+ ("anonymize_data", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "toolbar_mode",
+ models.CharField(
+ blank=True,
+ choices=[("disabled", "disabled"), ("toolbar", "toolbar")],
+ default="toolbar",
+ max_length=200,
+ null=True,
+ ),
+ ),
+ ("events_column_config", models.JSONField(default=posthog.models.user.events_column_config_default)),
+ (
+ "current_organization",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="users_currently+",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "current_team",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="teams_currently+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "groups",
+ models.ManyToManyField(
+ blank=True,
+ help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
+ related_name="user_set",
+ related_query_name="user",
+ to="auth.group",
+ verbose_name="groups",
+ ),
+ ),
+ (
+ "user_permissions",
+ models.ManyToManyField(
+ blank=True,
+ help_text="Specific permissions for this user.",
+ related_name="user_set",
+ related_query_name="user",
+ to="auth.permission",
+ verbose_name="user permissions",
+ ),
+ ),
+ ("is_email_verified", models.BooleanField(blank=True, null=True)),
+ (
+ "pending_email",
+ models.EmailField(
+ blank=True,
+ max_length=254,
+ null=True,
+ verbose_name="pending email address awaiting verification",
+ ),
+ ),
+ ("requested_password_reset_at", models.DateTimeField(blank=True, null=True)),
+ ("has_seen_product_intro_for", models.JSONField(blank=True, null=True)),
+ (
+ "theme_mode",
+ models.CharField(
+ blank=True,
+ choices=[("light", "Light"), ("dark", "Dark"), ("system", "System")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("strapi_id", models.PositiveSmallIntegerField(blank=True, null=True)),
+ ("hedgehog_config", models.JSONField(blank=True, null=True)),
+ (
+ "role_at_organization",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("engineering", "Engineering"),
+ ("data", "Data"),
+ ("product", "Product Management"),
+ ("founder", "Founder"),
+ ("leadership", "Leadership"),
+ ("marketing", "Marketing"),
+ ("sales", "Sales / Success"),
+ ("student", "Student"),
+ ("other", "Other"),
+ ],
+ max_length=64,
+ null=True,
+ ),
+ ),
+ ("allow_sidebar_suggestions", models.BooleanField(blank=True, default=True, null=True)),
+ (
+ "shortcut_position",
+ models.CharField(
+ blank=True,
+ choices=[("above", "Above"), ("below", "Below"), ("hidden", "Hidden")],
+ default="above",
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("allow_impersonation", models.BooleanField(blank=True, default=True, null=True)),
+ (
+ "passkeys_enabled_for_2fa",
+ models.BooleanField(
+ blank=True,
+ default=False,
+ help_text="Whether passkeys are enabled for 2FA authentication. Users can disable this to use only TOTP for 2FA while keeping passkeys for login.",
+ null=True,
+ ),
+ ),
+ ("requested_2fa_reset_at", models.DateTimeField(blank=True, null=True)),
+ ("onboarding_skipped_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "onboarding_skipped_reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("delegated", "Delegated to teammate"),
+ ("later", "Skipped for later"),
+ ("other", "Other"),
+ ("provisioned", "Account provisioned by a partner"),
+ ],
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ("onboarding_skipped_organization_id", models.UUIDField(blank=True, null=True)),
+ ("onboarding_delegated_to_organization_id", models.UUIDField(blank=True, null=True)),
+ ("onboarding_delegation_accepted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "onboarding_delegated_to_invite",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="delegating_users",
+ to="posthog.organizationinvite",
+ ),
+ ),
+ (
+ "hide_mcp_hints",
+ models.BooleanField(
+ db_default=False,
+ default=False,
+ help_text="When true, the user has opted out of in-app hints promoting the PostHog MCP integration after taking actions.",
+ ),
+ ),
+ ("credentials_reviewed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "ui_configuration",
+ models.JSONField(
+ blank=True,
+ help_text="Per-user UI customization (currently sidebar element visibility), shaped like the UserUIConfiguration schema. NULL means the user has no customization and every element shows.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "user",
+ "verbose_name_plural": "users",
+ "abstract": False,
+ "indexes": [
+ models.Index(
+ models.Func(
+ django.db.models.functions.text.Lower("email"),
+ models.Value("\\+[^@]*@"),
+ models.Value("@"),
+ function="regexp_replace",
+ ),
+ name="user_stripped_alias_idx",
+ )
+ ],
+ "constraints": [],
+ },
+ managers=[
+ ("objects", posthog.models.user.UserManager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ElementGroup",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("hash", models.CharField(blank=True, max_length=400, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "hash"), name="unique hash for each team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="Event",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("event", models.CharField(blank=True, max_length=200, null=True)),
+ ("distinct_id", models.CharField(max_length=200)),
+ ("properties", models.JSONField(default=dict)),
+ ("timestamp", models.DateTimeField(blank=True, default=django.utils.timezone.now)),
+ ("elements_hash", models.CharField(blank=True, max_length=200, null=True)),
+ ("site_url", models.CharField(blank=True, max_length=200, null=True)),
+ ("elements", models.JSONField(blank=True, default=list, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["elements_hash"], name="posthog_eve_element_48becd_idx"),
+ models.Index(fields=["timestamp", "team_id", "event"], name="posthog_eve_timesta_1f6a8c_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Group",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("group_key", models.CharField(max_length=400)),
+ ("group_type_index", models.IntegerField()),
+ ("group_properties", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("properties_last_updated_at", models.JSONField(default=dict)),
+ ("properties_last_operation", models.JSONField(default=dict)),
+ ("version", models.BigIntegerField()),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team_id", "group_key", "group_type_index"),
+ name="unique team_id/group_key/group_type_index combo",
+ )
+ ],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="GroupTypeMapping",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("group_type", models.CharField(max_length=400)),
+ ("group_type_index", models.IntegerField()),
+ ("name_singular", models.CharField(blank=True, max_length=400, null=True)),
+ ("name_plural", models.CharField(blank=True, max_length=400, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("project", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.project")),
+ (
+ "default_columns",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, null=True, size=None
+ ),
+ ),
+ ("created_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["project", "group_type"], name="posthog_group_type_proj_idx"),
+ models.Index(fields=["project", "group_type_index"], name="posthog_group_type_i_proj_idx"),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("group_type_index__lte", 5)),
+ name="group_type_index is less than or equal 5",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("project_id__isnull", False)), name="group_type_project_id_is_not_null"
+ ),
+ models.UniqueConstraint(fields=("project", "group_type"), name="unique group types for project"),
+ models.UniqueConstraint(
+ fields=("project", "group_type_index"), name="unique event column indexes for project"
+ ),
+ ],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="Person",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("properties_last_updated_at", models.JSONField(blank=True, default=dict, null=True)),
+ ("properties_last_operation", models.JSONField(blank=True, null=True)),
+ ("properties", models.JSONField(default=dict)),
+ ("is_identified", models.BooleanField(default=False)),
+ ("uuid", models.UUIDField(db_index=True, default=posthog.uuidt.UUIDT, editable=False)),
+ ("version", models.BigIntegerField(blank=True, null=True)),
+ ("is_user", models.IntegerField(blank=True, db_column="is_user_id", null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ "managed": False,
+ "db_table": "posthog_person",
+ },
+ ),
+ migrations.CreateModel(
+ name="Tag",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ "unique_together": {("name", "team")},
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingEvent",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("timestamp", models.DateTimeField(blank=True, default=django.utils.timezone.now)),
+ ("distinct_id", models.CharField(max_length=200)),
+ ("session_id", models.CharField(max_length=200)),
+ ("window_id", models.CharField(blank=True, max_length=200, null=True)),
+ ("snapshot_data", models.JSONField(default=dict)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "session_id"], name="posthog_ses_team_id_265946_idx"),
+ models.Index(
+ fields=["team_id", "distinct_id", "timestamp", "session_id"],
+ name="posthog_ses_team_id_46392f_idx",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecording",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("session_id", models.CharField(max_length=200, unique=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("click_count", models.IntegerField(blank=True, null=True)),
+ ("deleted", models.BooleanField(blank=True, null=True)),
+ ("distinct_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("duration", models.IntegerField(blank=True, null=True)),
+ ("end_time", models.DateTimeField(blank=True, null=True)),
+ ("keypress_count", models.IntegerField(blank=True, null=True)),
+ ("object_storage_path", models.CharField(blank=True, max_length=200, null=True)),
+ ("start_time", models.DateTimeField(blank=True, null=True)),
+ ("start_url", models.CharField(blank=True, max_length=512, null=True)),
+ ("active_seconds", models.IntegerField(blank=True, null=True)),
+ ("console_error_count", models.IntegerField(blank=True, null=True)),
+ ("console_log_count", models.IntegerField(blank=True, null=True)),
+ ("console_warn_count", models.IntegerField(blank=True, null=True)),
+ ("inactive_seconds", models.IntegerField(blank=True, null=True)),
+ ("mouse_activity_count", models.IntegerField(blank=True, null=True)),
+ ("storage_version", models.CharField(blank=True, max_length=20, null=True)),
+ ("full_recording_v2_path", models.CharField(blank=True, max_length=1000, null=True)),
+ ("retention_period_days", models.IntegerField(blank=True, null=True)),
+ ],
+ options={
+ "unique_together": {("team", "session_id")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PersonOverride",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("oldest_event", models.DateTimeField()),
+ ("version", models.BigIntegerField(blank=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "old_person_id",
+ models.ForeignKey(
+ db_column="old_person_id",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="person_override_old",
+ to="posthog.personoverridemapping",
+ ),
+ ),
+ (
+ "override_person_id",
+ models.ForeignKey(
+ db_column="override_person_id",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="person_override_override",
+ to="posthog.personoverridemapping",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "old_person_id"), name="unique override per old_person_id"),
+ models.CheckConstraint(
+ condition=models.Q(("old_person_id__exact", models.F("override_person_id")), _negated=True),
+ name="old_person_id_different_from_override_person_id",
+ ),
+ ],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="ProductIntent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("product_type", models.CharField(max_length=255)),
+ ("onboarding_completed_at", models.DateTimeField(blank=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "activated_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="The date the org completed activation for the product. Generally only used to know if we should continue updating the product_intent row.",
+ null=True,
+ ),
+ ),
+ (
+ "activation_last_checked_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="The date we last checked if the org had completed activation for the product.",
+ null=True,
+ ),
+ ),
+ ("contexts", models.JSONField(blank=True, default=dict, null=True)),
+ ],
+ options={
+ "unique_together": {("team", "product_type")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="RemoteConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("config", models.JSONField()),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("synced_at", models.DateTimeField(null=True)),
+ ("team", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserGroup",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="user_groups", to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HostDefinition",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("host", models.CharField(max_length=400)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_seen_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "project",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="host_definitions",
+ related_query_name="host_definition",
+ to="posthog.project",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="host_definitions",
+ related_query_name="host_definition",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_hostdefinition",
+ "indexes": [
+ models.Index(fields=["project", "host"], name="hostdefinition_project_idx"),
+ models.Index(fields=["team", "host"], name="hostdefinition_team_idx"),
+ ],
+ "constraints": [
+ posthog.models.utils.UniqueConstraintByExpression(
+ concurrently=False,
+ expression="(coalesce(project_id, team_id), host)",
+ name="hostdefinition_coalesced_idx",
+ )
+ ],
+ "unique_together": {("team", "host")},
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamRevenueAnalyticsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "base_currency",
+ models.CharField(
+ choices=[
+ ("AED", "AED"),
+ ("AFN", "AFN"),
+ ("ALL", "ALL"),
+ ("AMD", "AMD"),
+ ("ANG", "ANG"),
+ ("AOA", "AOA"),
+ ("ARS", "ARS"),
+ ("AUD", "AUD"),
+ ("AWG", "AWG"),
+ ("AZN", "AZN"),
+ ("BAM", "BAM"),
+ ("BBD", "BBD"),
+ ("BDT", "BDT"),
+ ("BGN", "BGN"),
+ ("BHD", "BHD"),
+ ("BIF", "BIF"),
+ ("BMD", "BMD"),
+ ("BND", "BND"),
+ ("BOB", "BOB"),
+ ("BRL", "BRL"),
+ ("BSD", "BSD"),
+ ("BTC", "BTC"),
+ ("BTN", "BTN"),
+ ("BWP", "BWP"),
+ ("BYN", "BYN"),
+ ("BZD", "BZD"),
+ ("CAD", "CAD"),
+ ("CDF", "CDF"),
+ ("CHF", "CHF"),
+ ("CLP", "CLP"),
+ ("CNY", "CNY"),
+ ("COP", "COP"),
+ ("CRC", "CRC"),
+ ("CVE", "CVE"),
+ ("CZK", "CZK"),
+ ("DJF", "DJF"),
+ ("DKK", "DKK"),
+ ("DOP", "DOP"),
+ ("DZD", "DZD"),
+ ("EGP", "EGP"),
+ ("ERN", "ERN"),
+ ("ETB", "ETB"),
+ ("EUR", "EUR"),
+ ("FJD", "FJD"),
+ ("GBP", "GBP"),
+ ("GEL", "GEL"),
+ ("GHS", "GHS"),
+ ("GIP", "GIP"),
+ ("GMD", "GMD"),
+ ("GNF", "GNF"),
+ ("GTQ", "GTQ"),
+ ("GYD", "GYD"),
+ ("HKD", "HKD"),
+ ("HNL", "HNL"),
+ ("HRK", "HRK"),
+ ("HTG", "HTG"),
+ ("HUF", "HUF"),
+ ("IDR", "IDR"),
+ ("ILS", "ILS"),
+ ("INR", "INR"),
+ ("IQD", "IQD"),
+ ("IRR", "IRR"),
+ ("ISK", "ISK"),
+ ("JMD", "JMD"),
+ ("JOD", "JOD"),
+ ("JPY", "JPY"),
+ ("KES", "KES"),
+ ("KGS", "KGS"),
+ ("KHR", "KHR"),
+ ("KMF", "KMF"),
+ ("KRW", "KRW"),
+ ("KWD", "KWD"),
+ ("KYD", "KYD"),
+ ("KZT", "KZT"),
+ ("LAK", "LAK"),
+ ("LBP", "LBP"),
+ ("LKR", "LKR"),
+ ("LRD", "LRD"),
+ ("LTL", "LTL"),
+ ("LVL", "LVL"),
+ ("LSL", "LSL"),
+ ("LYD", "LYD"),
+ ("MAD", "MAD"),
+ ("MDL", "MDL"),
+ ("MGA", "MGA"),
+ ("MKD", "MKD"),
+ ("MMK", "MMK"),
+ ("MNT", "MNT"),
+ ("MOP", "MOP"),
+ ("MRU", "MRU"),
+ ("MTL", "MTL"),
+ ("MUR", "MUR"),
+ ("MVR", "MVR"),
+ ("MWK", "MWK"),
+ ("MXN", "MXN"),
+ ("MYR", "MYR"),
+ ("MZN", "MZN"),
+ ("NAD", "NAD"),
+ ("NGN", "NGN"),
+ ("NIO", "NIO"),
+ ("NOK", "NOK"),
+ ("NPR", "NPR"),
+ ("NZD", "NZD"),
+ ("OMR", "OMR"),
+ ("PAB", "PAB"),
+ ("PEN", "PEN"),
+ ("PGK", "PGK"),
+ ("PHP", "PHP"),
+ ("PKR", "PKR"),
+ ("PLN", "PLN"),
+ ("PYG", "PYG"),
+ ("QAR", "QAR"),
+ ("RON", "RON"),
+ ("RSD", "RSD"),
+ ("RUB", "RUB"),
+ ("RWF", "RWF"),
+ ("SAR", "SAR"),
+ ("SBD", "SBD"),
+ ("SCR", "SCR"),
+ ("SDG", "SDG"),
+ ("SEK", "SEK"),
+ ("SGD", "SGD"),
+ ("SRD", "SRD"),
+ ("SSP", "SSP"),
+ ("STN", "STN"),
+ ("SYP", "SYP"),
+ ("SZL", "SZL"),
+ ("THB", "THB"),
+ ("TJS", "TJS"),
+ ("TMT", "TMT"),
+ ("TND", "TND"),
+ ("TOP", "TOP"),
+ ("TRY", "TRY"),
+ ("TTD", "TTD"),
+ ("TWD", "TWD"),
+ ("TZS", "TZS"),
+ ("UAH", "UAH"),
+ ("UGX", "UGX"),
+ ("USD", "USD"),
+ ("UYU", "UYU"),
+ ("UZS", "UZS"),
+ ("VES", "VES"),
+ ("VND", "VND"),
+ ("VUV", "VUV"),
+ ("WST", "WST"),
+ ("XAF", "XAF"),
+ ("XCD", "XCD"),
+ ("XOF", "XOF"),
+ ("XPF", "XPF"),
+ ("YER", "YER"),
+ ("ZAR", "ZAR"),
+ ("ZMW", "ZMW"),
+ ],
+ default="USD",
+ max_length=3,
+ ),
+ ),
+ ("_events", models.JSONField(db_column="events", default=list)),
+ ("notified_first_sync", models.BooleanField(default=False, null=True)),
+ ("_goals", models.JSONField(blank=True, db_column="goals", default=list, null=True)),
+ ("filter_test_accounts", models.BooleanField(default=False)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamMarketingAnalyticsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("_sources_map", models.JSONField(blank=True, db_column="sources_map", default=dict)),
+ (
+ "_conversion_goals",
+ models.JSONField(blank=True, db_column="conversion_goals", default=list, null=True),
+ ),
+ (
+ "attribution_mode",
+ models.CharField(
+ choices=[
+ ("first_touch", "First Touch"),
+ ("last_touch", "Last Touch"),
+ ("linear", "Linear"),
+ ("time_decay", "Time Decay"),
+ ("position_based", "Position Based"),
+ ],
+ default="last_touch",
+ help_text="Attribution mode: first_touch, last_touch, linear, time_decay, or position_based",
+ max_length=20,
+ ),
+ ),
+ (
+ "attribution_window_days",
+ models.IntegerField(default=90, help_text="Attribution window in days (1-90)"),
+ ),
+ (
+ "_campaign_name_mappings",
+ models.JSONField(
+ blank=True,
+ db_column="campaign_name_mappings",
+ default=dict,
+ help_text="Maps campaign names to lists of raw UTM values per data source",
+ ),
+ ),
+ (
+ "_custom_source_mappings",
+ models.JSONField(
+ blank=True,
+ db_column="custom_source_mappings",
+ default=dict,
+ help_text="Custom UTM source mappings: maps integration types to lists of custom UTM source values",
+ ),
+ ),
+ (
+ "_campaign_field_preferences",
+ models.JSONField(
+ blank=True,
+ db_column="campaign_field_preferences",
+ default=dict,
+ help_text="Campaign field matching preferences: defines which field (campaign_name or campaign_id) to match utm_campaign against per integration. Manual mappings always take precedence.",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="GroupUsageMetric",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("group_type_index", models.IntegerField()),
+ ("name", models.CharField(max_length=255, verbose_name="Name")),
+ (
+ "format",
+ models.CharField(
+ choices=[("numeric", "numeric"), ("currency", "currency")], default="numeric", max_length=64
+ ),
+ ),
+ ("interval", models.IntegerField(default=7, help_text="In days")),
+ (
+ "display",
+ models.CharField(
+ choices=[("number", "number"), ("sparkline", "sparkline")], default="number", max_length=64
+ ),
+ ),
+ ("filters", models.JSONField()),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("bytecode_error", models.TextField(blank=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "math",
+ models.CharField(choices=[("count", "count"), ("sum", "sum")], default="count", max_length=16),
+ ),
+ ("math_property", models.CharField(blank=True, max_length=255, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "group_type_index", "name"), name="unique_metric_name")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="QuickFilter",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("property_name", models.CharField(max_length=500)),
+ (
+ "type",
+ models.CharField(
+ choices=[("manual-options", "manual-options"), ("auto-discovery", "auto-discovery")],
+ default="manual-options",
+ max_length=50,
+ ),
+ ),
+ ("options", models.JSONField(blank=True, default=list, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_quickfilter",
+ "indexes": [models.Index(fields=["team"], name="posthog_qui_team_id_24fea4_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CoreEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(help_text="Display name for this core event", max_length=255)),
+ ("description", models.TextField(blank=True, default="", help_text="Optional description")),
+ (
+ "category",
+ models.CharField(
+ choices=[
+ ("acquisition", "Acquisition"),
+ ("activation", "Activation"),
+ ("monetization", "Monetization"),
+ ("expansion", "Expansion"),
+ ("referral", "Referral"),
+ ("retention", "Retention"),
+ ("churn", "Churn"),
+ ("reactivation", "Reactivation"),
+ ],
+ help_text="Lifecycle category for this core event",
+ max_length=20,
+ ),
+ ),
+ ("filter", models.JSONField(help_text="Filter configuration - event, action, or data warehouse node")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="core_events", to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Core Event",
+ "verbose_name_plural": "Core Events",
+ "ordering": ["created_at"],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HealthIssue",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("kind", models.CharField(max_length=100)),
+ (
+ "severity",
+ models.CharField(
+ choices=[("critical", "Critical"), ("warning", "Warning"), ("info", "Info")], max_length=20
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("resolved", "Resolved")], default="active", max_length=20
+ ),
+ ),
+ ("payload", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("resolved_at", models.DateTimeField(blank=True, null=True)),
+ ("unique_hash", models.CharField(max_length=64)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="health_issues", to="posthog.team"
+ ),
+ ),
+ ("dismissed", models.BooleanField(default=False)),
+ ("snoozed_until", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("status", "active")),
+ fields=("team_id", "kind", "unique_hash"),
+ name="unique_active_health_issue",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamJsSnippetConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("js_snippet_version", models.CharField(blank=True, default=None, max_length=50, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LinkedIdentityProviderConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "identity_provider_config",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="linked_identity_provider_configs",
+ to="posthog.identityproviderconfig",
+ ),
+ ),
+ (
+ "organization_domain",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="linked_identity_provider_configs",
+ to="posthog.organizationdomain",
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization_domain", "identity_provider_config"),
+ name="unique_linked_identity_provider_config",
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ActivityLog",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("team_id", models.PositiveIntegerField(null=True)),
+ ("organization_id", models.UUIDField(null=True)),
+ ("is_system", models.BooleanField(null=True)),
+ ("activity", models.CharField(max_length=79)),
+ ("item_id", models.CharField(max_length=72, null=True)),
+ ("scope", models.CharField(max_length=79)),
+ ("detail", models.JSONField(encoder=posthog.models.utils.ActivityDetailEncoder, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("was_impersonated", models.BooleanField(null=True)),
+ ("client", models.CharField(blank=True, max_length=32, null=True)),
+ ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "scope", "item_id"], name="posthog_act_team_id_13a0a8_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["detail"], name="activitylog_detail_gin", opclasses=["jsonb_ops"]
+ ),
+ models.Index(
+ condition=models.Q(("detail__isnull", False), ("detail__jsonb_typeof", "object")),
+ fields=["organization_id", "scope", "-created_at"],
+ name="idx_alog_org_scope_created_at",
+ ),
+ models.Index(
+ condition=models.Q(("detail__isnull", False), ("detail__jsonb_typeof", "object")),
+ fields=["organization_id"],
+ name="idx_alog_org_detail_exists",
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ condition=models.Q(("detail__isnull", False)),
+ fields=["detail"],
+ name="idx_alog_detail_gin_path_ops",
+ opclasses=["jsonb_path_ops"],
+ ),
+ models.Index(
+ condition=models.Q(("was_impersonated", False), ("is_system", False)),
+ fields=["team_id", "scope", "activity", "-created_at"],
+ name="idx_alog_team_scp_act_crtd",
+ ),
+ models.Index(
+ condition=models.Q(("was_impersonated", False), ("is_system", False)),
+ fields=["team_id", "scope", "-created_at"],
+ name="idx_alog_team_scope_created",
+ ),
+ models.Index(
+ condition=models.Q(("was_impersonated", False), ("is_system", False)),
+ fields=["team_id", "activity", "scope", "user"],
+ name="idx_alog_team_act_scope_usr",
+ ),
+ models.Index(fields=["organization_id", "-created_at"], name="idx_alog_org_created_at"),
+ models.Index(fields=["team_id", "-created_at"], name="idx_alog_team_created_at"),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("team_id__isnull", False), ("organization_id__isnull", False), _connector="OR"
+ ),
+ name="must_have_team_or_organization_id",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="AsyncDeletion",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ (
+ "deletion_type",
+ models.PositiveSmallIntegerField(
+ choices=[(0, "Team"), (1, "Person"), (2, "Group"), (3, "Cohort Stale"), (4, "Cohort Full")]
+ ),
+ ),
+ ("team_id", models.IntegerField()),
+ ("key", models.CharField(max_length=400)),
+ ("group_type_index", models.IntegerField(null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("delete_verified_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["delete_verified_at"], name="delete_verified_at index")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("group_type_index__isnull", True)),
+ fields=("deletion_type", "key"),
+ name="unique deletion",
+ ),
+ models.UniqueConstraint(
+ fields=("deletion_type", "key", "group_type_index"), name="unique deletion for groups"
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingPlaylist",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("derived_name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True)),
+ ("pinned", models.BooleanField(default=False)),
+ ("deleted", models.BooleanField(default=False)),
+ ("filters", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("is_static", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_playlists",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("last_counted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "type",
+ models.CharField(
+ blank=True,
+ choices=[("collection", "Collection"), ("filters", "Filters")],
+ max_length=50,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["deleted", "last_counted_at"], name="deleted_n_last_count_idx"),
+ models.Index(fields=["deleted", "-last_modified_at"], name="deleted_n_last_mod_desc_idx"),
+ ],
+ "constraints": [],
+ "unique_together": {("team", "short_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="UserPromptState",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("last_updated_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("step", models.IntegerField(default=None, null=True)),
+ ("completed", models.BooleanField(default=False)),
+ ("dismissed", models.BooleanField(default=False)),
+ (
+ "sequence",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.promptsequence"),
+ ),
+ ("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("user", "sequence"), name="unique_user_prompt_state")],
+ },
+ ),
+ migrations.CreateModel(
+ name="UploadedMedia",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("media_location", models.TextField(blank=True, max_length=1000, null=True)),
+ ("content_type", models.TextField(blank=True, max_length=100, null=True)),
+ ("file_name", models.TextField(blank=True, max_length=1000, null=True)),
+ (
+ "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")),
+ (
+ "project",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"
+ ),
+ ),
+ ("pending", models.BooleanField(default=False)),
+ ("purpose", models.CharField(blank=True, max_length=100, null=True)),
+ ("size_bytes", models.IntegerField(blank=True, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ models.Index(
+ condition=models.Q(("pending", False), ("purpose__isnull", False)),
+ fields=["team", "purpose", "-created_at"],
+ name="uploadedmedia_lib_by_created",
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingViewed",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("session_id", models.CharField(max_length=200)),
+ ("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)),
+ ("bulk_viewed", models.BooleanField(default=False)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "user_id", "session_id"], name="posthog_ses_team_id_465af1_idx")
+ ],
+ "constraints": [],
+ "unique_together": {("team_id", "user_id", "session_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="PersonalAPIKey",
+ fields=[
+ (
+ "id",
+ models.CharField(
+ default=posthog.models.utils.generate_random_token,
+ max_length=50,
+ primary_key=True,
+ serialize=False,
+ ),
+ ),
+ ("label", models.CharField(max_length=40)),
+ ("value", models.CharField(blank=True, editable=False, max_length=50, null=True, unique=True)),
+ ("secure_value", models.CharField(editable=False, max_length=300, null=True, unique=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("last_used_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="personal_api_keys+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="personal_api_keys",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scoped_organizations",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "scoped_teams",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.IntegerField(), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "scopes",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), default=list, size=None
+ ),
+ ),
+ ("mask_value", models.CharField(editable=False, max_length=11, null=True)),
+ ("last_rolled_at", models.DateTimeField(blank=True, null=True)),
+ ("description", models.TextField(blank=True, max_length=1000, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationMembership",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "level",
+ models.PositiveSmallIntegerField(
+ choices=[(1, "member"), (8, "administrator"), (15, "owner")], default=1
+ ),
+ ),
+ ("joined_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="memberships",
+ related_query_name="membership",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="organization_memberships",
+ related_query_name="organization_membership",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "invited_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["organization", "-joined_at"], name="org_membership_org_joined_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization_id", "user_id"), name="unique_organization_membership"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="NotificationViewed",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("last_viewed_activity_date", models.DateTimeField(default=None)),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("user",), name="posthog_user_unique_viewed_date")],
+ },
+ ),
+ migrations.CreateModel(
+ name="Integration",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ (
+ "kind",
+ models.CharField(choices=posthog.models.integration.model.integration_kind_choices, max_length=32),
+ ),
+ ("config", models.JSONField(default=dict)),
+ ("sensitive_config", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ ("errors", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "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")),
+ ("integration_id", models.TextField(blank=True, null=True)),
+ ("repository_cache", models.JSONField(blank=True, default=list)),
+ ("repository_cache_updated_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [models.Index(fields=["kind", "integration_id"], name="posthog_integration_kind_ext")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "kind", "integration_id"), name="posthog_integration_kind_id_unique"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserScenePersonalisation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("scene", models.CharField(max_length=200)),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scene_personalisation",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "scene"), name="posthog_unique_scene_personalisation"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Comment",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("content", models.TextField(blank=True, null=True)),
+ ("version", models.IntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("item_id", models.CharField(max_length=72, null=True)),
+ ("item_context", models.JSONField(null=True)),
+ ("scope", models.CharField(max_length=79)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "source_comment",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.comment"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("rich_content", models.JSONField(blank=True, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "completed_by",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("is_task", models.BooleanField(blank=True, default=False, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "scope", "item_id"], name="posthog_com_team_id_be2206_idx"),
+ models.Index(
+ fields=["team_id", "scope", "item_id", "deleted", "-created_at"],
+ name="posthog_comment_convo_idx",
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ django.contrib.postgres.indexes.OpClass(
+ django.db.models.functions.text.Upper("content"), name="gin_trgm_ops"
+ ),
+ condition=models.Q(("scope", "conversations_ticket")),
+ name="comment_convo_content_trgm",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ProxyRecord",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("domain", models.CharField(max_length=64, unique=True)),
+ ("target_cname", models.CharField(max_length=256)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("waiting", "Waiting"),
+ ("issuing", "Issuing"),
+ ("valid", "Valid"),
+ ("warning", "Warning"),
+ ("erroring", "Erroring"),
+ ("deleting", "Deleting"),
+ ("timed_out", "Timed Out"),
+ ],
+ default="waiting",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="proxy_records",
+ to="posthog.organization",
+ ),
+ ),
+ ("message", models.CharField(max_length=1024, null=True)),
+ ("root_redirect_url", models.URLField(blank=True, max_length=1024, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataColorTheme",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(max_length=100)),
+ ("colors", models.JSONField(default=list)),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("deleted", models.BooleanField(blank=True, null=True)),
+ (
+ "project",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FileSystem",
+ fields=[
+ ("id", models.UUIDField(default=posthog.uuidt.uuid7, primary_key=True, serialize=False)),
+ ("path", models.TextField()),
+ ("type", models.CharField(blank=True, max_length=100)),
+ ("ref", models.CharField(blank=True, max_length=100, null=True)),
+ ("href", models.TextField(blank=True, null=True)),
+ ("meta", models.JSONField(blank=True, default=dict, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now, editable=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ 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")),
+ ("depth", models.IntegerField(blank=True, null=True)),
+ (
+ "project",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"),
+ ),
+ ("shortcut", models.BooleanField(blank=True, null=True)),
+ ("surface", models.CharField(blank=True, max_length=100, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team"], name="posthog_fil_team_id_4941ed_idx"),
+ models.Index(
+ models.F("team_id"), models.F("surface"), models.F("path"), name="posthog_fs_team_s_path"
+ ),
+ models.Index(
+ models.F("team_id"), models.F("surface"), models.F("depth"), name="posthog_fs_team_s_depth"
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.F("surface"),
+ models.F("type"),
+ models.F("ref"),
+ name="posthog_fs_team_s_typeref",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FileSystemShortcut",
+ fields=[
+ ("id", models.UUIDField(default=posthog.uuidt.uuid7, primary_key=True, serialize=False)),
+ ("path", models.TextField()),
+ ("type", models.CharField(blank=True, max_length=100)),
+ ("ref", models.CharField(blank=True, max_length=100, null=True)),
+ ("href", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now, editable=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)),
+ ("order", models.IntegerField(default=0)),
+ ("surface", models.CharField(blank=True, max_length=100, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "user"], name="posthog_fil_team_id_e8b1fe_idx"),
+ models.Index(models.F("team_id"), models.F("path"), name="posthog_fs_s_team_path"),
+ models.Index(
+ models.F("team_id"), models.F("type"), models.F("ref"), name="posthog_fs_s_team_typeref"
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.F("user_id"),
+ models.F("order"),
+ django.db.models.functions.text.Lower("path"),
+ name="posthog_fss_t_u_ordpathlc",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PersistedFolder",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[("home", "Home"), ("pinned", "Pinned"), ("custom_products", "Custom Products")],
+ max_length=32,
+ ),
+ ),
+ ("protocol", models.CharField(default="products://", max_length=64)),
+ ("path", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now, editable=False)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("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)),
+ ("surface", models.CharField(blank=True, max_length=100, null=True)),
+ ],
+ options={
+ "verbose_name": "Persisted Folder",
+ "verbose_name_plural": "Persisted Folders",
+ "indexes": [
+ models.Index(models.F("team_id"), models.F("user_id"), name="posthog_pf_team_user"),
+ models.Index(
+ models.F("team_id"), models.F("user_id"), models.F("type"), name="posthog_pf_team_user_type"
+ ),
+ ],
+ "unique_together": set(),
+ "constraints": [
+ models.UniqueConstraint(
+ models.F("team_id"),
+ models.F("user_id"),
+ models.F("type"),
+ django.db.models.functions.comparison.Coalesce(models.F("surface"), models.Value("web")),
+ name="posthog_pf_team_user_type_surface_uniq",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="OAuthApplication",
+ fields=[
+ (
+ "client_id",
+ models.CharField(
+ db_index=True,
+ default=oauth2_provider.generators.generate_client_id,
+ max_length=2048,
+ unique=True,
+ ),
+ ),
+ ("redirect_uris", models.TextField(blank=True, help_text="Allowed URIs list, space separated")),
+ (
+ "post_logout_redirect_uris",
+ models.TextField(
+ blank=True, default="", help_text="Allowed Post Logout URIs list, space separated"
+ ),
+ ),
+ (
+ "client_type",
+ models.CharField(choices=[("confidential", "Confidential"), ("public", "Public")], max_length=32),
+ ),
+ (
+ "authorization_grant_type",
+ models.CharField(
+ choices=[
+ ("authorization-code", "Authorization code"),
+ ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"),
+ ("implicit", "Implicit"),
+ ("password", "Resource owner password-based"),
+ ("client-credentials", "Client credentials"),
+ ("openid-hybrid", "OpenID connect hybrid"),
+ ],
+ max_length=44,
+ ),
+ ),
+ (
+ "client_secret",
+ oauth2_provider.models.ClientSecretField(
+ blank=True,
+ db_index=True,
+ default=oauth2_provider.generators.generate_client_secret,
+ help_text="Hashed on Save. Copy it now if this is a new secret.",
+ max_length=255,
+ ),
+ ),
+ ("hash_client_secret", models.BooleanField(default=True)),
+ ("name", models.CharField(blank=True, max_length=255)),
+ ("skip_authorization", models.BooleanField(default=False)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ (
+ "algorithm",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("", "No OIDC support"),
+ ("RS256", "RSA with SHA-2 256"),
+ ("HS256", "HMAC with SHA-2 256"),
+ ],
+ default="",
+ max_length=5,
+ ),
+ ),
+ (
+ "allowed_origins",
+ models.TextField(
+ blank=True, default="", help_text="Allowed origins list to enable CORS, space separated"
+ ),
+ ),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="oauth_applications",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "dcr_client_id_issued_at",
+ models.DateTimeField(
+ blank=True, help_text="When the client_id was issued (for DCR clients)", null=True
+ ),
+ ),
+ (
+ "is_dcr_client",
+ models.BooleanField(
+ default=False,
+ help_text="True if this client was registered via Dynamic Client Registration",
+ verbose_name="Is DCR client",
+ ),
+ ),
+ (
+ "is_verified",
+ models.BooleanField(
+ default=False, help_text="True if this application has been verified by PostHog"
+ ),
+ ),
+ (
+ "is_first_party",
+ models.BooleanField(
+ default=False,
+ help_text="True if this is a first-party PostHog application that skips OAuth consent",
+ ),
+ ),
+ (
+ "auth_brand",
+ models.CharField(
+ choices=[("posthog", "posthog"), ("twig", "twig")],
+ default="posthog",
+ help_text="Branding to use on authentication pages",
+ max_length=32,
+ ),
+ ),
+ (
+ "cimd_metadata_last_fetched",
+ models.DateTimeField(
+ blank=True, help_text="When the CIMD metadata was last successfully fetched", null=True
+ ),
+ ),
+ (
+ "is_cimd_client",
+ models.BooleanField(
+ default=False,
+ help_text="True if this client was registered via Client ID Metadata Document (CIMD)",
+ verbose_name="Is CIMD client",
+ ),
+ ),
+ (
+ "logo_uri",
+ models.URLField(blank=True, help_text="URL to the client's logo image", max_length=2048, null=True),
+ ),
+ (
+ "scopes",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100),
+ blank=True,
+ db_default=[],
+ default=list,
+ help_text="Required scope ceiling — strings tokens issued for this app may carry, all required and locked on the consent screen. Empty list means a broad/deferred request (the user picks freely).",
+ size=None,
+ ),
+ ),
+ (
+ "sessions_revoked_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When an admin last force-revoked every session for this app. Tokens issued before this are rejected on refresh, forcing re-authorization.",
+ null=True,
+ ),
+ ),
+ (
+ "optional_scopes",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100),
+ blank=True,
+ db_default=[],
+ default=list,
+ help_text="Additive declinable scopes layered on top of the required `scopes` base — the user may decline these at consent. Requires a non-empty `scopes` (an app with optional extras must have a required base).",
+ size=None,
+ ),
+ ),
+ (
+ "is_provisioning_partner",
+ models.BooleanField(
+ db_default=False,
+ default=False,
+ help_text="Whether this app may act as an agentic provisioning partner. How it authenticates follows from client_type, so there is no separate provisioning auth method.",
+ ),
+ ),
+ (
+ "jwks_uri",
+ models.URLField(
+ blank=True,
+ help_text="HTTPS URL serving the client's public keys as a JWK Set. Setting this on a confidential client switches it to private_key_jwt authentication (RFC 7523): it signs an assertion we verify against these keys instead of holding a shared secret.",
+ max_length=2048,
+ null=True,
+ ),
+ ),
+ (
+ "_provisioning_config",
+ models.JSONField(
+ blank=True,
+ db_column="provisioning_config",
+ db_default={},
+ default=dict,
+ help_text="Provisioning capabilities and per-endpoint rate limits. Every capability is off unless explicitly granted.",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "OAuth Application",
+ "verbose_name_plural": "OAuth Applications",
+ "abstract": False,
+ "swappable": "OAUTH2_PROVIDER_APPLICATION_MODEL",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("skip_authorization", False)), name="enforce_skip_authorization_false"
+ ),
+ models.CheckConstraint(condition=models.Q(("algorithm", "RS256")), name="enforce_rs256_algorithm"),
+ models.CheckConstraint(
+ condition=models.Q(("authorization_grant_type", "authorization-code")),
+ name="enforce_supported_grant_types",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationIntegration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("kind", models.CharField(choices=[("vercel", "Vercel")], max_length=50)),
+ ("integration_id", models.TextField(blank=True, null=True)),
+ ("config", models.JSONField(default=dict)),
+ ("sensitive_config", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization", "kind", "integration_id"),
+ name="posthog_organization_integration_kind_id_unique",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="FileSystemViewLog",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("type", models.CharField(max_length=150)),
+ ("ref", models.CharField(max_length=200)),
+ ("viewed_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("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)),
+ ("surface", models.CharField(blank=True, max_length=100, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "user", "-viewed_at"], name="posthog_fsvl_recent_user_views"),
+ models.Index(fields=["team", "type", "ref", "-viewed_at"], name="posthog_fsvl_recent_item_views"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "type", "ref"), name="posthog_fsvl_unique_user_item"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserHomeSettings",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("tabs", models.JSONField(blank=True, default=list)),
+ ("homepage", models.JSONField(blank=True, default=dict, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="home_settings",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user"), name="posthog_unique_user_home_settings")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserProductList",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("product_path", models.CharField(max_length=200)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("enabled", models.BooleanField(default=True)),
+ ("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={
+ "verbose_name": "User Product List",
+ "verbose_name_plural": "User Product Lists",
+ "indexes": [models.Index(models.F("team_id"), models.F("user_id"), name="posthog_upl_team_user")],
+ "unique_together": {("team", "user", "product_path")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ColumnConfiguration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("context_key", models.CharField(db_index=True, max_length=255)),
+ (
+ "columns",
+ django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), default=list, size=None),
+ ),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("name", models.CharField(default="Column configuration", max_length=255)),
+ (
+ "visibility",
+ models.CharField(
+ choices=[("private", "Private (only visible to creator)"), ("shared", "Shared with team")],
+ default="shared",
+ max_length=10,
+ ),
+ ),
+ ("filters", models.JSONField(blank=True, default=dict, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "order_by",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, default=None, null=True, size=None
+ ),
+ ),
+ ("properties", models.JSONField(blank=True, default=dict, null=True)),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "context_key"], name="posthog_col_team_id_0cba64_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("visibility", "private")),
+ fields=("team", "context_key", "name", "created_by"),
+ name="unique_user_view_name",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("visibility", "shared")),
+ fields=("team", "context_key", "name"),
+ name="unique_team_view_name",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MaterializedColumnSlot",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="materialized_column_slots",
+ related_query_name="materialized_column_slot",
+ to="posthog.team",
+ ),
+ ),
+ ("slot_index", models.PositiveSmallIntegerField(blank=True, null=True)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("PENDING", "Pending"),
+ ("BACKFILL", "Backfill"),
+ ("READY", "Ready"),
+ ("ERROR", "Error"),
+ ],
+ default="PENDING",
+ max_length=20,
+ ),
+ ),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("backfill_temporal_run_id", models.CharField(blank=True, max_length=400, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ models.Index(fields=["team", "state"], name="posthog_mat_team_st_idx"),
+ models.Index(fields=["team", "slot_index"], name="posthog_mat_team_sl_idx"),
+ models.Index(fields=["backfill_temporal_run_id"], name="posthog_mat_run_id_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("slot_index__isnull", False)),
+ fields=("team", "slot_index"),
+ name="unique_team_slot_index",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("slot_index__isnull", True),
+ models.Q(("slot_index__gte", 0), ("slot_index__lte", 9)),
+ _connector="OR",
+ ),
+ name="valid_slot_index",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("state", "PENDING"), ("state", "ERROR"), ("slot_index__isnull", False), _connector="OR"
+ ),
+ name="slot_index_required_when_assigned",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="WebauthnCredential",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "credential_id",
+ models.BinaryField(
+ help_text="ID generated by the user's authenticator during credential creation. Stored as bytes."
+ ),
+ ),
+ (
+ "label",
+ models.CharField(help_text="The user-facing label assigned to this credential.", max_length=200),
+ ),
+ (
+ "public_key",
+ models.BinaryField(
+ help_text="The public key used to verify attestations from the user's authenticator. Stored as bytes."
+ ),
+ ),
+ (
+ "algorithm",
+ models.IntegerField(
+ help_text="The COSE algorithm identifier used for public-key verification (e.g., -7 for ES256, -257 for RS256)."
+ ),
+ ),
+ (
+ "counter",
+ models.IntegerField(
+ default=0,
+ help_text="Tracks the counter of the credential. Traditionally used to detect cloned authenticators, however for our use case we expect to see some inconsistencies here because of the behavior of different passkey managers.",
+ ),
+ ),
+ (
+ "transports",
+ models.JSONField(
+ default=list,
+ help_text="The transport methods that the authenticator uses to communicate with the browser (e.g., ['internal', 'hybrid']).",
+ ),
+ ),
+ (
+ "verified",
+ models.BooleanField(
+ default=False,
+ help_text="Whether the credential has been verified by the user after registration. Only verified credentials can be used for login.",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="webauthn_credentials",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "unique_together": {("user", "credential_id")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ProjectSecretAPIKey",
+ fields=[
+ (
+ "id",
+ models.CharField(
+ default=posthog.models.utils.generate_random_token,
+ max_length=50,
+ primary_key=True,
+ serialize=False,
+ ),
+ ),
+ ("label", models.CharField(max_length=40)),
+ ("mask_value", models.CharField(editable=False, max_length=11, null=True)),
+ ("secure_value", models.CharField(editable=False, max_length=300, null=True, unique=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("last_used_at", models.DateTimeField(blank=True, null=True)),
+ ("last_rolled_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "scopes",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), null=True, size=None
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="created_project_secret_api_keys",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="project_secret_api_keys",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_projectsecretapikey",
+ "indexes": [
+ models.Index(fields=["team", "created_at"], name="posthog_pro_team_id_d4c925_idx"),
+ django.contrib.postgres.indexes.GinIndex(fields=["scopes"], name="projectsecretapikey_scopes_gin"),
+ ],
+ "constraints": [models.UniqueConstraint(fields=("team", "label"), name="unique_team_label")],
+ },
+ ),
+ migrations.CreateModel(
+ name="ResourceTransfer",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("resource_kind", models.CharField(max_length=100)),
+ ("resource_id", models.CharField(max_length=100)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_transferred_at", models.DateTimeField(auto_now=True)),
+ (
+ "destination_team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="inbound_resource_transfers",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "source_team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="outbound_resource_transfers",
+ to="posthog.team",
+ ),
+ ),
+ ("duplicated_resource_id", models.CharField(max_length=100)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ models.Index(
+ fields=["resource_kind", "resource_id", "-last_transferred_at"],
+ name="idx_restransfer_kind_id_time",
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserRepoPreference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("scope_type", models.CharField(choices=[("slack_channel", "Slack Channel")], max_length=32)),
+ ("scope_id", models.CharField(blank=True, default="", max_length=128)),
+ ("repository", models.CharField(max_length=255)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="user_repo_preferences",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="user_repo_preferences",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "user", "scope_type"], name="idx_user_repo_pref_lookup")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "scope_type", "scope_id"), name="uniq_user_repo_preference"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="RepoRoutingRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("rule_text", models.TextField()),
+ ("repository", models.CharField(max_length=255)),
+ ("priority", models.PositiveIntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ 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,
+ related_name="repo_routing_rules",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["priority", "id"],
+ "indexes": [models.Index(fields=["team", "priority"], name="idx_repo_routing_rule_team")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataDeletionRequest",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("team_id", models.IntegerField()),
+ (
+ "request_type",
+ models.CharField(
+ choices=[
+ ("property_removal", "Property Removal"),
+ ("event_removal", "Event Removal"),
+ ("person_removal", "Person Removal"),
+ ],
+ help_text="property_removal: remove specific properties from matching events. event_removal: delete entire events matching the criteria.",
+ max_length=40,
+ ),
+ ),
+ ("start_time", models.DateTimeField(blank=True, null=True)),
+ ("end_time", models.DateTimeField(blank=True, null=True)),
+ (
+ "events",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=1024),
+ blank=True,
+ default=list,
+ help_text="Event names to match. May be empty only when delete_all_events is true.",
+ size=None,
+ ),
+ ),
+ (
+ "properties",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=1024),
+ blank=True,
+ default=list,
+ help_text="Property names to remove from events.properties. Required for property_removal requests when person_properties is empty.",
+ size=None,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("draft", "Draft"),
+ ("pending", "Pending"),
+ ("approved", "Approved"),
+ ("in_progress", "In Progress"),
+ ("queued", "Queued"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ],
+ default="draft",
+ max_length=40,
+ ),
+ ),
+ (
+ "count",
+ models.BigIntegerField(blank=True, help_text="Number of events matching criteria", null=True),
+ ),
+ ("part_count", models.IntegerField(blank=True, help_text="Number of ClickHouse parts", null=True)),
+ ("parts_size", models.BigIntegerField(blank=True, null=True)),
+ ("parts_row_count", models.BigIntegerField(blank=True, null=True)),
+ ("stats_calculated_at", models.DateTimeField(blank=True, null=True)),
+ ("notes", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "criteria_updated_at",
+ models.DateTimeField(blank=True, help_text="When deletion criteria were last changed.", null=True),
+ ),
+ (
+ "requires_approval",
+ models.BooleanField(
+ default=True,
+ help_text="Force manual ClickHouse Team approval, opting out of auto-approval. ClickHouse deletes are heavyweight mutations that can degrade query performance and increase disk usage while running, so approval ensures they are scheduled during low-traffic windows. Small event_removal requests are cheap enough to skip that review, so the auto-approval sweep job approves them unless this is set. Written by the submit page only.",
+ ),
+ ),
+ ("approved", models.BooleanField(default=False)),
+ ("approved_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "approved_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="data_deletion_requests_approved",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="data_deletion_requests_created",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "criteria_updated_by",
+ models.ForeignKey(
+ blank=True,
+ help_text="Last user who changed deletion criteria (events, properties, time range, or request type).",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="data_deletion_requests_criteria_updated",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "max_timestamp",
+ models.DateTimeField(blank=True, help_text="Latest timestamp of matching events.", null=True),
+ ),
+ (
+ "min_timestamp",
+ models.DateTimeField(blank=True, help_text="Earliest timestamp of matching events.", null=True),
+ ),
+ (
+ "created_by_staff",
+ models.BooleanField(blank=True, help_text="Was this created by instance operator.", null=True),
+ ),
+ (
+ "execution_mode",
+ models.CharField(
+ choices=[("immediate", "Immediate"), ("deferred", "Deferred")],
+ default="immediate",
+ help_text="Picked by ClickHouse Team at approval time. Immediate: run a dedicated delete mutation now. Deferred: queue event UUIDs into adhoc_events_deletion so the scheduled deletes_job drains them. Only honored for event_removal.",
+ max_length=20,
+ ),
+ ),
+ (
+ "person_drop_events",
+ models.BooleanField(
+ blank=True,
+ default=None,
+ help_text="Drop event records linked to these persons. NULL when not a person_removal request.",
+ null=True,
+ ),
+ ),
+ (
+ "person_drop_profiles",
+ models.BooleanField(
+ blank=True,
+ default=None,
+ help_text="Drop person profiles (Postgres + ClickHouse tombstone). NULL when not a person_removal request.",
+ null=True,
+ ),
+ ),
+ (
+ "person_drop_recordings",
+ models.BooleanField(
+ blank=True,
+ default=None,
+ help_text="Drop session recordings linked to these persons. NULL when not a person_removal request.",
+ null=True,
+ ),
+ ),
+ (
+ "delete_all_events",
+ models.BooleanField(
+ default=False,
+ help_text="Opt in to matching every event for the team in the given time range. For event_removal this deletes every event; for property_removal it removes the property from every event. Not valid for person_removal. Requires events to be empty.",
+ ),
+ ),
+ (
+ "hogql_predicate",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Optional HogQL boolean expression to further narrow matching events. Validated against the events table at save time. Combined with the other filters (team/timestamp/events) via AND. Example: properties.$browser = 'Chrome'.",
+ ),
+ ),
+ (
+ "person_distinct_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=400),
+ blank=True,
+ default=list,
+ help_text="Person distinct IDs to target. Mutually exclusive with person_uuids; max 1000.",
+ size=None,
+ ),
+ ),
+ (
+ "person_uuids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.UUIDField(),
+ blank=True,
+ default=list,
+ help_text="Person UUIDs to target. Mutually exclusive with person_distinct_ids; max 1000.",
+ size=None,
+ ),
+ ),
+ (
+ "attempt_count",
+ models.PositiveIntegerField(
+ default=0,
+ help_text="Number of times execution has been attempted. Incremented when a load_* op transitions the request to IN_PROGRESS.",
+ ),
+ ),
+ (
+ "first_executed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When execution was first attempted (set on the first APPROVED → IN_PROGRESS transition).",
+ null=True,
+ ),
+ ),
+ (
+ "last_executed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When execution was most recently attempted (updated on every APPROVED → IN_PROGRESS transition).",
+ null=True,
+ ),
+ ),
+ (
+ "person_properties",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=1024),
+ blank=True,
+ default=list,
+ help_text="Property names to remove from events.person_properties. Required for property_removal requests when properties is empty.",
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "property_removal_marker",
+ models.DateTimeField(
+ blank=True,
+ help_text="inserted_at/_timestamp stamp applied to cleaned re-inserts of this property_removal request. Set once on the first execution attempt and reused by every retry so re-runs recognize already-cleaned rows and never insert a second copy. Cleared when deletion criteria change.",
+ null=True,
+ ),
+ ),
+ (
+ "last_dagster_run_id",
+ models.CharField(
+ blank=True,
+ help_text="Dagster run ID of the most recent execution attempt (set on every APPROVED → IN_PROGRESS transition). Rendered as a link to the Dagster run in the admin.",
+ max_length=255,
+ null=True,
+ ),
+ ),
+ (
+ "approved_automatically",
+ models.BooleanField(
+ default=False,
+ help_text="Approved by the auto-approval sweep job rather than a person. approved_by is NULL for these.",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EventFilterConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "mode",
+ models.CharField(
+ choices=[("disabled", "Disabled"), ("dry_run", "Dry Run"), ("live", "Live")],
+ default="disabled",
+ max_length=20,
+ ),
+ ),
+ (
+ "filter_tree",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text='Boolean expression tree. Nodes: {"type": "and"|"or", "children": [...]}, {"type": "not", "child": {...}}, {"type": "condition", "field": "event_name"|"distinct_id", "operator": "exact"|"contains", "value": "<string>"}',
+ null=True,
+ ),
+ ),
+ (
+ "test_cases",
+ models.JSONField(
+ blank=True,
+ default=list,
+ help_text='Test events to validate the filter. Each: {"event_name": "...", "distinct_id": "...", "expected_result": "drop"|"ingest"}',
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE, related_name="event_filter", to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="RoleExternalReference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("provider", models.CharField(max_length=32)),
+ ("provider_organization_id", models.CharField(max_length=255)),
+ ("provider_role_id", models.CharField(max_length=255)),
+ ("provider_role_slug", models.CharField(blank=True, max_length=255, null=True)),
+ ("provider_role_name", models.CharField(max_length=255)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="role_external_references",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ fields=["provider", "provider_organization_id", "provider_role_slug"],
+ name="idx_role_ext_ref_slug_lookup",
+ ),
+ models.Index(
+ fields=["provider", "provider_organization_id", "provider_role_id"],
+ name="idx_role_ext_ref_id_lookup",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ django.db.models.functions.text.Lower("provider_organization_id"),
+ django.db.models.functions.text.Lower("provider_role_slug"),
+ models.F("organization"),
+ models.F("provider"),
+ name="unique_role_ext_ref_slug_per_org",
+ ),
+ models.UniqueConstraint(
+ django.db.models.functions.text.Lower("provider_organization_id"),
+ django.db.models.functions.text.Lower("provider_role_id"),
+ models.F("organization"),
+ models.F("provider"),
+ name="unique_role_ext_ref_id_per_org",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserIntegration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("kind", models.CharField(choices=[("github", "Github"), ("slack", "Slack")], max_length=32)),
+ ("integration_id", models.TextField()),
+ ("config", models.JSONField(default=dict)),
+ ("sensitive_config", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ ("repository_cache", models.JSONField(blank=True, default=list)),
+ ("repository_cache_updated_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="integrations",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_user_integration",
+ "unique_together": {("user", "kind", "integration_id")},
+ "indexes": [models.Index(fields=["kind", "integration_id"], name="user_integration_kind_extid")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CIMDVerificationToken",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("label", models.CharField(max_length=40)),
+ ("mask_value", models.CharField(editable=False, max_length=11, null=True)),
+ ("secure_value", models.CharField(editable=False, max_length=300, unique=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("last_used_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="cimd_verification_tokens",
+ to="posthog.organization",
+ ),
+ ),
+ ("cimd_url", models.URLField(blank=True, max_length=2048, null=True)),
+ ],
+ options={
+ "verbose_name": "CIMD Verification Token",
+ "verbose_name_plural": "CIMD Verification Tokens",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserPushToken",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "token",
+ models.TextField(
+ help_text="Opaque push token issued by the platform push service (e.g. Expo push token)."
+ ),
+ ),
+ (
+ "platform",
+ models.CharField(
+ choices=[("ios", "iOS"), ("android", "Android"), ("web", "Web")],
+ help_text="Device platform the token was issued for.",
+ max_length=16,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "last_seen_at",
+ models.DateTimeField(
+ auto_now=True,
+ help_text="Last time the mobile app re-registered this token. Bumped on every save.",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="push_tokens",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_user_push_token",
+ "unique_together": {("user", "token")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="GitHubInstallRequest",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("github_user_id", models.BigIntegerField(blank=True, null=True)),
+ ("github_login", models.CharField(blank=True, max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "Pending"), ("approved", "Approved"), ("unidentified", "Unidentified")],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ ("installation_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("requested_at", models.DateTimeField(auto_now_add=True)),
+ ("resolved_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="github_install_requests",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("account_login", models.CharField(blank=True, max_length=255, null=True)),
+ ("account_type", models.CharField(blank=True, max_length=32, null=True)),
+ ],
+ options={
+ "db_table": "posthog_github_install_request",
+ "indexes": [models.Index(fields=["github_user_id", "status"], name="github_install_req_ghuser_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserFacetSettings",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("product", models.CharField(choices=[("logs", "Logs"), ("tracing", "Tracing")], max_length=32)),
+ ("custom_facets", models.JSONField(blank=True, default=list)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="facet_settings",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "product"), name="posthog_unique_user_facet_settings"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Element",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("text", models.CharField(blank=True, max_length=10000, null=True)),
+ ("tag_name", models.CharField(blank=True, max_length=1000, null=True)),
+ ("href", models.CharField(blank=True, max_length=10000, null=True)),
+ ("attr_id", models.CharField(blank=True, max_length=10000, null=True)),
+ (
+ "attr_class",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(blank=True, max_length=200), blank=True, null=True, size=None
+ ),
+ ),
+ ("nth_child", models.IntegerField(blank=True, null=True)),
+ ("nth_of_type", models.IntegerField(blank=True, null=True)),
+ ("attributes", models.JSONField(default=dict)),
+ ("order", models.IntegerField(blank=True, null=True)),
+ (
+ "event",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.event"
+ ),
+ ),
+ (
+ "group",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.elementgroup"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PersonDistinctId",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("distinct_id", models.CharField(max_length=400)),
+ ("version", models.BigIntegerField(blank=True, null=True)),
+ ("person", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.person")),
+ (
+ "team",
+ models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "distinct_id"), name="unique distinct_id for team")
+ ],
+ "managed": False,
+ },
+ ),
+ migrations.CreateModel(
+ name="TaggedItem",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "tag",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="tagged_items", to="posthog.tag"
+ ),
+ ),
+ (
+ "project",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="posthog.project",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("project__isnull", False)),
+ fields=("tag", "project"),
+ name="unique_project_tagged_item",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SharingConfiguration",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("enabled", models.BooleanField(default=False)),
+ (
+ "access_token",
+ models.CharField(
+ blank=True,
+ default=posthog.models.sharing_configuration.get_default_access_token,
+ max_length=400,
+ null=True,
+ unique=True,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "recording",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sharing_configurations",
+ to="posthog.sessionrecording",
+ to_field="session_id",
+ ),
+ ),
+ (
+ "expires_at",
+ models.DateTimeField(
+ blank=True, help_text="When this sharing configuration expires (null = active)", null=True
+ ),
+ ),
+ (
+ "settings",
+ models.JSONField(
+ blank=True, help_text="JSON settings for storing configuration options", null=True
+ ),
+ ),
+ ("password_required", models.BooleanField(default=False)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserGroupMembership",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("group", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.usergroup")),
+ ("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("group", "user"), name="unique_per_user_per_group")],
+ },
+ ),
+ migrations.CreateModel(
+ name="QuickFilterContext",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("context", models.CharField(max_length=100)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "quick_filter",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="context_memberships",
+ to="posthog.quickfilter",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_quickfiltercontext",
+ "indexes": [
+ models.Index(fields=["team", "context"], name="posthog_qui_team_id_3d3d27_idx"),
+ models.Index(fields=["quick_filter", "context"], name="posthog_qui_quick_f_ff6325_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "quick_filter", "context"), name="unique_filter_context")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingPlaylistItem",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("session_id", models.CharField(blank=True, max_length=200, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(blank=True, null=True)),
+ (
+ "playlist",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="playlist_items",
+ to="posthog.sessionrecordingplaylist",
+ ),
+ ),
+ (
+ "recording",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="playlist_items",
+ to="posthog.sessionrecording",
+ to_field="session_id",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["playlist"], name="srpi_playlist_idx")],
+ "constraints": [],
+ "unique_together": {("recording", "playlist")},
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingPlaylistViewed",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("viewed_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "playlist",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to="posthog.sessionrecordingplaylist"
+ ),
+ ),
+ ("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={
+ "indexes": [
+ models.Index(fields=["playlist"], name="posthog_ses_playlis_9e7475_idx"),
+ models.Index(fields=["playlist", "viewed_at"], name="posthog_ses_playlis_5051b6_idx"),
+ ],
+ "unique_together": {("user", "playlist", "viewed_at")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ObjectMediaPreview",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ (
+ "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")),
+ (
+ "uploaded_media",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="object_previews",
+ to="posthog.uploadedmedia",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationMemberNotificationLock",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "setting",
+ models.CharField(
+ choices=posthog.models.organization_notification_lock.lockable_setting_choices, max_length=64
+ ),
+ ),
+ ("scope_id", models.CharField(blank=True, db_default="", default="", max_length=160)),
+ ("locked_value", models.BooleanField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="member_notification_locks",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "organization_membership",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="notification_locks",
+ to="posthog.organizationmembership",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["organization", "setting"], name="posthog_org_organiz_a3f912_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization", "organization_membership", "setting", "scope_id"),
+ name="unique_member_notification_lock",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SessionRecordingExternalReference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("external_context", models.JSONField(blank=True, null=True)),
+ (
+ "integration",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="external_references",
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "session_recording",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="external_references",
+ related_query_name="external_reference",
+ to="posthog.sessionrecording",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_sessionrecordingexternalreference",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CommentSlackThread",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("scope", models.CharField(max_length=79)),
+ ("item_id", models.CharField(blank=True, max_length=72, null=True)),
+ ("slack_channel_id", models.CharField(max_length=255)),
+ ("slack_thread_ts", models.CharField(blank=True, default="", max_length=255)),
+ ("slack_team_id", models.CharField(blank=True, max_length=255, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "integration",
+ models.ForeignKey(
+ help_text="Slack integration whose bot token posts to and reads from the mirrored thread",
+ limit_choices_to={"kind": "slack"},
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "source_comment",
+ models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="posthog.comment"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("slack_channel_name", models.CharField(blank=True, db_default="", default="", max_length=255)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "scope", "item_id"], name="posthog_com_team_id_5c412f_idx"),
+ models.Index(fields=["slack_channel_id", "slack_thread_ts"], name="posthog_com_slack_c_7add63_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OAuthIDToken",
+ fields=[
+ ("jti", models.UUIDField(default=uuid.uuid4, editable=False, unique=True, verbose_name="JWT Token ID")),
+ ("expires", models.DateTimeField()),
+ ("scope", models.TextField(blank=True)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "application",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL,
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_id_tokens",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "OAuth ID Token",
+ "verbose_name_plural": "OAuth ID Tokens",
+ "abstract": False,
+ "swappable": "OAUTH2_PROVIDER_ID_TOKEN_MODEL",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OAuthGrant",
+ fields=[
+ ("code", models.CharField(max_length=255, unique=True)),
+ ("expires", models.DateTimeField()),
+ ("redirect_uri", models.TextField()),
+ ("scope", models.TextField(blank=True)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ ("code_challenge", models.CharField(blank=True, default="", max_length=128)),
+ (
+ "code_challenge_method",
+ models.CharField(
+ blank=True, choices=[("plain", "plain"), ("S256", "S256")], default="", max_length=10
+ ),
+ ),
+ ("nonce", models.CharField(blank=True, default="", max_length=255)),
+ ("claims", models.TextField(blank=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "scoped_teams",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.IntegerField(), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "scoped_organizations",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "application",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_grants",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "impersonated_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "OAuth Grant",
+ "verbose_name_plural": "OAuth Grants",
+ "abstract": False,
+ "swappable": "OAUTH2_PROVIDER_GRANT_MODEL",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("code_challenge_method", "S256")),
+ name="enforce_supported_code_challenge_method",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamProvisioningConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("stripe_project_id", models.CharField(blank=True, max_length=255, null=True, unique=True)),
+ ("service_id", models.CharField(default="analytics", max_length=255)),
+ (
+ "application",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="provisioned_team_configs",
+ to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["application"], name="tpc_application_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="IntegrationRepositoryCacheEntry",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("full_name", models.TextField()),
+ ("description", models.TextField(blank=True, null=True)),
+ ("topics", models.JSONField(blank=True, default=list)),
+ ("archived", models.BooleanField(default=False)),
+ ("fork", models.BooleanField(default=False)),
+ ("primary_language", models.TextField(blank=True, null=True)),
+ ("default_branch", models.TextField()),
+ ("default_branch_sha", models.TextField()),
+ ("readme", models.TextField(blank=True, default="")),
+ ("tree_paths", models.TextField(blank=True, default="")),
+ ("tree_truncated", models.BooleanField(default=False)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="repository_cache_entries",
+ to="posthog.integration",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "user_integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="repository_cache_entries",
+ to="posthog.userintegration",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "updated_at"], name="posthog_int_team_id_dc6d07_idx")],
+ "unique_together": set(),
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("integration__isnull", False)),
+ fields=("integration", "full_name"),
+ name="integration_full_name_unique",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("user_integration__isnull", False)),
+ fields=("user_integration", "team", "full_name"),
+ name="user_integration_team_full_name_unique",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("integration__isnull", False), ("user_integration__isnull", True)),
+ models.Q(("integration__isnull", True), ("user_integration__isnull", False)),
+ _connector="OR",
+ ),
+ name="integration_xor_user_integration",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SharePassword",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("password_hash", models.CharField(max_length=128)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("note", models.CharField(blank=True, max_length=100, null=True)),
+ ("is_active", models.BooleanField(default=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="created_share_passwords",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "sharing_configuration",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="share_passwords",
+ to="posthog.sharingconfiguration",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OAuthAccessToken",
+ fields=[
+ ("token", models.TextField()),
+ (
+ "token_checksum",
+ oauth2_provider.models.TokenChecksumField(db_index=True, max_length=64, unique=True),
+ ),
+ ("expires", models.DateTimeField()),
+ ("scope", models.TextField(blank=True)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "scoped_teams",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.IntegerField(), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "scoped_organizations",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "application",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL,
+ ),
+ ),
+ (
+ "id_token",
+ models.OneToOneField(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="access_token",
+ to=settings.OAUTH2_PROVIDER_ID_TOKEN_MODEL,
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_access_tokens",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "impersonated_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "label",
+ models.CharField(
+ blank=True,
+ db_default="",
+ default="",
+ help_text="Optional user-facing label so a user can identify a token (per-device, per-IP, or by purpose).",
+ max_length=40,
+ ),
+ ),
+ ("sandbox_task_id", models.UUIDField(blank=True, null=True)),
+ ],
+ options={
+ "verbose_name": "OAuth Access Token",
+ "verbose_name_plural": "OAuth Access Tokens",
+ "abstract": False,
+ "swappable": "OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL",
+ "indexes": [
+ models.Index(fields=["token"], name="oauthaccesstoken_token_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ models.Func(
+ models.F("scope"),
+ models.Value(" "),
+ function="string_to_array",
+ output_field=django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), size=None
+ ),
+ ),
+ condition=models.Q(("application__isnull", False)),
+ fastupdate=False,
+ name="oauthaccesstoken_scopes_gin",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OAuthRefreshToken",
+ fields=[
+ ("token", models.CharField(max_length=255)),
+ ("token_family", models.UUIDField(blank=True, editable=False, null=True)),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ ("revoked", models.DateTimeField(null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "scoped_teams",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.IntegerField(), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "scoped_organizations",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=100), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "access_token",
+ models.OneToOneField(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="refresh_token",
+ to=settings.OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL,
+ ),
+ ),
+ (
+ "application",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_refresh_tokens",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "impersonated_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "OAuth Refresh Token",
+ "verbose_name_plural": "OAuth Refresh Tokens",
+ "abstract": False,
+ "swappable": "OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL",
+ "unique_together": {("token", "revoked")},
+ "indexes": [models.Index(fields=["token_family"], name="oauthrefreshtoken_family_idx")],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/posthog/migrations/0717_errortrackingassignmentrule_role_and_more.py b/posthog/migrations/0717_errortrackingassignmentrule_role_and_more.py
index ff117ede81e4..5711c9830924 100644
--- a/posthog/migrations/0717_errortrackingassignmentrule_role_and_more.py
+++ b/posthog/migrations/0717_errortrackingassignmentrule_role_and_more.py
@@ -27,7 +27,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
atomic = False # Added to support concurrent index creation
dependencies = [
- ("ee", "0026_conversation_created_at_conversation_title_and_more"),
("posthog", "0716_backfill_team_revenue_analytics_config"),
]
diff --git a/posthog/migrations/0829_organization_default_role.py b/posthog/migrations/0829_organization_default_role.py
index fadd937b2f70..a851ba58e0e1 100644
--- a/posthog/migrations/0829_organization_default_role.py
+++ b/posthog/migrations/0829_organization_default_role.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
atomic = False # Added to support concurrent index creation
dependencies = [
- ("ee", "0026_conversation_created_at_conversation_title_and_more"),
("posthog", "0828_grouptypemapping_created_at"),
]
diff --git a/posthog/migrations/0886_fake_social_django_jsonfield_migrations.py b/posthog/migrations/0886_fake_social_django_jsonfield_migrations.py
index 1b62ac2ea7a4..c3c71dfbfab6 100644
--- a/posthog/migrations/0886_fake_social_django_jsonfield_migrations.py
+++ b/posthog/migrations/0886_fake_social_django_jsonfield_migrations.py
@@ -70,8 +70,6 @@ def unmark_social_django_migrations(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("posthog", "0885_migrate_notebooks_models"),
- # Ensure social_django 0010 is applied before we mark 0011-0016
- ("social_django", "0010_uid_db_index"),
]
operations = [
diff --git a/posthog/migrations/0993_approvalpolicy_bypass_options.py b/posthog/migrations/0993_approvalpolicy_bypass_options.py
index 39f3d2e57894..80ed5d4e4e45 100644
--- a/posthog/migrations/0993_approvalpolicy_bypass_options.py
+++ b/posthog/migrations/0993_approvalpolicy_bypass_options.py
@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "0992_drop_approvalpolicy_bypass_roles_column"),
- ("ee", "0025_role_members"),
]
operations = [
diff --git a/posthog/migrations/1018_migrate_event_definition_models.py b/posthog/migrations/1018_migrate_event_definition_models.py
index ee5fe55a34a1..dc816e540905 100644
--- a/posthog/migrations/1018_migrate_event_definition_models.py
+++ b/posthog/migrations/1018_migrate_event_definition_models.py
@@ -42,8 +42,6 @@ def reverse_content_type(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("event_definitions", "0001_initial"),
- ("ee", "0038_alter_enterpriseeventdefinition_eventdefinition_ptr_and_more"),
("posthog", "1017_survey_form_content"),
]
diff --git a/posthog/migrations/1032_remove_taggeditem_exactly_one_related_object_and_more.py b/posthog/migrations/1032_remove_taggeditem_exactly_one_related_object_and_more.py
index 915ddba0ea4e..e3ffbb0a8504 100644
--- a/posthog/migrations/1032_remove_taggeditem_exactly_one_related_object_and_more.py
+++ b/posthog/migrations/1032_remove_taggeditem_exactly_one_related_object_and_more.py
@@ -6,8 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("event_definitions", "0002_schemapropertygroupproperty_is_optional_in_types"),
- ("conversations", "0023_ticket_sla_due_at_index"),
("posthog", "1031_team_data_attributes_allow_blank"),
]
diff --git a/posthog/migrations/1056_migrate_experiments_models.py b/posthog/migrations/1056_migrate_experiments_models.py
index 308150889e2a..5d0dc1f39d64 100644
--- a/posthog/migrations/1056_migrate_experiments_models.py
+++ b/posthog/migrations/1056_migrate_experiments_models.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("experiments", "0001_migrate_experiments_models"),
("posthog", "1055_cohort_last_backfill_person_properties_at"),
]
diff --git a/posthog/migrations/1063_remove_surveyresponsearchive_survey_and_more.py b/posthog/migrations/1063_remove_surveyresponsearchive_survey_and_more.py
index 41fccd519762..c7cd02cbe26c 100644
--- a/posthog/migrations/1063_remove_surveyresponsearchive_survey_and_more.py
+++ b/posthog/migrations/1063_remove_surveyresponsearchive_survey_and_more.py
@@ -6,8 +6,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("posthog", "1062_migrate_links_models"),
- ("surveys", "0001_initial"),
- ("product_tours", "0006_alter_producttour_linked_surveys"),
]
operations = [
diff --git a/posthog/migrations/1064_migrate_messaging_models.py b/posthog/migrations/1064_migrate_messaging_models.py
index dfba7f155093..dfd0ad87b88d 100644
--- a/posthog/migrations/1064_migrate_messaging_models.py
+++ b/posthog/migrations/1064_migrate_messaging_models.py
@@ -6,7 +6,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
- ("messaging", "0001_migrate_messaging_models"),
("posthog", "1063_remove_surveyresponsearchive_survey_and_more"),
]
diff --git a/posthog/migrations/1073_migrate_dashboards_models.py b/posthog/migrations/1073_migrate_dashboards_models.py
index 1ed8ab59d42a..b8fe4cebaa34 100644
--- a/posthog/migrations/1073_migrate_dashboards_models.py
+++ b/posthog/migrations/1073_migrate_dashboards_models.py
@@ -41,9 +41,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("ee", "0041_migrate_dashboards_models"),
- ("dashboards", "0001_migrate_dashboards_models"),
- ("data_warehouse", "0038_migrate_dashboards_models"),
("posthog", "1072_backfill_condition_aggregation"),
]
diff --git a/posthog/migrations/1106_alert_investigation_fields.py b/posthog/migrations/1106_alert_investigation_fields.py
index 473707842323..34ff2c470bfe 100644
--- a/posthog/migrations/1106_alert_investigation_fields.py
+++ b/posthog/migrations/1106_alert_investigation_fields.py
@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "1105_alter_oauthapplication_authorization_grant_type"),
- ("notebooks", "0003_add_kernel_timeouts"),
]
operations = [
diff --git a/posthog/migrations/1117_role_external_reference.py b/posthog/migrations/1117_role_external_reference.py
index 953e063d31fa..b73014faf54e 100644
--- a/posthog/migrations/1117_role_external_reference.py
+++ b/posthog/migrations/1117_role_external_reference.py
@@ -10,7 +10,6 @@ import posthog.models.utils
class Migration(migrations.Migration):
dependencies = [
- ("ee", "0041_migrate_dashboards_models"),
("posthog", "1116_datadeletionrequest_hogql_predicate"),
]
diff --git a/posthog/migrations/1132_insight_dashboarditem_team_lmod_idx.py b/posthog/migrations/1132_insight_dashboarditem_team_lmod_idx.py
index cd04e6a5e7e4..92954e5b9416 100644
--- a/posthog/migrations/1132_insight_dashboarditem_team_lmod_idx.py
+++ b/posthog/migrations/1132_insight_dashboarditem_team_lmod_idx.py
@@ -8,7 +8,6 @@ class Migration(migrations.Migration):
atomic = False
dependencies = [
- ("dashboards", "0001_migrate_dashboards_models"),
("posthog", "1131_exportedasset_is_system"),
]
diff --git a/posthog/migrations/1143_sharingconfiguration_notebook.py b/posthog/migrations/1143_sharingconfiguration_notebook.py
index 5e01bb17cefc..d24f4fa2ca1f 100644
--- a/posthog/migrations/1143_sharingconfiguration_notebook.py
+++ b/posthog/migrations/1143_sharingconfiguration_notebook.py
@@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "1142_alter_batchexportdestination_type_and_more"),
- ("notebooks", "0003_add_kernel_timeouts"),
]
operations = [
diff --git a/posthog/migrations/1155_sharingconfiguration_interviewee_context.py b/posthog/migrations/1155_sharingconfiguration_interviewee_context.py
index 87f534734fc0..3361cf44f639 100644
--- a/posthog/migrations/1155_sharingconfiguration_interviewee_context.py
+++ b/posthog/migrations/1155_sharingconfiguration_interviewee_context.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "1154_userpushtoken"),
- ("user_interviews", "0003_intervieweecontext"),
]
operations = [
diff --git a/posthog/migrations/1168_migrate_alerts_actions_models.py b/posthog/migrations/1168_migrate_alerts_actions_models.py
index 16ed3553e052..3fed10cc40d8 100644
--- a/posthog/migrations/1168_migrate_alerts_actions_models.py
+++ b/posthog/migrations/1168_migrate_alerts_actions_models.py
@@ -36,10 +36,7 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("alerts", "0001_migrate_models"),
- ("actions", "0001_migrate_actions_models"),
("posthog", "1167_remove_alertconfiguration_is_calculating"),
- ("surveys", "0002_action_fk_repoint"),
]
operations = [
diff --git a/posthog/migrations/1172_remove_taggeditem_exactly_one_related_object_and_more.py b/posthog/migrations/1172_remove_taggeditem_exactly_one_related_object_and_more.py
index 1aaa01046d39..b580e723925a 100644
--- a/posthog/migrations/1172_remove_taggeditem_exactly_one_related_object_and_more.py
+++ b/posthog/migrations/1172_remove_taggeditem_exactly_one_related_object_and_more.py
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("customer_analytics", "0005_account"),
("posthog", "1171_backfill_credentials_reviewed_at"),
]
diff --git a/posthog/migrations/1179_taggeditem_endpoint.py b/posthog/migrations/1179_taggeditem_endpoint.py
index c33418ef06e1..5e9097ecd72f 100644
--- a/posthog/migrations/1179_taggeditem_endpoint.py
+++ b/posthog/migrations/1179_taggeditem_endpoint.py
@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("endpoints", "0029_remove_data_modeling_models"),
("posthog", "1178_datadeletionrequest_person_properties"),
]
diff --git a/posthog/migrations/1182_migrate_feature_flags_models.py b/posthog/migrations/1182_migrate_feature_flags_models.py
index 2ad19a1c777d..23407dd1f8a0 100644
--- a/posthog/migrations/1182_migrate_feature_flags_models.py
+++ b/posthog/migrations/1182_migrate_feature_flags_models.py
@@ -48,13 +48,7 @@ def reverse_content_type(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("early_access_features", "0006_migrate_feature_flags_models"),
- ("ee", "0045_migrate_feature_flags_models"),
- ("experiments", "0015_migrate_feature_flags_models"),
- ("feature_flags", "0002_migrate_feature_flags_models"),
("posthog", "1181_taggeditem_endpoint_unique_constraint"),
- ("product_tours", "0007_migrate_feature_flags_models"),
- ("surveys", "0004_migrate_feature_flags_models"),
]
operations = [
diff --git a/posthog/migrations/1184_migrate_product_analytics_models.py b/posthog/migrations/1184_migrate_product_analytics_models.py
index 183e750c4d24..75a98ea86898 100644
--- a/posthog/migrations/1184_migrate_product_analytics_models.py
+++ b/posthog/migrations/1184_migrate_product_analytics_models.py
@@ -41,12 +41,7 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("alerts", "0002_migrate_product_analytics_models"),
- ("customer_analytics", "0006_migrate_product_analytics_models"),
- ("dashboards", "0006_migrate_product_analytics_models"),
("posthog", "1183_migrate_product_analytics_models_state"),
- ("product_analytics", "0001_migrate_product_analytics_models"),
- ("surveys", "0005_migrate_product_analytics_models"),
]
operations = [
diff --git a/posthog/migrations/1187_migrate_hog_flow_models.py b/posthog/migrations/1187_migrate_hog_flow_models.py
index d6e2c47bb99d..9215113ef9c2 100644
--- a/posthog/migrations/1187_migrate_hog_flow_models.py
+++ b/posthog/migrations/1187_migrate_hog_flow_models.py
@@ -32,7 +32,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("posthog", "1186_activitylog_ip_address"),
- ("workflows", "0007_migrate_hog_flow_models"),
]
operations = [
diff --git a/posthog/migrations/1188_migrate_cdp_models.py b/posthog/migrations/1188_migrate_cdp_models.py
index cf6bba1b2a95..154dc964e11d 100644
--- a/posthog/migrations/1188_migrate_cdp_models.py
+++ b/posthog/migrations/1188_migrate_cdp_models.py
@@ -40,7 +40,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("posthog", "1187_migrate_hog_flow_models"),
- ("cdp", "0001_migrate_cdp_models"),
]
operations = [
diff --git a/posthog/migrations/1202_migrate_exports_models.py b/posthog/migrations/1202_migrate_exports_models.py
index 37161caa8372..47a81092b1e4 100644
--- a/posthog/migrations/1202_migrate_exports_models.py
+++ b/posthog/migrations/1202_migrate_exports_models.py
@@ -34,7 +34,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("exports", "0001_migrate_exports_models"),
("posthog", "1201_persistedfolder_drop_old_unique"),
]
diff --git a/posthog/migrations/1203_migrate_annotations_models.py b/posthog/migrations/1203_migrate_annotations_models.py
index 61350d8295a9..e6ae72e20156 100644
--- a/posthog/migrations/1203_migrate_annotations_models.py
+++ b/posthog/migrations/1203_migrate_annotations_models.py
@@ -33,7 +33,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("annotations", "0001_migrate_annotations_models"),
("posthog", "1202_migrate_exports_models"),
]
diff --git a/posthog/migrations/1204_migrate_batch_exports_models.py b/posthog/migrations/1204_migrate_batch_exports_models.py
index 17d1a9535afc..402fb0e994dd 100644
--- a/posthog/migrations/1204_migrate_batch_exports_models.py
+++ b/posthog/migrations/1204_migrate_batch_exports_models.py
@@ -33,7 +33,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("batch_exports", "0001_migrate_batch_exports_models"),
("posthog", "1203_migrate_annotations_models"),
]
diff --git a/posthog/migrations/1205_delete_batch_export_models.py b/posthog/migrations/1205_delete_batch_export_models.py
index 824673020ef0..ead99da6b69d 100644
--- a/posthog/migrations/1205_delete_batch_export_models.py
+++ b/posthog/migrations/1205_delete_batch_export_models.py
@@ -40,8 +40,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("batch_exports", "0002_batchexport_batchexportbackfill_and_more"),
- ("cdp", "0002_alter_hogfunction_batch_export"),
("posthog", "1204_migrate_batch_exports_models"),
]
diff --git a/posthog/migrations/1207_migrate_ai_observability_models.py b/posthog/migrations/1207_migrate_ai_observability_models.py
index 06da55b62aa1..220e64c84ce9 100644
--- a/posthog/migrations/1207_migrate_ai_observability_models.py
+++ b/posthog/migrations/1207_migrate_ai_observability_models.py
@@ -40,7 +40,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("posthog", "1206_cohort_list_indexes"),
- ("ai_observability", "0002_migrate_ai_observability_models"),
]
operations = [
diff --git a/posthog/migrations/1215_migrate_replay_models.py b/posthog/migrations/1215_migrate_replay_models.py
index af68edf26af7..7d97c6b2c4b7 100644
--- a/posthog/migrations/1215_migrate_replay_models.py
+++ b/posthog/migrations/1215_migrate_replay_models.py
@@ -38,7 +38,9 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
- dependencies = [("posthog", "1214_oauthapplication_sessions_revoked_at"), ("replay", "0001_migrate_replay_models")]
+ dependencies = [
+ ("posthog", "1214_oauthapplication_sessions_revoked_at"),
+ ]
operations = [
migrations.SeparateDatabaseAndState(
diff --git a/posthog/migrations/1216_migrate_cohorts_models.py b/posthog/migrations/1216_migrate_cohorts_models.py
index fdf33d746c6c..7e5f7b5f398d 100644
--- a/posthog/migrations/1216_migrate_cohorts_models.py
+++ b/posthog/migrations/1216_migrate_cohorts_models.py
@@ -39,10 +39,7 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("error_tracking", "0017_migrate_cohorts_models"),
- ("experiments", "0018_migrate_cohorts_models"),
("posthog", "1215_migrate_replay_models"),
- ("cohorts", "0001_migrate_cohorts_models"),
]
operations = [
diff --git a/posthog/migrations/1239_migrate_approvals_models.py b/posthog/migrations/1239_migrate_approvals_models.py
index 580eba27da76..492389e97ad1 100644
--- a/posthog/migrations/1239_migrate_approvals_models.py
+++ b/posthog/migrations/1239_migrate_approvals_models.py
@@ -31,7 +31,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ("approvals", "0001_migrate_approvals_models"),
("posthog", "1238_ducklakebackfill_earliest_event_date"),
]
diff --git a/posthog/migrations/1281_migrate_managed_warehouse_models.py b/posthog/migrations/1281_migrate_managed_warehouse_models.py
index 120575b288ce..35a70b94ee60 100644
--- a/posthog/migrations/1281_migrate_managed_warehouse_models.py
+++ b/posthog/migrations/1281_migrate_managed_warehouse_models.py
@@ -73,7 +73,6 @@ def reverse_content_types(apps: Any, schema_editor: Any) -> None:
class Migration(migrations.Migration):
dependencies = [
- ("managed_warehouse", "0001_migrate_managed_warehouse_models"),
("posthog", "1280_alter_integration_kind"),
]
diff --git a/posthog/migrations/1285_drop_desktop_file_system.py b/posthog/migrations/1285_drop_desktop_file_system.py
index 101d6fbb532c..0bff6a3690de 100644
--- a/posthog/migrations/1285_drop_desktop_file_system.py
+++ b/posthog/migrations/1285_drop_desktop_file_system.py
@@ -12,7 +12,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("posthog", "1284_organization_enforce_verified_domains"),
- ("canvas", "0003_migrate_desktop_tree"),
]
operations = [
diff --git a/posthog/migrations/1301_taggeditem_replay_scanner.py b/posthog/migrations/1301_taggeditem_replay_scanner.py
index 70c214409ac8..ce695052beb0 100644
--- a/posthog/migrations/1301_taggeditem_replay_scanner.py
+++ b/posthog/migrations/1301_taggeditem_replay_scanner.py
@@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("replay_vision", "0065_replayscannerbackfill_skipped_count_and_more"),
("posthog", "1300_identityproviderconfig_saml_relay_state_unique"),
]
diff --git a/posthog/migrations/1319_team_posthog_team_widget_token_idx.py b/posthog/migrations/1319_team_posthog_team_widget_token_idx.py
index e5c38274d8b6..b8c8f43ed36c 100644
--- a/posthog/migrations/1319_team_posthog_team_widget_token_idx.py
+++ b/posthog/migrations/1319_team_posthog_team_widget_token_idx.py
@@ -11,7 +11,6 @@ class Migration(migrations.Migration):
atomic = False
dependencies = [
- ("dashboards", "0015_dashboard_customization"),
("posthog", "1318_disable_oauth_scope_trgm_fastupdate"),
]
diff --git a/posthog/migrations/1344_squash_2026_09_07_finalize_fks.py b/posthog/migrations/1344_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..feb5e4f0af8f
--- /dev/null
+++ b/posthog/migrations/1344_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,639 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0001_squash_2026_09_07_initial"),
+ ("dashboards", "0001_squash_2026_09_07_initial"),
+ ("ee", "0001_squash_2026_09_07_initial"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0001_squash_2026_09_07_initial"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("posthog", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="grouptypemapping",
+ name="detail_dashboard",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ to="dashboards.dashboard",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="materializedcolumnslot",
+ name="property_definition",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="materialized_column_slots",
+ related_query_name="materialized_column_slot",
+ to="event_definitions.propertydefinition",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="oauthaccesstoken",
+ name="source_refresh_token",
+ field=models.OneToOneField(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="refreshed_access_token",
+ to=settings.OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL,
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="objectmediapreview",
+ name="event_definition",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="media_previews",
+ to="event_definitions.eventdefinition",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="objectmediapreview",
+ name="exported_asset",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="object_previews",
+ to="exports.exportedasset",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="organization",
+ name="default_role",
+ field=models.ForeignKey(
+ blank=True,
+ help_text="Role automatically assigned to new members joining the organization",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="default_for_organizations",
+ to="ee.role",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="organization",
+ name="logo_media",
+ field=models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="posthog.uploadedmedia"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="organization",
+ name="members",
+ field=models.ManyToManyField(
+ related_name="organizations",
+ related_query_name="organization",
+ through="posthog.OrganizationMembership",
+ through_fields=("organization", "user"),
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="organization",
+ name="members",
+ field=models.ManyToManyField(
+ related_name="organizations",
+ related_query_name="organization",
+ through="posthog.OrganizationMembership",
+ through_fields=("organization", "user"),
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="organizationinvite",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="organization_invites",
+ related_query_name="organization_invite",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="roleexternalreference",
+ name="role",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="role_external_references", to="ee.role"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="sharingconfiguration",
+ name="dashboard",
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="dashboards.dashboard"),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="sharingconfiguration",
+ name="insight",
+ field=models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="sharingconfiguration",
+ name="interviewee_context",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sharing_configurations",
+ to="user_interviews.intervieweecontext",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="sharingconfiguration",
+ name="notebook",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sharing_configurations",
+ to="notebooks.notebook",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="account",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="customer_analytics.account",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="action",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="actions.action",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="dashboard",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="dashboards.dashboard",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="endpoint",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="endpoints.endpoint",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="event_definition",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="event_definitions.eventdefinition",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="experiment_saved_metric",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="experiments.experimentsavedmetric",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="feature_flag",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="insight",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="product_analytics.insight",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="property_definition",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="event_definitions.propertydefinition",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="replay_scanner",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="replay_vision.replayscanner",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="taggeditem",
+ name="ticket",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tagged_items",
+ to="conversations.ticket",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="team",
+ name="primary_dashboard",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="primary_dashboard_teams",
+ to="dashboards.dashboard",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="usergroup",
+ name="members",
+ field=models.ManyToManyField(through="posthog.UserGroupMembership", to=settings.AUTH_USER_MODEL),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="userscenepersonalisation",
+ name="dashboard",
+ field=models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="dashboards.dashboard"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddIndexIfMissing(
+ model_name="materializedcolumnslot",
+ index=models.Index(fields=["team", "property_definition"], name="posthog_mat_team_pr_idx"),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddIndexIfMissing(
+ model_name="objectmediapreview",
+ index=models.Index(fields=["team", "event_definition"], name="posthog_obj_team_id_e93ae8_idx"),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="materializedcolumnslot",
+ constraint=models.UniqueConstraint(
+ fields=("team", "property_definition"), name="unique_team_property_definition"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("dashboard__isnull", False)),
+ fields=("tag", "dashboard"),
+ name="unique_dashboard_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("insight__isnull", False)),
+ fields=("tag", "insight"),
+ name="unique_insight_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("event_definition__isnull", False)),
+ fields=("tag", "event_definition"),
+ name="unique_event_definition_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("property_definition__isnull", False)),
+ fields=("tag", "property_definition"),
+ name="unique_property_definition_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("action__isnull", False)),
+ fields=("tag", "action"),
+ name="unique_action_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("feature_flag__isnull", False)),
+ fields=("tag", "feature_flag"),
+ name="unique_feature_flag_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("experiment_saved_metric__isnull", False)),
+ fields=("tag", "experiment_saved_metric"),
+ name="unique_experiment_saved_metric_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("ticket__isnull", False)),
+ fields=("tag", "ticket"),
+ name="unique_ticket_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("account__isnull", False)),
+ fields=("tag", "account"),
+ name="unique_account_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("endpoint__isnull", False)),
+ fields=("tag", "endpoint"),
+ name="unique_endpoint_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("replay_scanner__isnull", False)),
+ fields=("tag", "replay_scanner"),
+ name="unique_replay_scanner_tagged_item",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="taggeditem",
+ constraint=models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("dashboard__isnull", False),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", False),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", False),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", False),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", False),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", False),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", False),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", False),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", False),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", False),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", False),
+ ("project__isnull", True),
+ ),
+ models.Q(
+ ("dashboard__isnull", True),
+ ("insight__isnull", True),
+ ("event_definition__isnull", True),
+ ("property_definition__isnull", True),
+ ("action__isnull", True),
+ ("feature_flag__isnull", True),
+ ("experiment_saved_metric__isnull", True),
+ ("ticket__isnull", True),
+ ("account__isnull", True),
+ ("endpoint__isnull", True),
+ ("replay_scanner__isnull", True),
+ ("project__isnull", False),
+ ),
+ _connector="OR",
+ ),
+ name="exactly_one_related_object",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="objectmediapreview",
+ constraint=models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("exported_asset__isnull", True), ("uploaded_media__isnull", False)),
+ models.Q(("exported_asset__isnull", False), ("uploaded_media__isnull", True)),
+ _connector="OR",
+ ),
+ name="exactly_one_media",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="objectmediapreview",
+ constraint=models.CheckConstraint(
+ condition=models.Q(("event_definition__isnull", False)), name="exactly_one_object"
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AlterUniqueTogetherIfMissing(
+ name="taggeditem",
+ unique_together={
+ (
+ "tag",
+ "dashboard",
+ "insight",
+ "event_definition",
+ "property_definition",
+ "action",
+ "feature_flag",
+ "experiment_saved_metric",
+ "ticket",
+ "account",
+ "endpoint",
+ "replay_scanner",
+ "project",
+ )
+ },
+ ),
+ ]
diff --git a/posthog/migrations/1345_squash_2026_09_07_schema_addons.py b/posthog/migrations/1345_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..0bbe85037bd7
--- /dev/null
+++ b/posthog/migrations/1345_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,350 @@
+# Generated by Django 5.2.17
+
+import django.contrib.postgres.operations
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_foreign_key
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1343_teammarketinganalyticsconfig_filter_test_accounts"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS idx_messagingrecord_unique_on_email_hash_campaign_key_campaign_count\n ON posthog_messagingrecord (email_hash, campaign_key, campaign_count);\n ",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_experiment_created_by_id_b40aea95_fk_posthog_user_id\') THEN\nALTER TABLE "posthog_experiment" ADD CONSTRAINT "posthog_experiment_created_by_id_b40aea95_fk_posthog_user_id" FOREIGN KEY ("created_by_id") REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_featureflag_created_by_id_4571fe1a_fk_posthog_user_id\') THEN\nALTER TABLE "posthog_featureflag" ADD CONSTRAINT "posthog_featureflag_created_by_id_4571fe1a_fk_posthog_user_id" FOREIGN KEY ("created_by_id") REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_experiment_exposure_cohort_id_19450b9e" ON "posthog_experiment" ("exposure_cohort_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="CREATE INDEX CONCURRENTLY IF NOT EXISTS posthog_eventproperty_team_id_and_property_r32khd9s ON posthog_eventproperty(team_id, property)",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_pluginconfig_match_action_id_1cbf8562" ON "posthog_pluginconfig" ("match_action_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_survey_internal_targeting_flag_id_b3911925" ON "posthog_survey" ("internal_targeting_flag_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_annotation_dashboard_id_91ef4125" ON "posthog_annotation" ("dashboard_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_plugin_organization_id_d040b9a9_fk_posthog_o\') THEN\nALTER TABLE "posthog_plugin" ADD CONSTRAINT "posthog_plugin_organization_id_d040b9a9_fk_posthog_o" FOREIGN KEY ("organization_id") REFERENCES "posthog_organization" ("id") DEFERRABLE INITIALLY DEFERRED;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_plugin_url_bccac89d_like" ON "posthog_plugin" ("url" varchar_pattern_ops);\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_organization_logo_media_id_1c12c9dc" ON "posthog_organization" ("logo_media_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_datawarehousesavedquery_table_id_96fdb4f5" ON "posthog_datawarehousesavedquery" ("table_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_experiment_holdout_id_ffd173dd_fk_posthog_e" ON "posthog_experiment" ("holdout_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_survey_internal_response_sampling_flag_id_e682f708" ON "posthog_survey" ("internal_response_sampling_flag_id")\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_errortrackin_issue_id_d9cce9cb_fk_posthog_e\') THEN\n-- existing-table-constraint-ignore\n ALTER TABLE "posthog_errortrackingissueassignment" ADD CONSTRAINT "posthog_errortrackin_issue_id_d9cce9cb_fk_posthog_e" FOREIGN KEY ("issue_id") REFERENCES "posthog_errortrackingissue" ("id") DEFERRABLE INITIALLY DEFERRED;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_errortrackin_user_id_83f2e696_fk_posthog_u\') THEN\nALTER TABLE "posthog_errortrackingissueassignment" ADD CONSTRAINT "posthog_errortrackin_user_id_83f2e696_fk_posthog_u" FOREIGN KEY ("user_id") REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_experiment_saved_metric_id_b6af2199" ON "posthog_taggeditem" ("experiment_saved_metric_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_734394e1_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_batchexportrun_backfill_id_9243c0f7" ON "posthog_batchexportrun" ("backfill_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_filesystem_project_id_767c1359_239c0515" ON "posthog_filesystem" ("project_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_action_project_id_4taf4ZLMhR8D_utgqv8kQuJmp" ON "posthog_action" ("project_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_uploadedmedia_project_id_uzTGNcheyj_WxVp79RtER" ON "posthog_uploadedmedia" ("project_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_datacolortheme_project_id_CZYFwmeeLU_Rvzb4NfvcS" ON "posthog_datacolortheme" ("project_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_dashboard_data_color_theme_id_0084ccbf" ON "posthog_dashboard" ("data_color_theme_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_team_parent_team_id_bkr8e799nE_TkKe5yC3C5" ON "posthog_team" ("parent_team_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_errortrackingassignmentrule_role_id_5faac145" ON "posthog_errortrackingassignmentrule" ("role_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_errortrackingissueassignment_role_id_f84c52d3" ON "posthog_errortrackingissueassignment" ("role_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS team_secret_api_token_unique_idx ON posthog_team (secret_api_token);",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS team_secret_api_token_backup_unique_idx ON posthog_team (secret_api_token_backup);",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_hogfunction_hog_function_template_id_3dc757e7" ON "posthog_hogfunction" ("hog_function_template_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="CREATE INDEX CONCURRENTLY IF NOT EXISTS posthog_dashboarditem_query_gin ON posthog_dashboarditem USING GIN (query jsonb_ops);",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_err_team_id_e9f6b2_idx"\n ON "posthog_errortrackingrelease" ("team_id", "hash_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_errortrackingsymbolset_release_id_idx"\n ON "posthog_errortrackingsymbolset" ("release_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="CREATE INDEX CONCURRENTLY IF NOT EXISTS dashboarditem_query_metadata ON posthog_dashboarditem USING GIN (query_metadata jsonb_ops);",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_organization_default_role_id_03bcd28b" ON "posthog_organization" ("default_role_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="\n CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_activitylog_featureflag_updates\n ON posthog_activitylog (team_id, item_id, created_at DESC)\n WHERE scope = 'FeatureFlag' AND activity = 'updated';\n ",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_batchexportdestination_integration_id_7927a172" ON "posthog_batchexportdestination" ("integration_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_datawarehousesavedquery_managed_viewset_id_1cbf8562" ON "posthog_datawarehousesavedquery" ("managed_viewset_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_survey_linked_insight_id_586524f3_fk_posthog_d\') THEN\nALTER TABLE "posthog_survey" ADD CONSTRAINT "posthog_survey_linked_insight_id_586524f3_fk_posthog_d" FOREIGN KEY ("linked_insight_id") REFERENCES "posthog_dashboarditem" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_survey_linked_insight_id_586524f3" ON "posthog_survey" ("linked_insight_id"); -- existing-table-constraint-ignore\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_insightviewed_null_team_user_unique"\n ON "posthog_insightviewed" ("insight_id")\n WHERE "team_id" IS NULL AND "user_id" IS NULL\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_hogfunction_batch_export_id_d64c3403" ON "posthog_hogfunction" ("batch_export_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_resourcetransfer_created_by_id_cfdd93a0" ON "posthog_resourcetransfer" ("created_by_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_ticket_id_idx"\n ON "posthog_taggeditem" ("ticket_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_d90686d0_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id"\n );\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "unique_cohort_kind_per_team"\n ON "posthog_cohort" ("team_id", "kind")\n WHERE "kind" IS NOT NULL AND "deleted" = false\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_user_onboarding_delegated_to_invite_id_fkey\') THEN\nALTER TABLE "posthog_user" ADD CONSTRAINT "posthog_user_onboarding_delegated_to_invite_id_fkey" FOREIGN KEY ("onboarding_delegated_to_invite_id") REFERENCES "posthog_organizationinvite"("id") ON DELETE SET NULL NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_user_onboarding_delegated_to_invite_id_idx" ON "posthog_user" ("onboarding_delegated_to_invite_id") WHERE "onboarding_delegated_to_invite_id" IS NOT NULL',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_account_id_idx"\n ON "posthog_taggeditem" ("account_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_4fe7898b_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id",\n "account_id"\n );\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_endpoint_id_idx"\n ON "posthog_taggeditem" ("endpoint_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_endpoint_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id",\n "account_id",\n "endpoint_id"\n );\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "cohort_team_created_idx" ON "posthog_cohort" (team_id, created_at DESC)',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "cohort_name_trgm_idx" ON "posthog_cohort" USING gin (name gin_trgm_ops)',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "oauthaccesstoken_scope_trgm" ON "posthog_oauthaccesstoken" USING gin (scope gin_trgm_ops) WHERE application_id IS NOT NULL',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_identityproviderconfig_saml_relay_state_a35fb61b_uniq" ON "posthog_identityproviderconfig" (saml_relay_state)',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_identityproviderconfig_saml_relay_state_a35fb61b_like" ON "posthog_identityproviderconfig" (saml_relay_state varchar_pattern_ops)',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_replay_scanner_id_idx" ON "posthog_taggeditem" ("replay_scanner_id")',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_replay_scan_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id", "ticket_id", "account_id", "endpoint_id", "replay_scanner_id")',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_project_id_0a61d235" ON "posthog_taggeditem" ("project_id")',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_4ec15a8f_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id", "ticket_id", "account_id", "endpoint_id", "replay_scanner_id", "project_id")',
+ reverse_sql="",
+ ),
+ django.contrib.postgres.operations.ValidateConstraint(
+ model_name="team",
+ name="project_id_is_not_null",
+ ),
+ django.contrib.postgres.operations.ValidateConstraint(
+ model_name="grouptypemapping",
+ name="group_type_project_id_is_not_null",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="taggeditem",
+ name="posthog_taggeditem_project_id_fk",
+ column="project_id",
+ to_table="posthog_project",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="taggeditem",
+ name="posthog_taggeditem_project_id_fk",
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 73243bde303d..d6677b013bd9 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1343_teammarketinganalyticsconfig_filter_test_accounts
+1345_squash_2026_09_07_schema_addons
diff --git a/posthog/settings/__init__.py b/posthog/settings/__init__.py
index f9f1fac1a1e3..9676c97dcabd 100644
--- a/posthog/settings/__init__.py
+++ b/posthog/settings/__init__.py
@@ -47,6 +47,7 @@ from posthog.settings.web import *
from posthog.settings.web_bot_auth import *
from posthog.settings.data_warehouse import *
from posthog.settings.managed_migrations import *
+from posthog.settings.nextgensquash import *
from posthog.settings.session_replay import *
from posthog.settings.session_replay_v2 import *
from posthog.settings.signals import *
diff --git a/posthog/settings/nextgensquash.py b/posthog/settings/nextgensquash.py
new file mode 100644
index 000000000000..79f10be9c870
--- /dev/null
+++ b/posthog/settings/nextgensquash.py
@@ -0,0 +1,19 @@
+# Project config for django-nextgensquash, the migration squasher. The package
+# is a dev-only tool run through `uv run --with`; see the "Squash the Django
+# migration history" entry in docs/internal/ci-things-already-tried.md.
+NEXTGENSQUASH = {
+ # Not in common.migration_utils' managed set either; fold it at the next cutoff.
+ "IGNORED_APPS": ["posthog_session"],
+ # 0001_initial creates partitioned tables and a view with raw SQL that
+ # CreateModel cannot reproduce, and its migrate cost is negligible.
+ "FROZEN_APPS": ["warehouse_sources_queue"],
+ # Created in the stub: bin/migrate runs migrate_clickhouse in parallel with
+ # `manage.py migrate`, and it reads posthog_instancesetting.
+ "EARLY_MODELS": {"posthog": ["instancesetting"]},
+ # The stub claims posthog's root so check_consistent_history stamps it on
+ # live databases (swappable deps resolve to ("posthog", "__first__")).
+ "STUB_CLAIMS": {"posthog": [["posthog", "0001_initial_squashed_0284_improved_caching_state_idx"]]},
+ # The generated finalize files import these idempotent operations at
+ # migrate time, so they stay in this repo instead of the package.
+ "OPERATIONS_MODULE": "posthog.migration_helpers.squash_idempotent",
+}
diff --git a/posthog/test/test_migration_1324.py b/posthog/test/test_migration_1324.py
deleted file mode 100644
index 04459219246a..000000000000
--- a/posthog/test/test_migration_1324.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from typing import Any
-
-from posthog.test.base import NonAtomicTestMigrations
-
-LEGACY_URL = "https://legacy.example.com/.well-known/oauth-client-metadata"
-MOVED_URL = "https://moved.example.com/.well-known/oauth-client-metadata"
-STRAY_URL = "https://stray.example.com/.well-known/oauth-client-metadata"
-
-
-# The latest migration creates an index concurrently, so teardown must not run inside a transaction.
-class BackfillCimdClientIdMigrationTest(NonAtomicTestMigrations):
- migrate_from = "1323_proxyrecord_root_redirect_url"
- migrate_to = "1324_backfill_cimd_client_id"
-
- CLASS_DATA_LEVEL_SETUP = False
-
- def setUpBeforeMigration(self, apps: Any) -> None:
- OAuthApplication = apps.get_model("posthog", "OAuthApplication")
- self.OAuthApplication = OAuthApplication
-
- def create(client_id: str, **kwargs: Any) -> Any:
- return OAuthApplication.objects.create(
- name=client_id,
- client_id=client_id,
- client_secret="",
- client_type="public",
- authorization_grant_type="authorization-code",
- redirect_uris="https://example.com/callback",
- algorithm="RS256",
- **kwargs,
- )
-
- self.legacy_cimd = create("generated-legacy", is_cimd_client=True, cimd_metadata_url=LEGACY_URL)
- # Registered by the code that already writes the URL into client_id.
- self.already_moved = create(MOVED_URL, is_cimd_client=True, cimd_metadata_url=MOVED_URL)
- # A stray URL on a non-CIMD row must not become its client_id: the app authenticates
- # under the opaque id an admin gave it.
- self.non_cimd = create("opaque-admin-registered", is_cimd_client=False, cimd_metadata_url=STRAY_URL)
-
- def test_only_cimd_apps_take_their_metadata_url_as_client_id(self) -> None:
- assert self.OAuthApplication.objects.get(pk=self.legacy_cimd.pk).client_id == LEGACY_URL
- assert self.OAuthApplication.objects.get(pk=self.already_moved.pk).client_id == MOVED_URL
- assert self.OAuthApplication.objects.get(pk=self.non_cimd.pk).client_id == "opaque-admin-registered"
diff --git a/products/access_control/backend/migrations/0001_squash_2026_09_07_initial.py b/products/access_control/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..1559138e8c1a
--- /dev/null
+++ b/products/access_control/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,88 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("access_control", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("ee", "0059_scimprovisioneduser_unique_config"),
+ ("event_definitions", "0009_drop_eventproperty_proj_event_coalesce_idx"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="PropertyAccessControl",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("access_level", models.CharField(max_length=32)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization_member",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="property_access_controls",
+ related_query_name="property_access_controls",
+ to="posthog.organizationmembership",
+ ),
+ ),
+ (
+ "property_definition",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="property_access_controls",
+ related_query_name="property_access_controls",
+ to="event_definitions.propertydefinition",
+ ),
+ ),
+ (
+ "role",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="property_access_controls",
+ related_query_name="property_access_controls",
+ to="ee.role",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="property_access_controls",
+ related_query_name="property_access_controls",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("property_definition", "team", "organization_member", "role"),
+ name="unique property per target",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/access_control/backend/migrations/max_migration.txt b/products/access_control/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/access_control/backend/migrations/max_migration.txt
+++ b/products/access_control/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/actions/backend/migrations/0001_squash_2026_09_07_initial.py b/products/actions/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..bb4f52d62802
--- /dev/null
+++ b/products/actions/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,132 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ replaces = [("actions", "0001_migrate_actions_models")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Action",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("post_to_slack", models.BooleanField(default=False)),
+ ("slack_message_format", models.CharField(blank=True, default="", max_length=1200)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("bytecode_error", models.TextField(blank=True, null=True)),
+ ("steps_json", models.JSONField(blank=True, null=True)),
+ ("pinned_at", models.DateTimeField(blank=True, default=None, null=True)),
+ (
+ "summary",
+ models.TextField(blank=True, help_text="A summary of the action, generated by AI", null=True),
+ ),
+ (
+ "last_summarized_at",
+ models.DateTimeField(
+ blank=True, help_text="The last time the action was summarized by AI", null=True
+ ),
+ ),
+ (
+ "embedding_last_synced_at",
+ models.DateTimeField(
+ blank=True, help_text="The last time the action was synced to the vector database", null=True
+ ),
+ ),
+ (
+ "embedding_version",
+ models.PositiveSmallIntegerField(
+ blank=True, help_text="The version of the embedding model used to embed the action", null=True
+ ),
+ ),
+ ("is_calculating", models.BooleanField(default=False)),
+ ("last_calculated_at", models.DateTimeField(blank=True, default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("events", models.ManyToManyField(blank=True, to="posthog.event")),
+ (
+ "project",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_action",
+ "indexes": [models.Index(fields=["team_id", "-updated_at"], name="posthog_act_team_id_8c04de_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ActionStep",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("text", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "text_matching",
+ models.CharField(
+ blank=True,
+ choices=[("contains", "contains"), ("regex", "regex"), ("exact", "exact")],
+ max_length=400,
+ null=True,
+ ),
+ ),
+ ("href", models.CharField(blank=True, max_length=65535, null=True)),
+ (
+ "href_matching",
+ models.CharField(
+ blank=True,
+ choices=[("contains", "contains"), ("regex", "regex"), ("exact", "exact")],
+ max_length=400,
+ null=True,
+ ),
+ ),
+ ("selector", models.CharField(blank=True, max_length=65535, null=True)),
+ ("url", models.CharField(blank=True, max_length=65535, null=True)),
+ (
+ "url_matching",
+ models.CharField(
+ blank=True,
+ choices=[("contains", "contains"), ("regex", "regex"), ("exact", "exact")],
+ default="contains",
+ max_length=400,
+ null=True,
+ ),
+ ),
+ ("event", models.CharField(blank=True, max_length=400, null=True)),
+ ("properties", models.JSONField(blank=True, default=list, null=True)),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("tag_name", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "action",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="action_steps", to="actions.action"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_actionstep",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/actions/backend/migrations/max_migration.txt b/products/actions/backend/migrations/max_migration.txt
index 05ca0bd663e6..6903cd5e3dc2 100644
--- a/products/actions/backend/migrations/max_migration.txt
+++ b/products/actions/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_migrate_actions_models
+0001_squash_2026_09_07_initial
diff --git a/products/ai_observability/backend/migrations/0001_squash_2026_09_07_initial.py b/products/ai_observability/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..318a8aaa2302
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,1287 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.lookups
+import django.db.models.deletion
+import django.db.models.expressions
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+import django.db.models.functions.text
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("ai_observability", "0001_adopt_llm_analytics_models"),
+ ("ai_observability", "0002_migrate_ai_observability_models"),
+ ("ai_observability", "0003_normalize_evaluation_conditions"),
+ ("ai_observability", "0004_parserrecipe"),
+ ("ai_observability", "0005_release_skills_to_skills_app"),
+ ("ai_observability", "0006_alter_evaluation_evaluation_type_and_more"),
+ ("ai_observability", "0007_retire_reports_for_deleted_evaluations"),
+ ("ai_observability", "0008_alter_evaluation_status_reason"),
+ ("ai_observability", "0009_alter_evaluation_status_reason"),
+ ("ai_observability", "0010_add_minimax_provider"),
+ ("ai_observability", "0011_evaluation_target"),
+ ("ai_observability", "0012_clear_model_config_from_non_judge_evals"),
+ ("ai_observability", "0013_add_model_config_only_on_llm_judge"),
+ ("ai_observability", "0014_validate_model_config_only_on_llm_judge"),
+ ("ai_observability", "0015_llmprompt_version_description"),
+ ("ai_observability", "0016_deprecate_trial_evaluations"),
+ ("ai_observability", "0017_relabel_terminal_status_reasons"),
+ ("ai_observability", "0018_deduplicate_evaluation_reports"),
+ ("ai_observability", "0019_delete_duplicate_evaluation_reports"),
+ ("ai_observability", "0020_unique_evaluation_report_per_evaluation"),
+ ("ai_observability", "0021_add_zeabur_provider"),
+ ("ai_observability", "0022_add_generated_delivery_status"),
+ ("ai_observability", "0023_llmpromptlabel"),
+ ("ai_observability", "0024_relabel_trial_status_reasons"),
+ ("ai_observability", "0025_alter_evaluation_status_reason"),
+ ("ai_observability", "0026_retire_trial_columns"),
+ ("ai_observability", "0027_resweep_trial_status_reasons"),
+ ("ai_observability", "0028_drop_trial_eval_columns"),
+ ("ai_observability", "0029_disable_reports_for_disabled_evaluations"),
+ ("ai_observability", "0030_evaluationreport_last_attempted_at"),
+ ("ai_observability", "0031_llmprompt_config"),
+ ("ai_observability", "0032_dataset_versioning"),
+ ("ai_observability", "0033_evaluation_target_session"),
+ ("ai_observability", "0034_evaluationdirectory_evaluation_directory_and_more"),
+ ("ai_observability", "0035_evaluation_directory_index"),
+ ("ai_observability", "0036_dataset_item_client_id_and_version_dataset"),
+ ("ai_observability", "0037_backfill_dataset_item_version_dataset"),
+ ("ai_observability", "0038_make_dataset_item_version_dataset_non_null"),
+ ("ai_observability", "0039_dataset_item_version_ownership_constraints"),
+ ("ai_observability", "0040_validate_dataset_item_version_ownership"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ClusteringConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="clustering_config",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("event_filters", models.JSONField(blank=True, default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "db_table": "llm_analytics_clusteringconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EvaluationDirectory",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_evaluationdirectory",
+ "ordering": ["name", "id"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ django.db.models.functions.text.Lower("name"),
+ models.F("team"),
+ name="uniq_llma_eval_dir_team_name_ci",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMProviderKey",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "provider",
+ models.CharField(
+ choices=[
+ ("openai", "Openai"),
+ ("anthropic", "Anthropic"),
+ ("gemini", "Gemini"),
+ ("openrouter", "Openrouter"),
+ ("fireworks", "Fireworks"),
+ ("azure_openai", "Azure OpenAI"),
+ ("together_ai", "Together AI"),
+ ("minimax", "MiniMax"),
+ ("zeabur", "Zeabur AI Hub"),
+ ],
+ max_length=50,
+ ),
+ ),
+ ("name", models.CharField(max_length=255)),
+ (
+ "state",
+ models.CharField(
+ choices=[("unknown", "Unknown"), ("ok", "Ok"), ("invalid", "Invalid"), ("error", "Error")],
+ default="unknown",
+ max_length=20,
+ ),
+ ),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("encrypted_config", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_used_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
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "llm_analytics_llmproviderkey",
+ "indexes": [models.Index(fields=["team", "provider"], name="llm_analyti_team_id_a78410_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReviewQueue",
+ 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.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ (
+ "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={
+ "db_table": "llm_analytics_reviewqueue",
+ "ordering": ["name", "id"],
+ "indexes": [models.Index(fields=["team", "name"], name="llma_rev_queue_name_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)), fields=("team", "name"), name="llma_rev_queue_name_uniq"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ScoreDefinition",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "kind",
+ models.CharField(
+ choices=[("categorical", "categorical"), ("numeric", "numeric"), ("boolean", "boolean")],
+ max_length=32,
+ ),
+ ),
+ ("archived", models.BooleanField(default=False)),
+ (
+ "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={
+ "db_table": "llm_analytics_scoredefinition",
+ "ordering": ["name", "id"],
+ "indexes": [models.Index(fields=["team", "kind", "archived"], name="llma_score_def_team_kind_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TraceReview",
+ 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.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("trace_id", models.CharField(max_length=255)),
+ ("comment", models.TextField(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
+ ),
+ ),
+ (
+ "reviewed_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "llm_analytics_tracereview",
+ "ordering": ["-updated_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "trace_id"], name="llma_tr_rev_trace_idx"),
+ models.Index(fields=["team", "-updated_at", "id"], name="llma_tr_rev_upd_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("team", "trace_id"),
+ name="llma_tr_rev_active_uniq",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ClusteringJob",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=100)),
+ (
+ "analysis_level",
+ models.CharField(
+ choices=[("trace", "trace"), ("generation", "generation"), ("evaluation", "evaluation")],
+ max_length=20,
+ ),
+ ),
+ ("event_filters", models.JSONField(blank=True, default=list)),
+ ("enabled", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="clustering_jobs", to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_clusteringjob",
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="unique_clustering_job_name_per_team")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMPrompt",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("prompt", models.JSONField()),
+ ("version", models.PositiveIntegerField(default=1)),
+ ("is_latest", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "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")),
+ ("version_description", models.CharField(blank=True, max_length=400, null=True)),
+ ("config", models.JSONField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_llmprompt",
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("team", "name", "version"),
+ name="unique_llm_prompt_version_per_team",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("is_latest", True)),
+ fields=("team", "name"),
+ name="unique_llm_prompt_latest_per_team",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMTraceSummary",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "trace_summary_type",
+ models.CharField(
+ choices=[("issues_search", "Issues Search")], default="issues_search", max_length=100
+ ),
+ ),
+ ("trace_id", models.CharField(help_text="Trace ID", max_length=255)),
+ ("summary", models.CharField(help_text="Trace summary", max_length=1000)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "ee_llmtracesummary",
+ "indexes": [
+ models.Index(
+ fields=["team", "trace_id", "trace_summary_type"], name="ee_llmtrace_team_id_93a147_idx"
+ )
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "trace_id", "trace_summary_type"), name="unique_trace_summary"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ParserRecipe",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("source", models.TextField()),
+ (
+ "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={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Dataset",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("archived", 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={
+ "db_table": "llm_analytics_dataset_v2",
+ "ordering": ["-created_at", "id"],
+ "indexes": [
+ models.Index(
+ fields=["team", "archived", "-created_at", "id"], name="llma_dataset_v2_team_arch_idx"
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["name"], name="llma_dataset_v2_name_trgm", opclasses=["gin_trgm_ops"]
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["description"], name="llma_dataset_v2_desc_trgm", opclasses=["gin_trgm_ops"]
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="uniq_llma_dataset_v2_team_name"),
+ models.CheckConstraint(
+ condition=django.db.models.lookups.Exact(
+ models.Func(models.F("metadata"), function="jsonb_typeof", output_field=models.CharField()),
+ models.Value("object"),
+ ),
+ name="llma_dataset_v2_metadata_object",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMModelConfiguration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "provider",
+ models.CharField(
+ choices=[
+ ("openai", "Openai"),
+ ("anthropic", "Anthropic"),
+ ("gemini", "Gemini"),
+ ("openrouter", "Openrouter"),
+ ("fireworks", "Fireworks"),
+ ("azure_openai", "Azure OpenAI"),
+ ("together_ai", "Together AI"),
+ ("minimax", "MiniMax"),
+ ("zeabur", "Zeabur AI Hub"),
+ ],
+ max_length=50,
+ ),
+ ),
+ ("model", models.CharField(max_length=100)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "provider_key",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="model_configurations",
+ to="ai_observability.llmproviderkey",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_llmmodelconfiguration",
+ "indexes": [models.Index(fields=["team", "provider"], name="llm_analyti_team_id_e3928e_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EvaluationConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="evaluation_config",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "active_provider_key",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="ai_observability.llmproviderkey",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_evaluationconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReviewQueueItem",
+ 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.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("trace_id", models.CharField(max_length=255)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "queue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="items",
+ to="ai_observability.reviewqueue",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "llm_analytics_reviewqueueitem",
+ "ordering": ["created_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "queue", "created_at", "id"], name="llma_rev_q_item_queue_idx"),
+ models.Index(fields=["team", "trace_id"], name="llma_rev_q_item_trace_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("team", "trace_id"),
+ name="llma_rev_q_item_trace_uniq",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ScoreDefinitionVersion",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("version", models.PositiveIntegerField()),
+ ("config", models.JSONField(default=dict)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "definition",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="versions",
+ to="ai_observability.scoredefinition",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_scoredefinitionversion",
+ "ordering": ["-version"],
+ "indexes": [
+ models.Index(fields=["definition", "-version"], name="llma_score_def_ver_def_idx"),
+ models.Index(fields=["created_at"], name="llma_score_def_ver_created_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("definition", "version"), name="uniq_llma_score_def_ver")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TraceReviewScore",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("definition_version", models.UUIDField()),
+ ("definition_version_number", models.PositiveIntegerField()),
+ ("definition_config", models.JSONField(default=dict)),
+ (
+ "categorical_values",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=128), blank=True, null=True, size=None
+ ),
+ ),
+ ("numeric_value", models.DecimalField(blank=True, decimal_places=6, max_digits=12, null=True)),
+ ("boolean_value", models.BooleanField(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
+ ),
+ ),
+ (
+ "definition",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="trace_review_scores",
+ to="ai_observability.scoredefinition",
+ ),
+ ),
+ (
+ "review",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scores",
+ to="ai_observability.tracereview",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "llm_analytics_tracereviewscore",
+ "ordering": ["definition__name", "id"],
+ "indexes": [
+ models.Index(fields=["team", "definition"], name="llma_tr_score_def_idx"),
+ models.Index(fields=["team", "review"], name="llma_tr_score_rev_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["categorical_values"], name="llma_tr_score_cat_gin"
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("review", "definition"), name="llma_tr_score_def_uniq"),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("categorical_values__isnull", False),
+ ("numeric_value__isnull", True),
+ ("boolean_value__isnull", True),
+ ),
+ models.Q(
+ ("categorical_values__isnull", True),
+ ("numeric_value__isnull", False),
+ ("boolean_value__isnull", True),
+ ),
+ models.Q(
+ ("categorical_values__isnull", True),
+ ("numeric_value__isnull", True),
+ ("boolean_value__isnull", False),
+ ),
+ _connector="OR",
+ ),
+ name="llma_tr_score_one_chk",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMPromptLabel",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=128)),
+ ("prompt_name", models.CharField(max_length=255)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "prompt",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="labels",
+ to="ai_observability.llmprompt",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_llmpromptlabel",
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "prompt_name", "name"), name="unique_llm_prompt_label_per_prompt"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DatasetItem",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=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,
+ ),
+ ),
+ (
+ "dataset",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="items", to="ai_observability.dataset"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("client_item_id", models.CharField(blank=True, db_column="external_id", max_length=255, null=True)),
+ ],
+ options={
+ "db_table": "llm_analytics_datasetitem_v2",
+ "ordering": ["-created_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "dataset", "-created_at", "id"], name="llma_dataset_item_v2_list_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("client_item_id__isnull", False)),
+ fields=("dataset", "client_item_id"),
+ name="uniq_llma_dataset_item_v2_ext",
+ ),
+ models.UniqueConstraint(fields=("id", "dataset", "team"), name="uniq_llma_dataset_item_v2_owner"),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DatasetRevision",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("revision", models.PositiveIntegerField()),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "dataset",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="revisions",
+ to="ai_observability.dataset",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_datasetrevision_v2",
+ "ordering": ["-revision"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("dataset", "revision"), name="uniq_llma_dataset_revision_v2"),
+ models.CheckConstraint(
+ condition=models.Q(("revision__gte", 1)), name="llma_dataset_revision_v2_positive"
+ ),
+ models.UniqueConstraint(fields=("id", "dataset", "team"), name="uniq_llma_dataset_rev_v2_owner"),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Evaluation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("enabled", models.BooleanField(default=False)),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("paused", "Paused"), ("error", "Error")],
+ default="paused",
+ max_length=20,
+ ),
+ ),
+ (
+ "status_reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("provider_key_required", "No provider API key configured"),
+ ("provider_key_deleted", "Provider API key was deleted"),
+ ("no_default_model", "No default model available for the selected provider"),
+ ("provider_key_invalid", "Provider API key is invalid"),
+ ("provider_key_permission_denied", "Provider API key lacks model access"),
+ ("provider_key_quota_exceeded", "Provider API key quota exceeded"),
+ ("provider_key_rate_limited", "Provider API key is rate limited"),
+ ("model_not_found", "Model not found"),
+ ("hog_error", "Hog evaluation code failed"),
+ ],
+ max_length=50,
+ null=True,
+ ),
+ ),
+ (
+ "evaluation_type",
+ models.CharField(
+ choices=[("llm_judge", "LLM as a judge"), ("hog", "Hog"), ("sentiment", "Sentiment analysis")],
+ max_length=50,
+ ),
+ ),
+ ("evaluation_config", models.JSONField(default=dict)),
+ (
+ "output_type",
+ models.CharField(
+ choices=[("boolean", "Boolean (Pass/Fail)"), ("sentiment", "Sentiment")], max_length=50
+ ),
+ ),
+ ("output_config", models.JSONField(default=dict)),
+ ("conditions", models.JSONField(default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "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")),
+ (
+ "model_configuration",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="evaluations",
+ to="ai_observability.llmmodelconfiguration",
+ ),
+ ),
+ ("status_reason_detail", models.TextField(blank=True, null=True)),
+ (
+ "target",
+ models.CharField(
+ choices=[("generation", "Generation"), ("trace", "Trace"), ("session", "Session")],
+ db_default="generation",
+ default="generation",
+ max_length=20,
+ ),
+ ),
+ ("target_config", models.JSONField(db_default=models.Value("{}"), default=dict)),
+ (
+ "directory",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="evaluations",
+ to="ai_observability.evaluationdirectory",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_evaluation",
+ "ordering": ["-created_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "-created_at", "id"], name="llm_analyti_team_id_2ed8fb_idx"),
+ models.Index(fields=["team", "enabled"], name="llm_analyti_team_id_03a4ef_idx"),
+ models.Index(fields=["model_configuration"], name="llm_analyti_model_c_idx"),
+ models.Index(
+ fields=["team", "directory", "-created_at", "id"], name="llma_eval_team_dir_created_idx"
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("model_configuration__isnull", True), ("evaluation_type", "llm_judge"), _connector="OR"
+ ),
+ name="model_config_only_on_llm_judge",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Tagger",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("enabled", models.BooleanField(default=False)),
+ (
+ "tagger_type",
+ models.CharField(choices=[("llm", "LLM"), ("hog", "Hog")], default="llm", max_length=50),
+ ),
+ ("tagger_config", models.JSONField(default=dict)),
+ ("conditions", models.JSONField(default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "model_configuration",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="taggers",
+ to="ai_observability.llmmodelconfiguration",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "llm_analytics_tagger",
+ "ordering": ["-created_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "-created_at", "id"], name="llm_analyti_team_id_tagger_idx"),
+ models.Index(fields=["team", "enabled"], name="llm_analyti_tagger_enabled_idx"),
+ models.Index(fields=["model_configuration"], name="llm_analyti_tagger_model_c_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DatasetItemVersion",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("version", models.PositiveIntegerField()),
+ ("archived", models.BooleanField(default=False)),
+ ("input", models.JSONField()),
+ ("expected_output", models.JSONField(blank=True, null=True)),
+ ("source_output", models.JSONField(blank=True, null=True)),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("source_trace_id", models.CharField(blank=True, max_length=255, null=True)),
+ ("source_event_id", models.CharField(blank=True, max_length=255, null=True)),
+ ("source_timestamp", models.DateTimeField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "dataset_item",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="versions",
+ to="ai_observability.datasetitem",
+ ),
+ ),
+ (
+ "dataset_revision",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.RESTRICT,
+ related_name="item_versions",
+ to="ai_observability.datasetrevision",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "dataset",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="item_versions",
+ to="ai_observability.dataset",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_datasetitemversion_v2",
+ "ordering": ["-version"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("dataset_item", "version"), name="uniq_llma_dataset_item_version_v2"
+ ),
+ models.UniqueConstraint(
+ fields=("dataset_item", "dataset_revision"), name="uniq_llma_dataset_item_revision_v2"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("version__gte", 1)), name="llma_dataset_item_ver_v2_positive"
+ ),
+ models.CheckConstraint(
+ condition=django.db.models.expressions.NegatedExpression(
+ django.db.models.lookups.Exact(
+ models.Func(
+ models.F("input"), function="jsonb_typeof", output_field=models.CharField()
+ ),
+ models.Value("null"),
+ )
+ ),
+ name="llma_dataset_item_ver_v2_input",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("expected_output__isnull", True),
+ django.db.models.expressions.NegatedExpression(
+ django.db.models.lookups.Exact(
+ models.Func(
+ models.F("expected_output"),
+ function="jsonb_typeof",
+ output_field=models.CharField(),
+ ),
+ models.Value("null"),
+ )
+ ),
+ _connector="OR",
+ ),
+ name="llma_dataset_item_ver_v2_expected",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("source_output__isnull", True),
+ django.db.models.expressions.NegatedExpression(
+ django.db.models.lookups.Exact(
+ models.Func(
+ models.F("source_output"),
+ function="jsonb_typeof",
+ output_field=models.CharField(),
+ ),
+ models.Value("null"),
+ )
+ ),
+ _connector="OR",
+ ),
+ name="llma_dataset_item_ver_v2_source",
+ ),
+ models.CheckConstraint(
+ condition=django.db.models.lookups.Exact(
+ models.Func(models.F("metadata"), function="jsonb_typeof", output_field=models.CharField()),
+ models.Value("object"),
+ ),
+ name="llma_dataset_item_ver_v2_metadata",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("source_event_id__isnull", True),
+ ("source_timestamp__isnull", True),
+ ("source_trace_id__isnull", True),
+ ),
+ models.Q(("source_timestamp__isnull", False), ("source_trace_id__isnull", False)),
+ _connector="OR",
+ ),
+ name="llma_dataset_item_ver_v2_source_ref",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EvaluationReport",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "frequency",
+ models.CharField(
+ choices=[("scheduled", "Scheduled"), ("every_n", "Every N")], default="every_n", max_length=16
+ ),
+ ),
+ ("rrule", models.TextField(blank=True, default="")),
+ ("starts_at", models.DateTimeField(blank=True, null=True)),
+ ("timezone_name", models.CharField(default="UTC", max_length=64)),
+ ("next_delivery_date", models.DateTimeField(blank=True, null=True)),
+ ("delivery_targets", models.JSONField(default=list)),
+ ("max_sample_size", models.IntegerField(default=200)),
+ ("enabled", models.BooleanField(default=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("last_delivered_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "trigger_threshold",
+ models.IntegerField(
+ blank=True,
+ default=100,
+ help_text="Number of new eval results that triggers a report",
+ null=True,
+ ),
+ ),
+ (
+ "cooldown_minutes",
+ models.IntegerField(default=60, help_text="Minimum minutes between count-triggered reports"),
+ ),
+ (
+ "daily_run_cap",
+ models.IntegerField(
+ default=10, help_text="Maximum count-triggered report runs per calendar day (UTC)"
+ ),
+ ),
+ ("report_prompt_guidance", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "evaluation",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="reports",
+ to="ai_observability.evaluation",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("last_attempted_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "llm_analytics_evaluationreport",
+ "ordering": ["-created_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "-created_at", "id"], name="llm_analyti_team_id_b9ccef_idx"),
+ models.Index(
+ fields=["next_delivery_date", "enabled", "deleted"], name="llm_analyti_next_de_a58933_idx"
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("evaluation",), name="unique_evaluation_report_per_evaluation")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EvaluationReportRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("content", models.JSONField(default=dict)),
+ ("metadata", models.JSONField(default=dict)),
+ ("period_start", models.DateTimeField()),
+ ("period_end", models.DateTimeField()),
+ (
+ "delivery_status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("generated", "Generated"),
+ ("delivered", "Delivered"),
+ ("partial_failure", "Partial Failure"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("delivery_errors", models.JSONField(default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "report",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="runs",
+ to="ai_observability.evaluationreport",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_evaluationreportrun",
+ "ordering": ["-created_at"],
+ "indexes": [models.Index(fields=["report", "-created_at"], name="llm_analyti_report__f6c41e_idx")],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/0044_squash_2026_09_07_finalize_fks.py b/products/ai_observability/backend/migrations/0044_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..cc0e35a909cd
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0044_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,50 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("ai_observability", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="dataset",
+ name="current_revision",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.RESTRICT,
+ related_name="+",
+ to="ai_observability.datasetrevision",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="datasetitem",
+ name="current_version",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.RESTRICT,
+ related_name="+",
+ to="ai_observability.datasetitemversion",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="scoredefinition",
+ name="current_version",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="ai_observability.scoredefinitionversion",
+ ),
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/0045_squash_2026_09_07_schema_addons.py b/products/ai_observability/backend/migrations/0045_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..55d5d7f76d90
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0045_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,107 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_constraint
+import posthog.migration_helpers.not_valid_foreign_key
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0043_drop_legacy_dataset_tables"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql="DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'llma_item_ver_item_owner_fk') THEN\nALTER TABLE llm_analytics_datasetitemversion_v2\n ADD CONSTRAINT llma_item_ver_item_owner_fk\n FOREIGN KEY (dataset_item_id, dataset_id, team_id)\n REFERENCES llm_analytics_datasetitem_v2 (id, dataset_id, team_id)\n DEFERRABLE INITIALLY DEFERRED NOT VALID;\nEND IF; END $$;",
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql="DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'llma_item_ver_revision_owner_fk') THEN\nALTER TABLE llm_analytics_datasetitemversion_v2\n ADD CONSTRAINT llma_item_ver_revision_owner_fk\n FOREIGN KEY (dataset_revision_id, dataset_id, team_id)\n REFERENCES llm_analytics_datasetrevision_v2 (id, dataset_id, team_id)\n DEFERRABLE INITIALLY DEFERRED NOT VALID;\nEND IF; END $$;",
+ reverse_sql="",
+ ),
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="evaluation",
+ name="model_config_only_on_llm_judge",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="datasetitemversion",
+ name="llma_item_ver_item_owner_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="datasetitemversion",
+ name="llma_item_ver_revision_owner_fk",
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txt
index ee998cb2575a..9b645a42a400 100644
--- a/products/ai_observability/backend/migrations/max_migration.txt
+++ b/products/ai_observability/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0043_drop_legacy_dataset_tables
+0045_squash_2026_09_07_schema_addons
diff --git a/products/alerts/backend/migrations/0001_squash_2026_09_07_initial.py b/products/alerts/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..7f6e1a9f6872
--- /dev/null
+++ b/products/alerts/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,286 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.db.models.expressions
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.schema_enums
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("alerts", "0001_migrate_models"),
+ ("alerts", "0002_migrate_product_analytics_models"),
+ ("alerts", "0003_alter_alertconfiguration_calculation_interval"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("notebooks", "0014_notebook_variables"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Alert",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(max_length=100)),
+ ("target_value", models.TextField()),
+ ("anomaly_condition", models.JSONField(default=dict)),
+ (
+ "insight",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_alert",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Threshold",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(blank=True, max_length=255)),
+ ("configuration", models.JSONField(default=dict)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "insight",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_threshold",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AlertConfiguration",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(blank=True, max_length=255)),
+ ("config", models.JSONField(blank=True, default=dict, null=True)),
+ (
+ "calculation_interval",
+ models.CharField(
+ blank=True,
+ choices=[
+ (posthog.schema_enums.AlertCalculationInterval["REAL_TIME"], "real_time"),
+ (posthog.schema_enums.AlertCalculationInterval["EVERY_15_MINUTES"], "every_15_minutes"),
+ (posthog.schema_enums.AlertCalculationInterval["HOURLY"], "hourly"),
+ (posthog.schema_enums.AlertCalculationInterval["DAILY"], "daily"),
+ (posthog.schema_enums.AlertCalculationInterval["WEEKLY"], "weekly"),
+ (posthog.schema_enums.AlertCalculationInterval["MONTHLY"], "monthly"),
+ ],
+ default=posthog.schema_enums.AlertCalculationInterval["DAILY"],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("condition", models.JSONField(default=dict)),
+ ("detector_config", models.JSONField(blank=True, null=True)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ (posthog.schema_enums.AlertState["FIRING"], posthog.schema_enums.AlertState["FIRING"]),
+ (
+ posthog.schema_enums.AlertState["NOT_FIRING"],
+ posthog.schema_enums.AlertState["NOT_FIRING"],
+ ),
+ (posthog.schema_enums.AlertState["ERRORED"], posthog.schema_enums.AlertState["ERRORED"]),
+ (posthog.schema_enums.AlertState["SNOOZED"], posthog.schema_enums.AlertState["SNOOZED"]),
+ ],
+ default=posthog.schema_enums.AlertState["NOT_FIRING"],
+ max_length=10,
+ ),
+ ),
+ ("enabled", models.BooleanField(default=True)),
+ ("last_notified_at", models.DateTimeField(blank=True, null=True)),
+ ("last_checked_at", models.DateTimeField(blank=True, null=True)),
+ ("next_check_at", models.DateTimeField(blank=True, null=True)),
+ ("snoozed_until", models.DateTimeField(blank=True, null=True)),
+ ("skip_weekend", models.BooleanField(blank=True, default=False, null=True)),
+ ("schedule_restriction", models.JSONField(blank=True, default=None, null=True)),
+ ("investigation_agent_enabled", models.BooleanField(default=False)),
+ ("investigation_gates_notifications", models.BooleanField(default=False)),
+ (
+ "investigation_inconclusive_action",
+ models.CharField(
+ choices=[("notify", "Notify"), ("suppress", "Suppress")], default="notify", max_length=10
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "insight",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "threshold",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="alerts.threshold"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_alertconfiguration",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AlertCheck",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("calculated_value", models.FloatField(blank=True, null=True)),
+ ("condition", models.JSONField(default=dict)),
+ ("targets_notified", models.JSONField(default=dict)),
+ ("error", models.JSONField(blank=True, null=True)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ (posthog.schema_enums.AlertState["FIRING"], posthog.schema_enums.AlertState["FIRING"]),
+ (
+ posthog.schema_enums.AlertState["NOT_FIRING"],
+ posthog.schema_enums.AlertState["NOT_FIRING"],
+ ),
+ (posthog.schema_enums.AlertState["ERRORED"], posthog.schema_enums.AlertState["ERRORED"]),
+ (posthog.schema_enums.AlertState["SNOOZED"], posthog.schema_enums.AlertState["SNOOZED"]),
+ ],
+ default=posthog.schema_enums.AlertState["NOT_FIRING"],
+ max_length=10,
+ ),
+ ),
+ ("anomaly_scores", models.JSONField(blank=True, null=True)),
+ ("triggered_points", models.JSONField(blank=True, null=True)),
+ ("triggered_dates", models.JSONField(blank=True, null=True)),
+ ("interval", models.CharField(blank=True, max_length=10, null=True)),
+ ("triggered_metadata", models.JSONField(blank=True, null=True)),
+ (
+ "investigation_status",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("pending", "pending"),
+ ("running", "running"),
+ ("done", "done"),
+ ("failed", "failed"),
+ ("skipped", "skipped"),
+ ],
+ max_length=10,
+ null=True,
+ ),
+ ),
+ (
+ "investigation_verdict",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("true_positive", "true_positive"),
+ ("false_positive", "false_positive"),
+ ("inconclusive", "inconclusive"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("investigation_summary", models.TextField(blank=True, null=True)),
+ ("investigation_error", models.JSONField(blank=True, null=True)),
+ ("notification_sent_at", models.DateTimeField(blank=True, null=True)),
+ ("notification_suppressed_by_agent", models.BooleanField(default=False)),
+ (
+ "investigation_notebook",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="notebooks.notebook",
+ ),
+ ),
+ (
+ "alert_configuration",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="alerts.alertconfiguration"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_alertcheck",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AlertSubscription",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("subscribed", models.BooleanField(default=True)),
+ (
+ "alert_configuration",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="alerts.alertconfiguration"),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ limit_choices_to={
+ "is_active": True,
+ "organization_id": django.db.models.expressions.OuterRef(
+ "alert_configuration__team__organization_id"
+ ),
+ },
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="alert_subscriptions",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_alertsubscription",
+ "unique_together": {("user", "alert_configuration")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/alerts/backend/migrations/0004_squash_2026_09_07_finalize_fks.py b/products/alerts/backend/migrations/0004_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..7be6d7dfe6fe
--- /dev/null
+++ b/products/alerts/backend/migrations/0004_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,27 @@
+# Generated by Django 5.2.17
+
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("alerts", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="alertconfiguration",
+ name="subscribed_users",
+ field=models.ManyToManyField(
+ related_name="alert_configurations",
+ through="alerts.AlertSubscription",
+ through_fields=("alert_configuration", "user"),
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/alerts/backend/migrations/max_migration.txt b/products/alerts/backend/migrations/max_migration.txt
index 5a717f07553e..bde7efb4f341 100644
--- a/products/alerts/backend/migrations/max_migration.txt
+++ b/products/alerts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0003_alter_alertconfiguration_calculation_interval
+0004_squash_2026_09_07_finalize_fks
diff --git a/products/analytics_platform/backend/migrations/0001_squash_2026_09_07_initial.py b/products/analytics_platform/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..f02226531bea
--- /dev/null
+++ b/products/analytics_platform/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,69 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("analytics_platform", "0001_preaggregation_job")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="PreaggregationJob",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("time_range_start", models.DateTimeField()),
+ ("time_range_end", models.DateTimeField()),
+ ("query_hash", models.CharField(max_length=64)),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "Pending"), ("ready", "Ready"), ("stale", "Stale"), ("failed", "Failed")],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("computed_at", models.DateTimeField(blank=True, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("error", models.TextField(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
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team_id", "query_hash"], name="analytics_p_team_id_f37a89_idx"),
+ models.Index(fields=["team_id", "status"], name="analytics_p_team_id_b17148_idx"),
+ models.Index(
+ fields=["team_id", "time_range_start", "time_range_end"], name="analytics_p_team_id_4e65a5_idx"
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("time_range_start__lt", models.F("time_range_end"))),
+ name="time_range_start_before_end",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/annotations/backend/migrations/0001_squash_2026_09_07_initial.py b/products/annotations/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..67913e01d351
--- /dev/null
+++ b/products/annotations/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,92 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("annotations", "0001_migrate_annotations_models"),
+ ("annotations", "0002_annotation_emoji"),
+ ("annotations", "0003_annotation_hidden_in_user_interface"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0015_dashboard_customization"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Annotation",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("content", models.CharField(blank=True, max_length=8192, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "scope",
+ models.CharField(
+ choices=[
+ ("dashboard_item", "insight"),
+ ("dashboard", "dashboard"),
+ ("project", "project"),
+ ("organization", "organization"),
+ ("recording", "recording"),
+ ],
+ default="dashboard_item",
+ max_length=24,
+ ),
+ ),
+ (
+ "creation_type",
+ models.CharField(choices=[("USR", "user"), ("GIT", "GitHub")], default="USR", max_length=3),
+ ),
+ ("date_marker", models.DateTimeField(blank=True, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("apply_all", models.BooleanField(null=True)),
+ ("recording_id", models.UUIDField(blank=True, null=True)),
+ ("is_emoji", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, 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, to="dashboards.dashboard"
+ ),
+ ),
+ (
+ "dashboard_item",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="product_analytics.insight",
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("emoji", models.CharField(blank=True, max_length=16, null=True)),
+ ("hidden_in_user_interface", models.BooleanField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_annotation",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/annotations/backend/migrations/max_migration.txt b/products/annotations/backend/migrations/max_migration.txt
index a76d998769c7..6903cd5e3dc2 100644
--- a/products/annotations/backend/migrations/max_migration.txt
+++ b/products/annotations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0003_annotation_hidden_in_user_interface
+0001_squash_2026_09_07_initial
diff --git a/products/approvals/backend/migrations/0001_squash_2026_09_07_initial.py b/products/approvals/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..053acc1250d2
--- /dev/null
+++ b/products/approvals/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,202 @@
+# Generated by Django 5.2.17
+
+import datetime
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("approvals", "0001_migrate_approvals_models")]
+
+ initial = True
+
+ dependencies = [
+ ("ee", "0059_scimprovisioneduser_unique_config"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ChangeRequest",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("action_key", models.CharField(max_length=128)),
+ ("action_version", models.IntegerField(default=1)),
+ ("resource_type", models.CharField(max_length=64)),
+ ("resource_id", models.CharField(blank=True, max_length=128, null=True)),
+ ("intent", models.JSONField()),
+ ("intent_display", models.JSONField()),
+ ("policy_snapshot", models.JSONField()),
+ (
+ "validation_status",
+ models.CharField(
+ choices=[
+ ("valid", "Valid"),
+ ("invalid", "Invalid"),
+ ("expired", "Expired"),
+ ("stale", "Stale (resource changed)"),
+ ],
+ default="valid",
+ max_length=16,
+ ),
+ ),
+ ("validation_errors", models.JSONField(blank=True, null=True)),
+ ("validated_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("approved", "Approved (awaiting application)"),
+ ("applied", "Applied"),
+ ("rejected", "Rejected"),
+ ("expired", "Expired"),
+ ("failed", "Failed to apply"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ ("expires_at", models.DateTimeField()),
+ ("applied_at", models.DateTimeField(blank=True, null=True)),
+ ("apply_error", models.TextField(blank=True)),
+ ("result_data", models.JSONField(blank=True, null=True)),
+ (
+ "applied_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="change_requests_applied",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_changerequest",
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(fields=["team", "state"], name="posthog_cha_team_id_0a5974_idx"),
+ models.Index(fields=["action_key", "state"], name="posthog_cha_action__2d384d_idx"),
+ models.Index(fields=["expires_at"], name="posthog_cha_expires_0a6444_idx"),
+ models.Index(fields=["validation_status", "state"], name="posthog_cha_validat_24672f_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ApprovalPolicy",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("action_key", models.CharField(max_length=128)),
+ ("conditions", models.JSONField(default=dict)),
+ ("approver_config", models.JSONField()),
+ ("allow_self_approve", models.BooleanField(default=False)),
+ ("bypass_org_membership_levels", models.JSONField(default=list)),
+ (
+ "expires_after",
+ models.DurationField(
+ default=datetime.timedelta(days=14), help_text="Auto-expire change requests after this duration"
+ ),
+ ),
+ ("enabled", models.BooleanField(default=True)),
+ (
+ "bypass_roles",
+ models.ManyToManyField(
+ blank=True,
+ db_table="posthog_approvalpolicy_bypass_roles",
+ related_name="bypass_policies",
+ to="ee.role",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "verbose_name_plural": "Approval policies",
+ "db_table": "posthog_approvalpolicy",
+ "indexes": [
+ models.Index(fields=["action_key", "enabled"], name="posthog_app_action__871059_idx"),
+ models.Index(fields=["organization", "enabled"], name="posthog_app_organiz_36e124_idx"),
+ models.Index(fields=["team", "enabled"], name="posthog_app_team_id_9f077f_idx"),
+ ],
+ "unique_together": {("organization", "team", "action_key")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Approval",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "decision",
+ models.CharField(choices=[("approved", "Approved"), ("rejected", "Rejected")], max_length=16),
+ ),
+ ("reason", models.TextField(blank=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "change_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="approvals",
+ to="approvals.changerequest",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_approval",
+ "indexes": [models.Index(fields=["change_request", "decision"], name="posthog_app_change__5af5e4_idx")],
+ "constraints": [],
+ "unique_together": {("change_request", "created_by")},
+ },
+ ),
+ ]
diff --git a/products/autoresearch/backend/migrations/0001_squash_2026_09_07_initial.py b/products/autoresearch/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..0a6ab47e54c4
--- /dev/null
+++ b/products/autoresearch/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,733 @@
+# Generated by Django 5.2.17
+
+import django.core.validators
+import django.db.models.manager
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("autoresearch", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="AutoresearchPipeline",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("description", models.TextField(blank=True, default="")),
+ ("target_event", models.CharField(help_text="Event name to predict, e.g. '$pageview'", max_length=255)),
+ (
+ "target_definition",
+ models.JSONField(
+ default=dict, help_text="Full target definition including filters and positive-label logic"
+ ),
+ ),
+ (
+ "horizon_days",
+ models.IntegerField(
+ default=7,
+ help_text="Predict whether the target occurs within N days",
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "training_lookback_days",
+ models.IntegerField(
+ default=180,
+ help_text="How far back to look for training examples. Larger windows give more data but may include stale behavior.",
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "training_population",
+ models.JSONField(default=dict, help_text="HogQL cohort or filter defining the training population"),
+ ),
+ (
+ "inference_population",
+ models.JSONField(
+ default=dict, help_text="HogQL cohort or filter defining the daily scoring population"
+ ),
+ ),
+ (
+ "cadence_days",
+ models.IntegerField(
+ default=1,
+ help_text="Re-score every N days",
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "iteration_budget",
+ models.IntegerField(
+ default=50,
+ help_text="Max training iterations for the autoresearch loop",
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "iteration_budget_remaining",
+ models.IntegerField(
+ blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(0)]
+ ),
+ ),
+ (
+ "success_auc",
+ models.FloatField(
+ blank=True,
+ help_text="Stop when holdout AUC reaches this threshold",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ (
+ "plateau_iterations",
+ models.IntegerField(
+ default=10,
+ help_text="Stop if no improvement after this many consecutive iterations",
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "output_person_property",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Person property name for champion scores, e.g. 'predicted_p_pageview'",
+ max_length=255,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("draft", "Draft"),
+ ("bootstrapping", "Bootstrapping"),
+ ("running", "Running"),
+ ("converged", "Converged"),
+ ("paused", "Paused"),
+ ("archived", "Archived"),
+ ],
+ default="draft",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("last_scored_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("horizon_days__gte", 1)), name="autoresearch_horizon_days_positive"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("training_lookback_days__gte", 1)),
+ name="autoresearch_lookback_days_positive",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("cadence_days__gte", 1)), name="autoresearch_cadence_days_positive"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("iteration_budget__gte", 1)), name="autoresearch_iteration_budget_positive"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("plateau_iterations__gte", 1)),
+ name="autoresearch_plateau_iterations_positive",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("success_auc__isnull", True),
+ models.Q(("success_auc__gte", 0.0), ("success_auc__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_success_auc_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("iteration_budget_remaining__isnull", True),
+ ("iteration_budget_remaining__gte", 0),
+ _connector="OR",
+ ),
+ name="autoresearch_budget_remaining_nonnegative",
+ ),
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="AutoresearchSuggestion",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("prompt", models.TextField(help_text="Free-text hypothesis or direction for the agent to explore")),
+ (
+ "priority",
+ models.CharField(
+ choices=[("try_next", "Try next"), ("consider", "Consider")],
+ default="consider",
+ help_text="'try_next' instructs the agent to act on this before other iterations; 'consider' is advisory",
+ max_length=20,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("queued", "Queued"),
+ ("picked_up", "Picked up"),
+ ("acted_on", "Acted on"),
+ ("dismissed", "Dismissed"),
+ ],
+ default="queued",
+ max_length=20,
+ ),
+ ),
+ (
+ "source",
+ models.CharField(
+ choices=[("user", "User"), ("agent", "Agent")],
+ default="user",
+ help_text="Whether the suggestion came from a human user or an agent",
+ max_length=20,
+ ),
+ ),
+ (
+ "agent_response",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Agent's note on how the suggestion was interpreted and acted upon",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="suggestions",
+ to="autoresearch.autoresearchpipeline",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="AutoresearchTrainingRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "task_id",
+ models.UUIDField(blank=True, help_text="Parent Task ID in the tasks product sandbox", null=True),
+ ),
+ (
+ "task_run_id",
+ models.UUIDField(blank=True, help_text="TaskRun ID in the tasks product sandbox", null=True),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("running", "Running"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ (
+ "iteration_budget",
+ models.IntegerField(default=50, validators=[django.core.validators.MinValueValidator(1)]),
+ ),
+ (
+ "iteration_count",
+ models.IntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)]),
+ ),
+ (
+ "best_holdout_score",
+ models.FloatField(
+ blank=True,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ ("error", models.TextField(blank=True, default="")),
+ ("summary", models.JSONField(blank=True, default=dict)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="training_runs",
+ to="autoresearch.autoresearchpipeline",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("best_holdout_score__isnull", True),
+ models.Q(("best_holdout_score__gte", 0.0), ("best_holdout_score__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_training_run_best_holdout_score_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("iteration_budget__gte", 1)),
+ name="autoresearch_training_run_iteration_budget_positive",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("iteration_count__gte", 0)),
+ name="autoresearch_training_run_iteration_count_nonnegative",
+ ),
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="AutoresearchModel",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "role",
+ models.CharField(
+ choices=[("champion", "Champion"), ("challenger", "Challenger"), ("archived", "Archived")],
+ default="challenger",
+ max_length=20,
+ ),
+ ),
+ ("recipe_hash", models.CharField(help_text="SHA-256 of the serialized recipe JSON", max_length=64)),
+ (
+ "model_recipe",
+ models.JSONField(
+ help_text="Portable recipe: feature_sql, feature_transforms, model_class, model_params, etc."
+ ),
+ ),
+ ("artifact_prefix", models.CharField(blank=True, default="", max_length=500)),
+ (
+ "model_explanation",
+ models.JSONField(
+ default=dict, help_text="Global feature importance, directionality, stability, leakage warnings"
+ ),
+ ),
+ (
+ "holdout_score",
+ models.FloatField(
+ blank=True,
+ help_text="Offline holdout AUC",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ (
+ "realized_score",
+ models.FloatField(
+ blank=True,
+ help_text="Online realized AUC once labels mature",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ ("calibration_error", models.FloatField(blank=True, null=True)),
+ ("metrics", models.JSONField(default=dict, help_text="Full metrics bundle (train/holdout/realized)")),
+ ("agent_description", models.TextField(blank=True, default="")),
+ ("trained_on_start", models.DateField(blank=True, null=True)),
+ ("trained_on_end", models.DateField(blank=True, null=True)),
+ (
+ "is_preliminary",
+ models.BooleanField(
+ default=True, help_text="True until at least one realized validation cycle completes"
+ ),
+ ),
+ ("promoted_at", models.DateTimeField(blank=True, null=True)),
+ ("archived_at", models.DateTimeField(blank=True, null=True)),
+ ("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,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="models",
+ to="autoresearch.autoresearchpipeline",
+ ),
+ ),
+ (
+ "source_training_run",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="candidate_models",
+ to="autoresearch.autoresearchtrainingrun",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("role", "champion")),
+ fields=("pipeline",),
+ name="autoresearch_one_champion_per_pipeline",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("holdout_score__isnull", True),
+ models.Q(("holdout_score__gte", 0.0), ("holdout_score__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_model_holdout_score_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("realized_score__isnull", True),
+ models.Q(("realized_score__gte", 0.0), ("realized_score__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_model_realized_score_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("trained_on_start__isnull", True),
+ ("trained_on_end__isnull", True),
+ ("trained_on_start__lte", models.F("trained_on_end")),
+ _connector="OR",
+ ),
+ name="autoresearch_model_trained_on_range_ordered",
+ ),
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="AutoresearchIteration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("iteration_number", models.IntegerField()),
+ ("recipe_hash", models.CharField(max_length=64)),
+ (
+ "recipe_snapshot",
+ models.JSONField(help_text="Compact recipe at time of iteration; full artifact in model row"),
+ ),
+ (
+ "model_spec",
+ models.JSONField(default=dict, help_text="model_class + hyperparams tried this iteration"),
+ ),
+ (
+ "train_score",
+ models.FloatField(
+ blank=True,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ (
+ "holdout_score",
+ models.FloatField(
+ blank=True,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("kept", "Kept"), ("discarded", "Discarded"), ("crashed", "Crashed")], max_length=20
+ ),
+ ),
+ ("agent_description", models.TextField(blank=True, default="")),
+ (
+ "agent_confidence",
+ models.FloatField(
+ blank=True,
+ help_text="Agent's self-assessed confidence 0–1",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="iterations",
+ to="autoresearch.autoresearchpipeline",
+ ),
+ ),
+ (
+ "parent_suggestion",
+ models.ForeignKey(
+ blank=True,
+ help_text="Suggestion that spawned this iteration, if any",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="iterations",
+ to="autoresearch.autoresearchsuggestion",
+ ),
+ ),
+ (
+ "training_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="iterations",
+ to="autoresearch.autoresearchtrainingrun",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["iteration_number"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("train_score__isnull", True),
+ models.Q(("train_score__gte", 0.0), ("train_score__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_iteration_train_score_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("holdout_score__isnull", True),
+ models.Q(("holdout_score__gte", 0.0), ("holdout_score__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_iteration_holdout_score_in_unit_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("agent_confidence__isnull", True),
+ models.Q(("agent_confidence__gte", 0.0), ("agent_confidence__lte", 1.0)),
+ _connector="OR",
+ ),
+ name="autoresearch_iteration_agent_confidence_in_unit_range",
+ ),
+ ],
+ "unique_together": {("training_run", "iteration_number")},
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="AutoresearchRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "run_type",
+ models.CharField(choices=[("inference", "Inference"), ("validation", "Validation")], max_length=20),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("running", "Running"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ (
+ "rows_scored",
+ models.IntegerField(
+ blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)]
+ ),
+ ),
+ ("metrics", models.JSONField(default=dict)),
+ ("error", models.TextField(blank=True, default="")),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "model",
+ models.ForeignKey(
+ blank=True,
+ help_text="Champion model used for this run",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="runs",
+ to="autoresearch.autoresearchmodel",
+ ),
+ ),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="runs",
+ to="autoresearch.autoresearchpipeline",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("rows_scored__isnull", True), ("rows_scored__gte", 0), _connector="OR"),
+ name="autoresearch_run_rows_scored_nonnegative",
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/autoresearch/backend/migrations/max_migration.txt b/products/autoresearch/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/autoresearch/backend/migrations/max_migration.txt
+++ b/products/autoresearch/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/batch_exports/backend/migrations/0001_squash_2026_09_07_initial.py b/products/batch_exports/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..71e21d553682
--- /dev/null
+++ b/products/batch_exports/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,1106 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("batch_exports", "0001_migrate_batch_exports_models"),
+ ("batch_exports", "0002_batchexport_batchexportbackfill_and_more"),
+ ("batch_exports", "0003_alter_batchexportdestination_type"),
+ ("batch_exports", "0004_migrate_managed_migrations_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="BatchExportDestination",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("S3", "S3"),
+ ("AwsS3", "Aws S3"),
+ ("S3Compatible", "S3 Compatible"),
+ ("Snowflake", "Snowflake"),
+ ("Postgres", "Postgres"),
+ ("Redshift", "Redshift"),
+ ("BigQuery", "Bigquery"),
+ ("Databricks", "Databricks"),
+ ("AzureBlob", "Azure Blob"),
+ ("Workflows", "Workflows"),
+ ("HTTP", "Http"),
+ ("NoOp", "Noop"),
+ ("FileDownload", "File Download"),
+ ],
+ help_text="A choice of supported BatchExportDestination types.",
+ max_length=64,
+ ),
+ ),
+ (
+ "config",
+ posthog.helpers.encrypted_fields.EncryptedJSONField(
+ blank=True,
+ default=dict,
+ help_text="A JSON field to store all configuration parameters required to access a BatchExportDestination.",
+ ),
+ ),
+ (
+ "created_at",
+ models.DateTimeField(
+ auto_now_add=True, help_text="The timestamp at which this BatchExportDestination was created."
+ ),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(
+ auto_now=True, help_text="The timestamp at which this BatchExportDestination was last updated."
+ ),
+ ),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True,
+ help_text="The integration for this destination.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog.integration",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexportdestination",
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="BatchExport",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.TextField(help_text="A human-readable name for this BatchExport.")),
+ (
+ "interval",
+ models.CharField(
+ choices=[
+ ("hour", "hour"),
+ ("day", "day"),
+ ("week", "week"),
+ ("every 5 minutes", "every 5 minutes"),
+ ("every 15 minutes", "every 15 minutes"),
+ ],
+ default="hour",
+ help_text="The interval at which to export data.",
+ max_length=64,
+ ),
+ ),
+ ("paused", models.BooleanField(default=False, help_text="Whether this BatchExport is paused or not.")),
+ (
+ "deleted",
+ models.BooleanField(default=False, help_text="Whether this BatchExport is deleted or not."),
+ ),
+ (
+ "created_at",
+ models.DateTimeField(
+ auto_now_add=True, help_text="The timestamp at which this BatchExport was created."
+ ),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(
+ auto_now=True, help_text="The timestamp at which this BatchExport was last updated."
+ ),
+ ),
+ (
+ "last_paused_at",
+ models.DateTimeField(
+ default=None, help_text="The timestamp at which this BatchExport was last paused.", null=True
+ ),
+ ),
+ (
+ "start_at",
+ models.DateTimeField(
+ default=None, help_text="Time before which any Batch Export runs won't be triggered.", null=True
+ ),
+ ),
+ (
+ "end_at",
+ models.DateTimeField(
+ default=None, help_text="Time after which any Batch Export runs won't be triggered.", null=True
+ ),
+ ),
+ (
+ "schema",
+ models.JSONField(
+ default=None, help_text="A schema of custom fields to select when exporting data.", null=True
+ ),
+ ),
+ (
+ "model",
+ models.CharField(
+ blank=True,
+ choices=[("events", "Events"), ("persons", "Persons"), ("sessions", "Sessions")],
+ default="events",
+ help_text="Which model this BatchExport is exporting.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ ("filters", models.JSONField(blank=True, null=True)),
+ (
+ "timezone",
+ models.CharField(
+ choices=[
+ ("Africa/Abidjan", "Africa/Abidjan"),
+ ("Africa/Accra", "Africa/Accra"),
+ ("Africa/Addis_Ababa", "Africa/Addis_Ababa"),
+ ("Africa/Algiers", "Africa/Algiers"),
+ ("Africa/Asmara", "Africa/Asmara"),
+ ("Africa/Asmera", "Africa/Asmera"),
+ ("Africa/Bamako", "Africa/Bamako"),
+ ("Africa/Bangui", "Africa/Bangui"),
+ ("Africa/Banjul", "Africa/Banjul"),
+ ("Africa/Bissau", "Africa/Bissau"),
+ ("Africa/Blantyre", "Africa/Blantyre"),
+ ("Africa/Brazzaville", "Africa/Brazzaville"),
+ ("Africa/Bujumbura", "Africa/Bujumbura"),
+ ("Africa/Cairo", "Africa/Cairo"),
+ ("Africa/Casablanca", "Africa/Casablanca"),
+ ("Africa/Ceuta", "Africa/Ceuta"),
+ ("Africa/Conakry", "Africa/Conakry"),
+ ("Africa/Dakar", "Africa/Dakar"),
+ ("Africa/Dar_es_Salaam", "Africa/Dar_es_Salaam"),
+ ("Africa/Djibouti", "Africa/Djibouti"),
+ ("Africa/Douala", "Africa/Douala"),
+ ("Africa/El_Aaiun", "Africa/El_Aaiun"),
+ ("Africa/Freetown", "Africa/Freetown"),
+ ("Africa/Gaborone", "Africa/Gaborone"),
+ ("Africa/Harare", "Africa/Harare"),
+ ("Africa/Johannesburg", "Africa/Johannesburg"),
+ ("Africa/Juba", "Africa/Juba"),
+ ("Africa/Kampala", "Africa/Kampala"),
+ ("Africa/Khartoum", "Africa/Khartoum"),
+ ("Africa/Kigali", "Africa/Kigali"),
+ ("Africa/Kinshasa", "Africa/Kinshasa"),
+ ("Africa/Lagos", "Africa/Lagos"),
+ ("Africa/Libreville", "Africa/Libreville"),
+ ("Africa/Lome", "Africa/Lome"),
+ ("Africa/Luanda", "Africa/Luanda"),
+ ("Africa/Lubumbashi", "Africa/Lubumbashi"),
+ ("Africa/Lusaka", "Africa/Lusaka"),
+ ("Africa/Malabo", "Africa/Malabo"),
+ ("Africa/Maputo", "Africa/Maputo"),
+ ("Africa/Maseru", "Africa/Maseru"),
+ ("Africa/Mbabane", "Africa/Mbabane"),
+ ("Africa/Mogadishu", "Africa/Mogadishu"),
+ ("Africa/Monrovia", "Africa/Monrovia"),
+ ("Africa/Nairobi", "Africa/Nairobi"),
+ ("Africa/Ndjamena", "Africa/Ndjamena"),
+ ("Africa/Niamey", "Africa/Niamey"),
+ ("Africa/Nouakchott", "Africa/Nouakchott"),
+ ("Africa/Ouagadougou", "Africa/Ouagadougou"),
+ ("Africa/Porto-Novo", "Africa/Porto-Novo"),
+ ("Africa/Sao_Tome", "Africa/Sao_Tome"),
+ ("Africa/Timbuktu", "Africa/Timbuktu"),
+ ("Africa/Tripoli", "Africa/Tripoli"),
+ ("Africa/Tunis", "Africa/Tunis"),
+ ("Africa/Windhoek", "Africa/Windhoek"),
+ ("America/Adak", "America/Adak"),
+ ("America/Anchorage", "America/Anchorage"),
+ ("America/Anguilla", "America/Anguilla"),
+ ("America/Antigua", "America/Antigua"),
+ ("America/Araguaina", "America/Araguaina"),
+ ("America/Argentina/Buenos_Aires", "America/Argentina/Buenos_Aires"),
+ ("America/Argentina/Catamarca", "America/Argentina/Catamarca"),
+ ("America/Argentina/ComodRivadavia", "America/Argentina/ComodRivadavia"),
+ ("America/Argentina/Cordoba", "America/Argentina/Cordoba"),
+ ("America/Argentina/Jujuy", "America/Argentina/Jujuy"),
+ ("America/Argentina/La_Rioja", "America/Argentina/La_Rioja"),
+ ("America/Argentina/Mendoza", "America/Argentina/Mendoza"),
+ ("America/Argentina/Rio_Gallegos", "America/Argentina/Rio_Gallegos"),
+ ("America/Argentina/Salta", "America/Argentina/Salta"),
+ ("America/Argentina/San_Juan", "America/Argentina/San_Juan"),
+ ("America/Argentina/San_Luis", "America/Argentina/San_Luis"),
+ ("America/Argentina/Tucuman", "America/Argentina/Tucuman"),
+ ("America/Argentina/Ushuaia", "America/Argentina/Ushuaia"),
+ ("America/Aruba", "America/Aruba"),
+ ("America/Asuncion", "America/Asuncion"),
+ ("America/Atikokan", "America/Atikokan"),
+ ("America/Atka", "America/Atka"),
+ ("America/Bahia", "America/Bahia"),
+ ("America/Bahia_Banderas", "America/Bahia_Banderas"),
+ ("America/Barbados", "America/Barbados"),
+ ("America/Belem", "America/Belem"),
+ ("America/Belize", "America/Belize"),
+ ("America/Blanc-Sablon", "America/Blanc-Sablon"),
+ ("America/Boa_Vista", "America/Boa_Vista"),
+ ("America/Bogota", "America/Bogota"),
+ ("America/Boise", "America/Boise"),
+ ("America/Buenos_Aires", "America/Buenos_Aires"),
+ ("America/Cambridge_Bay", "America/Cambridge_Bay"),
+ ("America/Campo_Grande", "America/Campo_Grande"),
+ ("America/Cancun", "America/Cancun"),
+ ("America/Caracas", "America/Caracas"),
+ ("America/Catamarca", "America/Catamarca"),
+ ("America/Cayenne", "America/Cayenne"),
+ ("America/Cayman", "America/Cayman"),
+ ("America/Chicago", "America/Chicago"),
+ ("America/Chihuahua", "America/Chihuahua"),
+ ("America/Ciudad_Juarez", "America/Ciudad_Juarez"),
+ ("America/Coral_Harbour", "America/Coral_Harbour"),
+ ("America/Cordoba", "America/Cordoba"),
+ ("America/Costa_Rica", "America/Costa_Rica"),
+ ("America/Creston", "America/Creston"),
+ ("America/Cuiaba", "America/Cuiaba"),
+ ("America/Curacao", "America/Curacao"),
+ ("America/Danmarkshavn", "America/Danmarkshavn"),
+ ("America/Dawson", "America/Dawson"),
+ ("America/Dawson_Creek", "America/Dawson_Creek"),
+ ("America/Denver", "America/Denver"),
+ ("America/Detroit", "America/Detroit"),
+ ("America/Dominica", "America/Dominica"),
+ ("America/Edmonton", "America/Edmonton"),
+ ("America/Eirunepe", "America/Eirunepe"),
+ ("America/El_Salvador", "America/El_Salvador"),
+ ("America/Ensenada", "America/Ensenada"),
+ ("America/Fort_Nelson", "America/Fort_Nelson"),
+ ("America/Fort_Wayne", "America/Fort_Wayne"),
+ ("America/Fortaleza", "America/Fortaleza"),
+ ("America/Glace_Bay", "America/Glace_Bay"),
+ ("America/Godthab", "America/Godthab"),
+ ("America/Goose_Bay", "America/Goose_Bay"),
+ ("America/Grand_Turk", "America/Grand_Turk"),
+ ("America/Grenada", "America/Grenada"),
+ ("America/Guadeloupe", "America/Guadeloupe"),
+ ("America/Guatemala", "America/Guatemala"),
+ ("America/Guayaquil", "America/Guayaquil"),
+ ("America/Guyana", "America/Guyana"),
+ ("America/Halifax", "America/Halifax"),
+ ("America/Havana", "America/Havana"),
+ ("America/Hermosillo", "America/Hermosillo"),
+ ("America/Indiana/Indianapolis", "America/Indiana/Indianapolis"),
+ ("America/Indiana/Knox", "America/Indiana/Knox"),
+ ("America/Indiana/Marengo", "America/Indiana/Marengo"),
+ ("America/Indiana/Petersburg", "America/Indiana/Petersburg"),
+ ("America/Indiana/Tell_City", "America/Indiana/Tell_City"),
+ ("America/Indiana/Vevay", "America/Indiana/Vevay"),
+ ("America/Indiana/Vincennes", "America/Indiana/Vincennes"),
+ ("America/Indiana/Winamac", "America/Indiana/Winamac"),
+ ("America/Indianapolis", "America/Indianapolis"),
+ ("America/Inuvik", "America/Inuvik"),
+ ("America/Iqaluit", "America/Iqaluit"),
+ ("America/Jamaica", "America/Jamaica"),
+ ("America/Jujuy", "America/Jujuy"),
+ ("America/Juneau", "America/Juneau"),
+ ("America/Kentucky/Louisville", "America/Kentucky/Louisville"),
+ ("America/Kentucky/Monticello", "America/Kentucky/Monticello"),
+ ("America/Knox_IN", "America/Knox_IN"),
+ ("America/Kralendijk", "America/Kralendijk"),
+ ("America/La_Paz", "America/La_Paz"),
+ ("America/Lima", "America/Lima"),
+ ("America/Los_Angeles", "America/Los_Angeles"),
+ ("America/Louisville", "America/Louisville"),
+ ("America/Lower_Princes", "America/Lower_Princes"),
+ ("America/Maceio", "America/Maceio"),
+ ("America/Managua", "America/Managua"),
+ ("America/Manaus", "America/Manaus"),
+ ("America/Marigot", "America/Marigot"),
+ ("America/Martinique", "America/Martinique"),
+ ("America/Matamoros", "America/Matamoros"),
+ ("America/Mazatlan", "America/Mazatlan"),
+ ("America/Mendoza", "America/Mendoza"),
+ ("America/Menominee", "America/Menominee"),
+ ("America/Merida", "America/Merida"),
+ ("America/Metlakatla", "America/Metlakatla"),
+ ("America/Mexico_City", "America/Mexico_City"),
+ ("America/Miquelon", "America/Miquelon"),
+ ("America/Moncton", "America/Moncton"),
+ ("America/Monterrey", "America/Monterrey"),
+ ("America/Montevideo", "America/Montevideo"),
+ ("America/Montreal", "America/Montreal"),
+ ("America/Montserrat", "America/Montserrat"),
+ ("America/Nassau", "America/Nassau"),
+ ("America/New_York", "America/New_York"),
+ ("America/Nipigon", "America/Nipigon"),
+ ("America/Nome", "America/Nome"),
+ ("America/Noronha", "America/Noronha"),
+ ("America/North_Dakota/Beulah", "America/North_Dakota/Beulah"),
+ ("America/North_Dakota/Center", "America/North_Dakota/Center"),
+ ("America/North_Dakota/New_Salem", "America/North_Dakota/New_Salem"),
+ ("America/Nuuk", "America/Nuuk"),
+ ("America/Ojinaga", "America/Ojinaga"),
+ ("America/Panama", "America/Panama"),
+ ("America/Pangnirtung", "America/Pangnirtung"),
+ ("America/Paramaribo", "America/Paramaribo"),
+ ("America/Phoenix", "America/Phoenix"),
+ ("America/Port-au-Prince", "America/Port-au-Prince"),
+ ("America/Port_of_Spain", "America/Port_of_Spain"),
+ ("America/Porto_Acre", "America/Porto_Acre"),
+ ("America/Porto_Velho", "America/Porto_Velho"),
+ ("America/Puerto_Rico", "America/Puerto_Rico"),
+ ("America/Punta_Arenas", "America/Punta_Arenas"),
+ ("America/Rainy_River", "America/Rainy_River"),
+ ("America/Rankin_Inlet", "America/Rankin_Inlet"),
+ ("America/Recife", "America/Recife"),
+ ("America/Regina", "America/Regina"),
+ ("America/Resolute", "America/Resolute"),
+ ("America/Rio_Branco", "America/Rio_Branco"),
+ ("America/Rosario", "America/Rosario"),
+ ("America/Santa_Isabel", "America/Santa_Isabel"),
+ ("America/Santarem", "America/Santarem"),
+ ("America/Santiago", "America/Santiago"),
+ ("America/Santo_Domingo", "America/Santo_Domingo"),
+ ("America/Sao_Paulo", "America/Sao_Paulo"),
+ ("America/Scoresbysund", "America/Scoresbysund"),
+ ("America/Shiprock", "America/Shiprock"),
+ ("America/Sitka", "America/Sitka"),
+ ("America/St_Barthelemy", "America/St_Barthelemy"),
+ ("America/St_Johns", "America/St_Johns"),
+ ("America/St_Kitts", "America/St_Kitts"),
+ ("America/St_Lucia", "America/St_Lucia"),
+ ("America/St_Thomas", "America/St_Thomas"),
+ ("America/St_Vincent", "America/St_Vincent"),
+ ("America/Swift_Current", "America/Swift_Current"),
+ ("America/Tegucigalpa", "America/Tegucigalpa"),
+ ("America/Thule", "America/Thule"),
+ ("America/Thunder_Bay", "America/Thunder_Bay"),
+ ("America/Tijuana", "America/Tijuana"),
+ ("America/Toronto", "America/Toronto"),
+ ("America/Tortola", "America/Tortola"),
+ ("America/Vancouver", "America/Vancouver"),
+ ("America/Virgin", "America/Virgin"),
+ ("America/Whitehorse", "America/Whitehorse"),
+ ("America/Winnipeg", "America/Winnipeg"),
+ ("America/Yakutat", "America/Yakutat"),
+ ("America/Yellowknife", "America/Yellowknife"),
+ ("Antarctica/Casey", "Antarctica/Casey"),
+ ("Antarctica/Davis", "Antarctica/Davis"),
+ ("Antarctica/DumontDUrville", "Antarctica/DumontDUrville"),
+ ("Antarctica/Macquarie", "Antarctica/Macquarie"),
+ ("Antarctica/Mawson", "Antarctica/Mawson"),
+ ("Antarctica/McMurdo", "Antarctica/McMurdo"),
+ ("Antarctica/Palmer", "Antarctica/Palmer"),
+ ("Antarctica/Rothera", "Antarctica/Rothera"),
+ ("Antarctica/South_Pole", "Antarctica/South_Pole"),
+ ("Antarctica/Syowa", "Antarctica/Syowa"),
+ ("Antarctica/Troll", "Antarctica/Troll"),
+ ("Antarctica/Vostok", "Antarctica/Vostok"),
+ ("Arctic/Longyearbyen", "Arctic/Longyearbyen"),
+ ("Asia/Aden", "Asia/Aden"),
+ ("Asia/Almaty", "Asia/Almaty"),
+ ("Asia/Amman", "Asia/Amman"),
+ ("Asia/Anadyr", "Asia/Anadyr"),
+ ("Asia/Aqtau", "Asia/Aqtau"),
+ ("Asia/Aqtobe", "Asia/Aqtobe"),
+ ("Asia/Ashgabat", "Asia/Ashgabat"),
+ ("Asia/Ashkhabad", "Asia/Ashkhabad"),
+ ("Asia/Atyrau", "Asia/Atyrau"),
+ ("Asia/Baghdad", "Asia/Baghdad"),
+ ("Asia/Bahrain", "Asia/Bahrain"),
+ ("Asia/Baku", "Asia/Baku"),
+ ("Asia/Bangkok", "Asia/Bangkok"),
+ ("Asia/Barnaul", "Asia/Barnaul"),
+ ("Asia/Beirut", "Asia/Beirut"),
+ ("Asia/Bishkek", "Asia/Bishkek"),
+ ("Asia/Brunei", "Asia/Brunei"),
+ ("Asia/Calcutta", "Asia/Calcutta"),
+ ("Asia/Chita", "Asia/Chita"),
+ ("Asia/Choibalsan", "Asia/Choibalsan"),
+ ("Asia/Chongqing", "Asia/Chongqing"),
+ ("Asia/Chungking", "Asia/Chungking"),
+ ("Asia/Colombo", "Asia/Colombo"),
+ ("Asia/Dacca", "Asia/Dacca"),
+ ("Asia/Damascus", "Asia/Damascus"),
+ ("Asia/Dhaka", "Asia/Dhaka"),
+ ("Asia/Dili", "Asia/Dili"),
+ ("Asia/Dubai", "Asia/Dubai"),
+ ("Asia/Dushanbe", "Asia/Dushanbe"),
+ ("Asia/Famagusta", "Asia/Famagusta"),
+ ("Asia/Gaza", "Asia/Gaza"),
+ ("Asia/Harbin", "Asia/Harbin"),
+ ("Asia/Hebron", "Asia/Hebron"),
+ ("Asia/Ho_Chi_Minh", "Asia/Ho_Chi_Minh"),
+ ("Asia/Hong_Kong", "Asia/Hong_Kong"),
+ ("Asia/Hovd", "Asia/Hovd"),
+ ("Asia/Irkutsk", "Asia/Irkutsk"),
+ ("Asia/Istanbul", "Asia/Istanbul"),
+ ("Asia/Jakarta", "Asia/Jakarta"),
+ ("Asia/Jayapura", "Asia/Jayapura"),
+ ("Asia/Jerusalem", "Asia/Jerusalem"),
+ ("Asia/Kabul", "Asia/Kabul"),
+ ("Asia/Kamchatka", "Asia/Kamchatka"),
+ ("Asia/Karachi", "Asia/Karachi"),
+ ("Asia/Kashgar", "Asia/Kashgar"),
+ ("Asia/Kathmandu", "Asia/Kathmandu"),
+ ("Asia/Katmandu", "Asia/Katmandu"),
+ ("Asia/Khandyga", "Asia/Khandyga"),
+ ("Asia/Kolkata", "Asia/Kolkata"),
+ ("Asia/Krasnoyarsk", "Asia/Krasnoyarsk"),
+ ("Asia/Kuala_Lumpur", "Asia/Kuala_Lumpur"),
+ ("Asia/Kuching", "Asia/Kuching"),
+ ("Asia/Kuwait", "Asia/Kuwait"),
+ ("Asia/Macao", "Asia/Macao"),
+ ("Asia/Macau", "Asia/Macau"),
+ ("Asia/Magadan", "Asia/Magadan"),
+ ("Asia/Makassar", "Asia/Makassar"),
+ ("Asia/Manila", "Asia/Manila"),
+ ("Asia/Muscat", "Asia/Muscat"),
+ ("Asia/Nicosia", "Asia/Nicosia"),
+ ("Asia/Novokuznetsk", "Asia/Novokuznetsk"),
+ ("Asia/Novosibirsk", "Asia/Novosibirsk"),
+ ("Asia/Omsk", "Asia/Omsk"),
+ ("Asia/Oral", "Asia/Oral"),
+ ("Asia/Phnom_Penh", "Asia/Phnom_Penh"),
+ ("Asia/Pontianak", "Asia/Pontianak"),
+ ("Asia/Pyongyang", "Asia/Pyongyang"),
+ ("Asia/Qatar", "Asia/Qatar"),
+ ("Asia/Qostanay", "Asia/Qostanay"),
+ ("Asia/Qyzylorda", "Asia/Qyzylorda"),
+ ("Asia/Rangoon", "Asia/Rangoon"),
+ ("Asia/Riyadh", "Asia/Riyadh"),
+ ("Asia/Saigon", "Asia/Saigon"),
+ ("Asia/Sakhalin", "Asia/Sakhalin"),
+ ("Asia/Samarkand", "Asia/Samarkand"),
+ ("Asia/Seoul", "Asia/Seoul"),
+ ("Asia/Shanghai", "Asia/Shanghai"),
+ ("Asia/Singapore", "Asia/Singapore"),
+ ("Asia/Srednekolymsk", "Asia/Srednekolymsk"),
+ ("Asia/Taipei", "Asia/Taipei"),
+ ("Asia/Tashkent", "Asia/Tashkent"),
+ ("Asia/Tbilisi", "Asia/Tbilisi"),
+ ("Asia/Tehran", "Asia/Tehran"),
+ ("Asia/Tel_Aviv", "Asia/Tel_Aviv"),
+ ("Asia/Thimbu", "Asia/Thimbu"),
+ ("Asia/Thimphu", "Asia/Thimphu"),
+ ("Asia/Tokyo", "Asia/Tokyo"),
+ ("Asia/Tomsk", "Asia/Tomsk"),
+ ("Asia/Ujung_Pandang", "Asia/Ujung_Pandang"),
+ ("Asia/Ulaanbaatar", "Asia/Ulaanbaatar"),
+ ("Asia/Ulan_Bator", "Asia/Ulan_Bator"),
+ ("Asia/Urumqi", "Asia/Urumqi"),
+ ("Asia/Ust-Nera", "Asia/Ust-Nera"),
+ ("Asia/Vientiane", "Asia/Vientiane"),
+ ("Asia/Vladivostok", "Asia/Vladivostok"),
+ ("Asia/Yakutsk", "Asia/Yakutsk"),
+ ("Asia/Yangon", "Asia/Yangon"),
+ ("Asia/Yekaterinburg", "Asia/Yekaterinburg"),
+ ("Asia/Yerevan", "Asia/Yerevan"),
+ ("Atlantic/Azores", "Atlantic/Azores"),
+ ("Atlantic/Bermuda", "Atlantic/Bermuda"),
+ ("Atlantic/Canary", "Atlantic/Canary"),
+ ("Atlantic/Cape_Verde", "Atlantic/Cape_Verde"),
+ ("Atlantic/Faeroe", "Atlantic/Faeroe"),
+ ("Atlantic/Faroe", "Atlantic/Faroe"),
+ ("Atlantic/Jan_Mayen", "Atlantic/Jan_Mayen"),
+ ("Atlantic/Madeira", "Atlantic/Madeira"),
+ ("Atlantic/Reykjavik", "Atlantic/Reykjavik"),
+ ("Atlantic/South_Georgia", "Atlantic/South_Georgia"),
+ ("Atlantic/St_Helena", "Atlantic/St_Helena"),
+ ("Atlantic/Stanley", "Atlantic/Stanley"),
+ ("Australia/ACT", "Australia/ACT"),
+ ("Australia/Adelaide", "Australia/Adelaide"),
+ ("Australia/Brisbane", "Australia/Brisbane"),
+ ("Australia/Broken_Hill", "Australia/Broken_Hill"),
+ ("Australia/Canberra", "Australia/Canberra"),
+ ("Australia/Currie", "Australia/Currie"),
+ ("Australia/Darwin", "Australia/Darwin"),
+ ("Australia/Eucla", "Australia/Eucla"),
+ ("Australia/Hobart", "Australia/Hobart"),
+ ("Australia/LHI", "Australia/LHI"),
+ ("Australia/Lindeman", "Australia/Lindeman"),
+ ("Australia/Lord_Howe", "Australia/Lord_Howe"),
+ ("Australia/Melbourne", "Australia/Melbourne"),
+ ("Australia/NSW", "Australia/NSW"),
+ ("Australia/North", "Australia/North"),
+ ("Australia/Perth", "Australia/Perth"),
+ ("Australia/Queensland", "Australia/Queensland"),
+ ("Australia/South", "Australia/South"),
+ ("Australia/Sydney", "Australia/Sydney"),
+ ("Australia/Tasmania", "Australia/Tasmania"),
+ ("Australia/Victoria", "Australia/Victoria"),
+ ("Australia/West", "Australia/West"),
+ ("Australia/Yancowinna", "Australia/Yancowinna"),
+ ("Brazil/Acre", "Brazil/Acre"),
+ ("Brazil/DeNoronha", "Brazil/DeNoronha"),
+ ("Brazil/East", "Brazil/East"),
+ ("Brazil/West", "Brazil/West"),
+ ("CET", "CET"),
+ ("CST6CDT", "CST6CDT"),
+ ("Canada/Atlantic", "Canada/Atlantic"),
+ ("Canada/Central", "Canada/Central"),
+ ("Canada/Eastern", "Canada/Eastern"),
+ ("Canada/Mountain", "Canada/Mountain"),
+ ("Canada/Newfoundland", "Canada/Newfoundland"),
+ ("Canada/Pacific", "Canada/Pacific"),
+ ("Canada/Saskatchewan", "Canada/Saskatchewan"),
+ ("Canada/Yukon", "Canada/Yukon"),
+ ("Chile/Continental", "Chile/Continental"),
+ ("Chile/EasterIsland", "Chile/EasterIsland"),
+ ("Cuba", "Cuba"),
+ ("EET", "EET"),
+ ("EST", "EST"),
+ ("EST5EDT", "EST5EDT"),
+ ("Egypt", "Egypt"),
+ ("Eire", "Eire"),
+ ("Etc/GMT", "Etc/GMT"),
+ ("Etc/GMT+0", "Etc/GMT+0"),
+ ("Etc/GMT+1", "Etc/GMT+1"),
+ ("Etc/GMT+10", "Etc/GMT+10"),
+ ("Etc/GMT+11", "Etc/GMT+11"),
+ ("Etc/GMT+12", "Etc/GMT+12"),
+ ("Etc/GMT+2", "Etc/GMT+2"),
+ ("Etc/GMT+3", "Etc/GMT+3"),
+ ("Etc/GMT+4", "Etc/GMT+4"),
+ ("Etc/GMT+5", "Etc/GMT+5"),
+ ("Etc/GMT+6", "Etc/GMT+6"),
+ ("Etc/GMT+7", "Etc/GMT+7"),
+ ("Etc/GMT+8", "Etc/GMT+8"),
+ ("Etc/GMT+9", "Etc/GMT+9"),
+ ("Etc/GMT-0", "Etc/GMT-0"),
+ ("Etc/GMT-1", "Etc/GMT-1"),
+ ("Etc/GMT-10", "Etc/GMT-10"),
+ ("Etc/GMT-11", "Etc/GMT-11"),
+ ("Etc/GMT-12", "Etc/GMT-12"),
+ ("Etc/GMT-13", "Etc/GMT-13"),
+ ("Etc/GMT-14", "Etc/GMT-14"),
+ ("Etc/GMT-2", "Etc/GMT-2"),
+ ("Etc/GMT-3", "Etc/GMT-3"),
+ ("Etc/GMT-4", "Etc/GMT-4"),
+ ("Etc/GMT-5", "Etc/GMT-5"),
+ ("Etc/GMT-6", "Etc/GMT-6"),
+ ("Etc/GMT-7", "Etc/GMT-7"),
+ ("Etc/GMT-8", "Etc/GMT-8"),
+ ("Etc/GMT-9", "Etc/GMT-9"),
+ ("Etc/GMT0", "Etc/GMT0"),
+ ("Etc/Greenwich", "Etc/Greenwich"),
+ ("Etc/UCT", "Etc/UCT"),
+ ("Etc/UTC", "Etc/UTC"),
+ ("Etc/Universal", "Etc/Universal"),
+ ("Etc/Zulu", "Etc/Zulu"),
+ ("Europe/Amsterdam", "Europe/Amsterdam"),
+ ("Europe/Andorra", "Europe/Andorra"),
+ ("Europe/Astrakhan", "Europe/Astrakhan"),
+ ("Europe/Athens", "Europe/Athens"),
+ ("Europe/Belfast", "Europe/Belfast"),
+ ("Europe/Belgrade", "Europe/Belgrade"),
+ ("Europe/Berlin", "Europe/Berlin"),
+ ("Europe/Bratislava", "Europe/Bratislava"),
+ ("Europe/Brussels", "Europe/Brussels"),
+ ("Europe/Bucharest", "Europe/Bucharest"),
+ ("Europe/Budapest", "Europe/Budapest"),
+ ("Europe/Busingen", "Europe/Busingen"),
+ ("Europe/Chisinau", "Europe/Chisinau"),
+ ("Europe/Copenhagen", "Europe/Copenhagen"),
+ ("Europe/Dublin", "Europe/Dublin"),
+ ("Europe/Gibraltar", "Europe/Gibraltar"),
+ ("Europe/Guernsey", "Europe/Guernsey"),
+ ("Europe/Helsinki", "Europe/Helsinki"),
+ ("Europe/Isle_of_Man", "Europe/Isle_of_Man"),
+ ("Europe/Istanbul", "Europe/Istanbul"),
+ ("Europe/Jersey", "Europe/Jersey"),
+ ("Europe/Kaliningrad", "Europe/Kaliningrad"),
+ ("Europe/Kiev", "Europe/Kiev"),
+ ("Europe/Kirov", "Europe/Kirov"),
+ ("Europe/Kyiv", "Europe/Kyiv"),
+ ("Europe/Lisbon", "Europe/Lisbon"),
+ ("Europe/Ljubljana", "Europe/Ljubljana"),
+ ("Europe/London", "Europe/London"),
+ ("Europe/Luxembourg", "Europe/Luxembourg"),
+ ("Europe/Madrid", "Europe/Madrid"),
+ ("Europe/Malta", "Europe/Malta"),
+ ("Europe/Mariehamn", "Europe/Mariehamn"),
+ ("Europe/Minsk", "Europe/Minsk"),
+ ("Europe/Monaco", "Europe/Monaco"),
+ ("Europe/Moscow", "Europe/Moscow"),
+ ("Europe/Nicosia", "Europe/Nicosia"),
+ ("Europe/Oslo", "Europe/Oslo"),
+ ("Europe/Paris", "Europe/Paris"),
+ ("Europe/Podgorica", "Europe/Podgorica"),
+ ("Europe/Prague", "Europe/Prague"),
+ ("Europe/Riga", "Europe/Riga"),
+ ("Europe/Rome", "Europe/Rome"),
+ ("Europe/Samara", "Europe/Samara"),
+ ("Europe/San_Marino", "Europe/San_Marino"),
+ ("Europe/Sarajevo", "Europe/Sarajevo"),
+ ("Europe/Saratov", "Europe/Saratov"),
+ ("Europe/Simferopol", "Europe/Simferopol"),
+ ("Europe/Skopje", "Europe/Skopje"),
+ ("Europe/Sofia", "Europe/Sofia"),
+ ("Europe/Stockholm", "Europe/Stockholm"),
+ ("Europe/Tallinn", "Europe/Tallinn"),
+ ("Europe/Tirane", "Europe/Tirane"),
+ ("Europe/Tiraspol", "Europe/Tiraspol"),
+ ("Europe/Ulyanovsk", "Europe/Ulyanovsk"),
+ ("Europe/Uzhgorod", "Europe/Uzhgorod"),
+ ("Europe/Vaduz", "Europe/Vaduz"),
+ ("Europe/Vatican", "Europe/Vatican"),
+ ("Europe/Vienna", "Europe/Vienna"),
+ ("Europe/Vilnius", "Europe/Vilnius"),
+ ("Europe/Volgograd", "Europe/Volgograd"),
+ ("Europe/Warsaw", "Europe/Warsaw"),
+ ("Europe/Zagreb", "Europe/Zagreb"),
+ ("Europe/Zaporozhye", "Europe/Zaporozhye"),
+ ("Europe/Zurich", "Europe/Zurich"),
+ ("GB", "GB"),
+ ("GB-Eire", "GB-Eire"),
+ ("GMT", "GMT"),
+ ("GMT+0", "GMT+0"),
+ ("GMT-0", "GMT-0"),
+ ("GMT0", "GMT0"),
+ ("Greenwich", "Greenwich"),
+ ("HST", "HST"),
+ ("Hongkong", "Hongkong"),
+ ("Iceland", "Iceland"),
+ ("Indian/Antananarivo", "Indian/Antananarivo"),
+ ("Indian/Chagos", "Indian/Chagos"),
+ ("Indian/Christmas", "Indian/Christmas"),
+ ("Indian/Cocos", "Indian/Cocos"),
+ ("Indian/Comoro", "Indian/Comoro"),
+ ("Indian/Kerguelen", "Indian/Kerguelen"),
+ ("Indian/Mahe", "Indian/Mahe"),
+ ("Indian/Maldives", "Indian/Maldives"),
+ ("Indian/Mauritius", "Indian/Mauritius"),
+ ("Indian/Mayotte", "Indian/Mayotte"),
+ ("Indian/Reunion", "Indian/Reunion"),
+ ("Iran", "Iran"),
+ ("Israel", "Israel"),
+ ("Jamaica", "Jamaica"),
+ ("Japan", "Japan"),
+ ("Kwajalein", "Kwajalein"),
+ ("Libya", "Libya"),
+ ("MET", "MET"),
+ ("MST", "MST"),
+ ("MST7MDT", "MST7MDT"),
+ ("Mexico/BajaNorte", "Mexico/BajaNorte"),
+ ("Mexico/BajaSur", "Mexico/BajaSur"),
+ ("Mexico/General", "Mexico/General"),
+ ("NZ", "NZ"),
+ ("NZ-CHAT", "NZ-CHAT"),
+ ("Navajo", "Navajo"),
+ ("PRC", "PRC"),
+ ("PST8PDT", "PST8PDT"),
+ ("Pacific/Apia", "Pacific/Apia"),
+ ("Pacific/Auckland", "Pacific/Auckland"),
+ ("Pacific/Bougainville", "Pacific/Bougainville"),
+ ("Pacific/Chatham", "Pacific/Chatham"),
+ ("Pacific/Chuuk", "Pacific/Chuuk"),
+ ("Pacific/Easter", "Pacific/Easter"),
+ ("Pacific/Efate", "Pacific/Efate"),
+ ("Pacific/Enderbury", "Pacific/Enderbury"),
+ ("Pacific/Fakaofo", "Pacific/Fakaofo"),
+ ("Pacific/Fiji", "Pacific/Fiji"),
+ ("Pacific/Funafuti", "Pacific/Funafuti"),
+ ("Pacific/Galapagos", "Pacific/Galapagos"),
+ ("Pacific/Gambier", "Pacific/Gambier"),
+ ("Pacific/Guadalcanal", "Pacific/Guadalcanal"),
+ ("Pacific/Guam", "Pacific/Guam"),
+ ("Pacific/Honolulu", "Pacific/Honolulu"),
+ ("Pacific/Johnston", "Pacific/Johnston"),
+ ("Pacific/Kanton", "Pacific/Kanton"),
+ ("Pacific/Kiritimati", "Pacific/Kiritimati"),
+ ("Pacific/Kosrae", "Pacific/Kosrae"),
+ ("Pacific/Kwajalein", "Pacific/Kwajalein"),
+ ("Pacific/Majuro", "Pacific/Majuro"),
+ ("Pacific/Marquesas", "Pacific/Marquesas"),
+ ("Pacific/Midway", "Pacific/Midway"),
+ ("Pacific/Nauru", "Pacific/Nauru"),
+ ("Pacific/Niue", "Pacific/Niue"),
+ ("Pacific/Norfolk", "Pacific/Norfolk"),
+ ("Pacific/Noumea", "Pacific/Noumea"),
+ ("Pacific/Pago_Pago", "Pacific/Pago_Pago"),
+ ("Pacific/Palau", "Pacific/Palau"),
+ ("Pacific/Pitcairn", "Pacific/Pitcairn"),
+ ("Pacific/Pohnpei", "Pacific/Pohnpei"),
+ ("Pacific/Ponape", "Pacific/Ponape"),
+ ("Pacific/Port_Moresby", "Pacific/Port_Moresby"),
+ ("Pacific/Rarotonga", "Pacific/Rarotonga"),
+ ("Pacific/Saipan", "Pacific/Saipan"),
+ ("Pacific/Samoa", "Pacific/Samoa"),
+ ("Pacific/Tahiti", "Pacific/Tahiti"),
+ ("Pacific/Tarawa", "Pacific/Tarawa"),
+ ("Pacific/Tongatapu", "Pacific/Tongatapu"),
+ ("Pacific/Truk", "Pacific/Truk"),
+ ("Pacific/Wake", "Pacific/Wake"),
+ ("Pacific/Wallis", "Pacific/Wallis"),
+ ("Pacific/Yap", "Pacific/Yap"),
+ ("Poland", "Poland"),
+ ("Portugal", "Portugal"),
+ ("ROC", "ROC"),
+ ("ROK", "ROK"),
+ ("Singapore", "Singapore"),
+ ("Turkey", "Turkey"),
+ ("UCT", "UCT"),
+ ("US/Alaska", "US/Alaska"),
+ ("US/Aleutian", "US/Aleutian"),
+ ("US/Arizona", "US/Arizona"),
+ ("US/Central", "US/Central"),
+ ("US/East-Indiana", "US/East-Indiana"),
+ ("US/Eastern", "US/Eastern"),
+ ("US/Hawaii", "US/Hawaii"),
+ ("US/Indiana-Starke", "US/Indiana-Starke"),
+ ("US/Michigan", "US/Michigan"),
+ ("US/Mountain", "US/Mountain"),
+ ("US/Pacific", "US/Pacific"),
+ ("US/Samoa", "US/Samoa"),
+ ("UTC", "UTC"),
+ ("Universal", "Universal"),
+ ("W-SU", "W-SU"),
+ ("WET", "WET"),
+ ("Zulu", "Zulu"),
+ ],
+ default="UTC",
+ max_length=240,
+ ),
+ ),
+ (
+ "interval_offset",
+ models.IntegerField(
+ blank=True,
+ help_text="The offset in seconds from the start of the default interval that this batch export should run at.",
+ null=True,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "destination",
+ models.ForeignKey(
+ help_text="The destination to export data to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexportdestination",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexport",
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="BatchExportOnDemand",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("deleted", models.BooleanField(default=False, help_text="Whether this is deleted or not.")),
+ (
+ "created_at",
+ models.DateTimeField(auto_now_add=True, help_text="The timestamp at which this was created."),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(auto_now=True, help_text="The timestamp at which this was last updated."),
+ ),
+ (
+ "model",
+ models.CharField(
+ blank=True,
+ choices=[("events", "Events"), ("persons", "Persons"), ("sessions", "Sessions")],
+ default="events",
+ help_text="Which model this batch export is exporting.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ ("filters", models.JSONField(blank=True, null=True)),
+ (
+ "destination",
+ models.ForeignKey(
+ help_text="The destination to export data to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexportdestination",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexportondemand",
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="BatchExportBackfill",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("start_at", models.DateTimeField(help_text="The start of the data interval.", null=True)),
+ ("end_at", models.DateTimeField(help_text="The end of the data interval.", null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("Cancelled", "Cancelled"),
+ ("Completed", "Completed"),
+ ("ContinuedAsNew", "Continued As New"),
+ ("Failed", "Failed"),
+ ("FailedRetryable", "Failed Retryable"),
+ ("Terminated", "Terminated"),
+ ("TimedOut", "Timedout"),
+ ("Running", "Running"),
+ ("Starting", "Starting"),
+ ],
+ help_text="The status of this backfill.",
+ max_length=64,
+ ),
+ ),
+ (
+ "created_at",
+ models.DateTimeField(
+ auto_now_add=True, help_text="The timestamp at which this BatchExportBackfill was created."
+ ),
+ ),
+ (
+ "finished_at",
+ models.DateTimeField(
+ help_text="The timestamp at which this BatchExportBackfill finished, successfully or not.",
+ null=True,
+ ),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(
+ auto_now=True, help_text="The timestamp at which this BatchExportBackfill was last updated."
+ ),
+ ),
+ (
+ "total_records_count",
+ models.BigIntegerField(
+ blank=True,
+ help_text="The total number of records to export. Initially estimated, updated with actual count after completion.",
+ null=True,
+ ),
+ ),
+ (
+ "adjusted_start_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="The actual start time after adjustment for earliest available data. May differ from start_at if user requested a date before data exists.",
+ null=True,
+ ),
+ ),
+ (
+ "batch_export",
+ models.ForeignKey(
+ help_text="The BatchExport this backfill belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexport",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexportbackfill",
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="BatchExportRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("Cancelled", "Cancelled"),
+ ("Completed", "Completed"),
+ ("ContinuedAsNew", "Continued As New"),
+ ("Failed", "Failed"),
+ ("FailedRetryable", "Failed Retryable"),
+ ("FailedBilling", "Failed Billing"),
+ ("Terminated", "Terminated"),
+ ("TimedOut", "Timedout"),
+ ("Running", "Running"),
+ ("Starting", "Starting"),
+ ],
+ help_text="The status of this run.",
+ max_length=64,
+ ),
+ ),
+ (
+ "records_completed",
+ models.IntegerField(help_text="The number of records that have been exported.", null=True),
+ ),
+ (
+ "records_failed",
+ models.IntegerField(
+ help_text="The number of records that failed downstream processing (e.g. hog function execution errors).",
+ null=True,
+ ),
+ ),
+ (
+ "latest_error",
+ models.TextField(help_text="The latest error that occurred during this run.", null=True),
+ ),
+ ("data_interval_start", models.DateTimeField(help_text="The start of the data interval.", null=True)),
+ ("data_interval_end", models.DateTimeField(help_text="The end of the data interval.")),
+ ("cursor", models.TextField(help_text="An opaque cursor that may be used to resume.", null=True)),
+ (
+ "created_at",
+ models.DateTimeField(
+ auto_now_add=True, help_text="The timestamp at which this BatchExportRun was created."
+ ),
+ ),
+ (
+ "finished_at",
+ models.DateTimeField(
+ help_text="The timestamp at which this BatchExportRun finished, successfully or not.", null=True
+ ),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(
+ auto_now=True, help_text="The timestamp at which this BatchExportRun was last updated."
+ ),
+ ),
+ (
+ "records_total_count",
+ models.IntegerField(
+ help_text="The total count of records that should be exported in this BatchExportRun.",
+ null=True,
+ ),
+ ),
+ (
+ "bytes_exported",
+ models.BigIntegerField(
+ blank=True,
+ help_text="The number of bytes that have been exported in this BatchExportRun.",
+ null=True,
+ ),
+ ),
+ (
+ "backfill",
+ models.ForeignKey(
+ blank=True,
+ help_text="The backfill this run belongs to.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="runs",
+ related_query_name="run",
+ to="batch_exports.batchexportbackfill",
+ ),
+ ),
+ (
+ "batch_export",
+ models.ForeignKey(
+ help_text="The `BatchExport` this run belongs to.",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexport",
+ ),
+ ),
+ (
+ "batch_export_on_demand",
+ models.ForeignKey(
+ help_text="The `BatchExportOnDemand` this run belongs to.",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexportondemand",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexportrun",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("batch_export__isnull", False), ("batch_export_on_demand__isnull", True)),
+ models.Q(("batch_export__isnull", True), ("batch_export_on_demand__isnull", False)),
+ _connector="OR",
+ ),
+ name="run_has_exactly_one_parent_batch_export_or_batch_export_on_demand",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="BatchExportFileDownload",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("key", models.TextField(help_text="The S3 key containing the file to download.")),
+ ("expires_at", models.DateTimeField(help_text="When will this key expire, if available.", null=True)),
+ (
+ "created_at",
+ models.DateTimeField(auto_now_add=True, help_text="The timestamp at which this was created."),
+ ),
+ (
+ "last_updated_at",
+ models.DateTimeField(auto_now=True, help_text="The timestamp at which this was last updated."),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "batch_export_run",
+ models.ForeignKey(
+ help_text="The batch export run that generated this file downloads.",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="batch_exports.batchexportrun",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_batchexportfiledownload",
+ "indexes": [models.Index(fields=["team", "key"], name="team_key_idx")],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/batch_exports/backend/migrations/0004_migrate_managed_migrations_models.py b/products/batch_exports/backend/migrations/0004_migrate_managed_migrations_models.py
index 6a186f345784..3e964823f31f 100644
--- a/products/batch_exports/backend/migrations/0004_migrate_managed_migrations_models.py
+++ b/products/batch_exports/backend/migrations/0004_migrate_managed_migrations_models.py
@@ -40,7 +40,6 @@ def reverse_content_types(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("batch_exports", "0003_alter_batchexportdestination_type"),
- ("managed_migrations", "0001_migrate_managed_migrations_models"),
]
operations = [
diff --git a/products/billing_alerts/backend/migrations/0001_squash_2026_09_07_initial.py b/products/billing_alerts/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..78ad95de3b2a
--- /dev/null
+++ b/products/billing_alerts/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,328 @@
+# Generated by Django 5.2.17
+
+from decimal import Decimal
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("billing_alerts", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="BillingAlertConfiguration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True,
+ db_column="execution_team_id",
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "updated_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("name", models.CharField(max_length=160)),
+ ("description", models.TextField(blank=True)),
+ ("enabled", models.BooleanField(default=True)),
+ (
+ "metric",
+ models.CharField(
+ choices=[("spend", "Spend"), ("projected_spend", "Projected spend")],
+ default="spend",
+ max_length=20,
+ ),
+ ),
+ ("currency", models.CharField(choices=[("USD", "USD")], default="USD", max_length=3)),
+ ("configuration_revision", models.PositiveIntegerField(default=1)),
+ (
+ "threshold_type",
+ models.CharField(
+ choices=[
+ ("relative_increase", "Relative increase"),
+ ("absolute_value", "Absolute value"),
+ ("absolute_increase", "Absolute increase"),
+ ],
+ default="absolute_value",
+ max_length=32,
+ ),
+ ),
+ ("threshold_percentage", models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
+ ("threshold_value", models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True)),
+ ("minimum_value", models.DecimalField(decimal_places=6, default=Decimal("0"), max_digits=20)),
+ ("baseline_window_days", models.PositiveSmallIntegerField(default=7)),
+ ("evaluation_delay_hours", models.PositiveSmallIntegerField(default=6)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("not_firing", "Not firing"),
+ ("firing", "Firing"),
+ ("errored", "Errored"),
+ ("snoozed", "Snoozed"),
+ ("broken", "Broken"),
+ ],
+ default="not_firing",
+ max_length=20,
+ ),
+ ),
+ ("cooldown_hours", models.PositiveSmallIntegerField(default=24)),
+ ("snoozed_until", models.DateTimeField(blank=True, null=True)),
+ ("next_check_at", models.DateTimeField(blank=True, null=True)),
+ ("pending_evaluation_date", models.DateField(blank=True, null=True)),
+ ("retry_attempt_count", models.PositiveSmallIntegerField(default=0)),
+ ("last_checked_at", models.DateTimeField(blank=True, null=True)),
+ ("last_notified_at", models.DateTimeField(blank=True, null=True)),
+ ("consecutive_failures", models.PositiveIntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ ],
+ options={
+ "db_table": "billing_alerts_configuration",
+ "indexes": [
+ models.Index(fields=["organization", "-created_at"], name="billing_alert_org_created_idx"),
+ models.Index(
+ models.F("enabled"),
+ models.OrderBy(models.F("next_check_at"), nulls_first=True),
+ name="billing_alert_scheduler_idx",
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("baseline_window_days__gte", 1)),
+ name="billing_alert_baseline_window_positive",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("minimum_value__gte", 0)), name="billing_alert_minimum_nonnegative"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("threshold_percentage__gt", 0),
+ ("threshold_percentage__isnull", False),
+ ("threshold_type", "relative_increase"),
+ ),
+ models.Q(
+ ("threshold_type__in", ("absolute_value", "absolute_increase")),
+ ("threshold_value__gte", 0),
+ ("threshold_value__isnull", False),
+ ),
+ _connector="OR",
+ ),
+ name="billing_alert_threshold_configuration_valid",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="BillingAlertEvaluationClaim",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("evaluation_date", models.DateField()),
+ ("configuration_revision", models.PositiveIntegerField()),
+ ("delivery_uuid", models.UUIDField(default=posthog.uuidt.uuid7, editable=False, unique=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("evaluating", "Evaluating"),
+ ("retryable", "Retryable"),
+ ("completed", "Completed"),
+ ("superseded", "Superseded"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("lease_expires_at", models.DateTimeField(blank=True, null=True)),
+ ("next_retry_at", models.DateTimeField(blank=True, null=True)),
+ ("attempt_count", models.PositiveIntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "alert",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="evaluation_claims",
+ to="billing_alerts.billingalertconfiguration",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "billing_alerts_evaluation_claim",
+ "indexes": [models.Index(fields=["status", "next_retry_at"], name="billing_claim_retry_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("alert", "evaluation_date", "configuration_revision"),
+ name="unique_billing_alert_evaluation_claim",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="BillingAlertEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("check", "Check"),
+ ("firing", "Firing"),
+ ("resolved", "Resolved"),
+ ("errored", "Errored"),
+ ("broken_config", "Broken config"),
+ ],
+ default="check",
+ max_length=32,
+ ),
+ ),
+ ("source", models.CharField(choices=[("scheduled", "Scheduled"), ("manual", "Manual")], max_length=16)),
+ ("attempt_number", models.PositiveIntegerField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("period_start", models.DateTimeField(blank=True, null=True)),
+ ("period_end", models.DateTimeField(blank=True, null=True)),
+ (
+ "metric",
+ models.CharField(
+ choices=[("spend", "Spend"), ("projected_spend", "Projected spend")], max_length=20
+ ),
+ ),
+ ("current_value", models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True)),
+ ("baseline_value", models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True)),
+ ("absolute_delta", models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True)),
+ (
+ "relative_delta_percentage",
+ models.DecimalField(blank=True, decimal_places=6, max_digits=28, null=True),
+ ),
+ (
+ "threshold_value_snapshot",
+ models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True),
+ ),
+ (
+ "threshold_percentage_snapshot",
+ models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True),
+ ),
+ ("minimum_value_snapshot", models.DecimalField(blank=True, decimal_places=6, max_digits=20, null=True)),
+ ("threshold_breached", models.BooleanField(default=False)),
+ (
+ "state_before",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("not_firing", "Not firing"),
+ ("firing", "Firing"),
+ ("errored", "Errored"),
+ ("snoozed", "Snoozed"),
+ ("broken", "Broken"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "state_after",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("not_firing", "Not firing"),
+ ("firing", "Firing"),
+ ("errored", "Errored"),
+ ("snoozed", "Snoozed"),
+ ("broken", "Broken"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("notification_sent_at", models.DateTimeField(blank=True, null=True)),
+ ("targets_notified", models.JSONField(default=dict)),
+ ("query_duration_ms", models.PositiveIntegerField(blank=True, null=True)),
+ ("error_code", models.CharField(blank=True, max_length=80, null=True)),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("is_transient_error", models.BooleanField(default=False)),
+ ("reason", models.TextField(blank=True)),
+ ("payload", models.JSONField(default=dict)),
+ (
+ "claim",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="attempts",
+ to="billing_alerts.billingalertevaluationclaim",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "billing_alerts_event",
+ "indexes": [models.Index(fields=["team", "-created_at"], name="billing_event_team_ts_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("claim", "attempt_number"), name="unique_billing_alert_evaluation_attempt"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/billing_alerts/backend/migrations/max_migration.txt b/products/billing_alerts/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/billing_alerts/backend/migrations/max_migration.txt
+++ b/products/billing_alerts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/business_knowledge/backend/migrations/0001_squash_2026_09_07_initial.py b/products/business_knowledge/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..b72db685708a
--- /dev/null
+++ b/products/business_knowledge/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,253 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.search
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("business_knowledge", "0001_initial"),
+ ("business_knowledge", "0002_knowledgedocument_stable_id_max_length"),
+ ("business_knowledge", "0003_knowledgedocument_safety_reason_and_more"),
+ ("business_knowledge", "0004_bk_doc_pending_classify_index"),
+ ("business_knowledge", "0005_bk_doc_tombstoned_index"),
+ ("business_knowledge", "0006_bk_source_refresh_due_index"),
+ ("business_knowledge", "0007_knowledgedocument_classification_attempts"),
+ ("business_knowledge", "0008_knowledgechunk_content_search_vector"),
+ ("business_knowledge", "0009_bk_chunk_content_tsv_index"),
+ ("business_knowledge", "0010_knowledgedocument_embeddings_emitted_at"),
+ ("business_knowledge", "0011_bk_doc_embed_state_index"),
+ ("business_knowledge", "0012_knowledgesource_always_include"),
+ ("business_knowledge", "0013_bk_source_always_include_index"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="KnowledgeSource",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ (
+ "source_type",
+ models.CharField(choices=[("text", "Text"), ("url", "URL"), ("file", "File")], max_length=16),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("processing", "Processing"),
+ ("ready", "Ready"),
+ ("error", "Error"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ ("error_message", models.TextField(blank=True, default="")),
+ ("source_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("last_refresh_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "last_refresh_status",
+ models.CharField(
+ blank=True,
+ choices=[("success", "Success"), ("not_modified", "Not modified"), ("error", "Error")],
+ default="",
+ max_length=16,
+ ),
+ ),
+ ("last_refresh_error", models.TextField(blank=True, default="")),
+ ("last_etag", models.CharField(blank=True, default="", max_length=255)),
+ (
+ "crawl_mode",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("single", "Single page"),
+ ("sitemap", "Sitemap"),
+ ("same_origin", "Same origin crawl"),
+ ("github_repo", "GitHub repository"),
+ ],
+ default="single",
+ max_length=16,
+ ),
+ ),
+ ("crawl_config", models.JSONField(blank=True, default=dict)),
+ ("original_filename", models.CharField(blank=True, default="", max_length=255)),
+ ("file_content_type", models.CharField(blank=True, default="", max_length=128)),
+ ("file_size_bytes", models.PositiveIntegerField(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
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="business_knowledge_sources",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "refresh_interval",
+ models.CharField(
+ choices=[
+ ("manual", "Manual only"),
+ ("1h", "Every hour"),
+ ("6h", "Every 6 hours"),
+ ("24h", "Every day"),
+ ("7d", "Every week"),
+ ],
+ default="manual",
+ max_length=16,
+ ),
+ ),
+ ("always_include", models.BooleanField(default=False)),
+ ],
+ options={
+ "db_table": "posthog_business_knowledge_knowledgesource",
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(fields=["team", "-created_at"], name="bk_source_team_created"),
+ models.Index(fields=["team", "status"], name="bk_source_team_status"),
+ models.Index(fields=["team", "source_type"], name="bk_source_team_type"),
+ models.Index(fields=["refresh_interval", "last_refresh_at"], name="bk_source_refresh_due"),
+ models.Index(
+ condition=models.Q(("always_include", True)), fields=["team"], name="bk_source_always_include"
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="KnowledgeDocument",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("stable_id", models.CharField(max_length=2048)),
+ ("title", models.CharField(blank=True, default="", max_length=512)),
+ ("content", models.TextField()),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("url", models.URLField(blank=True, default="", max_length=2048)),
+ ("etag", models.CharField(blank=True, default="", max_length=255)),
+ ("content_hash", models.CharField(blank=True, default="", max_length=64)),
+ ("tombstoned_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ (
+ "source",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="documents",
+ to="business_knowledge.knowledgesource",
+ ),
+ ),
+ ("safety_reason", models.TextField(blank=True, default="")),
+ (
+ "safety_verdict",
+ models.CharField(
+ choices=[("unknown", "Unknown"), ("safe", "Safe"), ("unsafe", "Unsafe")],
+ default="unknown",
+ max_length=16,
+ ),
+ ),
+ ("classification_attempts", models.PositiveSmallIntegerField(db_default=0, default=0)),
+ ("embeddings_emitted_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_business_knowledge_knowledgedocument",
+ "indexes": [
+ models.Index(fields=["team", "source"], name="bk_doc_team_source"),
+ models.Index(fields=["source"], name="bk_doc_source"),
+ models.Index(
+ condition=models.Q(("safety_verdict", "unknown")),
+ fields=["tombstoned_at"],
+ name="bk_doc_pending_classify",
+ ),
+ models.Index(fields=["tombstoned_at"], name="bk_doc_tombstoned"),
+ models.Index(
+ condition=models.Q(("safety_verdict", "safe")),
+ fields=["embeddings_emitted_at"],
+ name="bk_doc_embed_state",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("source", "stable_id"), name="bk_doc_unique_per_source")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="KnowledgeChunk",
+ fields=[
+ ("id", models.UUIDField(editable=False, primary_key=True, serialize=False)),
+ ("heading_path", models.CharField(blank=True, default="", max_length=1024)),
+ ("ordinal", models.IntegerField()),
+ ("content", models.TextField()),
+ ("char_count", models.PositiveIntegerField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ (
+ "document",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="chunks",
+ to="business_knowledge.knowledgedocument",
+ ),
+ ),
+ (
+ "source",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="chunks",
+ to="business_knowledge.knowledgesource",
+ ),
+ ),
+ ("content_search_vector", django.contrib.postgres.search.SearchVectorField(null=True)),
+ ],
+ options={
+ "db_table": "posthog_business_knowledge_knowledgechunk",
+ "indexes": [
+ models.Index(fields=["team", "source"], name="bk_chunk_team_source"),
+ models.Index(fields=["document", "ordinal"], name="bk_chunk_doc_ordinal"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["content"], name="bk_chunk_content_trgm", opclasses=["gin_trgm_ops"]
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["content_search_vector"], name="bk_chunk_content_tsv"
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("document", "heading_path", "ordinal"), name="bk_chunk_unique_position"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/canvas/backend/migrations/0001_squash_2026_09_07_initial.py b/products/canvas/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..a51be27fae6f
--- /dev/null
+++ b/products/canvas/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,294 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("canvas", "0001_initial"),
+ ("canvas", "0002_source_version_required"),
+ ("canvas", "0003_migrate_desktop_tree"),
+ ("canvas", "0004_build_enqueued_at"),
+ ("canvas", "0005_backfill_build_enqueued_at"),
+ ("canvas", "0006_require_build_enqueued_at"),
+ ("canvas", "0007_soft_delete_home_canvases"),
+ ("canvas", "0008_remove_home_canvas"),
+ ("canvas", "0009_canvassourceversion_capabilities"),
+ ("canvas", "0010_canvassourceversion_draft"),
+ ("canvas", "0011_canvasstate"),
+ ("canvas", "0012_grid_canvas_foundation"),
+ ("canvas", "0013_canvas_kind_store_index"),
+ ("canvas", "0014_canvas_discussion_task_id"),
+ ("canvas", "0015_remove_canvas_discussion_task_id"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Canvas",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("template_id", models.CharField(default="freeform", max_length=64)),
+ ("context", models.TextField(blank=True, default="")),
+ ("generation_task_id", models.UUIDField(blank=True, null=True)),
+ ("pinned_at", models.DateTimeField(blank=True, null=True)),
+ ("legacy_code", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "channel",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="canvases",
+ to="tasks.channel",
+ ),
+ ),
+ (
+ "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"
+ ),
+ ),
+ ("description", models.TextField(blank=True, default="")),
+ ("kind", models.CharField(default="freeform", max_length=16)),
+ ],
+ options={
+ "db_table": "posthog_canvas",
+ "indexes": [
+ models.Index(fields=["channel", "-created_at"], name="canvas_channel_recency"),
+ models.Index(
+ condition=models.Q(("kind", "freeform"), _negated=True),
+ fields=["team", "kind"],
+ name="canvas_kind_store",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CanvasSourceVersion",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("source_hash", models.CharField(max_length=64)),
+ ("source_object_key", models.TextField()),
+ ("source_size", models.PositiveIntegerField()),
+ ("task_id", models.UUIDField(blank=True, null=True)),
+ ("task_run_id", models.UUIDField(blank=True, null=True)),
+ ("prompt", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "canvas",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="source_versions", to="canvas.canvas"
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "parent_version",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="canvas.canvassourceversion",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("capabilities", models.JSONField(blank=True, null=True)),
+ ("draft", models.BooleanField(default=False)),
+ ("component_meta", models.JSONField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_canvas_source_version",
+ "indexes": [models.Index(fields=["canvas", "-created_at"], name="canvas_source_version_recency")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CanvasState",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("scope", models.CharField(max_length=8)),
+ ("key", models.CharField(max_length=200)),
+ ("value", models.JSONField()),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "canvas",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="state_entries", to="canvas.canvas"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_canvas_state",
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("user__isnull", False)),
+ fields=("canvas", "scope", "user", "key"),
+ name="canvas_state_user_key",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("user__isnull", True)),
+ fields=("canvas", "scope", "key"),
+ name="canvas_state_shared_key",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CanvasHomePreference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "canvas",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="+", to="canvas.canvas"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_canvas_home_preference",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "user"), name="canvas_home_one_per_user_team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="CanvasBuild",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("status", models.CharField(default="queued", max_length=16)),
+ ("artifact_object_prefix", models.TextField(blank=True, null=True)),
+ ("integrity", models.CharField(blank=True, max_length=64, null=True)),
+ ("diagnostics", models.JSONField(blank=True, default=list)),
+ ("manifest", models.JSONField(blank=True, null=True)),
+ ("pinned", models.BooleanField(default=False)),
+ ("attempt_count", models.PositiveIntegerField(default=0)),
+ ("lease_expires_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "canvas",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="builds", to="canvas.canvas"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "source_version",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="builds",
+ to="canvas.canvassourceversion",
+ ),
+ ),
+ ("enqueued_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ],
+ options={
+ "db_table": "posthog_canvas_build",
+ "indexes": [
+ models.Index(fields=["canvas", "-created_at"], name="canvas_build_recency"),
+ models.Index(
+ condition=models.Q(("status__in", ["queued", "building"])),
+ fields=["team", "status"],
+ name="canvas_build_active",
+ ),
+ models.Index(
+ condition=models.Q(("artifact_object_prefix__isnull", False), ("pinned", False)),
+ fields=["finished_at"],
+ name="canvas_build_retention",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/canvas/backend/migrations/0017_squash_2026_09_07_finalize_fks.py b/products/canvas/backend/migrations/0017_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..accba9ab279f
--- /dev/null
+++ b/products/canvas/backend/migrations/0017_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,40 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("canvas", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0016_canvas_source_policy"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="canvas",
+ name="current_source_version",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="canvas.canvassourceversion",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="canvas",
+ name="published_build",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="canvas.canvasbuild",
+ ),
+ ),
+ ]
diff --git a/products/canvas/backend/migrations/max_migration.txt b/products/canvas/backend/migrations/max_migration.txt
index c67378cbd8db..6a7a268df071 100644
--- a/products/canvas/backend/migrations/max_migration.txt
+++ b/products/canvas/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0016_canvas_source_policy
+0017_squash_2026_09_07_finalize_fks
diff --git a/products/cdp/backend/migrations/0001_squash_2026_09_07_initial.py b/products/cdp/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..7d45f13aa6d1
--- /dev/null
+++ b/products/cdp/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,331 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.models.utils
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [("cdp", "0001_migrate_cdp_models"), ("cdp", "0002_alter_hogfunction_batch_export")]
+
+ initial = True
+
+ dependencies = [
+ ("actions", "0001_migrate_actions_models"),
+ ("batch_exports", "0004_migrate_managed_migrations_models"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="HogFunctionTemplate",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("template_id", models.CharField(db_index=True, max_length=255)),
+ ("sha", models.CharField(db_index=True, max_length=100)),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, null=True)),
+ ("code", models.TextField()),
+ ("code_language", models.CharField(default="hog", max_length=20)),
+ ("inputs_schema", models.JSONField()),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("type", models.CharField(max_length=50)),
+ ("status", models.CharField(default="alpha", max_length=20)),
+ ("category", models.JSONField(default=list)),
+ ("kind", models.CharField(blank=True, max_length=50, null=True)),
+ ("free", models.BooleanField(default=False)),
+ ("icon_url", models.CharField(blank=True, null=True)),
+ ("filters", models.JSONField(blank=True, null=True)),
+ ("masking", models.JSONField(blank=True, null=True)),
+ ("mapping_templates", models.JSONField(blank=True, null=True)),
+ ("mappings", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "db_table": "posthog_hogfunctiontemplate",
+ "indexes": [
+ models.Index(fields=["template_id", "sha"], name="posthog_hog_templat_55950b_idx"),
+ models.Index(fields=["type", "status"], name="posthog_hog_type_8cac9a_idx"),
+ models.Index(fields=["created_at"], name="posthog_hog_created_6a9df3_idx"),
+ models.Index(fields=["template_id", "created_at"], name="posthog_hog_templat_d1778e_idx"),
+ ],
+ "unique_together": {("template_id", "sha")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Hook",
+ fields=[
+ (
+ "id",
+ models.CharField(
+ default=posthog.models.utils.generate_random_token,
+ max_length=50,
+ primary_key=True,
+ serialize=False,
+ ),
+ ),
+ ("event", models.CharField(db_index=True, max_length=64, verbose_name="Event")),
+ ("resource_id", models.IntegerField(blank=True, null=True)),
+ ("target", models.URLField(max_length=255, verbose_name="Target URL")),
+ ("created", models.DateTimeField(auto_now_add=True)),
+ ("updated", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="rest_hooks", to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="rest_hooks",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_hook",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Plugin",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ (
+ "plugin_type",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("local", "local"),
+ ("custom", "custom"),
+ ("repository", "repository"),
+ ("source", "source"),
+ ("inline", "inline"),
+ ],
+ default=None,
+ max_length=200,
+ null=True,
+ ),
+ ),
+ ("is_global", models.BooleanField(default=False)),
+ ("is_preinstalled", models.BooleanField(default=False)),
+ ("is_stateless", models.BooleanField(blank=True, default=False, null=True)),
+ ("name", models.CharField(blank=True, max_length=200, null=True)),
+ ("description", models.TextField(blank=True, null=True)),
+ ("url", models.CharField(blank=True, max_length=800, null=True, unique=True)),
+ ("icon", models.CharField(blank=True, max_length=800, null=True)),
+ ("config_schema", models.JSONField(blank=True, default=dict)),
+ ("tag", models.CharField(blank=True, max_length=200, null=True)),
+ ("archive", models.BinaryField(blank=True, null=True)),
+ ("latest_tag", models.CharField(blank=True, max_length=800, null=True)),
+ ("latest_tag_checked_at", models.DateTimeField(blank=True, null=True)),
+ ("capabilities", models.JSONField(default=dict)),
+ ("metrics", models.JSONField(blank=True, default=dict, null=True)),
+ ("public_jobs", models.JSONField(blank=True, default=dict, null=True)),
+ ("error", models.JSONField(blank=True, default=None, null=True)),
+ ("from_json", models.BooleanField(default=False)),
+ ("from_web", models.BooleanField(default=False)),
+ ("source", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(blank=True, null=True)),
+ ("log_level", models.IntegerField(blank=True, null=True)),
+ ("has_private_access", models.ManyToManyField(to="posthog.organization")),
+ (
+ "organization",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="plugins",
+ related_query_name="plugin",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_plugin",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HogFunction",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("enabled", models.BooleanField(default=False)),
+ ("type", models.CharField(blank=True, max_length=24, null=True)),
+ ("kind", models.CharField(blank=True, max_length=24, null=True)),
+ ("icon_url", models.TextField(blank=True, null=True)),
+ ("hog", models.TextField()),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("transpiled", models.TextField(blank=True, null=True)),
+ ("inputs_schema", models.JSONField(null=True)),
+ ("inputs", models.JSONField(null=True)),
+ ("encrypted_inputs", posthog.helpers.encrypted_fields.EncryptedJSONStringField(blank=True, null=True)),
+ ("filters", models.JSONField(blank=True, null=True)),
+ ("mappings", models.JSONField(blank=True, null=True)),
+ ("masking", models.JSONField(blank=True, null=True)),
+ ("template_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("execution_order", models.PositiveSmallIntegerField(blank=True, null=True)),
+ (
+ "batch_export",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="batch_exports.batchexport",
+ ),
+ ),
+ (
+ "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")),
+ (
+ "hog_function_template",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="hog_functions",
+ to="cdp.hogfunctiontemplate",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_hogfunction",
+ "indexes": [models.Index(fields=["type", "enabled", "team"], name="posthog_hog_type_6f8967_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PluginConfig",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("enabled", models.BooleanField(default=False)),
+ ("order", models.IntegerField()),
+ ("config", models.JSONField(default=dict)),
+ ("error", models.JSONField(blank=True, default=None, null=True)),
+ ("web_token", models.CharField(default=None, max_length=64, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.CharField(blank=True, max_length=1000, null=True)),
+ ("deleted", models.BooleanField(default=False, null=True)),
+ ("filters", models.JSONField(blank=True, null=True)),
+ (
+ "match_action",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="plugin_configs",
+ to="actions.action",
+ ),
+ ),
+ ("plugin", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="cdp.plugin")),
+ ("team", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_pluginconfig",
+ "indexes": [
+ models.Index(fields=["web_token"], name="posthog_plu_web_tok_ac760a_idx"),
+ models.Index(fields=["enabled"], name="posthog_plu_enabled_f5ed94_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PluginSourceFile",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filename", models.CharField(max_length=200)),
+ ("source", models.TextField(blank=True, null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[("LOCKED", "locked"), ("TRANSPILED", "transpiled"), ("ERROR", "error")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("transpiled", models.TextField(blank=True, null=True)),
+ ("error", models.TextField(blank=True, null=True)),
+ ("updated_at", models.DateTimeField(blank=True, null=True)),
+ ("plugin", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="cdp.plugin")),
+ ],
+ options={
+ "db_table": "posthog_pluginsourcefile",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("plugin_id", "filename"), name="unique_filename_for_plugin")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="PluginAttachment",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("key", models.CharField(max_length=200)),
+ ("content_type", models.CharField(max_length=200)),
+ ("file_name", models.CharField(max_length=200)),
+ ("file_size", models.IntegerField()),
+ ("contents", models.BinaryField()),
+ ("team", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "plugin_config",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="cdp.pluginconfig"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_pluginattachment",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PluginStorage",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("key", models.CharField(max_length=200)),
+ ("value", models.TextField(blank=True, null=True)),
+ (
+ "plugin_config",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="cdp.pluginconfig"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_pluginstorage",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("plugin_config_id", "key"), name="posthog_unique_plugin_storage_key"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/cohorts/backend/migrations/0001_squash_2026_09_07_initial.py b/products/cohorts/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..258084789c7f
--- /dev/null
+++ b/products/cohorts/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,443 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("cohorts", "0001_migrate_cohorts_models"),
+ ("cohorts", "0002_cohort_last_backfill_events_at"),
+ ("cohorts", "0003_cohort_filters_shape_hash"),
+ ("cohorts", "0004_cohort_backfill_tables"),
+ ("cohorts", "0005_cohort_condition_type"),
+ ("cohorts", "0006_cohort_backfill_completion"),
+ ("cohorts", "0007_cohortbackfillrun_cohort_bfr_reconciling_idx"),
+ ("cohorts", "0008_person_property_backfill_foundation"),
+ ("cohorts", "0009_cohort_backfill_per_kind_uniqueness"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Cohort",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.CharField(blank=True, max_length=1000)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "filters",
+ models.JSONField(
+ blank=True,
+ help_text='Filters for the cohort. The `negation` field shown below is specific to\n cohort definitions (the inner sub-filters that build a cohort). Property filters used\n *outside* cohort definitions — e.g. on `team.test_account_filters`, insight filters, or\n feature flag conditions — must use `operator: "in"`/`"not_in"` for cohort exclusion and\n do NOT accept `negation`.\n\n Examples:\n\n # Behavioral filter (performed event)\n {\n "properties": {\n "type": "OR",\n "values": [{\n "type": "OR",\n "values": [{\n "key": "address page viewed",\n "type": "behavioral",\n "value": "performed_event",\n "negation": false,\n "event_type": "events",\n "time_value": "30",\n "time_interval": "day"\n }]\n }]\n }\n }\n\n # Person property filter\n {\n "properties": {\n "type": "OR",\n "values": [{\n "type": "AND",\n "values": [{\n "key": "promoCodes",\n "type": "person",\n "value": ["1234567890"],\n "negation": false,\n "operator": "exact"\n }]\n }]\n }\n }\n\n # Cohort filter (inner — within a cohort definition)\n {\n "properties": {\n "type": "OR",\n "values": [{\n "type": "AND",\n "values": [{\n "key": "id",\n "type": "cohort",\n "value": 8814,\n "negation": false\n }]\n }]\n }\n }',
+ null=True,
+ ),
+ ),
+ ("query", models.JSONField(blank=True, null=True)),
+ ("version", models.IntegerField(blank=True, null=True)),
+ ("pending_version", models.IntegerField(blank=True, null=True)),
+ ("count", models.IntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True)),
+ ("is_calculating", models.BooleanField(default=False)),
+ ("last_calculation", models.DateTimeField(blank=True, null=True)),
+ ("last_calculation_duration_ms", models.IntegerField(blank=True, null=True)),
+ ("errors_calculating", models.IntegerField(default=0)),
+ ("last_error_at", models.DateTimeField(blank=True, null=True)),
+ ("last_backfill_person_properties_at", models.DateTimeField(blank=True, null=True)),
+ ("last_realtime_cohort_calculation_at", models.DateTimeField(blank=True, null=True)),
+ ("is_static", models.BooleanField(default=False)),
+ (
+ "kind",
+ models.CharField(
+ blank=True,
+ choices=[("internal_test_users", "internal_test_users")],
+ help_text="System-defined cohort kind. Null for user-created cohorts.",
+ max_length=50,
+ null=True,
+ ),
+ ),
+ (
+ "cohort_type",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("static", "static"),
+ ("person_property", "person_property"),
+ ("behavioral", "behavioral"),
+ ("realtime", "realtime"),
+ ("analytical", "analytical"),
+ ],
+ help_text="Type of cohort based on filter complexity",
+ max_length=50,
+ null=True,
+ ),
+ ),
+ ("groups", models.JSONField(default=list)),
+ (
+ "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")),
+ ("last_backfill_events_at", models.DateTimeField(blank=True, null=True)),
+ ("filters_shape_hash", models.CharField(blank=True, max_length=64, null=True)),
+ ("behavioral_filters_shape_hash", models.CharField(blank=True, max_length=64, null=True)),
+ (
+ "condition_type",
+ models.JSONField(
+ blank=True,
+ help_text="Flags describing which kinds of conditions the cohort's filters contain: person_properties (property or person_metadata), behavioral, lifecycle (first-seen/regularly/stopped/restarted performing an event), and cohorts (nested cohort references). Null when the cohort has no filters to classify.",
+ null=True,
+ ),
+ ),
+ ("person_filters_shape_hash", models.CharField(blank=True, max_length=64, null=True)),
+ ],
+ options={
+ "db_table": "posthog_cohort",
+ "indexes": [
+ models.Index(fields=["team", "-created_at"], name="cohort_team_created_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["name"], name="cohort_name_trgm_idx", opclasses=["gin_trgm_ops"]
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("kind__isnull", False)),
+ fields=("team", "kind"),
+ name="unique_cohort_kind_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CohortPeople",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("version", models.IntegerField(blank=True, null=True)),
+ (
+ "cohort",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to="cohorts.cohort"
+ ),
+ ),
+ (
+ "person",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, to="posthog.person"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_cohortpeople",
+ "managed": False,
+ "indexes": [models.Index(fields=["cohort_id", "person_id"], name="posthog_coh_cohort__89c25f_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CohortCalculationHistory",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filters", models.JSONField(help_text="Cohort filters/properties at time of calculation")),
+ ("count", models.PositiveIntegerField(blank=True, help_text="Number of people in cohort", null=True)),
+ (
+ "started_at",
+ models.DateTimeField(default=django.utils.timezone.now, help_text="When calculation started"),
+ ),
+ ("finished_at", models.DateTimeField(blank=True, help_text="When calculation finished", null=True)),
+ (
+ "queries",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Array of query information (query, query_id, query_ms, memory_mb, read_rows, written_rows)",
+ null=True,
+ ),
+ ),
+ ("error", models.TextField(blank=True, help_text="Error message if calculation failed", null=True)),
+ (
+ "error_code",
+ models.CharField(
+ blank=True,
+ help_text="Error code for categorizing failures (e.g., 'timeout', 'memory_limit'), used for displaying errors to end-users",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ ("cohort", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="cohorts.cohort")),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_cohortcalculationhistory",
+ "indexes": [
+ models.Index(fields=["team", "cohort"], name="posthog_coh_team_id_0ba00c_idx"),
+ models.Index(fields=["team", "started_at"], name="posthog_coh_team_id_762cc7_idx"),
+ models.Index(fields=["cohort", "-started_at"], name="posthog_coh_cohort__cbac1b_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CohortBackfillRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_by_id", models.BigIntegerField(blank=True, null=True)),
+ (
+ "backfill_kind",
+ models.CharField(
+ choices=[("behavioral", "Behavioral"), ("person_property", "Person property")],
+ default="behavioral",
+ max_length=32,
+ ),
+ ),
+ (
+ "trigger_kind",
+ models.CharField(
+ choices=[
+ ("team_enablement", "Team enablement"),
+ ("cohort_created", "Cohort created"),
+ ("cohort_edited", "Cohort edited"),
+ ("disaster_recovery", "Disaster recovery"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("scope", models.CharField(choices=[("team", "Team"), ("cohort", "Cohort")], max_length=16)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("awaiting_boundary", "Awaiting boundary"),
+ ("blocked", "Blocked"),
+ ("seeding", "Seeding"),
+ ("reconciling", "Reconciling"),
+ ("completed", "Completed"),
+ ("superseded", "Superseded"),
+ ("cancelled", "Cancelled"),
+ ("failed", "Failed"),
+ ],
+ default="awaiting_boundary",
+ max_length=32,
+ ),
+ ),
+ ("timezone", models.CharField(max_length=240)),
+ ("boundary_at", models.DateTimeField(blank=True, null=True)),
+ ("boundary_established_at", models.DateTimeField(blank=True, null=True)),
+ ("pinned", models.JSONField(default=dict)),
+ ("preconditions", models.JSONField(default=dict)),
+ ("reconcile_hwms", models.JSONField(blank=True, null=True)),
+ ("blocked_reason", models.TextField(blank=True, default="")),
+ ("error", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "cohort",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="backfill_runs",
+ to="cohorts.cohort",
+ ),
+ ),
+ (
+ "superseded_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="superseded_runs",
+ to="cohorts.cohortbackfillrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("chunks_planned_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "marker_watch",
+ models.JSONField(
+ blank=True,
+ help_text='Opaque watcher resume state written by the Rust seeder, shape {"schema":1,"positions":{...},"ends":{...}|null}. Django never interprets it.',
+ null=True,
+ ),
+ ),
+ ("reconcile_dispatched_at", models.DateTimeField(blank=True, null=True)),
+ ("reconcile_observed_at", models.DateTimeField(blank=True, null=True)),
+ ("person_scan_since", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "cohort_backfill_runs",
+ "indexes": [
+ models.Index(fields=["team", "status"], name="cohort_bfr_team_status_idx"),
+ models.Index(fields=["team", "-created_at"], name="cohort_bfr_team_created_idx"),
+ models.Index(
+ condition=models.Q(("status", "reconciling")),
+ fields=["backfill_kind", "reconcile_observed_at"],
+ name="cohort_bfr_reconciling_idx",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(
+ ("cohort__isnull", False),
+ ("status__in", ("awaiting_boundary", "blocked", "seeding", "reconciling")),
+ ),
+ fields=("cohort", "backfill_kind"),
+ name="cohort_bfr_active_cohort_kind_uq",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(
+ ("scope", "team"),
+ ("status__in", ("awaiting_boundary", "blocked", "seeding", "reconciling")),
+ ),
+ fields=("team", "backfill_kind"),
+ name="cohort_bfr_active_team_kind_uq",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CohortBackfillChunk",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("day", models.DateField()),
+ ("band", models.SmallIntegerField(default=0)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("scanning", "Scanning"),
+ ("produced", "Produced"),
+ ("confirmed", "Confirmed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ ("claim_epoch", models.IntegerField(default=0)),
+ ("claimed_by", models.CharField(blank=True, default="", max_length=255)),
+ ("claimed_at", models.DateTimeField(blank=True, null=True)),
+ ("lease_expires_at", models.DateTimeField(blank=True, null=True)),
+ ("s_chunk_at", models.DateTimeField(blank=True, null=True)),
+ ("attempts", models.IntegerField(default=0)),
+ ("last_error", models.TextField(blank=True, default="")),
+ ("tiles_produced", models.BigIntegerField(default=0)),
+ ("produce_hwms", models.JSONField(blank=True, null=True)),
+ ("confirmed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="chunks",
+ to="cohorts.cohortbackfillrun",
+ ),
+ ),
+ ("person_range_hi", models.UUIDField(blank=True, null=True)),
+ ("person_range_lo", models.UUIDField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "cohort_backfill_chunks",
+ "indexes": [models.Index(fields=["run", "status", "day"], name="cohort_bfc_run_status_day_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("run", "day", "band"), name="cohort_bfc_run_day_band_uq")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CohortBackfillRunCohort",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filters_shape_hash", models.CharField(max_length=64)),
+ ("behavioral_filters_shape_hash", models.CharField(default="", max_length=64)),
+ ("pinned_filters", models.JSONField()),
+ ("stamped_at", models.DateTimeField(blank=True, null=True)),
+ ("superseded_at", models.DateTimeField(blank=True, null=True)),
+ ("error", models.TextField(blank=True, default="")),
+ (
+ "cohort",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="backfill_participations",
+ to="cohorts.cohort",
+ ),
+ ),
+ (
+ "run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="run_cohorts",
+ to="cohorts.cohortbackfillrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("reconcile_completed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "reconcile_marker_bits",
+ models.BigIntegerField(
+ db_default=0,
+ default=0,
+ help_text="Bitmap of seed partitions whose reconcile_complete marker was observed, maintained as an i64 by the Rust seeder (bits |= 1 << partition; all 64 partitions full is -1). Django never interprets the bits.",
+ ),
+ ),
+ ("person_filters_shape_hash", models.CharField(default="", max_length=64)),
+ ],
+ options={
+ "db_table": "cohort_backfill_run_cohorts",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("run", "cohort"), name="cohort_bfrc_run_cohort_uq")],
+ },
+ ),
+ ]
diff --git a/products/cohorts/backend/migrations/0013_squash_2026_09_07_finalize_fks.py b/products/cohorts/backend/migrations/0013_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..998feb7e1417
--- /dev/null
+++ b/products/cohorts/backend/migrations/0013_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,22 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("cohorts", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0012_cohortbackfillchunk_next_attempt_at_and_more"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="cohort",
+ name="people",
+ field=models.ManyToManyField(through="cohorts.CohortPeople", to="posthog.person"),
+ ),
+ ]
diff --git a/products/cohorts/backend/migrations/max_migration.txt b/products/cohorts/backend/migrations/max_migration.txt
index 312ff35f23b9..7346a6beab69 100644
--- a/products/cohorts/backend/migrations/max_migration.txt
+++ b/products/cohorts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0012_cohortbackfillchunk_next_attempt_at_and_more
+0013_squash_2026_09_07_finalize_fks
diff --git a/products/context_layer/backend/migrations/0001_squash_2026_09_07_initial.py b/products/context_layer/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..cf18a84ed747
--- /dev/null
+++ b/products/context_layer/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,57 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("context_layer", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ContextLayerConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("head_sha", models.CharField(max_length=64)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "context_layer_config",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/conversations/backend/migrations/0001_squash_2026_09_07_initial.py b/products/conversations/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..e8e7a43339f4
--- /dev/null
+++ b/products/conversations/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,888 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("conversations", "0001_initial"),
+ ("conversations", "0002_ticket_ticket_number"),
+ ("conversations", "0003_ticket_number_index"),
+ ("conversations", "0004_backfill_ticket_numbers"),
+ ("conversations", "0005_ticket_number_not_null"),
+ ("conversations", "0006_ticket_number_unique_constraint"),
+ ("conversations", "0007_validate_ticket_number_constraint"),
+ ("conversations", "0008_ticket_session_context_ticket_session_id_and_more"),
+ ("conversations", "0009_ticket_dashboard_indexes"),
+ ("conversations", "0010_ticket_status_updated_index"),
+ ("conversations", "0011_ticket_message_stats_fields"),
+ ("conversations", "0012_backfill_ticket_message_stats"),
+ ("conversations", "0013_ticket_assignment"),
+ ("conversations", "0014_remove_ticket_assigned_to"),
+ ("conversations", "0015_conversation_restore_token"),
+ ("conversations", "0016_ticket_slack_fields"),
+ ("conversations", "0017_ticket_slack_thread_idx"),
+ ("conversations", "0018_team_conversations_slack_config"),
+ ("conversations", "0019_slack_config_slack_team_id"),
+ ("conversations", "0020_backfill_slack_config_slack_team_id"),
+ ("conversations", "0021_slack_config_slack_team_id_index"),
+ ("conversations", "0022_ticket_sla_due_at"),
+ ("conversations", "0023_ticket_sla_due_at_index"),
+ ("conversations", "0024_ticket_channel_detail"),
+ ("conversations", "0025_email_channel"),
+ ("conversations", "0026_email_config_unique_domain"),
+ ("conversations", "0027_slack_config_unique_slack_team_id"),
+ ("conversations", "0028_multi_email_channel"),
+ ("conversations", "0029_ticket_email_config_index"),
+ ("conversations", "0030_ticketview"),
+ ("conversations", "0031_ticket_cc_participants"),
+ ("conversations", "0032_ticket_snoozed_until"),
+ ("conversations", "0033_ticket_snoozed_until_idx"),
+ ("conversations", "0034_teams_integration"),
+ ("conversations", "0035_ticket_teams_thread_idx"),
+ ("conversations", "0036_github_issues_channel"),
+ ("conversations", "0037_emailoutboxmessage"),
+ ("conversations", "0038_teamconversationsteamsconfig_teams_service_url_and_more"),
+ ("conversations", "0039_ticket_teams_thread_replies_synced_at"),
+ ("conversations", "0040_ticket_ai_triage"),
+ ("conversations", "0041_ticket_organization_id"),
+ ("conversations", "0042_ticket_identity_verified"),
+ ("conversations", "0043_backfill_identity_verified"),
+ ("conversations", "0044_zendesk_import"),
+ ("conversations", "0045_zendesk_ticket_uniq"),
+ ("conversations", "0046_ticket_org_id_indexes"),
+ ("conversations", "0047_emailchannel_is_default"),
+ ("conversations", "0048_backfill_default_email_channel"),
+ ("conversations", "0049_email_channel_default_constraint"),
+ ("conversations", "0050_alter_ticket_priority"),
+ ("conversations", "0051_ticketviewfavorite"),
+ ("conversations", "0052_ticket_organization_id_source"),
+ ("conversations", "0053_ticket_sla_snooze_desc_indexes"),
+ ("conversations", "0054_ticket_sla_snooze_asc_indexes"),
+ ("conversations", "0055_signingsecret"),
+ ("conversations", "0056_backfill_signing_secret"),
+ ("conversations", "0057_email_channel_kind_and_owner"),
+ ("conversations", "0058_add_email_channel_kind_constraint"),
+ ("conversations", "0059_validate_email_channel_kind_constraint"),
+ ("conversations", "0060_emailthread_emailthreadmessage_and_more"),
+ ("conversations", "0061_emailchannelsetup_emailchannel_connection_status_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("ee", "0059_scimprovisioneduser_unique_config"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="EmailChannel",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="email_channels", to="posthog.team"
+ ),
+ ),
+ ("inbound_token", models.CharField(db_index=True, max_length=64, unique=True)),
+ ("from_email", models.EmailField(max_length=254)),
+ ("from_name", models.CharField(max_length=255)),
+ ("domain", models.CharField(max_length=255)),
+ ("domain_verified", models.BooleanField(default=False)),
+ ("dns_records", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("is_default", models.BooleanField(default=False)),
+ (
+ "kind",
+ models.CharField(
+ choices=[("support", "Support"), ("customer_communication", "Customer communication")],
+ db_default="support",
+ default="support",
+ max_length=32,
+ ),
+ ),
+ (
+ "owner",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="owned_conversations_email_channels",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "connection_status",
+ models.CharField(
+ choices=[
+ ("pending_confirmation", "Pending confirmation"),
+ ("active", "Active"),
+ ("confirmation_expired", "Confirmation expired"),
+ ],
+ db_default="active",
+ default="active",
+ max_length=32,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_channel",
+ "constraints": [
+ models.UniqueConstraint(fields=("from_email",), name="unique_email_channel_from_email"),
+ models.UniqueConstraint(
+ condition=models.Q(("is_default", True)),
+ fields=("team",),
+ name="unique_default_email_channel_per_team",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("kind", "support"), ("is_default", False), _connector="OR"),
+ name="email_channel_customer_not_default",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("kind", "support"), ("owner__isnull", True)),
+ models.Q(("kind", "customer_communication"), ("owner__isnull", False)),
+ _connector="OR",
+ ),
+ name="email_channel_kind_owner",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ConversationRestoreToken",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("token_hash", models.CharField(db_index=True, max_length=64, unique=True)),
+ ("recipient_email", models.EmailField(max_length=254)),
+ ("expires_at", models.DateTimeField()),
+ ("consumed_at", models.DateTimeField(blank=True, null=True)),
+ ("consumed_by_widget_session_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="conversation_restore_tokens",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_restore_token",
+ "indexes": [
+ models.Index(fields=["team", "recipient_email"], name="posthog_crt_team_email_idx"),
+ models.Index(fields=["expires_at"], name="posthog_crt_expires_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamConversationsSlackConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "slack_bot_token",
+ posthog.helpers.encrypted_fields.EncryptedTextField(blank=True, max_length=500, null=True),
+ ),
+ ("slack_team_id", models.CharField(blank=True, max_length=64, null=True)),
+ ],
+ options={
+ "db_table": "posthog_conversations_slack_config",
+ "indexes": [models.Index(fields=["slack_team_id"], name="conv_slack_cfg_team_id_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("slack_team_id__isnull", False)),
+ fields=("slack_team_id",),
+ name="unique_slack_team_id",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TicketView",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(max_length=400)),
+ ("filters", models.JSONField(default=dict)),
+ (
+ "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={
+ "db_table": "posthog_conversations_tickets_views",
+ "indexes": [models.Index(fields=["team_id", "-created_at"], name="conv_ticket_view_team_idx")],
+ "unique_together": {("team", "short_id")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamConversationsTeamsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("teams_tenant_id", models.CharField(blank=True, max_length=64, null=True)),
+ (
+ "teams_graph_access_token",
+ posthog.helpers.encrypted_fields.EncryptedTextField(blank=True, max_length=4000, null=True),
+ ),
+ (
+ "teams_graph_refresh_token",
+ posthog.helpers.encrypted_fields.EncryptedTextField(blank=True, max_length=4000, null=True),
+ ),
+ ("teams_token_expires_at", models.DateTimeField(blank=True, null=True)),
+ ("teams_service_url", models.CharField(blank=True, max_length=512, null=True)),
+ ],
+ options={
+ "db_table": "posthog_conversations_teams_config",
+ "indexes": [models.Index(fields=["teams_tenant_id"], name="conv_teams_cfg_tenant_id_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("teams_tenant_id__isnull", False)),
+ fields=("teams_tenant_id",),
+ name="unique_teams_tenant_id",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamConversationsTeamsChannelSync",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("teams_team_id", models.CharField(max_length=255)),
+ ("channel_id", models.CharField(max_length=255)),
+ ("delta_link", models.TextField(blank=True, null=True)),
+ ("primed", models.BooleanField(default=False)),
+ ("last_polled_at", models.DateTimeField(blank=True, null=True)),
+ ("last_message_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_conversations_teams_channel_sync",
+ "indexes": [models.Index(fields=["team"], name="conv_teams_chan_sync_team_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "channel_id"), name="unique_teams_channel_sync_per_team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ZendeskImportJob",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("running", "Running"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=32,
+ ),
+ ),
+ ("total_tickets", models.BigIntegerField(default=0)),
+ ("processed_tickets", models.BigIntegerField(default=0)),
+ ("imported_tickets", models.BigIntegerField(default=0)),
+ ("skipped_tickets", models.BigIntegerField(default=0)),
+ ("failed_tickets", models.BigIntegerField(default=0)),
+ ("export_cursor", models.TextField(blank=True, null=True)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("workflow_run_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("latest_error", models.TextField(blank=True, null=True)),
+ ("job_inputs", posthog.helpers.encrypted_fields.EncryptedJSONField(blank=True, null=True)),
+ ("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"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_zendesk_import_job",
+ "indexes": [
+ models.Index(fields=["team", "-created_at"], name="posthog_con_zd_import_team_idx"),
+ models.Index(fields=["team", "status"], name="posthog_con_zd_import_stat_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SigningSecret",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("secret", posthog.helpers.encrypted_fields.EncryptedTextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="conversations_signing_secret",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_signing_secret",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailThread",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("canonical_thread_key", models.CharField(max_length=998)),
+ ("subject", models.TextField(blank=True, default="")),
+ ("first_message_at", models.DateTimeField(blank=True, null=True)),
+ ("last_message_at", models.DateTimeField(blank=True, null=True)),
+ ("message_count", models.PositiveIntegerField(default=0)),
+ ("preview", models.CharField(blank=True, default="", max_length=500)),
+ ("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"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_thread",
+ "indexes": [models.Index(fields=["team", "-last_message_at"], name="email_thread_team_last_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "canonical_thread_key"), name="unique_email_thread_key_per_team"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Ticket",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "channel_source",
+ models.CharField(
+ choices=[
+ ("widget", "Widget"),
+ ("email", "Email"),
+ ("slack", "Slack"),
+ ("teams", "Microsoft Teams"),
+ ("github", "GitHub"),
+ ],
+ default="widget",
+ max_length=20,
+ ),
+ ),
+ ("widget_session_id", models.CharField(db_index=True, max_length=64)),
+ ("distinct_id", models.CharField(max_length=400)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("new", "New"),
+ ("open", "Open"),
+ ("pending", "Pending"),
+ ("on_hold", "On hold"),
+ ("resolved", "Resolved"),
+ ],
+ default="new",
+ max_length=20,
+ ),
+ ),
+ (
+ "priority",
+ models.CharField(
+ blank=True,
+ choices=[("low", "Low"), ("medium", "Medium"), ("high", "High"), ("critical", "Critical")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("anonymous_traits", models.JSONField(blank=True, default=dict)),
+ ("ai_resolved", models.BooleanField(default=False)),
+ ("escalation_reason", models.TextField(blank=True, null=True)),
+ ("unread_customer_count", models.IntegerField(default=0)),
+ ("unread_team_count", models.IntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("ticket_number", models.PositiveIntegerField()),
+ ("session_context", models.JSONField(blank=True, default=dict)),
+ ("session_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("message_count", models.IntegerField(default=0)),
+ ("last_message_at", models.DateTimeField(blank=True, null=True)),
+ ("last_message_text", models.CharField(blank=True, max_length=500, null=True)),
+ ("slack_channel_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("slack_thread_ts", models.CharField(blank=True, max_length=64, null=True)),
+ ("slack_team_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("sla_due_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "channel_detail",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("slack_channel_message", "Channel message"),
+ ("slack_bot_mention", "Bot mention"),
+ ("slack_emoji_reaction", "Emoji reaction"),
+ ("teams_channel_message", "Teams channel message"),
+ ("teams_bot_mention", "Teams bot mention"),
+ ("widget_embedded", "Widget"),
+ ("widget_api", "API"),
+ ("github_issue", "GitHub issue"),
+ ],
+ max_length=30,
+ null=True,
+ ),
+ ),
+ ("email_subject", models.CharField(blank=True, max_length=500, null=True)),
+ ("email_from", models.EmailField(blank=True, max_length=254, null=True)),
+ (
+ "email_config",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="tickets",
+ to="conversations.emailchannel",
+ ),
+ ),
+ ("cc_participants", models.JSONField(blank=True, default=list)),
+ ("snoozed_until", models.DateTimeField(blank=True, null=True)),
+ ("teams_channel_id", models.CharField(blank=True, max_length=128, null=True)),
+ ("teams_conversation_id", models.CharField(blank=True, max_length=256, null=True)),
+ ("teams_service_url", models.URLField(blank=True, max_length=512, null=True)),
+ ("teams_tenant_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("github_issue_number", models.PositiveIntegerField(blank=True, null=True)),
+ ("github_repo", models.CharField(blank=True, max_length=256, null=True)),
+ ("teams_thread_replies_synced_at", models.DateTimeField(blank=True, null=True)),
+ ("ai_triage", models.JSONField(blank=True, default=dict)),
+ ("organization_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("identity_verified", models.BooleanField(null=True)),
+ ("zendesk_ticket_id", models.BigIntegerField(blank=True, null=True)),
+ ("organization_id_source", models.CharField(blank=True, max_length=32, null=True)),
+ ],
+ options={
+ "db_table": "posthog_conversations_ticket",
+ "indexes": [
+ models.Index(fields=["team", "widget_session_id"], name="posthog_con_team_id_cf3e51_idx"),
+ models.Index(fields=["team", "distinct_id"], name="posthog_con_team_id_943139_idx"),
+ models.Index(fields=["team", "status"], name="posthog_con_team_id_a21425_idx"),
+ models.Index(fields=["team", "-ticket_number"], name="posthog_con_team_id_ticket_idx"),
+ models.Index(fields=["team", "session_id"], name="posthog_con_team_id_1d12a2_idx"),
+ models.Index(fields=["team", "-updated_at"], name="posthog_con_team_updated_idx"),
+ models.Index(fields=["team", "status", "-updated_at"], name="posthog_con_status_upd_idx"),
+ models.Index(
+ fields=["team", "slack_channel_id", "slack_thread_ts"], name="posthog_con_slack_thread_idx"
+ ),
+ models.Index(
+ condition=models.Q(("snoozed_until__isnull", False)),
+ fields=["snoozed_until"],
+ name="posthog_con_snooze_wake_idx",
+ ),
+ models.Index(
+ fields=["team", "teams_channel_id", "teams_conversation_id"],
+ name="posthog_con_teams_thread_idx",
+ ),
+ models.Index(fields=["organization_id"], name="posthog_org_id_idx"),
+ models.Index(
+ condition=models.Q(("channel_source", "slack")),
+ fields=["organization_id", "slack_channel_id"],
+ name="posthog_org_slack_ch_idx",
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.OrderBy(models.F("sla_due_at"), descending=True, nulls_last=True),
+ models.OrderBy(models.F("ticket_number"), descending=True),
+ name="posthog_con_sla_desc_idx",
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.OrderBy(models.F("snoozed_until"), descending=True, nulls_last=True),
+ models.OrderBy(models.F("ticket_number"), descending=True),
+ name="posthog_con_snooze_desc_idx",
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.OrderBy(models.F("sla_due_at"), nulls_last=True),
+ models.OrderBy(models.F("ticket_number"), descending=True),
+ name="posthog_con_sla_asc_idx",
+ ),
+ models.Index(
+ models.F("team_id"),
+ models.OrderBy(models.F("snoozed_until"), nulls_last=True),
+ models.OrderBy(models.F("ticket_number"), descending=True),
+ name="posthog_con_snooze_asc_idx",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "ticket_number"), name="unique_ticket_number_per_team"),
+ models.UniqueConstraint(
+ condition=models.Q(("github_issue_number__isnull", False), ("github_repo__isnull", False)),
+ fields=("team", "github_repo", "github_issue_number"),
+ name="posthog_con_github_issue_uniq",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("zendesk_ticket_id__isnull", False)),
+ fields=("team", "zendesk_ticket_id"),
+ name="posthog_con_zendesk_ticket_uniq",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailChannelSetup",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("provider", models.CharField(choices=[("google", "Google")], max_length=32)),
+ ("expires_at", models.DateTimeField()),
+ ("confirmation_action", posthog.helpers.encrypted_fields.EncryptedTextField(blank=True, null=True)),
+ ("confirmation_message_id_hash", models.CharField(blank=True, default="", max_length=64)),
+ ("confirmation_received_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "channel",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="setup",
+ to="conversations.emailchannel",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_channel_setup",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TicketViewFavorite",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "ticket_view",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="favorites",
+ to="conversations.ticketview",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_ticket_view_favorites",
+ "unique_together": {("ticket_view", "user")},
+ "indexes": [models.Index(fields=["team_id", "user"], name="conv_ticket_view_fav_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailThreadMessage",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("message_id", models.CharField(blank=True, max_length=998, null=True)),
+ ("in_reply_to", models.CharField(blank=True, max_length=998, null=True)),
+ ("references", models.JSONField(blank=True, default=list)),
+ ("sent_at", models.DateTimeField()),
+ ("sender_email", models.CharField(max_length=400)),
+ ("sender_name", models.CharField(blank=True, default="", max_length=400)),
+ ("to_recipients", models.JSONField(blank=True, default=list)),
+ ("cc_recipients", models.JSONField(blank=True, default=list)),
+ (
+ "direction",
+ models.CharField(choices=[("inbound", "Inbound"), ("outbound", "Outbound")], max_length=16),
+ ),
+ ("source_type", models.CharField(max_length=64)),
+ ("source_id", models.CharField(max_length=512)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "comment",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.RESTRICT,
+ related_name="email_thread_message",
+ to="posthog.comment",
+ ),
+ ),
+ (
+ "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="messages",
+ to="conversations.emailthread",
+ ),
+ ),
+ ("sender_authenticated", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_thread_message",
+ "ordering": ["sent_at", "id"],
+ "indexes": [
+ models.Index(fields=["team", "thread", "sent_at", "id"], name="email_message_thread_time_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "source_type", "source_id"), name="unique_email_message_source_per_team"
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("message_id__isnull", False), models.Q(("message_id", ""), _negated=True)),
+ fields=("team", "message_id"),
+ name="unique_email_message_id_per_team",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailThreadParticipant",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("email", models.CharField(max_length=400)),
+ ("display_name", models.CharField(blank=True, default="", max_length=400)),
+ ("kind", models.CharField(choices=[("internal", "Internal"), ("customer", "Customer")], max_length=16)),
+ ("person_id", models.UUIDField(blank=True, null=True)),
+ ("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="participants",
+ to="conversations.emailthread",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_thread_participant",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "thread", "email"), name="unique_email_thread_participant")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TicketAssignment",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "ticket",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="assignment",
+ to="conversations.ticket",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("role", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="ee.role")),
+ ],
+ options={
+ "db_table": "posthog_conversations_ticket_assignment",
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("role__isnull", True), ("user__isnull", False)),
+ models.Q(("role__isnull", False), ("user__isnull", True)),
+ _connector="OR",
+ ),
+ name="exactly_one_assignee_type",
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailMessageMapping",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("message_id", models.CharField(db_index=True, max_length=255)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("ticket", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="conversations.ticket")),
+ ("comment", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.comment")),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_message_mapping",
+ "constraints": [models.UniqueConstraint(fields=("message_id", "team"), name="unique_message_per_team")],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="GithubCommentMapping",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("github_comment_id", models.BigIntegerField(db_index=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "comment",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.comment"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("ticket", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="conversations.ticket")),
+ ],
+ options={
+ "db_table": "posthog_conversations_github_comment_mapping",
+ "constraints": [
+ models.UniqueConstraint(fields=("github_comment_id", "team"), name="unique_github_comment_per_team")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EmailOutboxMessage",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("message_id", models.CharField(max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "Pending"), ("sent", "Sent"), ("failed_permanent", "Failed (permanent)")],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("attempts", models.PositiveIntegerField(default=0)),
+ ("last_error", models.TextField(blank=True, default="")),
+ ("next_attempt_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("locked_until", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("sent_at", models.DateTimeField(blank=True, null=True)),
+ ("comment", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="posthog.comment")),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("ticket", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="conversations.ticket")),
+ ],
+ options={
+ "db_table": "posthog_conversations_email_outbox_message",
+ "indexes": [models.Index(fields=["status", "next_attempt_at"], name="posthog_con_outbox_due_idx")],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/conversations/backend/migrations/0066_squash_2026_09_07_schema_addons.py b/products/conversations/backend/migrations/0066_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..c4bcabe37495
--- /dev/null
+++ b/products/conversations/backend/migrations/0066_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,98 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_constraint
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0064_alter_emailthreadaccountlink_match_source"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_conversations_ticket_email_config_id_aa259d61" ON "posthog_conversations_ticket" ("email_config_id");',
+ reverse_sql="",
+ ),
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="emailchannel",
+ name="email_channel_customer_not_default",
+ ),
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="emailchannel",
+ name="email_channel_kind_owner",
+ ),
+ ]
diff --git a/products/conversations/backend/migrations/max_migration.txt b/products/conversations/backend/migrations/max_migration.txt
index 43d1b287dfce..90e3a4c39792 100644
--- a/products/conversations/backend/migrations/max_migration.txt
+++ b/products/conversations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0064_alter_emailthreadaccountlink_match_source
+0066_squash_2026_09_07_schema_addons
diff --git a/products/customer_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/customer_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..7ecf00aa95c1
--- /dev/null
+++ b/products/customer_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,1438 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.manager
+import django.db.models.deletion
+import django.contrib.postgres.fields
+import django.db.models.functions.text
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+import products.customer_analytics.backend.models.custom_property_definition
+import products.customer_analytics.backend.models.team_customer_analytics_config
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("customer_analytics", "0001_team_customer_analytics_config"),
+ ("customer_analytics", "0002_customer_profile_config"),
+ ("customer_analytics", "0003_customer_journey"),
+ ("customer_analytics", "0004_teamcustomeranalyticsconfig_account_group_type_index"),
+ ("customer_analytics", "0005_account"),
+ ("customer_analytics", "0006_migrate_product_analytics_models"),
+ ("customer_analytics", "0007_custom_property_definition"),
+ ("customer_analytics", "0008_custom_property_value"),
+ ("customer_analytics", "0009_custompropertyvalue_validate_fks"),
+ ("customer_analytics", "0010_custompropertysource"),
+ ("customer_analytics", "0011_custompropertysource_validate_fks"),
+ ("customer_analytics", "0012_custompropertydefinition_options_and_more"),
+ ("customer_analytics", "0013_relationships"),
+ ("customer_analytics", "0014_relationships_validate_fks"),
+ ("customer_analytics", "0015_person_target_custom_properties"),
+ ("customer_analytics", "0016_announcement"),
+ ("customer_analytics", "0017_announcement_validate_fks"),
+ ("customer_analytics", "0018_custompropertysyncrun"),
+ ("customer_analytics", "0019_custompropertysyncrun_validate_fks"),
+ ("customer_analytics", "0020_custompropertydefinition_group_type_index_and_more"),
+ ("customer_analytics", "0021_custompropertysource_column_descriptions"),
+ ("customer_analytics", "0022_eventstream_eventstreammember"),
+ ("customer_analytics", "0023_eventstream_validate_fks"),
+ ("customer_analytics", "0024_alter_eventstream_team_and_more"),
+ ("customer_analytics", "0025_alter_eventstream_created_by"),
+ ("customer_analytics", "0026_account_slack_summary_cadence_accountchannelsummary"),
+ ("customer_analytics", "0027_accountchannelsummary_validate_fks"),
+ ("customer_analytics", "0028_accountchannelsummary_messages"),
+ ("customer_analytics", "0029_alter_custompropertysyncrun_trigger"),
+ ("customer_analytics", "0030_meeting_models"),
+ ("customer_analytics", "0031_featurerequest_featurerequestproductarea_and_more"),
+ ("customer_analytics", "0032_account_churned_at"),
+ ("customer_analytics", "0033_feature_request_lifecycle"),
+ ("customer_analytics", "0034_backfill_feature_request_history"),
+ ("customer_analytics", "0035_alter_feature_request_description"),
+ ("customer_analytics", "0036_custompropertysyncrun_saved_query_id"),
+ ("customer_analytics", "0037_account_ignored_at"),
+ ("customer_analytics", "0038_feature_request_multi_account_evidence"),
+ ("customer_analytics", "0039_feature_request_evidence_images"),
+ ("customer_analytics", "0040_account_track_rules"),
+ ("customer_analytics", "0041_account_track_rules_enabled_at"),
+ ("customer_analytics", "0042_backfill_account_track_rules_enabled_at"),
+ ("customer_analytics", "0043_custom_property_sync_run_observability"),
+ ("customer_analytics", "0044_custom_property_sync_run_temporal_run_id"),
+ ("customer_analytics", "0045_custom_property_definition_link_display_type"),
+ ("customer_analytics", "0046_usercustomeranalyticsconfig"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="TeamCustomerAnalyticsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("activity_event", models.JSONField(default=dict)),
+ ("signup_pageview_event", models.JSONField(default=dict)),
+ ("signup_event", models.JSONField(default=dict)),
+ ("subscription_event", models.JSONField(default=dict)),
+ ("payment_event", models.JSONField(default=dict)),
+ ("account_group_type_index", models.IntegerField(blank=True, null=True)),
+ (
+ "account_track_rules",
+ models.JSONField(
+ default=products.customer_analytics.backend.models.team_customer_analytics_config.default_account_track_rules
+ ),
+ ),
+ ("account_track_rules_enabled_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomerProfileConfig",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("content", models.JSONField(default=dict)),
+ ("sidebar", models.JSONField(default=dict)),
+ (
+ "scope",
+ models.CharField(
+ choices=[
+ ("person", "Person"),
+ ("group_0", "Group 0"),
+ ("group_1", "Group 1"),
+ ("group_2", "Group 2"),
+ ("group_3", "Group 3"),
+ ("group_4", "Group 4"),
+ ],
+ max_length=255,
+ ),
+ ),
+ (
+ "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={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomerJourney",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(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
+ ),
+ ),
+ (
+ "insight",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "insight_id"), name="unique insight journey per team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Account",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("external_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("name", models.CharField(max_length=400)),
+ ("_properties", models.JSONField(db_column="properties", default=dict)),
+ (
+ "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")),
+ (
+ "slack_summary_cadence",
+ models.CharField(
+ blank=True,
+ choices=[("daily", "Daily"), ("weekly", "Weekly"), ("monthly", "Monthly")],
+ max_length=10,
+ null=True,
+ ),
+ ),
+ ("churned_at", models.DateTimeField(blank=True, null=True)),
+ ("ignored_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("external_id__isnull", False)),
+ fields=("team", "external_id"),
+ name="unique_account_external_id_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomPropertyDefinition",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(null=True)),
+ (
+ "display_type",
+ models.CharField(
+ choices=[
+ ("text", "text"),
+ ("link", "link"),
+ ("number", "number"),
+ ("currency", "currency"),
+ ("percent", "percent"),
+ ("date", "date"),
+ ("datetime", "datetime"),
+ ("boolean", "boolean"),
+ ("select", "select"),
+ ],
+ default=products.customer_analytics.backend.models.custom_property_definition.DisplayType[
+ "TEXT"
+ ],
+ max_length=20,
+ ),
+ ),
+ (
+ "is_big_number",
+ models.BooleanField(
+ default=False,
+ help_text="Whether the property is a big number and should be abbreviated. E.g.: 10,000 -> 10K",
+ ),
+ ),
+ (
+ "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",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="For select properties: the allowed options, each {'id', 'label', 'color'}. Null for other types.",
+ null=True,
+ ),
+ ),
+ (
+ "target_type",
+ models.CharField(
+ choices=[("account", "account"), ("person", "person"), ("group", "group")],
+ default=products.customer_analytics.backend.models.custom_property_definition.TargetType[
+ "ACCOUNT"
+ ],
+ help_text="What entity this property is attached to: an account (default), a person, or a group.",
+ max_length=20,
+ ),
+ ),
+ (
+ "group_type_index",
+ models.PositiveSmallIntegerField(
+ blank=True,
+ help_text="For group targets only: the group type index (0-4). Null for account/person targets.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="unique_custom_property_per_team"),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("is_big_number", False),
+ ("display_type__in", ["number", "currency", "percent"]),
+ _connector="OR",
+ ),
+ name="is_big_number_requires_numeric_display_type",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("target_type", "group"), _negated=True),
+ ("group_type_index__isnull", False),
+ _connector="OR",
+ ),
+ name="group_target_requires_group_type_index",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AccountRelationshipDefinition",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ (
+ "description",
+ models.TextField(
+ blank=True,
+ help_text="What this relationship means, e.g. 'The customer success manager responsible for this account'.",
+ null=True,
+ ),
+ ),
+ (
+ "is_single_holder",
+ models.BooleanField(
+ default=True,
+ help_text="Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account.",
+ ),
+ ),
+ (
+ "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={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="unique_relationship_definition_name")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Announcement",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("message", models.TextField()),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("sending", "Sending"),
+ ("sent", "Sent"),
+ ("partially_failed", "Partially failed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("total_channels", models.PositiveIntegerField(default=0)),
+ ("sent_count", models.PositiveIntegerField(default=0)),
+ ("failed_count", models.PositiveIntegerField(default=0)),
+ ("sent_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "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",
+ "indexes": [models.Index(fields=["team_id", "-created_at"], name="ca_announcement_team_idx")],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="EventStream",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("enabled", models.BooleanField(default=False)),
+ ("event_names", models.JSONField(default=list)),
+ ("slack_channel_id", models.CharField(blank=True, default="", max_length=200)),
+ ("slack_channel_name", models.CharField(blank=True, default="", max_length=200)),
+ ("hog_function_id", models.UUIDField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "slack_integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "created_by"), name="unique_event_stream_per_user")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequest",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("title", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("requested", "Requested"),
+ ("planned", "Planned"),
+ ("completed", "Completed"),
+ ("wont_fix", "Won't fix"),
+ ("duplicate", "Duplicate"),
+ ],
+ default="requested",
+ max_length=32,
+ ),
+ ),
+ ("idempotency_key", models.UUIDField(blank=True, null=True)),
+ ("created_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("updated_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("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"
+ ),
+ ),
+ ("archived_at", models.DateTimeField(blank=True, null=True)),
+ ("archived_by_id", models.BigIntegerField(blank=True, null=True)),
+ (
+ "priority",
+ models.CharField(
+ blank=True,
+ choices=[("high", "High"), ("medium", "Medium"), ("low", "Low")],
+ max_length=16,
+ null=True,
+ ),
+ ),
+ ("version", models.PositiveIntegerField(db_default=1, default=1)),
+ ],
+ options={
+ "ordering": ["-updated_at", "-created_at", "-id"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("idempotency_key__isnull", False)),
+ fields=("team", "idempotency_key"),
+ name="unique_feature_request_idempotency_key_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequestProductArea",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("display_order", models.PositiveIntegerField(default=0)),
+ ("is_active", models.BooleanField(default=True)),
+ ("created_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("updated_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("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"
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["display_order", "name", "id"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ django.db.models.functions.text.Lower("name"),
+ models.F("team"),
+ name="unique_feature_request_area_name_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="AccountTrackRuleRun",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("config_version", models.PositiveIntegerField()),
+ (
+ "trigger",
+ models.CharField(
+ choices=[("manual", "manual"), ("scheduled", "scheduled")], default="manual", max_length=20
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "pending"),
+ ("running", "running"),
+ ("completed", "completed"),
+ ("failed", "failed"),
+ ("stale", "stale"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("idempotency_key", models.UUIDField()),
+ ("eligible_active", models.PositiveIntegerField(default=0)),
+ ("skipped_churned", models.PositiveIntegerField(default=0)),
+ ("tracked", models.PositiveIntegerField(default=0)),
+ ("ignored", models.PositiveIntegerField(default=0)),
+ ("newly_ignored", models.PositiveIntegerField(default=0)),
+ ("restored", models.PositiveIntegerField(default=0)),
+ ("processed", models.PositiveIntegerField(default=0)),
+ ("last_account_id", models.UUIDField(blank=True, null=True)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("error", models.TextField(blank=True, null=True)),
+ (
+ "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={
+ "indexes": [models.Index(fields=["team", "-created_at"], name="ca_track_run_team_created")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "idempotency_key"), name="ca_track_run_team_idem_uniq")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserCustomerAnalyticsConfig",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "pinned_custom_property_definition_ids",
+ django.contrib.postgres.fields.ArrayField(base_field=models.UUIDField(), default=list, size=None),
+ ),
+ ("properties", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user"), name="unique_user_customer_analytics_config_per_team"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AccountChannelSummary",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_channel_id", models.CharField(max_length=64)),
+ (
+ "cadence",
+ models.CharField(
+ choices=[("daily", "Daily"), ("weekly", "Weekly"), ("monthly", "Monthly")], max_length=10
+ ),
+ ),
+ ("period_start", models.DateTimeField()),
+ ("period_end", models.DateTimeField()),
+ ("content", models.TextField()),
+ ("message_count", models.PositiveIntegerField(default=0)),
+ ("model_name", models.CharField(blank=True, default="", max_length=100)),
+ ("generated_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="channel_summaries",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("messages", models.JSONField(default=list)),
+ ],
+ options={
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [models.Index(fields=["account_id", "-period_end"], name="ca_channel_summary_acct_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "account", "cadence", "period_start"), name="ca_channel_summary_period_uniq"
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="Meeting",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("ical_uid", models.CharField(max_length=1024)),
+ ("recurrence_instance_id", models.CharField(blank=True, default="", max_length=64)),
+ ("title", models.TextField(blank=True, default="")),
+ ("description", models.TextField(blank=True, default="")),
+ ("start_time", models.DateTimeField()),
+ ("end_time", models.DateTimeField(blank=True, null=True)),
+ ("organizer_email", models.CharField(blank=True, default="", max_length=400)),
+ ("meet_code", models.CharField(blank=True, default="", max_length=64)),
+ (
+ "status",
+ models.CharField(
+ choices=[("confirmed", "Confirmed"), ("tentative", "Tentative"), ("cancelled", "Cancelled")],
+ default="confirmed",
+ max_length=16,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "account",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="meetings",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "account", "-start_time"], name="idx_meeting_account_time")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "ical_uid", "recurrence_instance_id"), name="unique_meeting_per_team"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomPropertyValue",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("is_deleted", models.BooleanField(default=False)),
+ ("value_str", models.TextField(blank=True, null=True)),
+ ("value_bool", models.BooleanField(blank=True, null=True)),
+ ("value_num", models.FloatField(blank=True, null=True)),
+ ("value_datetime", models.DateTimeField(blank=True, null=True)),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="custom_property_values",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "definition",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="values",
+ to="customer_analytics.custompropertydefinition",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("is_deleted", False)),
+ fields=("team", "account", "definition"),
+ name="unique_active_custom_property_value",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("value_bool__isnull", True),
+ ("value_datetime__isnull", True),
+ ("value_num__isnull", True),
+ ("value_str__isnull", False),
+ ),
+ models.Q(
+ ("value_bool__isnull", False),
+ ("value_datetime__isnull", True),
+ ("value_num__isnull", True),
+ ("value_str__isnull", True),
+ ),
+ models.Q(
+ ("value_bool__isnull", True),
+ ("value_datetime__isnull", True),
+ ("value_num__isnull", False),
+ ("value_str__isnull", True),
+ ),
+ models.Q(
+ ("value_bool__isnull", True),
+ ("value_datetime__isnull", False),
+ ("value_num__isnull", True),
+ ("value_str__isnull", True),
+ ),
+ _connector="OR",
+ ),
+ name="custom_property_value_exactly_one_value",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomPropertySource",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("source_column", models.CharField(blank=True, max_length=400, null=True)),
+ ("key_column", models.CharField(max_length=400)),
+ ("is_enabled", models.BooleanField(default=True)),
+ ("consecutive_failures", models.PositiveIntegerField(default=0)),
+ ("last_synced_at", models.DateTimeField(blank=True, null=True)),
+ ("last_sync_error", models.TextField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "definition",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="source",
+ to="customer_analytics.custompropertydefinition",
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("column_property_map", models.JSONField(blank=True, default=None, null=True)),
+ (
+ "external_data_schema",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="warehouse_sources.externaldataschema",
+ ),
+ ),
+ ("column_descriptions", models.JSONField(blank=True, default=None, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AccountRelationship",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("started_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("ended_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="relationships",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "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"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "definition",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="relationships",
+ to="customer_analytics.accountrelationshipdefinition",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ condition=models.Q(("ended_at__isnull", True)),
+ fields=["team", "account", "definition"],
+ name="idx_active_account_rel",
+ ),
+ models.Index(
+ condition=models.Q(("ended_at__isnull", True)),
+ fields=["team", "user"],
+ name="idx_active_rel_by_user",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="AnnouncementDelivery",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_channel_id", models.CharField(max_length=64)),
+ ("slack_channel_name", models.CharField(blank=True, default="", max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "Pending"), ("sent", "Sent"), ("failed", "Failed")],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("error", models.TextField(blank=True, default="")),
+ ("slack_message_ts", models.CharField(blank=True, default="", max_length=64)),
+ ("sent_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "announcement",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="deliveries",
+ to="customer_analytics.announcement",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [models.Index(fields=["announcement_id", "status"], name="ca_ann_deliv_status_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("announcement", "slack_channel_id"), name="ca_announcement_delivery_uniq"
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="EventStreamMember",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="event_stream_memberships",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "stream",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="members",
+ to="customer_analytics.eventstream",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("stream", "account"), name="unique_event_stream_member")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequestAccountLink",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="feature_request_links",
+ to="customer_analytics.account",
+ ),
+ ),
+ (
+ "feature_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="account_links",
+ to="customer_analytics.featurerequest",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("unlinked_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "unlinked_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "feature_request", "account"), name="unique_feature_request_account_link"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequestHistory",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("changes", models.JSONField(default=list)),
+ ("is_initial", models.BooleanField(default=False)),
+ ("source", models.CharField(choices=[("manual", "Manual")], default="manual", max_length=32)),
+ ("actor_id", models.BigIntegerField(blank=True, null=True)),
+ ("changed_at", models.DateTimeField()),
+ (
+ "feature_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="history",
+ to="customer_analytics.featurerequest",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-changed_at", "-id"],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("is_initial", True)),
+ fields=("team", "feature_request"),
+ name="unique_feature_request_initial_history",
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequestProductAreaLink",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "feature_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="product_area_links",
+ to="customer_analytics.featurerequest",
+ ),
+ ),
+ (
+ "product_area",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.PROTECT,
+ related_name="request_links",
+ to="customer_analytics.featurerequestproductarea",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "feature_request", "product_area"),
+ name="unique_feature_request_product_area_link",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MeetingParticipant",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("email", models.CharField(max_length=400)),
+ ("display_name", models.CharField(blank=True, default="", max_length=400)),
+ ("person_id", models.UUIDField(blank=True, null=True)),
+ (
+ "response_status",
+ models.CharField(
+ choices=[
+ ("needs_action", "Needs Action"),
+ ("accepted", "Accepted"),
+ ("declined", "Declined"),
+ ("tentative", "Tentative"),
+ ],
+ default="needs_action",
+ max_length=16,
+ ),
+ ),
+ ("is_organizer", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "meeting",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="participants",
+ to="customer_analytics.meeting",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "meeting", "email"), name="unique_participant_per_meeting")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomPropertySyncRun",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("schema_id", models.UUIDField(blank=True, null=True)),
+ ("job_id", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "trigger",
+ models.CharField(
+ choices=[
+ ("scheduled", "scheduled"),
+ ("sync", "sync"),
+ ("manual", "manual"),
+ ("backfill", "backfill"),
+ ],
+ max_length=20,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("running", "running"), ("completed", "completed"), ("failed", "failed")],
+ default="running",
+ max_length=20,
+ ),
+ ),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("rows_read", models.PositiveIntegerField(default=0)),
+ ("changed", models.PositiveIntegerField(default=0)),
+ ("existing", models.PositiveIntegerField(default=0)),
+ ("produced", models.PositiveIntegerField(default=0)),
+ ("skipped_missing_person", models.PositiveIntegerField(default=0)),
+ ("error", models.TextField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "source",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sync_runs",
+ to="customer_analytics.custompropertysource",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("saved_query_id", models.UUIDField(blank=True, null=True)),
+ ("attempt", models.PositiveSmallIntegerField(blank=True, null=True)),
+ (
+ "phase",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("staging", "staging"),
+ ("dispatching", "dispatching"),
+ ("syncing", "syncing"),
+ ("completed", "completed"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "segment",
+ models.CharField(
+ blank=True, choices=[("tracked", "tracked"), ("ignored", "ignored")], max_length=20, null=True
+ ),
+ ),
+ ("workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("workflow_run_id", models.UUIDField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "source", "-created_at"], name="cpsr_team_source_created_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureRequestEvidence",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "account_link",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="evidence",
+ to="customer_analytics.featurerequestaccountlink",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("summary", models.TextField(blank=True, default="")),
+ ("customer_quote", models.TextField(blank=True, default="")),
+ ("source", models.CharField(max_length=200)),
+ ("source_url", models.URLField(blank=True, default="", max_length=2000)),
+ ("requested_on", models.DateField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "updated_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "image_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.UUIDField(), blank=True, default=list, size=None
+ ),
+ ),
+ ],
+ options={
+ "ordering": [
+ models.OrderBy(models.F("requested_on"), descending=True, nulls_last=True),
+ "-created_at",
+ "-id",
+ ],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/customer_analytics/backend/migrations/0050_squash_2026_09_07_finalize_fks.py b/products/customer_analytics/backend/migrations/0050_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..d5275cc2f5b6
--- /dev/null
+++ b/products/customer_analytics/backend/migrations/0050_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,25 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("customer_analytics", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="featurerequest",
+ name="product_areas",
+ field=models.ManyToManyField(
+ related_name="feature_requests",
+ through="customer_analytics.FeatureRequestProductAreaLink",
+ to="customer_analytics.featurerequestproductarea",
+ ),
+ ),
+ ]
diff --git a/products/customer_analytics/backend/migrations/0051_squash_2026_09_07_schema_addons.py b/products/customer_analytics/backend/migrations/0051_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..8399bfbdaafa
--- /dev/null
+++ b/products/customer_analytics/backend/migrations/0051_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,295 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_foreign_key
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0049_validate_customer_task_foreign_keys"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertyvalue",
+ name="custompropertyvalue_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertyvalue",
+ name="custompropertyvalue_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertyvalue",
+ name="custompropertyvalue_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertyvalue",
+ name="custompropertyvalue_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertysource",
+ name="custompropertysource_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertysource",
+ name="custompropertysource_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertysource",
+ name="custompropertysource_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertysource",
+ name="custompropertysource_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountrelationshipdefinition",
+ name="accountrelationshipdefinition_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountrelationshipdefinition",
+ name="accountrelationshipdefinition_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountrelationship",
+ name="accountrelationship_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountrelationship",
+ name="accountrelationship_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountrelationship",
+ name="accountrelationship_user_id_fk",
+ column="user_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountrelationshipdefinition",
+ name="accountrelationshipdefinition_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountrelationshipdefinition",
+ name="accountrelationshipdefinition_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountrelationship",
+ name="accountrelationship_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountrelationship",
+ name="accountrelationship_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountrelationship",
+ name="accountrelationship_user_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="announcement",
+ name="ca_announcement_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="announcement",
+ name="ca_announcement_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="announcementdelivery",
+ name="ca_announcement_delivery_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="announcement",
+ name="ca_announcement_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="announcement",
+ name="ca_announcement_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="announcementdelivery",
+ name="ca_announcement_delivery_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertysyncrun",
+ name="custompropertysyncrun_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="custompropertysyncrun",
+ name="custompropertysyncrun_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertysyncrun",
+ name="custompropertysyncrun_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="custompropertysyncrun",
+ name="custompropertysyncrun_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="eventstream",
+ name="eventstream_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="eventstream",
+ name="eventstream_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="eventstreammember",
+ name="eventstreammember_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="eventstreammember",
+ name="eventstreammember_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="eventstream",
+ name="eventstream_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="eventstream",
+ name="eventstream_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="eventstreammember",
+ name="eventstreammember_team_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="eventstreammember",
+ name="eventstreammember_created_by_id_fk",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="accountchannelsummary",
+ name="ca_channel_summary_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.ValidateForeignKey(
+ model_name="accountchannelsummary",
+ name="ca_channel_summary_team_id_fk",
+ ),
+ ]
diff --git a/products/customer_analytics/backend/migrations/max_migration.txt b/products/customer_analytics/backend/migrations/max_migration.txt
index 8a077a281e3d..b236708a9e5c 100644
--- a/products/customer_analytics/backend/migrations/max_migration.txt
+++ b/products/customer_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0049_validate_customer_task_foreign_keys
+0051_squash_2026_09_07_schema_addons
diff --git a/products/dashboards/backend/migrations/0001_squash_2026_09_07_initial.py b/products/dashboards/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..66f68853e12a
--- /dev/null
+++ b/products/dashboards/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,381 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.manager
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("dashboards", "0001_migrate_dashboards_models"),
+ ("dashboards", "0002_add_dashboardtile_team_id_column"),
+ ("dashboards", "0003_backfill_dashboardtile_team_id"),
+ ("dashboards", "0004_add_dashboardtile_team_id_index"),
+ ("dashboards", "0005_enforce_dashboardtile_team_id_not_null"),
+ ("dashboards", "0006_migrate_product_analytics_models"),
+ ("dashboards", "0007_dashboardwidget_table"),
+ ("dashboards", "0008_dashboardtile_widget_id"),
+ ("dashboards", "0009_dashboardtile_check_4way"),
+ ("dashboards", "0010_validate_dashboardtile_check"),
+ ("dashboards", "0011_dashboardtile_widget_id_idx"),
+ ("dashboards", "0012_alter_dashboardtemplate_scope"),
+ ("dashboards", "0013_dashboardtile_button_tile_id_idx"),
+ ("dashboards", "0014_backfill_dashboardtemplate_button_tile_type"),
+ ("dashboards", "0015_dashboard_customization"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ButtonTile",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("url", models.CharField(max_length=2000)),
+ ("text", models.CharField(max_length=200)),
+ (
+ "placement",
+ models.CharField(choices=[("left", "Left"), ("right", "Right")], default="left", max_length=10),
+ ),
+ (
+ "style",
+ models.CharField(
+ choices=[("primary", "Primary"), ("secondary", "Secondary")], default="primary", max_length=10
+ ),
+ ),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_button_tiles",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_buttontile",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Dashboard",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True)),
+ ("pinned", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("last_accessed_at", models.DateTimeField(blank=True, null=True)),
+ ("last_refresh", models.DateTimeField(blank=True, null=True)),
+ ("filters", models.JSONField(default=dict)),
+ ("variables", models.JSONField(blank=True, default=dict, null=True)),
+ ("breakdown_colors", models.JSONField(blank=True, default=list, null=True)),
+ (
+ "creation_mode",
+ models.CharField(
+ choices=[
+ ("default", "Default"),
+ ("template", "Template"),
+ ("duplicate", "Duplicate"),
+ ("unlisted", "Unlisted (product-embedded)"),
+ ],
+ default="default",
+ max_length=16,
+ ),
+ ),
+ (
+ "restriction_level",
+ models.PositiveSmallIntegerField(
+ choices=[
+ (21, "Everyone in the project can edit"),
+ (37, "Only those invited to this dashboard can edit"),
+ ],
+ default=21,
+ ),
+ ),
+ ("quick_filter_ids", models.JSONField(blank=True, default=list, null=True)),
+ (
+ "deprecated_tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "deprecated_tags_v2",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32),
+ blank=True,
+ db_column="tags",
+ default=None,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("share_token", models.CharField(blank=True, max_length=400, null=True)),
+ ("is_shared", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "data_color_theme",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="posthog.datacolortheme"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("customization", models.JSONField(blank=True, db_default={}, default=dict)),
+ ],
+ options={
+ "db_table": "posthog_dashboard",
+ "indexes": [
+ models.Index(
+ condition=models.Q(("deleted", False)),
+ fields=["-pinned", "name", "deleted", "team_id"],
+ name="idx_dashboard_deleted_team_id",
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Text",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("body", models.CharField(blank=True, max_length=4000, null=True)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_text_tiles",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_text",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DashboardWidget",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("widget_type", models.CharField(max_length=64)),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True)),
+ ("config", models.JSONField(default=dict)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_dashboard_widgets",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_dashboardwidget",
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="DashboardTemplate",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("template_name", models.CharField(blank=True, max_length=400, null=True)),
+ ("dashboard_description", models.CharField(blank=True, max_length=400, null=True)),
+ ("dashboard_filters", models.JSONField(blank=True, null=True)),
+ ("tiles", models.JSONField(blank=True, null=True)),
+ ("variables", models.JSONField(blank=True, null=True)),
+ (
+ "tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255), blank=True, null=True, size=None
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("deleted", models.BooleanField(blank=True, null=True)),
+ ("image_url", models.CharField(blank=True, max_length=8201, null=True)),
+ (
+ "scope",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("team", "Only team"),
+ ("organization", "Organization"),
+ ("global", "Global"),
+ ("feature_flag", "Feature Flag"),
+ ],
+ max_length=24,
+ null=True,
+ ),
+ ),
+ ("github_url", models.CharField(blank=True, max_length=8201, null=True)),
+ (
+ "availability_contexts",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "is_featured",
+ models.BooleanField(
+ default=False, help_text="Manually curated; used to highlight templates in the UI."
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("team", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_dashboardtemplate",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted__isnull", True), ("deleted", False), _connector="OR"),
+ fields=("template_name", "team"),
+ name="unique_template_name_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DashboardTile",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("layouts", models.JSONField(default=dict)),
+ ("color", models.CharField(blank=True, max_length=400, null=True)),
+ ("filters_hash", models.CharField(blank=True, max_length=400, null=True)),
+ ("last_refresh", models.DateTimeField(blank=True, null=True)),
+ ("refreshing", models.BooleanField(null=True)),
+ ("refresh_attempt", models.IntegerField(blank=True, null=True)),
+ ("filters_overrides", models.JSONField(blank=True, default=dict, null=True)),
+ ("show_description", models.BooleanField(blank=True, null=True)),
+ ("transparent_background", models.BooleanField(blank=True, null=True)),
+ ("deleted", models.BooleanField(blank=True, null=True)),
+ (
+ "button_tile",
+ models.ForeignKey(
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="dashboard_tiles",
+ to="dashboards.buttontile",
+ ),
+ ),
+ (
+ "dashboard",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="tiles", to="dashboards.dashboard"
+ ),
+ ),
+ (
+ "text",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="dashboard_tiles",
+ to="dashboards.text",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ (
+ "widget",
+ models.ForeignKey(
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.PROTECT,
+ related_name="dashboard_tiles",
+ to="dashboards.dashboardwidget",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_dashboardtile",
+ "indexes": [models.Index(fields=["filters_hash"], name="query_by_filters_hash_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("text__isnull", False)),
+ fields=("dashboard", "text"),
+ name="unique_dashboard_text",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("button_tile__isnull", False)),
+ fields=("dashboard", "button_tile"),
+ name="unique_dashboard_button_tile",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("widget__isnull", False)),
+ fields=("dashboard", "widget"),
+ name="unique_dashboard_widget",
+ ),
+ ],
+ },
+ ),
+ ]
diff --git a/products/dashboards/backend/migrations/0006_migrate_product_analytics_models.py b/products/dashboards/backend/migrations/0006_migrate_product_analytics_models.py
index 3c7c74054d82..228d5b371986 100644
--- a/products/dashboards/backend/migrations/0006_migrate_product_analytics_models.py
+++ b/products/dashboards/backend/migrations/0006_migrate_product_analytics_models.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("dashboards", "0005_enforce_dashboardtile_team_id_not_null"),
- ("product_analytics", "0001_migrate_product_analytics_models"),
]
operations = [
diff --git a/products/dashboards/backend/migrations/0017_squash_2026_09_07_finalize_fks.py b/products/dashboards/backend/migrations/0017_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..fae2cc046b5b
--- /dev/null
+++ b/products/dashboards/backend/migrations/0017_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,89 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="dashboard",
+ name="insights",
+ field=models.ManyToManyField(
+ blank=True,
+ related_name="dashboards",
+ through="dashboards.DashboardTile",
+ to="product_analytics.insight",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="dashboard",
+ name="insights",
+ field=models.ManyToManyField(
+ blank=True,
+ related_name="dashboards",
+ through="dashboards.DashboardTile",
+ to="product_analytics.insight",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="dashboardtile",
+ name="insight",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="dashboard_tiles",
+ to="product_analytics.insight",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="dashboardtile",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(("insight__isnull", False)),
+ fields=("dashboard", "insight"),
+ name="unique_dashboard_insight",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddConstraintIfMissing(
+ model_name="dashboardtile",
+ constraint=models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("insight__isnull", False),
+ ("text__isnull", True),
+ ("button_tile__isnull", True),
+ ("widget__isnull", True),
+ ),
+ models.Q(
+ ("insight__isnull", True),
+ ("text__isnull", False),
+ ("button_tile__isnull", True),
+ ("widget__isnull", True),
+ ),
+ models.Q(
+ ("insight__isnull", True),
+ ("text__isnull", True),
+ ("button_tile__isnull", False),
+ ("widget__isnull", True),
+ ),
+ models.Q(
+ ("insight__isnull", True),
+ ("text__isnull", True),
+ ("button_tile__isnull", True),
+ ("widget__isnull", False),
+ ),
+ _connector="OR",
+ ),
+ name="dash_tile_exactly_one_related_object",
+ ),
+ ),
+ ]
diff --git a/products/dashboards/backend/migrations/0018_squash_2026_09_07_schema_addons.py b/products/dashboards/backend/migrations/0018_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..0c914978d651
--- /dev/null
+++ b/products/dashboards/backend/migrations/0018_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,104 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0016_dashboardsavedview"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_dashboardtile_team_id_fkey\') THEN\nALTER TABLE "posthog_dashboardtile" ADD CONSTRAINT "posthog_dashboardtile_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "posthog_team"("id") ON DELETE CASCADE NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_dashboardtile_team_id_idx" ON "posthog_dashboardtile" ("team_id")',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = \'posthog_dashboardtile_widget_id_fk\') THEN\nALTER TABLE "posthog_dashboardtile" ADD CONSTRAINT "posthog_dashboardtile_widget_id_fk" -- existing-table-constraint-ignore\n FOREIGN KEY ("widget_id") REFERENCES "posthog_dashboardwidget"("id") ON DELETE RESTRICT NOT VALID;\nEND IF; END $$;',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_dashboardtile_widget_id_idx" ON "posthog_dashboardtile" ("widget_id") WHERE "widget_id" IS NOT NULL',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_dashboardtile_button_tile_id_idx" ON "posthog_dashboardtile" ("button_tile_id") WHERE "button_tile_id" IS NOT NULL',
+ reverse_sql="",
+ ),
+ ]
diff --git a/products/dashboards/backend/migrations/max_migration.txt b/products/dashboards/backend/migrations/max_migration.txt
index 500b16278a7a..c3ea6016b9a1 100644
--- a/products/dashboards/backend/migrations/max_migration.txt
+++ b/products/dashboards/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0016_dashboardsavedview
+0018_squash_2026_09_07_schema_addons
diff --git a/products/data_catalog/backend/migrations/0001_squash_2026_09_07_initial.py b/products/data_catalog/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..5c36378b74ac
--- /dev/null
+++ b/products/data_catalog/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,414 @@
+# Generated by Django 5.2.17
+
+import django.core.validators
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.data_catalog.backend.facade.enums
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("data_catalog", "0001_initial"),
+ ("data_catalog", "0002_tablecertification"),
+ ("data_catalog", "0003_relationshipproposal"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ("data_tools", "0003_datawarehouseexpression"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Metric",
+ 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.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ help_text="Identifier-safe run handle, unique per team and reserved forever. Write-once.",
+ max_length=128,
+ validators=[
+ django.core.validators.RegexValidator(
+ message="Name must start with a letter and contain only letters, numbers, and underscores.",
+ regex="^[A-Za-z][A-Za-z0-9_]*$",
+ )
+ ],
+ ),
+ ),
+ (
+ "display_name",
+ models.CharField(
+ blank=True, help_text="Human-friendly label. Mutable, unlike name.", max_length=255
+ ),
+ ),
+ (
+ "description",
+ models.TextField(help_text="What the metric means and how to interpret it. The load-bearing text."),
+ ),
+ (
+ "unit",
+ models.CharField(
+ blank=True, help_text="Unit of the result, e.g. usd, percent, cents.", max_length=64
+ ),
+ ),
+ (
+ "definition",
+ models.JSONField(
+ blank=True,
+ help_text="Machine-readable query (stored upgrade-canonical). Null means a name+description-only stub.",
+ null=True,
+ ),
+ ),
+ (
+ "referenced_table_names",
+ models.JSONField(
+ blank=True,
+ default=list,
+ help_text="Tables the definition directly references, extracted at write time for the catalog's denied-table filter.",
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("proposed", "proposed"), ("approved", "approved")],
+ default=products.data_catalog.backend.facade.enums.MetricStatus["PROPOSED"],
+ help_text="Persisted lifecycle state. drifted is computed at read time, not stored here.",
+ max_length=32,
+ ),
+ ),
+ ("approved_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "source_insight_short_id",
+ models.CharField(
+ blank=True,
+ help_text="Short ID of the insight this metric was created from, for drift detection.",
+ max_length=12,
+ null=True,
+ ),
+ ),
+ (
+ "source_insight_query_hash",
+ models.CharField(
+ blank=True,
+ help_text="Canonical hash of the insight query snapshot at create/refresh time.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ (
+ "last_run_at",
+ models.DateTimeField(
+ blank=True, help_text="When the metric was last run (30-minute throttle).", null=True
+ ),
+ ),
+ (
+ "created_source",
+ models.CharField(
+ choices=[("user", "user"), ("ai_generated", "ai_generated")],
+ default=products.data_catalog.backend.facade.enums.CreatedSource["USER"],
+ help_text="Whether a human or an agent authored this metric.",
+ max_length=32,
+ ),
+ ),
+ (
+ "ai_model",
+ models.CharField(
+ blank=True, help_text="Model that generated the metric, if AI-authored.", max_length=128
+ ),
+ ),
+ (
+ "confidence",
+ models.FloatField(blank=True, help_text="AI author's confidence in the proposal, 0-1.", null=True),
+ ),
+ (
+ "reasoning",
+ models.TextField(blank=True, help_text="AI author's reasoning, surfaced as review context."),
+ ),
+ (
+ "approved_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "owner",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The human accountable for this metric. AI generates, a human owns.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "status"], name="data_catalo_team_id_7d270a_idx"),
+ models.Index(fields=["team", "source_insight_short_id"], name="data_catalo_team_id_f2da25_idx"),
+ ],
+ "constraints": [models.UniqueConstraint(fields=("team", "name"), name="unique_metric_name_per_team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="TableCertification",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("proposed", "proposed"), ("certified", "certified"), ("deprecated", "deprecated")],
+ default=products.data_catalog.backend.facade.enums.CertificationStatus["PROPOSED"],
+ help_text="proposed, certified (prefer this source), or deprecated (avoid this source).",
+ max_length=32,
+ ),
+ ),
+ (
+ "notes",
+ models.TextField(
+ blank=True, help_text="Why this mark exists, e.g. 'canonical MRR source, refreshed daily'."
+ ),
+ ),
+ ("certified_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "certified_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The warehouse view this mark applies to (XOR table).",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The warehouse table this mark applies to (XOR saved_query).",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "status"], name="data_catalo_team_id_3f966c_idx")],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("saved_query__isnull", True), ("table__isnull", False)),
+ models.Q(("saved_query__isnull", False), ("table__isnull", True)),
+ _connector="OR",
+ ),
+ name="certification_exactly_one_target",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("table__isnull", False)),
+ fields=("team", "table"),
+ name="unique_certification_per_table",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("saved_query__isnull", False)),
+ fields=("team", "saved_query"),
+ name="unique_certification_per_saved_query",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="RelationshipProposal",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "source_table_name",
+ models.CharField(help_text="Name of the table the join starts from.", max_length=400),
+ ),
+ (
+ "source_table_key",
+ models.CharField(help_text="HogQL key expression on the source table.", max_length=400),
+ ),
+ (
+ "joining_table_name",
+ models.CharField(help_text="Name of the table being joined in.", max_length=400),
+ ),
+ (
+ "joining_table_key",
+ models.CharField(help_text="HogQL key expression on the joining table.", max_length=400),
+ ),
+ (
+ "field_name",
+ models.CharField(help_text="Accessor the join adds to the source table.", max_length=400),
+ ),
+ (
+ "configuration",
+ models.JSONField(
+ blank=True, default=dict, help_text="Extra join configuration (e.g. field mapping)."
+ ),
+ ),
+ (
+ "confidence",
+ models.FloatField(
+ blank=True,
+ help_text="Discovery confidence in this join, 0-1.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0),
+ django.core.validators.MaxValueValidator(1),
+ ],
+ ),
+ ),
+ ("reasoning", models.TextField(blank=True, help_text="Why this join is proposed.")),
+ (
+ "evidence",
+ models.JSONField(
+ blank=True, default=dict, help_text="Sampling evidence: match rates, sample values."
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("proposed", "proposed"), ("accepted", "accepted"), ("rejected", "rejected")],
+ default=products.data_catalog.backend.facade.enums.RelationshipStatus["PROPOSED"],
+ help_text="proposed, accepted (promoted to a real join), or rejected (never re-proposed).",
+ max_length=32,
+ ),
+ ),
+ ("reviewed_at", models.DateTimeField(blank=True, null=True)),
+ ("rejection_reason", models.TextField(blank=True, help_text="Why the proposal was rejected.")),
+ (
+ "undirected_fingerprint",
+ models.CharField(
+ help_text="sha256 of the sorted {(table, key), (table, key)} pair set -- one proposal per physical join pair.",
+ max_length=64,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_join",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The join created when this proposal was accepted (promotion provenance).",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="data_tools.datawarehousejoin",
+ ),
+ ),
+ (
+ "reviewed_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "status"], name="data_catalo_team_id_1b11e5_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "undirected_fingerprint"), name="unique_relationship_fingerprint"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/data_modeling/backend/migrations/0001_initial.py b/products/data_modeling/backend/migrations/0001_initial.py
index 9817d27f677d..9c12a3654488 100644
--- a/products/data_modeling/backend/migrations/0001_initial.py
+++ b/products/data_modeling/backend/migrations/0001_initial.py
@@ -12,7 +12,6 @@ class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
- ("data_warehouse", "0009_alter_externaldatasource_source_type"),
("posthog", "0923_add_quick_filters"),
]
diff --git a/products/data_modeling/backend/migrations/0001_squash_2026_09_07_initial.py b/products/data_modeling/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..9305763ef5f1
--- /dev/null
+++ b/products/data_modeling/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,841 @@
+# Generated by Django 5.2.17
+
+import datetime
+
+import django.utils.timezone
+import django.db.models.deletion
+import django.db.models.constraints
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.data_modeling.backend.models.modeling
+import products.data_modeling.backend.models.datawarehouse_saved_query
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("data_modeling", "0001_initial"),
+ ("data_modeling", "0002_edge_edge_unique_within_dag"),
+ ("data_modeling", "0003_create_detect_cycles_function"),
+ ("data_modeling", "0004_drop_detect_cycles_function"),
+ ("data_modeling", "0005_remove_node_name_unique_within_team_dag_and_more"),
+ ("data_modeling", "0006_backfill_nodes_edges_from_saved_queries"),
+ ("data_modeling", "0007_create_dag"),
+ ("data_modeling", "0008_backfill_dags"),
+ ("data_modeling", "0009_edge_dag_id_text_node_dag_id_text"),
+ ("data_modeling", "0010_add_endpoint_node_type"),
+ ("data_modeling", "0011_remove_edge_unique_within_dag"),
+ ("data_modeling", "0012_add_description_to_node"),
+ ("data_modeling", "0013_edge_dag_fk_node_dag_fk"),
+ ("data_modeling", "0014_node_dag_fk"),
+ ("data_modeling", "0015_add_dag_fk_indexes"),
+ ("data_modeling", "0016_backfill_dag_fks"),
+ ("data_modeling", "0017_make_old_dag_text_fields_nullable"),
+ ("data_modeling", "0018_switch_constraints_to_dag_fk"),
+ ("data_modeling", "0019_drop_old_dag_text_columns"),
+ ("data_modeling", "0020_dag_fk_not_null"),
+ ("data_modeling", "0021_dag_sync_frequency"),
+ ("data_modeling", "0022_github_sync_models"),
+ ("data_modeling", "0023_migrate_data_modeling_models"),
+ ("data_modeling", "0024_datamodelingjob_team_status_idx"),
+ ("data_modeling", "0025_datawarehouse_saved_query_column_annotation"),
+ ("data_modeling", "0026_datawarehousesavedquery_semantic_enrichment_hash"),
+ ("data_modeling", "0027_datawarehousesavedquery_column_order"),
+ ("data_modeling", "0028_alter_datawarehousemanagedviewset_kind"),
+ ("data_modeling", "0029_add_skipped_data_modeling_job_status"),
+ ("data_modeling", "0030_datawarehousesavedquery_incremental_config_and_more"),
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="DAG",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.TextField(db_index=True, max_length=2048)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "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")),
+ (
+ "sync_frequency_interval",
+ models.DurationField(blank=True, default=datetime.timedelta(days=1), null=True),
+ ),
+ (
+ "source_control_path",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Directory path in the source control repository for synced DAGs",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datamodelingdag",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "name"), name="name_unique_within_team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="GitHubSyncConfig",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "repository",
+ models.CharField(
+ blank=True, default="", help_text="GitHub repo in 'owner/repo' format", max_length=1024
+ ),
+ ),
+ (
+ "environment_name",
+ models.CharField(
+ blank=True,
+ default="production",
+ help_text="Environment name that maps to this team",
+ max_length=256,
+ ),
+ ),
+ (
+ "models_directory",
+ models.CharField(
+ blank=True,
+ default="models",
+ help_text="Directory within the repo containing model SQL files",
+ max_length=256,
+ ),
+ ),
+ (
+ "last_synced_sha",
+ models.CharField(blank=True, default="", help_text="Last synced Git commit SHA", max_length=64),
+ ),
+ (
+ "last_synced_at",
+ models.DateTimeField(blank=True, help_text="When the last sync completed", null=True),
+ ),
+ (
+ "sync_status",
+ models.CharField(
+ choices=[("idle", "Idle"), ("syncing", "Syncing"), ("error", "Error")],
+ default="idle",
+ max_length=32,
+ ),
+ ),
+ (
+ "last_sync_error",
+ models.TextField(blank=True, default="", help_text="Error message from the last failed sync"),
+ ),
+ (
+ "auto_merge_prs",
+ models.BooleanField(default=False, help_text="Auto-merge PRs created by PostHog for this env"),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="posthog.integration"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datamodelinggithubsyncconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseManagedViewSet",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("revenue_analytics", "Revenue Analytics"),
+ ("engineering_analytics", "Engineering Analytics"),
+ ],
+ max_length=64,
+ ),
+ ),
+ (
+ "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={
+ "db_table": "posthog_datawarehousemanagedviewset",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "kind"), name="datawarehouse_unique_managed_viewset_team_kind"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="GitHubSyncPlan",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("pr_number", models.IntegerField(help_text="GitHub PR number")),
+ ("pr_url", models.URLField(help_text="Full URL to the GitHub PR", max_length=1024)),
+ ("head_sha", models.CharField(help_text="Commit SHA the plan was computed from", max_length=64)),
+ (
+ "plan",
+ models.JSONField(
+ help_text="Structured plan: {models: {added, modified, removed, renamed}, dags: {added, modified, removed}}"
+ ),
+ ),
+ (
+ "github_comment_id",
+ models.BigIntegerField(
+ blank=True, help_text="GitHub comment ID for the plan comment on the PR", null=True
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("applied", "Applied"),
+ ("closed", "Closed"),
+ ("stale", "Stale"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ (
+ "applied_at",
+ models.DateTimeField(blank=True, help_text="When this plan was applied on merge", null=True),
+ ),
+ (
+ "applied_sha",
+ models.CharField(
+ blank=True, default="", help_text="Merge commit SHA that applied this plan", max_length=64
+ ),
+ ),
+ (
+ "config",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sync_plans",
+ to="data_modeling.githubsyncconfig",
+ ),
+ ),
+ (
+ "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={
+ "db_table": "posthog_datamodelinggithubsyncplan",
+ "indexes": [
+ models.Index(fields=["config", "pr_number"], name="idx_syncplan_config_pr"),
+ models.Index(fields=["status"], name="idx_syncplan_status"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseSavedQuery",
+ 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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ max_length=128,
+ validators=[
+ products.data_modeling.backend.models.datawarehouse_saved_query.validate_saved_query_name
+ ],
+ ),
+ ),
+ ("latest_error", models.TextField(blank=True, default=None, null=True)),
+ (
+ "columns",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Dict of all columns with ClickHouse type (including Nullable())",
+ null=True,
+ ),
+ ),
+ (
+ "external_tables",
+ models.JSONField(blank=True, default=list, help_text="List of all external tables", null=True),
+ ),
+ ("query", models.JSONField(blank=True, default=dict, help_text="HogQL query", null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("Cancelled", "Cancelled"),
+ ("Modified", "Modified"),
+ ("Completed", "Completed"),
+ ("Failed", "Failed"),
+ ("Running", "Running"),
+ ],
+ help_text="The status of when this SavedQuery last ran.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ (
+ "last_run_at",
+ models.DateTimeField(help_text="The timestamp of this SavedQuery's last run (if any).", null=True),
+ ),
+ ("sync_frequency_interval", models.DurationField(blank=True, default=None, null=True)),
+ ("is_materialized", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_name", models.CharField(blank=True, default=None, max_length=128, null=True)),
+ (
+ "origin",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("data_warehouse", "Data Warehouse"),
+ ("endpoint", "Endpoint"),
+ ("managed_viewset", "Managed Viewset"),
+ ],
+ default=None,
+ help_text="Where this SavedQuery is created.",
+ null=True,
+ ),
+ ),
+ (
+ "is_test",
+ models.BooleanField(
+ default=False, help_text="Whether this view is for testing only and will auto-expire."
+ ),
+ ),
+ (
+ "expires_at",
+ models.DateTimeField(
+ blank=True, help_text="When this test view should be automatically deleted.", null=True
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "managed_viewset",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="saved_queries",
+ to="data_modeling.datawarehousemanagedviewset",
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "semantic_enrichment_hash",
+ models.CharField(
+ blank=True,
+ help_text="Fingerprint of the view definition and column set used to skip AI semantic-description regeneration when nothing relevant changed. Not user-facing.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ (
+ "column_order",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Ordered column names capturing SELECT order (columns jsonb loses key order). Not user-facing.",
+ null=True,
+ ),
+ ),
+ (
+ "incremental_config",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Incremental materialization settings: enabled, incremental_key, unique_key, lookback_seconds. Null means this view is always fully refreshed.",
+ null=True,
+ ),
+ ),
+ (
+ "incremental_state",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Incremental materialization progress: watermark, definition_fingerprint, last_full_refresh_at, last_run_mode. System-written, not user-editable.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datawarehousesavedquery",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "name"), name="posthog_datawarehouse_saved_query_unique_name"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Node",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.TextField(db_index=True, max_length=2048)),
+ (
+ "type",
+ models.TextField(
+ choices=[
+ ("table", "Table"),
+ ("view", "View"),
+ ("matview", "Mat View"),
+ ("endpoint", "Endpoint"),
+ ],
+ default="table",
+ max_length=16,
+ ),
+ ),
+ ("properties", models.JSONField(default=dict)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.PROTECT,
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("description", models.TextField(blank=True, default="", max_length=1024)),
+ (
+ "dag",
+ models.ForeignKey(
+ db_column="dag_fk_id", on_delete=django.db.models.deletion.CASCADE, to="data_modeling.dag"
+ ),
+ ),
+ (
+ "source_control_path",
+ models.TextField(
+ blank=True, default="", help_text="File path in the source control repository for synced nodes"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datamodelingnode",
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("type", "table"), ("saved_query__isnull", False), _connector="OR"),
+ name="saved_query_required_on_non_table_node_type",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("saved_query__isnull", False)),
+ fields=("team", "dag", "saved_query"),
+ name="saved_query_unique_within_team_dag",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("saved_query__isnull", True)),
+ fields=("team", "dag", "name"),
+ name="name_unique_within_team_dag_for_tables",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="GitHubSyncedModel",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("file_path", models.TextField(help_text="Path relative to repo root, e.g. 'models/revenue.sql'")),
+ ("file_sha", models.CharField(help_text="Git blob SHA for change detection", max_length=64)),
+ (
+ "last_synced_sha",
+ models.CharField(help_text="Commit SHA when this model was last synced", max_length=64),
+ ),
+ (
+ "config",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="synced_models",
+ to="data_modeling.githubsyncconfig",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "saved_query",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="github_synced_model",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_datamodelinggithubsyncedmodel",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "file_path"), name="unique_team_file_path")],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseModelPath",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("path", products.data_modeling.backend.models.modeling.LabelTreeField()),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ default=None,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "saved_query",
+ models.ForeignKey(
+ default=None,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datawarehousemodelpath",
+ "indexes": [
+ models.Index(fields=["team_id", "path"], name="team_id_path"),
+ models.Index(fields=["team_id", "saved_query_id"], name="team_id_saved_query_id"),
+ django.contrib.postgres.indexes.GistIndex(models.F("path"), name="model_path_path"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ deferrable=django.db.models.constraints.Deferrable["IMMEDIATE"],
+ fields=("team_id", "path"),
+ name="unique_team_id_path",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataModelingJob",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("Cancelled", "Cancelled"),
+ ("Completed", "Completed"),
+ ("Failed", "Failed"),
+ ("Running", "Running"),
+ ("Skipped", "Skipped"),
+ ],
+ default="Running",
+ max_length=400,
+ ),
+ ),
+ (
+ "engine",
+ models.CharField(
+ choices=[("clickhouse", "ClickHouse"), ("duckgres", "Duckgres")],
+ default="clickhouse",
+ max_length=20,
+ ),
+ ),
+ ("rows_materialized", models.IntegerField(default=0)),
+ ("error", models.TextField(blank=True, null=True)),
+ ("workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("workflow_run_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("parent_workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("last_run_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "rows_expected",
+ models.IntegerField(blank=True, help_text="Total rows expected to be materialized", null=True),
+ ),
+ ("storage_delta_mib", models.FloatField(blank=True, default=0, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("team", models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to="posthog.team")),
+ (
+ "saved_query",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "run_mode",
+ models.CharField(
+ blank=True,
+ choices=[("full_refresh", "Full refresh"), ("incremental", "Incremental")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datamodelingjob",
+ "indexes": [models.Index(fields=["team", "status"], name="datamodelingjob_team_status")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseSavedQueryDraft",
+ 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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("query", models.JSONField(blank=True, default=dict, help_text="HogQL query draft")),
+ ("name", models.CharField(blank=True, help_text="Name of the draft", max_length=255, null=True)),
+ (
+ "edited_history_id",
+ models.CharField(
+ blank=True, help_text="view history id that the draft branched from", max_length=255, null=True
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ blank=True,
+ help_text="Original saved query this draft is editing (optional)",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_datawarehousesavedquerydraft",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseSavedQueryColumnAnnotation",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("column_name", models.CharField(blank=True, default="", max_length=400)),
+ ("description", models.TextField()),
+ (
+ "description_source",
+ models.CharField(
+ choices=[
+ ("canonical", "Canonical"),
+ ("ai_generated", "AI generated"),
+ ("user_edited", "User edited"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("ai_model", models.CharField(blank=True, max_length=128, null=True)),
+ ("is_user_edited", 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,
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="column_annotations",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("saved_query", "column_name"), name="unique_saved_query_column_annotation"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Edge",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("properties", models.JSONField(default=dict)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "source",
+ models.ForeignKey(
+ editable=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="outgoing_edges",
+ to="data_modeling.node",
+ ),
+ ),
+ (
+ "target",
+ models.ForeignKey(
+ editable=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="incoming_edges",
+ to="data_modeling.node",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ (
+ "dag",
+ models.ForeignKey(
+ db_column="dag_fk_id", on_delete=django.db.models.deletion.CASCADE, to="data_modeling.dag"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datamodelingedge",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/data_modeling/backend/migrations/0005_remove_node_name_unique_within_team_dag_and_more.py b/products/data_modeling/backend/migrations/0005_remove_node_name_unique_within_team_dag_and_more.py
index 5d4f7896a113..19af8bea0276 100644
--- a/products/data_modeling/backend/migrations/0005_remove_node_name_unique_within_team_dag_and_more.py
+++ b/products/data_modeling/backend/migrations/0005_remove_node_name_unique_within_team_dag_and_more.py
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("data_warehouse", "0014_mat_view_credential_deletion"),
("data_modeling", "0004_drop_detect_cycles_function"),
]
diff --git a/products/data_modeling/backend/migrations/0022_github_sync_models.py b/products/data_modeling/backend/migrations/0022_github_sync_models.py
index b73a96a60654..766e23ebaf6b 100644
--- a/products/data_modeling/backend/migrations/0022_github_sync_models.py
+++ b/products/data_modeling/backend/migrations/0022_github_sync_models.py
@@ -10,7 +10,6 @@ import posthog.models.utils
class Migration(migrations.Migration):
dependencies = [
("posthog", "1089_ducklake_backfill_populate"),
- ("data_warehouse", "0041_migrate_stripe_job_inputs_to_auth_type"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("data_modeling", "0021_dag_sync_frequency"),
]
diff --git a/products/data_modeling/backend/migrations/0023_migrate_data_modeling_models.py b/products/data_modeling/backend/migrations/0023_migrate_data_modeling_models.py
index b49b727a8c3b..e4717fa1a7d4 100644
--- a/products/data_modeling/backend/migrations/0023_migrate_data_modeling_models.py
+++ b/products/data_modeling/backend/migrations/0023_migrate_data_modeling_models.py
@@ -16,7 +16,6 @@ import products.data_modeling.backend.models.datawarehouse_saved_query
class Migration(migrations.Migration):
dependencies = [
("data_modeling", "0022_github_sync_models"),
- ("data_tools", "0001_migrate_data_tools_models"),
("posthog", "1162_drop_hourly_from_subscription_frequency_choices"),
("warehouse_sources", "0001_migrate_warehouse_sources_models"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
diff --git a/products/data_modeling/backend/migrations/0034_squash_2026_09_07_finalize_fks.py b/products/data_modeling/backend/migrations/0034_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..deda6858641c
--- /dev/null
+++ b/products/data_modeling/backend/migrations/0034_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,30 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="datawarehousesavedquery",
+ name="folder",
+ field=models.ForeignKey(
+ blank=True,
+ help_text="Optional folder used to organize this saved query in the SQL editor sidebar.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="saved_queries",
+ to="data_tools.datawarehousesavedqueryfolder",
+ ),
+ ),
+ ]
diff --git a/products/data_modeling/backend/migrations/0035_squash_2026_09_07_schema_addons.py b/products/data_modeling/backend/migrations/0035_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..a3cbb6abf484
--- /dev/null
+++ b/products/data_modeling/backend/migrations/0035_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,92 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0033_alter_datawarehousesavedquery_status"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_datamodelingedge_dag_fk_id_af85451c" ON "posthog_datamodelingedge" ("dag_fk_id");',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_datamodelingnode_dag_fk_id_a152d589" ON "posthog_datamodelingnode" ("dag_fk_id");',
+ reverse_sql="",
+ ),
+ ]
diff --git a/products/data_modeling/backend/migrations/max_migration.txt b/products/data_modeling/backend/migrations/max_migration.txt
index 0d8b6aa291fa..36e229988fab 100644
--- a/products/data_modeling/backend/migrations/max_migration.txt
+++ b/products/data_modeling/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0033_alter_datawarehousesavedquery_status
+0035_squash_2026_09_07_schema_addons
diff --git a/products/data_quality/backend/migrations/0001_squash_2026_09_07_initial.py b/products/data_quality/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..40cbf2923c40
--- /dev/null
+++ b/products/data_quality/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,538 @@
+# Generated by Django 5.2.17
+
+import django.core.validators
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.data_quality.backend.facade.enums
+import products.data_quality.backend.models.check
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("data_quality", "0001_initial"),
+ ("data_quality", "0002_editable_check_definitions"),
+ ("data_quality", "0003_dataqualitycheck_last_succeeded_at"),
+ ("data_quality", "0004_backfill_last_succeeded_at"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="TeamDataQualityConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "gate_materialization_on_checks",
+ models.BooleanField(
+ default=False,
+ help_text="When true, a materialization whose error-severity checks fail is not published.",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataQualityCheck",
+ 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.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ blank=True,
+ help_text="Optional identifier-safe handle, unique per team when set. Blank means address the check by id.",
+ max_length=128,
+ validators=[
+ django.core.validators.RegexValidator(
+ message="Name must start with a letter and contain only letters, numbers, and underscores.",
+ regex="^[A-Za-z][A-Za-z0-9_]*$",
+ )
+ ],
+ ),
+ ),
+ (
+ "description",
+ models.TextField(blank=True, help_text="Why this check exists and what a failure means."),
+ ),
+ (
+ "subject_type",
+ models.CharField(
+ choices=[("table", "table"), ("view", "view")],
+ help_text="Kind of catalog object being checked: table or view. Kept so orphaned checks stay readable.",
+ max_length=32,
+ ),
+ ),
+ (
+ "subject_name",
+ models.CharField(
+ help_text="Queryable name of the subject, refreshed on every run so renames self-heal.",
+ max_length=400,
+ ),
+ ),
+ (
+ "subject_status",
+ models.CharField(
+ choices=[("active", "active"), ("orphaned", "orphaned")],
+ default=products.data_quality.backend.facade.enums.SubjectStatus["ACTIVE"],
+ help_text="orphaned once the subject stops resolving; orphaned checks are skipped, not deleted.",
+ max_length=32,
+ ),
+ ),
+ (
+ "column_name",
+ models.CharField(
+ blank=True,
+ help_text="Column the check applies to. Blank for table-scoped types like row_count.",
+ max_length=400,
+ ),
+ ),
+ (
+ "check_type",
+ models.CharField(
+ help_text="Which assertion to make. Determines the shape of config.", max_length=32
+ ),
+ ),
+ (
+ "config",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Type-specific configuration, validated against the check type's JSON schema.",
+ ),
+ ),
+ (
+ "severity",
+ models.CharField(
+ choices=[("error", "error"), ("warn", "warn")],
+ default=products.data_quality.backend.facade.enums.CheckSeverity["ERROR"],
+ help_text="error failures mark the subject failing and notify; warn failures only surface.",
+ max_length=16,
+ ),
+ ),
+ (
+ "enabled",
+ models.BooleanField(default=True, help_text="Disabled checks are never run by any trigger."),
+ ),
+ (
+ "tags",
+ models.JSONField(
+ blank=True, default=list, help_text="Free-form labels for grouping and filtering."
+ ),
+ ),
+ ("last_run_at", models.DateTimeField(blank=True, help_text="When the check last executed.", null=True)),
+ (
+ "last_status",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("passed", "passed"),
+ ("failed", "failed"),
+ ("errored", "errored"),
+ ("skipped", "skipped"),
+ ],
+ help_text="Outcome of the newest run, denormalized so health rollups stay a single read.",
+ max_length=16,
+ ),
+ ),
+ (
+ "fingerprint",
+ models.CharField(
+ help_text="sha256 of the canonical subject + type + column + config. The idempotency key for authoring.",
+ max_length=64,
+ ),
+ ),
+ (
+ "created_source",
+ models.CharField(
+ choices=[("user", "user"), ("ai_generated", "ai_generated")],
+ default=products.data_quality.backend.facade.enums.CreatedSource["USER"],
+ help_text="Whether a human or an agent authored this check.",
+ max_length=32,
+ ),
+ ),
+ (
+ "ai_model",
+ models.CharField(
+ blank=True, help_text="Model that generated the check, if AI-authored.", max_length=128
+ ),
+ ),
+ (
+ "confidence",
+ models.FloatField(blank=True, help_text="AI author's confidence in the check, 0-1.", null=True),
+ ),
+ (
+ "reasoning",
+ models.TextField(blank=True, help_text="AI author's reasoning, surfaced as review context."),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "owner",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The human accountable for this check. AI generates, a human owns.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The view or matview this check audits. Exclusive with table.",
+ null=True,
+ on_delete=products.data_quality.backend.models.check.orphan_check_on_subject_delete,
+ related_name="+",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="The warehouse source table this check audits. Exclusive with saved_query.",
+ null=True,
+ on_delete=products.data_quality.backend.models.check.orphan_check_on_subject_delete,
+ related_name="+",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "definition_author",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ help_text="Who last changed what this check asserts. Automated runs authorize as them, falling back to created_by.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "last_succeeded_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the check last passed. Null means it has not passed within the run retention window.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ condition=models.Q(("saved_query__isnull", False)),
+ fields=["team", "saved_query"],
+ name="quality_check_saved_query_idx",
+ ),
+ models.Index(
+ condition=models.Q(("table__isnull", False)),
+ fields=["team", "table"],
+ name="quality_check_table_idx",
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("saved_query__isnull", False), ("table__isnull", False), _negated=True),
+ models.Q(
+ ("saved_query__isnull", False),
+ ("subject_type", products.data_quality.backend.facade.enums.SubjectType["TABLE"]),
+ _negated=True,
+ ),
+ models.Q(
+ ("subject_type", products.data_quality.backend.facade.enums.SubjectType["VIEW"]),
+ ("table__isnull", False),
+ _negated=True,
+ ),
+ ),
+ name="quality_check_subject_binding",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("name", ""), _negated=True),
+ fields=("team", "name"),
+ name="unique_quality_check_name_per_team",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(
+ ("saved_query__isnull", False),
+ models.Q(("deleted", False), ("deleted__isnull", True), _connector="OR"),
+ ),
+ fields=("team", "saved_query", "fingerprint"),
+ name="unique_quality_check_fp_view",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(
+ ("table__isnull", False),
+ models.Q(("deleted", False), ("deleted__isnull", True), _connector="OR"),
+ ),
+ fields=("team", "table", "fingerprint"),
+ name="unique_quality_check_fp_table",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataQualitySuiteRun",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "trigger",
+ models.CharField(
+ choices=[
+ ("manual", "manual"),
+ ("materialization", "materialization"),
+ ("source_sync", "source_sync"),
+ ],
+ help_text="What started this run: manual, materialization, or source_sync.",
+ max_length=32,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("running", "running"),
+ ("completed", "completed"),
+ ("failed", "failed"),
+ ("empty", "empty"),
+ ],
+ default=products.data_quality.backend.facade.enums.SuiteRunStatus["RUNNING"],
+ help_text="empty means the trigger matched no runnable checks, which is not a failure.",
+ max_length=16,
+ ),
+ ),
+ (
+ "subject_type",
+ models.CharField(
+ blank=True,
+ choices=[("table", "table"), ("view", "view")],
+ help_text="Set when the run targets exactly one subject.",
+ max_length=32,
+ ),
+ ),
+ (
+ "subject_uuid",
+ models.UUIDField(blank=True, help_text="Set when the run targets exactly one subject.", null=True),
+ ),
+ ("workflow_id", models.CharField(blank=True, max_length=400)),
+ ("workflow_run_id", models.CharField(blank=True, max_length=400)),
+ (
+ "data_modeling_job_id",
+ models.UUIDField(
+ blank=True, help_text="The materialization job that triggered this run, if any.", null=True
+ ),
+ ),
+ ("checks_passed", models.IntegerField(default=0)),
+ ("checks_failed", models.IntegerField(default=0)),
+ ("checks_errored", models.IntegerField(default=0)),
+ ("checks_skipped", models.IntegerField(default=0)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "error",
+ models.TextField(
+ blank=True, help_text="Why the suite itself failed, as opposed to an individual check."
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "-created_at"], name="data_qualit_team_id_8a05dd_idx"),
+ models.Index(
+ fields=["team", "subject_type", "subject_uuid"], name="data_qualit_team_id_e9c621_idx"
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataQualityCheckRun",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("subject_type", models.CharField(choices=[("table", "table"), ("view", "view")], max_length=32)),
+ ("subject_uuid", models.UUIDField()),
+ ("subject_name", models.CharField(max_length=400)),
+ ("check_type", models.CharField(max_length=32)),
+ ("check_fingerprint", models.CharField(max_length=64)),
+ ("column_name", models.CharField(blank=True, max_length=400)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("passed", "passed"),
+ ("failed", "failed"),
+ ("errored", "errored"),
+ ("skipped", "skipped"),
+ ],
+ max_length=16,
+ ),
+ ),
+ (
+ "failed_row_count",
+ models.BigIntegerField(
+ blank=True, help_text="Rows violating the assertion. 0 is a pass.", null=True
+ ),
+ ),
+ (
+ "observed_value",
+ models.FloatField(
+ blank=True,
+ help_text="The check's headline number (row count, staleness in seconds, ...), kept as a time series.",
+ null=True,
+ ),
+ ),
+ (
+ "compiled_query",
+ models.TextField(
+ blank=True,
+ help_text="HogQL selecting the failing rows. Re-run it to see them. Cleared by retention after 30 days.",
+ ),
+ ),
+ (
+ "error",
+ models.TextField(blank=True, help_text="Compilation or execution failure, for status=errored."),
+ ),
+ ("duration_ms", models.IntegerField(blank=True, null=True)),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "quality_check",
+ models.ForeignKey(
+ blank=True,
+ help_text="The definition executed. Nulled rather than cascaded so history outlives hard deletes.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="runs",
+ to="data_quality.dataqualitycheck",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "suite_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="check_runs",
+ to="data_quality.dataqualitysuiterun",
+ ),
+ ),
+ (
+ "check_config",
+ models.JSONField(
+ blank=True,
+ help_text="Canonical config this run executed. Null for runs recorded before snapshots.",
+ null=True,
+ ),
+ ),
+ (
+ "check_severity",
+ models.CharField(
+ blank=True,
+ choices=[("error", "error"), ("warn", "warn")],
+ help_text="Severity this run was judged at. Null for runs recorded before snapshots.",
+ max_length=16,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["quality_check", "-created_at"], name="data_qualit_quality_6f718b_idx"),
+ models.Index(fields=["team", "created_at"], name="data_qualit_team_id_0f3f54_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/data_tools/backend/migrations/0001_migrate_data_tools_models.py b/products/data_tools/backend/migrations/0001_migrate_data_tools_models.py
index 5b75a184a4ad..846e348201ce 100644
--- a/products/data_tools/backend/migrations/0001_migrate_data_tools_models.py
+++ b/products/data_tools/backend/migrations/0001_migrate_data_tools_models.py
@@ -11,7 +11,6 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- ("data_warehouse", "0053_remove_warehouse_sources_models"),
("posthog", "1162_drop_hourly_from_subscription_frequency_choices"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
diff --git a/products/data_tools/backend/migrations/0001_squash_2026_09_07_initial.py b/products/data_tools/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..646b92f059e4
--- /dev/null
+++ b/products/data_tools/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,205 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("data_tools", "0001_migrate_data_tools_models"),
+ ("data_tools", "0002_migrate_data_modeling_models"),
+ ("data_tools", "0003_datawarehouseexpression"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="DataWarehouseJoin",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("source_table_name", models.CharField(max_length=400)),
+ ("source_table_key", models.CharField(max_length=400)),
+ ("joining_table_name", models.CharField(max_length=400)),
+ ("joining_table_key", models.CharField(max_length=400)),
+ ("field_name", models.CharField(max_length=400)),
+ ("configuration", models.JSONField(default=dict, null=True)),
+ (
+ "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={
+ "db_table": "posthog_datawarehousejoin",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseViewLink",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("table", models.CharField(max_length=128)),
+ ("from_join_key", models.CharField(max_length=400)),
+ ("to_join_key", models.CharField(max_length=400)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to="data_modeling.datawarehousesavedquery"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_datawarehouseviewlink",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseSavedQueryFolder",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ help_text="Display name for the folder used to organize saved queries in the SQL editor sidebar.",
+ max_length=128,
+ ),
+ ),
+ (
+ "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={
+ "db_table": "posthog_datawarehousesavedqueryfolder",
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "name"), name="posthog_datawarehouse_saved_query_folder_unique_name"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="QueryTabState",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "state",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="\n Dict of query tab state for a user. Keys are editorModelsStateKey, activeModelStateKey, activeModelVariablesStateKey\n and values are the state for that key. EditorModelsStateKey is a list of all the editor models for a user.\n ActiveModelStateKey is the active model for a user. ActiveModelVariablesStateKey is the active model variables\n for a user.\n ",
+ null=True,
+ ),
+ ),
+ (
+ "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={
+ "db_table": "posthog_querytabstate",
+ "constraints": [models.UniqueConstraint(fields=("team", "created_by"), name="unique_team_created_by")],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseExpression",
+ fields=[
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("table_name", models.CharField(max_length=400)),
+ ("field_name", models.CharField(max_length=400)),
+ ("expression", models.TextField()),
+ ("connection_id", models.UUIDField(blank=True, null=True)),
+ (
+ "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={
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("deleted__isnull", True), _connector="OR"),
+ fields=("team", "table_name", "field_name", "connection_id"),
+ name="uniq_dw_expression_active_connection",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(
+ models.Q(("deleted", False), ("deleted__isnull", True), _connector="OR"),
+ ("connection_id__isnull", True),
+ ),
+ fields=("team", "table_name", "field_name"),
+ name="uniq_dw_expression_active_default",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ ]
diff --git a/products/data_tools/backend/migrations/max_migration.txt b/products/data_tools/backend/migrations/max_migration.txt
index 91157b9fea63..6903cd5e3dc2 100644
--- a/products/data_tools/backend/migrations/max_migration.txt
+++ b/products/data_tools/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0003_datawarehouseexpression
+0001_squash_2026_09_07_initial
diff --git a/products/data_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py b/products/data_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..59cdc4228064
--- /dev/null
+++ b/products/data_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,121 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("data_warehouse", "0001_migrate_data_warehouse_models"),
+ ("data_warehouse", "0002_cleanup_datawarehouse_contenttypes"),
+ ("data_warehouse", "0003_backfill_partition_format"),
+ ("data_warehouse", "0004_add_saved_query_origin"),
+ ("data_warehouse", "0005_dwh_anchor_time_reset"),
+ ("data_warehouse", "0006_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0007_alter_saved_query_origin_choices"),
+ ("data_warehouse", "0008_backfill_saved_query_origin"),
+ ("data_warehouse", "0009_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0010_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0011_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0012_externaldatasource_description"),
+ ("data_warehouse", "0013_credential_deletion"),
+ ("data_warehouse", "0014_mat_view_credential_deletion"),
+ ("data_warehouse", "0015_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0016_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0017_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0018_fix_orphaned_schemas"),
+ ("data_warehouse", "0019_fix_orphaned_tables"),
+ ("data_warehouse", "0020_migrate_github_job_inputs_to_auth_type"),
+ ("data_warehouse", "0021_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0022_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0023_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0024_alter_datamodelingjob_status"),
+ ("data_warehouse", "0025_datawarehousetable_options"),
+ ("data_warehouse", "0026_externaldatasource_access_method"),
+ ("data_warehouse", "0027_externaldataschema_webhook_fields"),
+ ("data_warehouse", "0028_datawarehousesavedquery_updated_at"),
+ ("data_warehouse", "0029_team_data_warehouse_config"),
+ ("data_warehouse", "0030_externaldataschema_description"),
+ ("data_warehouse", "0031_migrate_5min_to_15min"),
+ ("data_warehouse", "0032_add_engine_to_datamodelingjob"),
+ ("data_warehouse", "0033_datawarehousesavedquery_is_test_expires_at"),
+ ("data_warehouse", "0034_externaldatasource_connection_metadata"),
+ ("data_warehouse", "0035_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0036_externaldataschema_label"),
+ ("data_warehouse", "0037_add_webhook_sync_type"),
+ ("data_warehouse", "0038_migrate_dashboards_models"),
+ ("data_warehouse", "0039_add_parent_workflow_id_to_data_modeling_job"),
+ ("data_warehouse", "0040_saved_query_folders"),
+ ("data_warehouse", "0041_migrate_stripe_job_inputs_to_auth_type"),
+ ("data_warehouse", "0042_alter_externaldataschema_sync_type"),
+ ("data_warehouse", "0043_add_schema_snapshot_to_externaldatajob"),
+ ("data_warehouse", "0044_externaldatajob_pipeline_version_v3"),
+ ("data_warehouse", "0045_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0046_fix_vitally_region_job_inputs"),
+ ("data_warehouse", "0047_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0048_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0049_externaldatasource_created_via"),
+ ("data_warehouse", "0050_alter_externaldataschema_latest_error"),
+ ("data_warehouse", "0051_alter_externaldatasource_source_type"),
+ ("data_warehouse", "0052_externaldataschema_enabled_columns"),
+ ("data_warehouse", "0053_remove_warehouse_sources_models"),
+ ("data_warehouse", "0054_migrate_data_tools_models"),
+ ("data_warehouse", "0055_remove_data_modeling_models"),
+ ("data_warehouse", "0056_remove_data_modeling_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0015_dashboard_customization"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ExternalDataSourceRevenueAnalyticsConfig",
+ fields=[
+ (
+ "external_data_source",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="revenue_analytics_config",
+ serialize=False,
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ ("enabled", models.BooleanField(default=True)),
+ ("include_invoiceless_charges", models.BooleanField(default=True)),
+ ],
+ options={
+ "db_table": "posthog_externaldatasourcerevenueanalyticsconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamDataWarehouseConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "overview_dashboards",
+ models.ManyToManyField(blank=True, related_name="+", to="dashboards.dashboard"),
+ ),
+ ],
+ options={
+ "app_label": "data_warehouse",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/early_access_features/backend/migrations/0001_squash_2026_09_07_initial.py b/products/early_access_features/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..5419be18a492
--- /dev/null
+++ b/products/early_access_features/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,81 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("early_access_features", "0001_initial_migration"),
+ ("early_access_features", "0002_alter_earlyaccessfeature_options_and_more"),
+ ("early_access_features", "0003_fix_contenttype_duplicates"),
+ ("early_access_features", "0004_add_payload_field"),
+ ("early_access_features", "0005_clear_concept_super_groups"),
+ ("early_access_features", "0006_migrate_feature_flags_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("feature_flags", "0014_clean_flag_filters_inert_violations"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="EarlyAccessFeature",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("description", models.TextField(blank=True)),
+ (
+ "stage",
+ models.CharField(
+ choices=[
+ ("draft", "draft"),
+ ("concept", "concept"),
+ ("alpha", "alpha"),
+ ("beta", "beta"),
+ ("general-availability", "general availability"),
+ ("archived", "archived"),
+ ],
+ max_length=40,
+ ),
+ ),
+ ("documentation_url", models.URLField(blank=True, max_length=800)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "feature_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.PROTECT,
+ related_name="features",
+ related_query_name="feature",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="features",
+ related_query_name="feature",
+ to="posthog.team",
+ ),
+ ),
+ ("payload", models.JSONField(blank=True, default=dict)),
+ ],
+ options={
+ "db_table": "posthog_earlyaccessfeature",
+ "indexes": [],
+ "constraints": [],
+ "managed": True,
+ },
+ ),
+ ]
diff --git a/products/endpoints/backend/migrations/0001_squash_2026_09_07_initial.py b/products/endpoints/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..732a97894eb5
--- /dev/null
+++ b/products/endpoints/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,215 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.endpoints.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("endpoints", "0001_initial_migration"),
+ ("endpoints", "0002_endpoint_cache_age_seconds"),
+ ("endpoints", "0003_add_endpoint_materialization"),
+ ("endpoints", "0004_endpoint_current_version_endpointversion_and_more"),
+ ("endpoints", "0005_populate_initial_versions"),
+ ("endpoints", "0006_endpoint_derived_from_insight"),
+ ("endpoints", "0007_fix_hogql_variable_keys"),
+ ("endpoints", "0008_endpoint_last_executed_at"),
+ ("endpoints", "0009_endpointversion_version_fields"),
+ ("endpoints", "0010_populate_endpointversion_fields"),
+ ("endpoints", "0011_make_endpoint_fields_nullable"),
+ ("endpoints", "0012_remove_deprecated_endpoint_fields"),
+ ("endpoints", "0013_add_endpointversion_is_active"),
+ ("endpoints", "0014_endpointversion_columns"),
+ ("endpoints", "0015_endpoint_soft_delete"),
+ ("endpoints", "0016_endpoint_soft_delete_constraint"),
+ ("endpoints", "0017_remove_endpointversion_is_materialized_state"),
+ ("endpoints", "0018_endpointversion_bucket_overrides"),
+ ("endpoints", "0019_backfill_nodes_with_endpoints"),
+ ("endpoints", "0020_backfill_endpoint_edges"),
+ ("endpoints", "0021_add_team_to_endpointversion"),
+ ("endpoints", "0022_backfill_team_id_on_endpointversion"),
+ ("endpoints", "0023_backfill_team_id_on_endpointversion_fix"),
+ ("endpoints", "0024_endpointversion_updated_at"),
+ ("endpoints", "0025_alter_endpoint_created_by"),
+ ("endpoints", "0026_add_data_freshness_seconds"),
+ ("endpoints", "0027_copy_cache_age_to_data_freshness"),
+ ("endpoints", "0028_remove_cache_age_seconds"),
+ ("endpoints", "0029_remove_data_modeling_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("data_modeling", "0031_datamodelingjob_run_mode"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Endpoint",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ help_text="URL-safe name for the endpoint",
+ max_length=128,
+ validators=[products.endpoints.backend.models.validate_endpoint_name],
+ ),
+ ),
+ (
+ "is_active",
+ models.BooleanField(default=True, help_text="Whether this endpoint is available via the API"),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "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")),
+ (
+ "current_version",
+ models.IntegerField(default=1, help_text="Current version number of the endpoint query"),
+ ),
+ (
+ "derived_from_insight",
+ models.CharField(
+ blank=True,
+ help_text="Short ID of the insight this endpoint was created from",
+ max_length=12,
+ null=True,
+ ),
+ ),
+ (
+ "last_executed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When this endpoint was last executed via the run API. Updated with hour granularity.",
+ null=True,
+ ),
+ ),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "is_active"], name="endpoints_e_team_id_89f9b6_idx"),
+ models.Index(fields=["team", "name"], name="endpoints_e_team_id_4a08cd_idx"),
+ models.Index(
+ condition=models.Q(("deleted", False), ("deleted__isnull", True), _connector="OR"),
+ fields=["team", "name"],
+ name="team_id_endpoint_name_active",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EndpointVersion",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("version", models.IntegerField()),
+ ("query", models.JSONField(help_text="Immutable query snapshot")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="endpoint_versions_created",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "endpoint",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="versions", to="endpoints.endpoint"
+ ),
+ ),
+ (
+ "description",
+ models.TextField(
+ blank=True, default="", help_text="Optional description for this endpoint version"
+ ),
+ ),
+ (
+ "saved_query",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ help_text="The underlying materialized view for this version",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="endpoint_versions",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ (
+ "is_active",
+ models.BooleanField(
+ default=True,
+ help_text="Whether this version is available for execution. Inactive versions cannot be run.",
+ ),
+ ),
+ (
+ "columns",
+ models.JSONField(
+ blank=True,
+ help_text="SELECT column names and types. Null means not yet computed; empty list means no columns found.",
+ null=True,
+ ),
+ ),
+ (
+ "bucket_overrides",
+ models.JSONField(
+ blank=True,
+ help_text="Per-column bucket function overrides for range variable materialization. E.g. {'timestamp': 'toStartOfHour'}",
+ null=True,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="Team this version belongs to (denormalized from endpoint for HogQL system table access)",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "data_freshness_seconds",
+ models.IntegerField(
+ default=86400,
+ help_text="How fresh the data should be, in seconds. Controls cache TTL and materialization sync frequency.",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "endpoints_endpointversion",
+ "ordering": ["-version"],
+ "indexes": [
+ models.Index(fields=["endpoint", "version"], name="endpoint_version_idx"),
+ models.Index(fields=["endpoint", "-version"], name="endpoint_version_desc_idx"),
+ models.Index(fields=["created_at"], name="endpoint_version_created_idx"),
+ models.Index(fields=["saved_query"], name="endpointvers_saved_q_0dc3_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("endpoint", "version"), name="unique_endpoint_version")
+ ],
+ },
+ ),
+ ]
diff --git a/products/endpoints/backend/migrations/0003_add_endpoint_materialization.py b/products/endpoints/backend/migrations/0003_add_endpoint_materialization.py
index e70a430a5422..1f3aeb699327 100644
--- a/products/endpoints/backend/migrations/0003_add_endpoint_materialization.py
+++ b/products/endpoints/backend/migrations/0003_add_endpoint_materialization.py
@@ -5,7 +5,9 @@ from django.db import migrations, models
class Migration(migrations.Migration):
- dependencies = [("endpoints", "0002_endpoint_cache_age_seconds"), ("data_warehouse", "0004_add_saved_query_origin")]
+ dependencies = [
+ ("endpoints", "0002_endpoint_cache_age_seconds"),
+ ]
operations = [
migrations.AddField(
diff --git a/products/endpoints/backend/migrations/0009_endpointversion_version_fields.py b/products/endpoints/backend/migrations/0009_endpointversion_version_fields.py
index f7fb04414994..a29a72a8e8b1 100644
--- a/products/endpoints/backend/migrations/0009_endpointversion_version_fields.py
+++ b/products/endpoints/backend/migrations/0009_endpointversion_version_fields.py
@@ -7,7 +7,6 @@ class Migration(migrations.Migration):
atomic = False # Required for AddIndexConcurrently
dependencies = [
- ("data_warehouse", "0014_mat_view_credential_deletion"),
("endpoints", "0008_endpoint_last_executed_at"),
]
diff --git a/products/endpoints/backend/migrations/0011_make_endpoint_fields_nullable.py b/products/endpoints/backend/migrations/0011_make_endpoint_fields_nullable.py
index fade3ed3f0c3..7b12dcd45341 100644
--- a/products/endpoints/backend/migrations/0011_make_endpoint_fields_nullable.py
+++ b/products/endpoints/backend/migrations/0011_make_endpoint_fields_nullable.py
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("data_warehouse", "0014_mat_view_credential_deletion"),
("endpoints", "0010_populate_endpointversion_fields"),
]
diff --git a/products/error_tracking/backend/migrations/0001_squash_2026_09_07_initial.py b/products/error_tracking/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..baa5897df622
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,714 @@
+# Generated by Django 5.2.17
+
+from decimal import Decimal
+
+import django.core.validators
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("error_tracking", "0001_migrate_error_tracking_models"),
+ ("error_tracking", "0002_issue_cohort_reference"),
+ ("error_tracking", "0003_frame_part_field"),
+ ("error_tracking", "0004_frame_part_index"),
+ ("error_tracking", "0005_frame_part_constraint"),
+ ("error_tracking", "0006_frame_idx_removal"),
+ ("error_tracking", "0007_auto_capture_controls"),
+ ("error_tracking", "0008_spike_detection_config"),
+ ("error_tracking", "0009_errortrackingissueassignment_team"),
+ ("error_tracking", "0010_backfill_errortrackingissueassignment_team"),
+ ("error_tracking", "0011_errortrackingissueassignment_team_id_idx"),
+ ("error_tracking", "0012_suppression_rule_bytecode_and_sampling_rate"),
+ ("error_tracking", "0013_spike_events"),
+ ("error_tracking", "0014_recommendation"),
+ ("error_tracking", "0015_errortrackingsettings"),
+ ("error_tracking", "0016_errortrackingrecommendation_status"),
+ ("error_tracking", "0017_migrate_cohorts_models"),
+ ("error_tracking", "0018_symbolset_last_used_created_idx"),
+ ("error_tracking", "0019_errortrackingbypassrule"),
+ ("error_tracking", "0020_errortrackingsettings_autocapture_exceptions_opt_in"),
+ ("error_tracking", "0021_remove_errortrackingsettings_autocapture_exceptions_opt_in"),
+ ("error_tracking", "0022_drop_redundant_symbolset_team_ref_idx"),
+ ("error_tracking", "0023_symbolset_autovacuum_scale_factor"),
+ ("error_tracking", "0024_errortrackingissue_severity"),
+ ("error_tracking", "0025_issue_state_updated_at"),
+ ("error_tracking", "0026_issue_state_updated_at_index"),
+ ("error_tracking", "0027_add_severity_rules"),
+ ("error_tracking", "0028_add_symbol_set_cleanup_bucket_index"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("cohorts", "0009_cohort_backfill_per_kind_uniqueness"),
+ ("ee", "0059_scimprovisioneduser_unique_config"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ErrorTrackingGroup",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("fingerprint", django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), size=None)),
+ (
+ "merged_fingerprints",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), size=None),
+ default=list,
+ size=None,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("archived", "Archived"),
+ ("active", "Active"),
+ ("resolved", "Resolved"),
+ ("pending_release", "Pending release"),
+ ],
+ default="active",
+ max_length=40,
+ ),
+ ),
+ (
+ "assignee",
+ 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={
+ "db_table": "posthog_errortrackinggroup",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingIssue",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "status",
+ models.TextField(
+ choices=[
+ ("archived", "Archived"),
+ ("active", "Active"),
+ ("resolved", "Resolved"),
+ ("pending_release", "Pending release"),
+ ("suppressed", "Suppressed"),
+ ],
+ default="active",
+ ),
+ ),
+ ("name", models.TextField(blank=True, null=True)),
+ ("description", models.TextField(blank=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "severity",
+ models.TextField(
+ choices=[("low", "Low"), ("medium", "Medium"), ("high", "High"), ("critical", "Critical")],
+ default=None,
+ null=True,
+ ),
+ ),
+ ("state_updated_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingissue",
+ "indexes": [
+ models.Index(
+ condition=models.Q(("state_updated_at__isnull", False)),
+ fields=["team", "-state_updated_at"],
+ name="et_issue_team_state_idx",
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingRelease",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("hash_id", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("version", models.TextField()),
+ ("project", models.TextField()),
+ ("metadata", models.JSONField(null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_errortrackingrelease",
+ "indexes": [models.Index(fields=["team_id", "hash_id"], name="posthog_err_team_id_e9f6b2_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "hash_id"), name="unique_release_hash_id_per_team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSuppressionRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filters", models.JSONField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("order_key", models.IntegerField()),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("disabled_data", models.JSONField(blank=True, null=True)),
+ ("sampling_rate", models.FloatField(default=1.0)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingsuppressionrule",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_err_team_id_503a5b_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingGroupingRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("bytecode", models.JSONField()),
+ ("filters", models.JSONField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("disabled_data", models.JSONField(blank=True, null=True)),
+ ("order_key", models.IntegerField()),
+ ("description", models.TextField(null=True)),
+ ("role", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="ee.role")),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "user_group",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.usergroup"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackinggroupingrule",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_err_team_id_bf614f_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingAssignmentRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("order_key", models.IntegerField()),
+ ("bytecode", models.JSONField()),
+ ("filters", models.JSONField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("disabled_data", models.JSONField(blank=True, null=True)),
+ ("role", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="ee.role")),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "user_group",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.usergroup"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingassignmentrule",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_err_team_id_9da78b_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingAutoCaptureControls",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("library", models.CharField(choices=[("web", "Web")], default="web", max_length=24)),
+ (
+ "match_type",
+ models.CharField(choices=[("all", "All"), ("any", "Any")], default="all", max_length=24),
+ ),
+ (
+ "sample_rate",
+ models.DecimalField(
+ decimal_places=2,
+ default=Decimal("1"),
+ max_digits=3,
+ validators=[
+ django.core.validators.MinValueValidator(Decimal("0")),
+ django.core.validators.MaxValueValidator(Decimal("1")),
+ ],
+ ),
+ ),
+ ("linked_feature_flag", models.JSONField(blank=True, null=True)),
+ (
+ "event_triggers",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "url_triggers",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.JSONField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "url_blocklist",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.JSONField(blank=True, null=True),
+ blank=True,
+ default=list,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_errortrackingautocapturecontrols",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_err_team_id_eed4d1_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "library"), name="unique_controls_per_team_library")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSpikeDetectionConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="error_tracking_spike_detection_config",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("snooze_duration_minutes", models.IntegerField(default=10)),
+ ("multiplier", models.IntegerField(default=10)),
+ ("threshold", models.IntegerField(default=500)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingspikedetectionconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingRecommendation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("type", models.CharField(max_length=64)),
+ ("meta", models.JSONField(blank=True, default=dict)),
+ ("computed_at", models.DateTimeField(blank=True, null=True)),
+ ("dismissed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="error_tracking_recommendations",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("ready", "Ready"), ("computing", "Computing")], default="ready", max_length=16
+ ),
+ ),
+ ("status_changed_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingrecommendation",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "type"), name="unique_error_tracking_recommendation_per_team_type"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSettings",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="error_tracking_settings",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("project_rate_limit_value", models.IntegerField(blank=True, null=True)),
+ ("project_rate_limit_bucket_size_minutes", models.IntegerField(blank=True, null=True)),
+ ("per_issue_rate_limit_value", models.IntegerField(blank=True, null=True)),
+ ("per_issue_rate_limit_bucket_size_minutes", models.IntegerField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingsettings",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingBypassRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filters", models.JSONField()),
+ ("bytecode", models.JSONField(blank=True, null=True)),
+ ("disabled_data", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("order_key", models.IntegerField()),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingbypassrule",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_err_team_id_ba5150_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSeverityRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("filters", models.JSONField()),
+ ("bytecode", models.JSONField()),
+ (
+ "severity",
+ models.TextField(
+ choices=[("low", "Low"), ("medium", "Medium"), ("high", "High"), ("critical", "Critical")]
+ ),
+ ),
+ ("order_key", models.IntegerField()),
+ ("disabled_data", models.JSONField(blank=True, null=True)),
+ ("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"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingseverityrule",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingIssueFingerprint",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("fingerprint", models.TextField()),
+ ("version", models.BigIntegerField(blank=True, default=0)),
+ (
+ "issue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to="error_tracking.errortrackinggroup"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingissuefingerprint",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "fingerprint"), name="unique fingerprint for team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingIssueFingerprintV2",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("fingerprint", models.TextField()),
+ ("version", models.BigIntegerField(blank=True, default=0)),
+ ("first_seen", models.DateTimeField(auto_now_add=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "issue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="fingerprints",
+ to="error_tracking.errortrackingissue",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_errortrackingissuefingerprintv2",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "fingerprint"), name="unique_fingerprint_for_team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingIssueAssignment",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "issue",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="assignment",
+ to="error_tracking.errortrackingissue",
+ ),
+ ),
+ ("role", models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="ee.role")),
+ (
+ "user",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "user_group",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.usergroup"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_index=False, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingissueassignment",
+ "indexes": [models.Index(fields=["team_id"], name="posthog_et_assignment_team_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingExternalReference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("provider", models.TextField(null=True)),
+ ("external_id", models.TextField(null=True)),
+ ("external_context", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "integration",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.integration"),
+ ),
+ (
+ "issue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="external_issues",
+ related_query_name="external_issue",
+ to="error_tracking.errortrackingissue",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingexternalreference",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingIssueCohort",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("cohort", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="cohorts.cohort")),
+ (
+ "issue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="cohorts",
+ to="error_tracking.errortrackingissue",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_errortrackingissuecohort",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("issue",), name="unique_cohort_for_issue")],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSpikeEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("detected_at", models.DateTimeField()),
+ ("computed_baseline", models.FloatField()),
+ ("current_bucket_value", models.IntegerField()),
+ (
+ "issue",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="spike_events",
+ to="error_tracking.errortrackingissue",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_errortrackingspikeevent",
+ "indexes": [
+ models.Index(fields=["team", "-detected_at"], name="posthog_err_team_id_dbaf85_idx"),
+ models.Index(fields=["issue", "-detected_at"], name="posthog_err_issue_i_7c3037_idx"),
+ models.Index(fields=["-detected_at"], name="posthog_err_detecte_14b72d_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingSymbolSet",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("ref", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("storage_ptr", models.TextField(null=True)),
+ ("failure_reason", models.TextField(blank=True, null=True)),
+ ("content_hash", models.TextField(null=True)),
+ ("last_used", models.DateTimeField(blank=True, null=True)),
+ (
+ "release",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="error_tracking.errortrackingrelease"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_errortrackingsymbolset",
+ "indexes": [
+ models.Index(fields=["last_used", "created_at"], name="et_symset_used_created_idx"),
+ models.Index(
+ models.Func(
+ models.Func(models.F("id"), function="uuid_send", output_field=models.BinaryField()),
+ models.Value(15),
+ function="get_byte",
+ output_field=models.IntegerField(),
+ ),
+ models.F("last_used"),
+ models.F("created_at"),
+ models.F("id"),
+ name="et_symset_bucket_cleanup_idx",
+ ),
+ ],
+ "constraints": [models.UniqueConstraint(fields=("team_id", "ref"), name="unique_ref_per_team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="ErrorTrackingStackFrame",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("raw_id", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("contents", models.JSONField()),
+ ("resolved", models.BooleanField()),
+ ("context", models.JSONField(blank=True, null=True)),
+ (
+ "symbol_set",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="error_tracking.errortrackingsymbolset",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("part", models.IntegerField(default=0)),
+ ],
+ options={
+ "db_table": "posthog_errortrackingstackframe",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "raw_id", "part"), name="unique_team_id_raw_id_part")
+ ],
+ },
+ ),
+ ]
diff --git a/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py b/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..58447e0d19ad
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,88 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0031_errortrackingalert_errortrackingalertdestination_and_more"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "idx_team_id_raw_id_part" ON "posthog_errortrackingstackframe" ("team_id", "raw_id", "part");\n ',
+ reverse_sql="",
+ ),
+ ]
diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txt
index ff779ffb15bc..a04bc7b07031 100644
--- a/products/error_tracking/backend/migrations/max_migration.txt
+++ b/products/error_tracking/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0031_errortrackingalert_errortrackingalertdestination_and_more
+0033_squash_2026_09_07_schema_addons
diff --git a/products/event_definitions/backend/migrations/0001_squash_2026_09_07_initial.py b/products/event_definitions/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..93bc56abc9c9
--- /dev/null
+++ b/products/event_definitions/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,367 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+import django.contrib.postgres.indexes
+import django.db.models.functions.comparison
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.models.utils
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("event_definitions", "0001_initial"),
+ ("event_definitions", "0002_schemapropertygroupproperty_is_optional_in_types"),
+ ("event_definitions", "0003_eventdefinition_promoted_property"),
+ ("event_definitions", "0004_eventdefinition_team_name_idx"),
+ ("event_definitions", "0005_eventdefinition_rename_promoted_to_primary"),
+ ("event_definitions", "0006_drop_eventproperty_team_property_bloated_idx"),
+ ("event_definitions", "0007_drop_eventproperty_team_id_fk_idx"),
+ ("event_definitions", "0008_drop_eventproperty_proj_property_coalesce_idx"),
+ ("event_definitions", "0009_drop_eventproperty_proj_event_coalesce_idx"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="EventDefinition",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now, null=True)),
+ ("last_seen_at", models.DateTimeField(default=None, null=True)),
+ ("query_usage_30_day", models.IntegerField(default=None, null=True)),
+ ("volume_30_day", models.IntegerField(default=None, null=True)),
+ (
+ "enforcement_mode",
+ models.CharField(
+ choices=[("allow", "Allow"), ("reject", "Reject")], default="allow", max_length=10
+ ),
+ ),
+ (
+ "project",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="event_definitions",
+ related_query_name="team",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "primary_property",
+ models.CharField(blank=True, db_column="promoted_property", max_length=400, null=True),
+ ),
+ ],
+ options={
+ "db_table": "posthog_eventdefinition",
+ "indexes": [
+ models.Index(fields=["project"], name="posthog_eve_proj_id_f93fcbb0"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["name"], name="index_event_definition_name", opclasses=["gin_trgm_ops"]
+ ),
+ models.Index(
+ condition=models.Q(("enforcement_mode", "reject")),
+ fields=["team_id"],
+ name="posthog_eventdef_enforce_idx",
+ ),
+ models.Index(fields=["team_id", "name"], name="posthog_eventdef_team_name_idx"),
+ ],
+ "constraints": [
+ posthog.models.utils.UniqueConstraintByExpression(
+ concurrently=True,
+ expression="(coalesce(project_id, team_id), name)",
+ name="event_definition_proj_uniq",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SchemaPropertyGroup",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="created_schema_property_groups",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "project",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="schema_property_groups",
+ related_query_name="schema_property_group",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_schemapropertygroup",
+ "indexes": [models.Index(fields=["team", "name"], name="schema_pg_team_name_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="unique_schema_property_group_team_name")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="PropertyDefinition",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("is_numerical", models.BooleanField(default=False)),
+ (
+ "property_type",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("DateTime", "DateTime"),
+ ("String", "String"),
+ ("Numeric", "Numeric"),
+ ("Boolean", "Boolean"),
+ ("Duration", "Duration"),
+ ],
+ max_length=50,
+ null=True,
+ ),
+ ),
+ (
+ "type",
+ models.PositiveSmallIntegerField(
+ choices=[(1, "event"), (2, "person"), (3, "group"), (4, "session")], default=1
+ ),
+ ),
+ ("group_type_index", models.PositiveSmallIntegerField(null=True)),
+ (
+ "property_type_format",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("unix_timestamp", "Unix Timestamp in seconds"),
+ ("unix_timestamp_milliseconds", "Unix Timestamp in milliseconds"),
+ ("YYYY-MM-DDThh:mm:ssZ", "YYYY-MM-DDThh:mm:ssZ"),
+ ("YYYY-MM-DD hh:mm:ss", "YYYY-MM-DD hh:mm:ss"),
+ ("DD-MM-YYYY hh:mm:ss", "DD-MM-YYYY hh:mm:ss"),
+ ("YYYY-MM-DD", "YYYY-MM-DD"),
+ ("rfc_822", "day, DD MMM YYYY hh:mm:ss TZ"),
+ ("YYYY/MM/DD hh:mm:ss", "YYYY/MM/DD hh:mm:ss"),
+ ("DD/MM/YYYY hh:mm:ss", "DD/MM/YYYY hh:mm:ss"),
+ ],
+ max_length=50,
+ null=True,
+ ),
+ ),
+ ("volume_30_day", models.IntegerField(default=None, null=True)),
+ ("query_usage_30_day", models.IntegerField(default=None, null=True)),
+ (
+ "project",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="property_definitions",
+ related_query_name="team",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_propertydefinition",
+ "indexes": [
+ models.Index(fields=["project"], name="posthog_prop_proj_id_d3eb982d"),
+ models.Index(
+ models.F("team_id"),
+ models.F("type"),
+ django.db.models.functions.comparison.Coalesce(models.F("group_type_index"), -1),
+ models.OrderBy(models.F("query_usage_30_day"), descending=True, nulls_last=True),
+ models.OrderBy(models.F("name")),
+ name="index_property_def_query",
+ ),
+ models.Index(
+ django.db.models.functions.comparison.Coalesce(models.F("project_id"), models.F("team_id")),
+ models.F("type"),
+ django.db.models.functions.comparison.Coalesce(models.F("group_type_index"), -1),
+ models.OrderBy(models.F("query_usage_30_day"), descending=True, nulls_last=True),
+ models.OrderBy(models.F("name")),
+ name="index_property_def_query_proj",
+ ),
+ models.Index(fields=["team_id", "type", "is_numerical"], name="posthog_pro_team_id_eac36d_idx"),
+ models.Index(
+ django.db.models.functions.comparison.Coalesce(models.F("project_id"), models.F("team_id")),
+ models.F("type"),
+ models.F("is_numerical"),
+ name="posthog_pro_project_3583d2_idx",
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["name"], name="index_property_definition_name", opclasses=["gin_trgm_ops"]
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("property_type__in", ["DateTime", "String", "Numeric", "Boolean", "Duration"])
+ ),
+ name="property_type_is_valid",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("type", 3), _negated=True), ("group_type_index__isnull", False), _connector="OR"
+ ),
+ name="group_type_index_set",
+ ),
+ posthog.models.utils.UniqueConstraintByExpression(
+ concurrently=True,
+ expression="(coalesce(project_id, team_id), name, type, coalesce(group_type_index, -1))",
+ name="posthog_propdef_proj_uniq",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EventProperty",
+ fields=[
+ ("id", models.BigAutoField(primary_key=True, serialize=False)),
+ ("event", models.CharField(max_length=400)),
+ ("property", models.CharField(max_length=400)),
+ (
+ "project",
+ models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.project"),
+ ),
+ (
+ "team",
+ models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_eventproperty",
+ "indexes": [
+ models.Index(fields=["project"], name="posthog_eve_proj_id_dd2337d2"),
+ models.Index(fields=["team", "event"], name="posthog_eve_team_id_22de03_idx"),
+ ],
+ "constraints": [
+ posthog.models.utils.UniqueConstraintByExpression(
+ concurrently=True,
+ expression="(coalesce(project_id, team_id), event, property)",
+ name="posthog_event_property_unique_proj_event_property",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="EventSchema",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "event_definition",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="schemas",
+ related_query_name="schema",
+ to="event_definitions.eventdefinition",
+ ),
+ ),
+ (
+ "property_group",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="event_schemas",
+ related_query_name="event_schema",
+ to="event_definitions.schemapropertygroup",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_eventschema",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("event_definition", "property_group"), name="unique_event_schema")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SchemaPropertyGroupProperty",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ (
+ "property_type",
+ models.CharField(
+ choices=[
+ ("DateTime", "DateTime"),
+ ("String", "String"),
+ ("Numeric", "Numeric"),
+ ("Boolean", "Boolean"),
+ ("Object", "Object"),
+ ],
+ max_length=50,
+ ),
+ ),
+ ("is_required", models.BooleanField(default=False)),
+ ("description", models.TextField(blank=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "property_group",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="properties",
+ related_query_name="property",
+ to="event_definitions.schemapropertygroup",
+ ),
+ ),
+ ("is_optional_in_types", models.BooleanField(default=False)),
+ ],
+ options={
+ "db_table": "posthog_schemapropertygroupproperty",
+ "ordering": ["name"],
+ "indexes": [models.Index(fields=["property_group", "name"], name="schema_pgp_group_name_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("property_group", "name"), name="unique_property_group_property_name"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/0001_squash_2026_09_07_initial.py b/products/experiments/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..878ed09f839d
--- /dev/null
+++ b/products/experiments/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,524 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.core.validators
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("experiments", "0001_migrate_experiments_models"),
+ ("experiments", "0002_experiment_only_count_matured_users"),
+ ("experiments", "0003_migrate_only_count_matured_users_to_experiment"),
+ ("experiments", "0004_team_experiments_config"),
+ ("experiments", "0005_copy_team_experiment_fields"),
+ ("experiments", "0006_add_experiment_precomputation_enabled"),
+ ("experiments", "0007_drop_exposure_preaggregation_enabled"),
+ ("experiments", "0008_drop_exposure_preaggregation_column"),
+ ("experiments", "0009_increase_experiment_description_max_length"),
+ ("experiments", "0010_teamexperimentsconfig_default_only_count_matured_users"),
+ ("experiments", "0011_teamexperimentsconfig_funnel_steps_data_disabled"),
+ ("experiments", "0012_teamexperimentsconfig_default_cuped_enabled"),
+ ("experiments", "0013_teamexperimentsconfig_default_minimum_detectable_effect"),
+ ("experiments", "0014_teamexperimentsconfig_default_cuped_lookback_days"),
+ ("experiments", "0015_migrate_feature_flags_models"),
+ ("experiments", "0016_teamexperimentsconfig_default_sequential_testing_enabled_and_more"),
+ ("experiments", "0017_experimentmetricsrecalculation"),
+ ("experiments", "0018_migrate_cohorts_models"),
+ ("experiments", "0019_experiment_running_time_calculation"),
+ ("experiments", "0020_backfill_running_time_calculation"),
+ ("experiments", "0021_alter_experimentmetricsrecalculation_trigger"),
+ ("experiments", "0022_experiment_feature_flag_auto_archived"),
+ ("experiments", "0023_experiment_excluded_variants"),
+ ("experiments", "0024_backfill_excluded_variants"),
+ ("experiments", "0025_remove_teamexperimentsconfig_funnel_steps_data_disabled"),
+ ("experiments", "0026_strip_feature_flag_config_from_parameters"),
+ ("experiments", "0027_experiment_flag_cleanup_task_id"),
+ ("experiments", "0028_experimentmetricsrecalculation_metric_retries"),
+ ("experiments", "0029_experiment_repository"),
+ ("experiments", "0030_alter_experimentmetricsrecalculation_trigger"),
+ ("experiments", "0031_add_experiment_version"),
+ ("experiments", "0032_teamexperimentsconfig_flag_cleanup_repository"),
+ ("experiments", "0033_teamexperimentsconfig_precomputation_enabled_set_by"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("cohorts", "0009_cohort_backfill_per_kind_uniqueness"),
+ ("feature_flags", "0014_clean_flag_filters_inert_violations"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ExperimentHoldout",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.CharField(blank=True, max_length=400, null=True)),
+ ("filters", models.JSONField(default=list)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ 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={
+ "db_table": "posthog_experimentholdout",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExperimentSavedMetric",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.CharField(blank=True, max_length=400, null=True)),
+ ("query", models.JSONField()),
+ ("metadata", models.JSONField(blank=True, default=dict, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ 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={
+ "db_table": "posthog_experimentsavedmetric",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamExperimentsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "experiment_recalculation_time",
+ models.TimeField(
+ blank=True,
+ help_text="Time of day (UTC) when experiment metrics should be recalculated. If not set, uses the default recalculation time.",
+ null=True,
+ ),
+ ),
+ (
+ "default_experiment_confidence_level",
+ models.DecimalField(
+ blank=True,
+ decimal_places=2,
+ help_text="Default confidence level for new experiments in this environment. Valid values: 0.90, 0.95, 0.99.",
+ max_digits=3,
+ null=True,
+ ),
+ ),
+ (
+ "default_experiment_stats_method",
+ models.CharField(
+ blank=True,
+ choices=[("bayesian", "Bayesian"), ("frequentist", "Frequentist")],
+ default="bayesian",
+ help_text="Default statistical method for new experiments in this environment.",
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "experiment_precomputation_enabled",
+ models.BooleanField(
+ default=False,
+ help_text="Whether to precompute experiment exposure data for faster query execution.",
+ ),
+ ),
+ (
+ "default_only_count_matured_users",
+ models.BooleanField(
+ default=False,
+ help_text="Default value for 'only count matured users' on new experiments in this environment.",
+ ),
+ ),
+ (
+ "default_cuped_enabled",
+ models.BooleanField(
+ default=False,
+ help_text="Default for enabling CUPED variance reduction on experiment metrics. Overridden by the experiment-level `stats_config.cuped.enabled` setting when set.",
+ ),
+ ),
+ (
+ "default_minimum_detectable_effect",
+ models.PositiveSmallIntegerField(
+ blank=True,
+ help_text="Default minimum detectable effect (MDE) percentage for new experiments in this environment. Valid values: 1-100. MDE is the smallest effect size you want to be able to detect with statistical significance. Lower values require more data and longer run times.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(100),
+ ],
+ ),
+ ),
+ (
+ "default_cuped_lookback_days",
+ models.PositiveSmallIntegerField(
+ blank=True,
+ help_text="Default lookback window (in days) for CUPED variance reduction. Overridden by the experiment-level `stats_config.cuped.lookback_days` setting when set. Must be between 1 and 30 days.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(30),
+ ],
+ ),
+ ),
+ (
+ "default_sequential_testing_enabled",
+ models.BooleanField(
+ default=False,
+ help_text="Default for enabling sequential testing (always-valid p-values) on new experiments. Overridden by the experiment-level `stats_config.frequentist.sequential_testing_enabled` setting when set. Only applies to the frequentist statistical method.",
+ ),
+ ),
+ (
+ "default_sequential_tuning_parameter",
+ models.PositiveIntegerField(
+ blank=True,
+ help_text="Default tuning parameter for sequential testing. Roughly the sample size at which the confidence sequence is tightest. Overridden by the experiment-level `stats_config.frequentist.sequential_tuning_parameter` setting when set.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(1000000000),
+ ],
+ ),
+ ),
+ (
+ "flag_cleanup_repository",
+ models.CharField(
+ blank=True,
+ help_text="Default GitHub repository (organization/repository) for experiment flag-cleanup PRs in this environment. Used when an experiment has no repository of its own. It must belong to the team's GitHub installation at cleanup time or it is ignored.",
+ max_length=255,
+ null=True,
+ ),
+ ),
+ (
+ "precomputation_enabled_set_by",
+ models.CharField(
+ blank=True,
+ choices=[("manual", "Manual"), ("auto", "Auto")],
+ help_text="Who last set experiment_precomputation_enabled: a human (manual) or the auto-enrollment job (auto). Null means never set. The job only writes when this is null or auto, so a manual change in either direction sticks.",
+ max_length=10,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Experiment",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.CharField(blank=True, max_length=3000, null=True)),
+ ("filters", models.JSONField(blank=True, default=dict)),
+ ("parameters", models.JSONField(default=dict, null=True)),
+ ("secondary_metrics", models.JSONField(blank=True, default=list, null=True)),
+ ("start_date", models.DateTimeField(blank=True, null=True)),
+ ("end_date", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("archived", models.BooleanField(default=False)),
+ ("deleted", models.BooleanField(default=False, null=True)),
+ (
+ "type",
+ models.CharField(
+ blank=True,
+ choices=[("web", "web"), ("product", "product")],
+ default="product",
+ max_length=40,
+ null=True,
+ ),
+ ),
+ ("variants", models.JSONField(blank=True, default=dict, null=True)),
+ ("exposure_criteria", models.JSONField(blank=True, default=dict, null=True)),
+ ("metrics", models.JSONField(blank=True, default=list, null=True)),
+ ("metrics_secondary", models.JSONField(blank=True, default=list, null=True)),
+ ("primary_metrics_ordered_uuids", models.JSONField(blank=True, default=None, null=True)),
+ ("secondary_metrics_ordered_uuids", models.JSONField(blank=True, default=None, null=True)),
+ ("stats_config", models.JSONField(blank=True, default=dict, null=True)),
+ ("scheduling_config", models.JSONField(blank=True, default=dict, null=True)),
+ (
+ "status",
+ models.CharField(
+ blank=True,
+ choices=[("draft", "Draft"), ("running", "Running"), ("stopped", "Stopped")],
+ default=None,
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "conclusion",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("won", "Won"),
+ ("lost", "Lost"),
+ ("inconclusive", "Inconclusive"),
+ ("stopped_early", "Stopped Early"),
+ ("invalid", "Invalid"),
+ ],
+ max_length=30,
+ null=True,
+ ),
+ ),
+ ("conclusion_comment", models.TextField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "exposure_cohort",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="cohorts.cohort"
+ ),
+ ),
+ (
+ "feature_flag",
+ models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to="feature_flags.featureflag"),
+ ),
+ (
+ "holdout",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="experiments.experimentholdout",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("only_count_matured_users", models.BooleanField(default=False)),
+ ("running_time_calculation", models.JSONField(blank=True, default=dict, null=True)),
+ ("feature_flag_auto_archived", models.BooleanField(db_default=False, default=False)),
+ (
+ "excluded_variants",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, null=True, size=None
+ ),
+ ),
+ ("flag_cleanup_task_id", models.UUIDField(blank=True, null=True)),
+ ("repository", models.CharField(blank=True, max_length=255, null=True)),
+ ("version", models.IntegerField(blank=True, default=0, null=True)),
+ ],
+ options={
+ "db_table": "posthog_experiment",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExperimentToSavedMetric",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("metadata", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "experiment",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="experiments.experiment"),
+ ),
+ (
+ "saved_metric",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to="experiments.experimentsavedmetric"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_experimenttosavedmetric",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExperimentMetricResult",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("metric_uuid", models.CharField(max_length=255)),
+ ("fingerprint", models.CharField(blank=True, max_length=64, null=True)),
+ ("query_from", models.DateTimeField()),
+ ("query_to", models.DateTimeField()),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "Pending"), ("completed", "Completed"), ("failed", "Failed")],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("result", models.JSONField(blank=True, default=None, null=True)),
+ ("query_id", models.CharField(blank=True, max_length=255, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "experiment",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="experiments.experiment"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_experimentmetricresult",
+ "indexes": [
+ models.Index(
+ fields=["experiment", "metric_uuid", "query_to"], name="posthog_exp_experim_b5f6d4_idx"
+ )
+ ],
+ "constraints": [],
+ "unique_together": {("experiment", "metric_uuid", "query_to")},
+ },
+ ),
+ migrations.CreateModel(
+ name="WebExperiment",
+ fields=[],
+ options={
+ "proxy": True,
+ "indexes": [],
+ "constraints": [],
+ },
+ bases=("experiments.experiment", models.Model),
+ ),
+ migrations.CreateModel(
+ name="ExperimentTimeseriesRecalculation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("metric", models.JSONField()),
+ ("fingerprint", models.CharField(max_length=64)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("in_progress", "In Progress"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("last_successful_date", models.DateField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "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_experimenttimeseriesrecalculation",
+ "indexes": [models.Index(fields=["status"], name="posthog_exp_status_01657f_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("status__in", ["pending", "in_progress"])),
+ fields=("experiment", "fingerprint"),
+ name="unique_active_recalculation_per_experiment_metric",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExperimentMetricsRecalculation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.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"),
+ ("agent_mcp", "Agent (MCP)"),
+ ("cold_run", "Cold Run"),
+ ("stale_refresh", "Stale Refresh"),
+ ("auto_refresh", "Auto Refresh"),
+ ("config_change", "Config Change"),
+ ("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")),
+ ("metric_retries", models.JSONField(default=dict)),
+ ],
+ 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",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/0037_squash_2026_09_07_finalize_fks.py b/products/experiments/backend/migrations/0037_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..5395c34fc272
--- /dev/null
+++ b/products/experiments/backend/migrations/0037_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,27 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("experiments", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0036_alter_experimentmetricsrecalculation_trigger"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="experiment",
+ name="saved_metrics",
+ field=models.ManyToManyField(
+ blank=True,
+ related_name="experiments",
+ through="experiments.ExperimentToSavedMetric",
+ to="experiments.experimentsavedmetric",
+ ),
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/max_migration.txt b/products/experiments/backend/migrations/max_migration.txt
index d984f4c38343..22c7378ce572 100644
--- a/products/experiments/backend/migrations/max_migration.txt
+++ b/products/experiments/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0036_alter_experimentmetricsrecalculation_trigger
+0037_squash_2026_09_07_finalize_fks
diff --git a/products/exports/backend/migrations/0001_squash_2026_09_07_initial.py b/products/exports/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..b75f342c9000
--- /dev/null
+++ b/products/exports/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,272 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.exports.backend.models.exported_asset
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("exports", "0001_migrate_exports_models"),
+ ("exports", "0002_subscription_prompt"),
+ ("exports", "0003_alter_subscription_target_type"),
+ ("exports", "0004_subscription_ai_prompt_config"),
+ ("exports", "0005_subscriptiondelivery_posthog_subdel_sub_fin"),
+ ("exports", "0006_subscription_ai_query_plan"),
+ ("exports", "0007_alter_exportedasset_export_format"),
+ ("exports", "0008_exportedasset_source_authentication"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0015_dashboard_customization"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ExportedAsset",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ (
+ "export_format",
+ models.CharField(
+ choices=[
+ ("image/png", "image/png"),
+ ("application/pdf", "application/pdf"),
+ ("text/csv", "text/csv"),
+ (
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ ),
+ ("video/webm", "video/webm"),
+ ("video/mp4", "video/mp4"),
+ ("image/gif", "image/gif"),
+ ("application/json", "application/json"),
+ ("application/x-ndjson", "application/x-ndjson"),
+ ],
+ max_length=100,
+ ),
+ ),
+ ("content", models.BinaryField(null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("expires_after", models.DateTimeField(blank=True, null=True)),
+ ("export_context", models.JSONField(blank=True, null=True)),
+ ("content_location", models.TextField(blank=True, max_length=1000, null=True)),
+ ("exception", models.TextField(blank=True, null=True)),
+ ("exception_type", models.CharField(blank=True, max_length=255, null=True)),
+ ("failure_type", models.CharField(blank=True, max_length=255, null=True)),
+ ("is_system", models.BooleanField(default=False, null=True)),
+ (
+ "access_token",
+ models.CharField(
+ blank=True,
+ default=products.exports.backend.models.exported_asset.get_default_access_token,
+ max_length=400,
+ null=True,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "dashboard",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="dashboards.dashboard"
+ ),
+ ),
+ (
+ "insight",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "source_authentication",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("session", "Session"),
+ ("personal_api_key", "Personal API key"),
+ ("oauth_access_token", "OAuth access token"),
+ ],
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ("source_credential_id", models.CharField(blank=True, max_length=50, null=True)),
+ ],
+ options={
+ "db_table": "posthog_exportedasset",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Subscription",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("title", models.CharField(blank=True, max_length=100, null=True)),
+ ("target_type", models.CharField(choices=[("email", "Email"), ("slack", "Slack")], max_length=10)),
+ ("target_value", models.TextField()),
+ (
+ "frequency",
+ models.CharField(
+ choices=[
+ ("daily", "Daily"),
+ ("weekly", "Weekly"),
+ ("monthly", "Monthly"),
+ ("yearly", "Yearly"),
+ ],
+ max_length=10,
+ ),
+ ),
+ ("interval", models.IntegerField(default=1)),
+ ("count", models.IntegerField(null=True)),
+ (
+ "byweekday",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(
+ choices=[
+ ("monday", "Monday"),
+ ("tuesday", "Tuesday"),
+ ("wednesday", "Wednesday"),
+ ("thursday", "Thursday"),
+ ("friday", "Friday"),
+ ("saturday", "Saturday"),
+ ("sunday", "Sunday"),
+ ],
+ max_length=10,
+ ),
+ blank=True,
+ default=None,
+ null=True,
+ size=None,
+ ),
+ ),
+ ("bysetpos", models.IntegerField(null=True)),
+ ("start_date", models.DateTimeField()),
+ ("until_date", models.DateTimeField(blank=True, null=True)),
+ ("next_delivery_date", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("enabled", models.BooleanField(default=True)),
+ ("summary_enabled", models.BooleanField(default=False)),
+ ("summary_prompt_guide", models.CharField(blank=True, default="", max_length=500)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "dashboard",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="dashboards.dashboard"
+ ),
+ ),
+ (
+ "dashboard_export_insights",
+ models.ManyToManyField(
+ blank=True, related_name="subscriptions_dashboard_export", to="product_analytics.insight"
+ ),
+ ),
+ (
+ "insight",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"
+ ),
+ ),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog.integration",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("prompt", models.TextField(blank=True, null=True)),
+ ("ai_prompt_config", models.JSONField(blank=True, default=dict)),
+ ("ai_query_plan", models.JSONField(blank=True, default=None, null=True)),
+ ],
+ options={
+ "db_table": "posthog_subscription",
+ "indexes": [models.Index(fields=["integration"], name="posthog_sub_integration_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SubscriptionDelivery",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("temporal_workflow_id", models.CharField(max_length=255)),
+ ("idempotency_key", models.CharField(max_length=255, unique=True)),
+ ("trigger_type", models.CharField(max_length=20)),
+ ("scheduled_at", models.DateTimeField(null=True)),
+ ("target_type", models.CharField(max_length=10)),
+ ("target_value", models.TextField()),
+ (
+ "exported_asset_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.IntegerField(), default=list, size=None
+ ),
+ ),
+ ("content_snapshot", models.JSONField(default=dict)),
+ ("change_summary", models.TextField(blank=True, null=True)),
+ ("recipient_results", models.JSONField(default=list)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("starting", "Starting"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ("skipped", "Skipped"),
+ ],
+ default="starting",
+ max_length=24,
+ ),
+ ),
+ ("error", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_updated_at", models.DateTimeField(auto_now=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "subscription",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="deliveries",
+ to="exports.subscription",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_subscription_delivery",
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(fields=["subscription", "-created_at"], name="posthog_subdel_sub_crtd"),
+ models.Index(fields=["team", "-created_at"], name="posthog_subdel_team_crtd"),
+ models.Index(fields=["subscription", "status", "-finished_at"], name="posthog_subdel_sub_fin"),
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/feature_flags/backend/migrations/0001_squash_2026_09_07_initial.py b/products/feature_flags/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..22fb4b0007dd
--- /dev/null
+++ b/products/feature_flags/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,400 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.core.validators
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.feature_flags.backend.models.feature_flag
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("feature_flags", "0001_team_feature_flag_defaults_config"),
+ ("feature_flags", "0002_migrate_feature_flags_models"),
+ ("feature_flags", "0003_evaluationcontext_hidden_from_suggestions"),
+ ("feature_flags", "0004_featureflag_archived"),
+ ("feature_flags", "0005_featureflag_archived_disabled_constraint"),
+ ("feature_flags", "0006_validate_archived_flag_must_be_disabled"),
+ ("feature_flags", "0007_clean_invalid_multivariate_filters"),
+ ("feature_flags", "0008_team_feature_flags_config"),
+ ("feature_flags", "0009_scheduledchange_change_request"),
+ ("feature_flags", "0010_remove_featureflag_performed_rollback_and_more"),
+ ("feature_flags", "0011_clean_flag_filters_recoverable_violations"),
+ ("feature_flags", "0012_teamfeatureflagsconfig_max_feature_flags_override_and_more"),
+ ("feature_flags", "0013_narrow_whole_rollout_percentages"),
+ ("feature_flags", "0014_clean_flag_filters_inert_violations"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("approvals", "0001_migrate_approvals_models"),
+ ("dashboards", "0015_dashboard_customization"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="TeamFeatureFlagDefaultsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("enabled", models.BooleanField(default=False)),
+ ("default_groups", models.JSONField(default=list)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlagHashKeyOverride",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("feature_flag_key", models.CharField(max_length=400)),
+ ("hash_key", models.CharField(max_length=400)),
+ ],
+ options={
+ "db_table": "posthog_featureflaghashkeyoverride",
+ "managed": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EvaluationContext",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="evaluation_context_set",
+ to="posthog.team",
+ ),
+ ),
+ ("hidden_from_suggestions", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "db_table": "posthog_evaluationcontext",
+ "unique_together": {("team", "name")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlag",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("key", models.CharField(max_length=400)),
+ ("name", models.TextField(blank=True)),
+ (
+ "filters",
+ models.JSONField(default=products.feature_flags.backend.models.feature_flag.default_filters),
+ ),
+ ("rollout_percentage", models.IntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("active", models.BooleanField(default=True)),
+ ("version", models.IntegerField(default=1, null=True)),
+ ("ensure_experience_continuity", models.BooleanField(blank=True, default=False, null=True)),
+ ("has_enriched_analytics", models.BooleanField(blank=True, default=False, null=True)),
+ ("is_remote_configuration", models.BooleanField(blank=True, default=False, null=True)),
+ ("has_encrypted_payloads", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "evaluation_runtime",
+ models.CharField(
+ blank=True,
+ choices=[("server", "Server"), ("client", "Client"), ("all", "All")],
+ default="all",
+ help_text="Specifies where this feature flag should be evaluated",
+ max_length=10,
+ null=True,
+ ),
+ ),
+ (
+ "bucketing_identifier",
+ models.CharField(
+ blank=True,
+ choices=[("distinct_id", "User ID (default)"), ("device_id", "Device ID")],
+ default="distinct_id",
+ help_text="Identifier used for bucketing users into rollout and variants",
+ max_length=50,
+ null=True,
+ ),
+ ),
+ (
+ "last_called_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="Last time this feature flag was called (from $feature_flag_called events)",
+ null=True,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="updated_feature_flags",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "usage_dashboard",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="dashboards.dashboard"
+ ),
+ ),
+ ("archived", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "db_table": "posthog_featureflag",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "key"), name="unique key for team"),
+ models.CheckConstraint(
+ condition=models.Q(("active", True), ("archived", True), _negated=True),
+ name="archived_flag_must_be_disabled",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ScheduledChange",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("record_id", models.CharField(max_length=200)),
+ ("model_name", models.CharField(choices=[("FeatureFlag", "feature flag")], max_length=100)),
+ ("payload", models.JSONField(default=dict)),
+ ("scheduled_at", models.DateTimeField()),
+ ("executed_at", models.DateTimeField(blank=True, null=True)),
+ ("failure_reason", models.TextField(blank=True, null=True)),
+ ("failure_count", models.IntegerField(default=0)),
+ ("is_recurring", models.BooleanField(default=False)),
+ (
+ "recurrence_interval",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("daily", "daily"),
+ ("weekly", "weekly"),
+ ("monthly", "monthly"),
+ ("yearly", "yearly"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("last_executed_at", models.DateTimeField(blank=True, null=True)),
+ ("cron_expression", models.CharField(blank=True, max_length=100, null=True)),
+ ("end_date", models.DateTimeField(blank=True, null=True)),
+ ("timezone", models.CharField(blank=True, max_length=240, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ 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")),
+ (
+ "change_request",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="scheduled_changes",
+ to="approvals.changerequest",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_scheduledchange",
+ "indexes": [
+ models.Index(fields=["scheduled_at", "executed_at"], name="posthog_sch_schedul_c3687e_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamFeatureFlagsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("minimal_flag_called_events", models.BooleanField(default=False)),
+ (
+ "max_feature_flags_override",
+ models.PositiveIntegerField(
+ blank=True,
+ default=None,
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(1),
+ django.core.validators.MaxValueValidator(20000),
+ ],
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ ("max_feature_flags_override__isnull", True),
+ models.Q(
+ ("max_feature_flags_override__gte", 1), ("max_feature_flags_override__lte", 20000)
+ ),
+ _connector="OR",
+ ),
+ name="max_feature_flags_override_in_range",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamDefaultEvaluationContext",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "evaluation_context",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="team_defaults",
+ to="feature_flags.evaluationcontext",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="default_evaluation_context_set",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_teamdefaultevaluationcontext",
+ "indexes": [],
+ "constraints": [],
+ "unique_together": {("team", "evaluation_context")},
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlagDashboards",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "dashboard",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="dashboards.dashboard"),
+ ),
+ (
+ "feature_flag",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="feature_flags.featureflag"),
+ ),
+ ],
+ options={
+ "db_table": "posthog_featureflagdashboards",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("feature_flag", "dashboard"), name="unique feature flag for a dashboard"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlagEvaluationContext",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "evaluation_context",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="feature_flags",
+ to="feature_flags.evaluationcontext",
+ ),
+ ),
+ (
+ "feature_flag",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="flag_evaluation_contexts",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_featureflagevaluationcontext",
+ "indexes": [],
+ "constraints": [],
+ "unique_together": {("feature_flag", "evaluation_context")},
+ },
+ ),
+ migrations.CreateModel(
+ name="FeatureFlagOverride",
+ fields=[
+ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("override_value", models.JSONField()),
+ (
+ "feature_flag",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="feature_flags.featureflag"),
+ ),
+ ("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={
+ "db_table": "posthog_featureflagoverride",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("user", "feature_flag", "team"), name="unique feature flag for a user/team combo"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/feature_flags/backend/migrations/0018_squash_2026_09_07_finalize_fks.py b/products/feature_flags/backend/migrations/0018_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..be7102c5488a
--- /dev/null
+++ b/products/feature_flags/backend/migrations/0018_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,26 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("feature_flags", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="featureflag",
+ name="analytics_dashboards",
+ field=models.ManyToManyField(
+ related_name="analytics_dashboards",
+ related_query_name="analytics_dashboard",
+ through="feature_flags.FeatureFlagDashboards",
+ to="dashboards.dashboard",
+ ),
+ ),
+ ]
diff --git a/products/feature_flags/backend/migrations/0019_squash_2026_09_07_schema_addons.py b/products/feature_flags/backend/migrations/0019_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..4ba8dcacc088
--- /dev/null
+++ b/products/feature_flags/backend/migrations/0019_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,90 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_constraint
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0017_teamfeatureflagsconfig_property_matching_version"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="featureflag",
+ name="archived_flag_must_be_disabled",
+ ),
+ ]
diff --git a/products/feature_flags/backend/migrations/max_migration.txt b/products/feature_flags/backend/migrations/max_migration.txt
index 4e739ff04cf2..814d850ec43c 100644
--- a/products/feature_flags/backend/migrations/max_migration.txt
+++ b/products/feature_flags/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0017_teamfeatureflagsconfig_property_matching_version
+0019_squash_2026_09_07_schema_addons
diff --git a/products/feature_flags/backend/test/test_migration_0014_clean_inert_violations.py b/products/feature_flags/backend/test/test_migration_0014_clean_inert_violations.py
deleted file mode 100644
index 81ff965f4a22..000000000000
--- a/products/feature_flags/backend/test/test_migration_0014_clean_inert_violations.py
+++ /dev/null
@@ -1,187 +0,0 @@
-from typing import Any
-
-from posthog.test.base import TestMigrations
-
-MULTIVARIATE = {
- "variants": [
- {"key": "control", "name": "", "rollout_percentage": 50},
- {"key": "test", "name": "", "rollout_percentage": 50},
- ]
-}
-
-
-def group(**overrides: Any) -> dict:
- return {"properties": [], "rollout_percentage": 100, "variant": None, **overrides}
-
-
-class CleanInertFilterViolationsMigrationTest(TestMigrations):
- migrate_from = "0013_narrow_whole_rollout_percentages"
- migrate_to = "0014_clean_flag_filters_inert_violations"
-
- CLASS_DATA_LEVEL_SETUP = False
-
- @property
- def app(self) -> str:
- return "feature_flags"
-
- def setUpBeforeMigration(self, apps: Any) -> None:
- Organization = apps.get_model("posthog", "Organization")
- Project = apps.get_model("posthog", "Project")
- Team = apps.get_model("posthog", "Team")
- FeatureFlag = apps.get_model("feature_flags", "FeatureFlag")
-
- org = Organization.objects.create(name="Test Organization")
- project = Project.objects.create(id=999995, organization=org, name="Test Project")
- team = Team.objects.create(organization=org, project=project, name="Test Team")
-
- def make_flag(key: str, filters: dict, **kwargs: Any) -> Any:
- return FeatureFlag.objects.create(team=team, created_by=None, key=key, filters=filters, **kwargs)
-
- self.orphan_payload_id = make_flag(
- "orphan-payload",
- {"groups": [group()], "multivariate": MULTIVARIATE, "payloads": {"control": "1", "ghost": "2"}},
- ).id
- self.resolvable_payloads_id = make_flag(
- "resolvable-payloads",
- {
- "groups": [group()],
- "multivariate": MULTIVARIATE,
- "payloads": {"control": "1", "false": "2", "holdout-7": "3", "ghost": "4"},
- },
- ).id
- self.boolean_payloads_id = make_flag(
- "boolean-payloads",
- {"groups": [group()], "payloads": {"true": "1", "false": "2", "holdout-9": "3", "control": "4"}},
- ).id
- self.dangling_variant_id = make_flag(
- "dangling-variant",
- {"groups": [group(variant="ghost"), group(variant="control")], "multivariate": MULTIVARIATE},
- ).id
- self.already_clean_id = make_flag(
- "already-clean",
- {"groups": [group(variant="control")], "multivariate": MULTIVARIATE, "payloads": {"control": "1"}},
- ).id
- self.soft_deleted_id = make_flag(
- "soft-deleted",
- {"groups": [group(variant="ghost")], "multivariate": MULTIVARIATE},
- deleted=True,
- ).id
- self.inactive_id = make_flag(
- "inactive",
- {"groups": [group(variant="ghost")], "multivariate": MULTIVARIATE},
- active=False,
- ).id
- # Rules this migration deliberately does not own.
- self.non_inert_id = make_flag(
- "non-inert",
- {
- "groups": [group(properties=[{"key": "1", "type": "flag", "value": True, "operator": "exact"}])],
- "multivariate": {
- "variants": [
- {"key": "a", "name": "", "rollout_percentage": 40},
- {"key": "b", "name": "", "rollout_percentage": 40},
- {"key": "c", "name": "", "rollout_percentage": 40},
- ]
- },
- },
- ).id
- # Every payload key on an encrypted flag is ciphertext, so pruning one destroys a secret.
- self.encrypted_id = make_flag(
- "encrypted",
- {"groups": [group()], "payloads": {"true": "cipher-1", "staging": "cipher-2"}},
- has_encrypted_payloads=True,
- ).id
- self.encrypted_legacy_null_id = make_flag(
- "encrypted-legacy-null",
- {
- "groups": [group(variant="ghost")],
- "multivariate": MULTIVARIATE,
- "payloads": {"control": "1", "ghost": "2"},
- },
- has_encrypted_payloads=None,
- ).id
-
- # Shapes the scan must skip rather than raise on, which would abort the whole migration.
- self.junk_ids = [
- make_flag("junk-groups", {"groups": {}}).id,
- make_flag("junk-group-entry", {"groups": ["nope"], "multivariate": MULTIVARIATE}).id,
- make_flag(
- "junk-multivariate-list", {"groups": [group()], "multivariate": ["nope"], "payloads": {"x": "1"}}
- ).id,
- make_flag(
- "junk-multivariate-str", {"groups": [group()], "multivariate": "nope", "payloads": {"x": "1"}}
- ).id,
- make_flag("junk-payloads", {"groups": [group()], "payloads": []}).id,
- ]
-
- def _filters(self, flag_id: int) -> dict:
- assert self.apps is not None
- FeatureFlag = self.apps.get_model("feature_flags", "FeatureFlag")
- return FeatureFlag.objects.get(id=flag_id).filters
-
- def test_migration_cleans_inert_violations(self) -> None:
- for check in (
- self._check_clears_only_dangling_variant_overrides,
- self._check_covers_soft_deleted_and_inactive_flags,
- self._check_drops_payload_keys_no_evaluation_can_resolve,
- self._check_keeps_payload_keys_the_evaluator_resolves,
- self._check_leaves_an_already_clean_flag_untouched,
- self._check_leaves_encrypted_flags_alone,
- self._check_leaves_violations_it_does_not_own,
- self._check_skips_malformed_filters_without_raising,
- self._check_still_cleans_flags_with_a_null_encrypted_marker,
- ):
- with self.subTest(check=check.__name__):
- check()
-
- def _check_drops_payload_keys_no_evaluation_can_resolve(self) -> None:
- assert self._filters(self.orphan_payload_id)["payloads"] == {"control": "1"}
-
- def _check_keeps_payload_keys_the_evaluator_resolves(self) -> None:
- # "false" is reached by a boolean result and "holdout-N" by the synthesised holdout variant.
- assert self._filters(self.resolvable_payloads_id)["payloads"] == {
- "control": "1",
- "false": "2",
- "holdout-7": "3",
- }
- assert self._filters(self.boolean_payloads_id)["payloads"] == {
- "true": "1",
- "false": "2",
- "holdout-9": "3",
- }
-
- def _check_clears_only_dangling_variant_overrides(self) -> None:
- groups = self._filters(self.dangling_variant_id)["groups"]
- assert groups[0]["variant"] is None
- assert groups[1]["variant"] == "control"
-
- def _check_covers_soft_deleted_and_inactive_flags(self) -> None:
- assert self._filters(self.soft_deleted_id)["groups"][0]["variant"] is None
- assert self._filters(self.inactive_id)["groups"][0]["variant"] is None
-
- def _check_leaves_an_already_clean_flag_untouched(self) -> None:
- assert self._filters(self.already_clean_id) == {
- "groups": [group(variant="control")],
- "multivariate": MULTIVARIATE,
- "payloads": {"control": "1"},
- }
-
- def _check_leaves_violations_it_does_not_own(self) -> None:
- filters = self._filters(self.non_inert_id)
- assert filters["groups"][0]["properties"][0]["operator"] == "exact"
- assert [variant["rollout_percentage"] for variant in filters["multivariate"]["variants"]] == [40, 40, 40]
-
- def _check_leaves_encrypted_flags_alone(self) -> None:
- assert self._filters(self.encrypted_id)["payloads"] == {"true": "cipher-1", "staging": "cipher-2"}
-
- def _check_still_cleans_flags_with_a_null_encrypted_marker(self) -> None:
- filters = self._filters(self.encrypted_legacy_null_id)
- assert filters["payloads"] == {"control": "1"}
- assert filters["groups"][0]["variant"] is None
-
- def _check_skips_malformed_filters_without_raising(self) -> None:
- # Reaching any assertion here means the scan completed; these rows stay as they were.
- assert self._filters(self.junk_ids[0]) == {"groups": {}}
- assert self._filters(self.junk_ids[2])["payloads"] == {"x": "1"}
- assert self._filters(self.junk_ids[3])["payloads"] == {"x": "1"}
- assert self._filters(self.junk_ids[4])["payloads"] == []
diff --git a/products/feature_flags/backend/test/test_migration_0015_clamp_rollouts.py b/products/feature_flags/backend/test/test_migration_0015_clamp_rollouts.py
deleted file mode 100644
index 4ec018095a88..000000000000
--- a/products/feature_flags/backend/test/test_migration_0015_clamp_rollouts.py
+++ /dev/null
@@ -1,281 +0,0 @@
-from typing import Any
-
-from posthog.test.base import BaseTest, TestMigrations
-from unittest.mock import patch
-
-from django.apps import apps as global_apps
-from django.db import connection
-from django.test.utils import CaptureQueriesContext
-
-
-def variants(*percentages: Any) -> dict:
- return {"variants": [{"key": f"v{i}", "name": "", "rollout_percentage": p} for i, p in enumerate(percentages)]}
-
-
-def rollouts(filters: dict) -> list:
- return [variant["rollout_percentage"] for variant in filters["multivariate"]["variants"]]
-
-
-class ClampRolloutPercentagesMigrationTest(TestMigrations):
- migrate_from = "0014_clean_flag_filters_inert_violations"
- migrate_to = "0015_clamp_rollout_percentages_over_100"
-
- CLASS_DATA_LEVEL_SETUP = False
-
- @property
- def app(self) -> str:
- return "feature_flags"
-
- def setUpBeforeMigration(self, apps: Any) -> None:
- Organization = apps.get_model("posthog", "Organization")
- Project = apps.get_model("posthog", "Project")
- Team = apps.get_model("posthog", "Team")
- FeatureFlag = apps.get_model("feature_flags", "FeatureFlag")
-
- org = Organization.objects.create(name="Test Organization")
- project = Project.objects.create(id=999994, organization=org, name="Test Project")
- team = Team.objects.create(organization=org, project=project, name="Test Team")
-
- def make_flag(key: str, filters: dict, **kwargs: Any) -> Any:
- return FeatureFlag.objects.create(team=team, created_by=None, key=key, filters=filters, **kwargs)
-
- self.straddling_id = make_flag("straddling", {"groups": [], "multivariate": variants(40, 40, 40)}).id
- self.annotated_id = make_flag(
- "annotated",
- {
- "groups": [{"properties": [], "rollout_percentage": 100, "variant": None}],
- "multivariate": {
- "variants": [
- {"key": "v0", "name": "First", "rollout_percentage": 40},
- {"key": "v1", "name": "Second", "rollout_percentage": 40},
- {"key": "v2", "name": "Third", "rollout_percentage": 40},
- ],
- "some_unrelated_key": "kept",
- },
- "payloads": {"v0": "1"},
- },
- ).id
- self.two_over_id = make_flag("two-over", {"groups": [], "multivariate": variants(60, 60)}).id
- # Decimal inputs whose remainder lands whole: the only shape where the int conversion
- # changes the stored value, 33.0 without it and 33 with it.
- self.whole_remainder_id = make_flag(
- "whole-remainder", {"groups": [], "multivariate": variants(33.5, 33.5, 50)}
- ).id
- self.drifting_remainder_id = make_flag(
- "drifting-remainder", {"groups": [], "multivariate": variants(10.1, 20.2, 30.3, 50.5)}
- ).id
- self.first_takes_all_id = make_flag("first-takes-all", {"groups": [], "multivariate": variants(150, 10)}).id
- self.unreachable_id = make_flag("unreachable", {"groups": [], "multivariate": variants(50, 50, 50)}).id
- self.fractional_id = make_flag("fractional", {"groups": [], "multivariate": variants(33.33, 33.33, 50)}).id
- self.soft_deleted_id = make_flag(
- "soft-deleted", {"groups": [], "multivariate": variants(70, 70)}, deleted=True
- ).id
- self.inactive_id = make_flag("inactive", {"groups": [], "multivariate": variants(70, 70)}, active=False).id
- self.encrypted_id = make_flag(
- "encrypted", {"groups": [], "multivariate": variants(60, 60)}, has_encrypted_payloads=True
- ).id
-
- # Left alone: already correct, or a shortfall only the customer can resolve.
- self.exact_id = make_flag("exact", {"groups": [], "multivariate": variants(40, 40, 20)}).id
- self.under_id = make_flag("under", {"groups": [], "multivariate": variants(30, 30)}).id
- self.drifting_id = make_flag("drifting", {"groups": [], "multivariate": variants(0.01, 64.04, 35.95)}).id
-
- # Clamping a [40, 100] shape flips has_hash_dependent_variants, which starts the
- # continuity override lookup and can change which identifier is hashed.
- self.risky_with_continuity_id = make_flag(
- "risky-with-continuity",
- {"groups": [], "multivariate": variants(40, 100)},
- ensure_experience_continuity=True,
- ).id
- self.risky_without_continuity_id = make_flag(
- "risky-without-continuity", {"groups": [], "multivariate": variants(40, 100)}
- ).id
- self.leading_full_with_continuity_id = make_flag(
- "leading-full-with-continuity",
- {"groups": [], "multivariate": variants(100, 40)},
- ensure_experience_continuity=True,
- ).id
-
- # Past the first 500-row batch, so keyset pagination is actually exercised.
- for i in range(505):
- make_flag(f"filler-{i}", {"groups": [], "multivariate": variants(50, 50)})
- self.last_batch_id = make_flag("last-batch", {"groups": [], "multivariate": variants(80, 80)}).id
-
- # Shapes the scan must skip rather than raise on.
- self.junk = {
- "filters-not-dict": make_flag("junk-filters-not-dict", {}).id,
- "multivariate-list": make_flag("junk-multivariate-list", {"groups": [], "multivariate": ["nope"]}).id,
- "variants-not-list": make_flag(
- "junk-variants-not-list", {"groups": [], "multivariate": {"variants": {}}}
- ).id,
- "variant-entry": make_flag("junk-variant-entry", {"groups": [], "multivariate": {"variants": ["nope"]}}).id,
- "rollout-string": make_flag("junk-rollout-string", {"groups": [], "multivariate": variants("60", "60")}).id,
- "no-multivariate": make_flag("no-multivariate", {"groups": []}).id,
- "rollout-bool": make_flag("junk-rollout-bool", {"groups": [], "multivariate": variants(True, 100)}).id,
- }
- # A whole `filters` value that is not a dict at all; the model default blocks it on create.
- FeatureFlag.objects.filter(id=self.junk["filters-not-dict"]).update(filters=["nope"])
-
- def _raw_filters(self, flag_id: int) -> Any:
- assert self.apps is not None
- FeatureFlag = self.apps.get_model("feature_flags", "FeatureFlag")
- return FeatureFlag.objects.get(id=flag_id).filters
-
- def _filters(self, flag_id: int) -> dict:
- assert self.apps is not None
- FeatureFlag = self.apps.get_model("feature_flags", "FeatureFlag")
- return FeatureFlag.objects.get(id=flag_id).filters
-
- def test_migration_clamps_rollouts(self) -> None:
- for check in (
- self._check_clamps_a_straddling_variant_to_the_remainder,
- self._check_clamps_rows_past_the_first_batch,
- self._check_covers_soft_deleted_inactive_and_encrypted_flags,
- self._check_keeps_real_decimals,
- self._check_keeps_whole_numbers_as_integers,
- self._check_leaves_correct_and_short_sums_alone,
- self._check_preserves_every_other_field_while_clamping,
- self._check_rounds_the_remainder_instead_of_storing_a_float_artifact,
- self._check_skips_malformed_filters_without_raising,
- self._check_skips_only_the_shape_that_flips_hash_dependence_with_continuity,
- self._check_zeroes_variants_the_evaluator_can_never_reach,
- ):
- with self.subTest(check=check.__name__):
- check()
-
- def _check_preserves_every_other_field_while_clamping(self) -> None:
- assert self._filters(self.annotated_id) == {
- "groups": [{"properties": [], "rollout_percentage": 100, "variant": None}],
- "multivariate": {
- "variants": [
- {"key": "v0", "name": "First", "rollout_percentage": 40},
- {"key": "v1", "name": "Second", "rollout_percentage": 40},
- {"key": "v2", "name": "Third", "rollout_percentage": 20},
- ],
- "some_unrelated_key": "kept",
- },
- "payloads": {"v0": "1"},
- }
-
- def _check_skips_only_the_shape_that_flips_hash_dependence_with_continuity(self) -> None:
- # Continuity on plus a 100 after a smaller variant: the one shape that can move a user.
- assert rollouts(self._filters(self.risky_with_continuity_id)) == [40, 100]
- # Same shape without continuity hashes the distinct_id either way, so it is safe.
- assert rollouts(self._filters(self.risky_without_continuity_id)) == [40, 60]
- # The 100 comes first, so nothing smaller precedes it and the classification is unchanged.
- assert rollouts(self._filters(self.leading_full_with_continuity_id)) == [100, 0]
-
- def _check_clamps_rows_past_the_first_batch(self) -> None:
- assert rollouts(self._filters(self.last_batch_id)) == [80, 20]
-
- def _check_clamps_a_straddling_variant_to_the_remainder(self) -> None:
- assert rollouts(self._filters(self.straddling_id)) == [40, 40, 20]
- assert rollouts(self._filters(self.two_over_id)) == [60, 40]
-
- def _check_zeroes_variants_the_evaluator_can_never_reach(self) -> None:
- assert rollouts(self._filters(self.first_takes_all_id)) == [100, 0]
- assert rollouts(self._filters(self.unreachable_id)) == [50, 50, 0]
-
- def _check_keeps_whole_numbers_as_integers(self) -> None:
- # A float here would re-break the .NET and Java SDKs that #84957 fixed. The decimal
- # fixture is the one that pins the conversion: its remainder is whole, so without it
- # the stored value would be 33.0.
- assert [type(r) for r in rollouts(self._filters(self.straddling_id))] == [int, int, int]
- assert rollouts(self._filters(self.whole_remainder_id)) == [33.5, 33.5, 33]
- assert [type(r) for r in rollouts(self._filters(self.whole_remainder_id))] == [float, float, int]
-
- def _check_rounds_the_remainder_instead_of_storing_a_float_artifact(self) -> None:
- assert rollouts(self._filters(self.drifting_remainder_id)) == [10.1, 20.2, 30.3, 39.4]
-
- def _check_keeps_real_decimals(self) -> None:
- assert rollouts(self._filters(self.fractional_id)) == [33.33, 33.33, 33.34]
-
- def _check_covers_soft_deleted_inactive_and_encrypted_flags(self) -> None:
- assert rollouts(self._filters(self.soft_deleted_id)) == [70, 30]
- assert rollouts(self._filters(self.inactive_id)) == [70, 30]
- assert rollouts(self._filters(self.encrypted_id)) == [60, 40]
-
- def _check_leaves_correct_and_short_sums_alone(self) -> None:
- assert rollouts(self._filters(self.exact_id)) == [40, 40, 20]
- assert rollouts(self._filters(self.under_id)) == [30, 30]
- assert rollouts(self._filters(self.drifting_id)) == [0.01, 64.04, 35.95]
-
- def _check_skips_malformed_filters_without_raising(self) -> None:
- # Reaching any assertion here means the scan completed; these rows stay as they were.
- assert self._raw_filters(self.junk["filters-not-dict"]) == ["nope"]
- assert self._filters(self.junk["multivariate-list"])["multivariate"] == ["nope"]
- assert self._filters(self.junk["variants-not-list"])["multivariate"]["variants"] == {}
- assert self._filters(self.junk["variant-entry"])["multivariate"]["variants"] == ["nope"]
- assert rollouts(self._filters(self.junk["rollout-string"])) == ["60", "60"]
- assert "multivariate" not in self._filters(self.junk["no-multivariate"])
- # True is an int in Python, so without the bool guard this would become [1, 99].
- assert rollouts(self._filters(self.junk["rollout-bool"])) == [True, 100]
-
-
-class ClampRolloutCompareAndSwapTest(BaseTest):
- """The `filters=flag.filters` predicate is what stops a stale snapshot overwriting a newer
- edit, and only a write landing mid-scan exercises it."""
-
- def test_a_write_landing_mid_scan_survives(self) -> None:
- from importlib import import_module
-
- from products.feature_flags.backend.models.feature_flag import FeatureFlag
-
- migration = import_module("products.feature_flags.backend.migrations.0015_clamp_rollout_percentages_over_100")
- flag = FeatureFlag.objects.create(
- team=self.team,
- created_by=self.user,
- key="raced",
- filters={"groups": [], "multivariate": variants(60, 60)},
- )
- edited = {"groups": [], "multivariate": variants(25, 25)}
-
- original_clamp = migration._clamp_filters
-
- def clamp_then_race(filters: dict, has_continuity: bool) -> dict | None:
- result = original_clamp(filters, has_continuity)
- if result is not None:
- # Stand in for a user saving between the batch SELECT and the UPDATE.
- FeatureFlag.objects.filter(id=flag.id).update(filters=edited)
- return result
-
- with patch.object(migration, "_clamp_filters", clamp_then_race):
- migration.clamp_rollout_percentages_over_100(global_apps, None)
-
- flag.refresh_from_db()
- assert flag.filters == edited
-
-
-class ClampRolloutQueryCountTest(BaseTest):
- """The scan reads `ensure_experience_continuity`, so it has to be in the `.only()`. Without
- it Django refetches the column once per row, and the field has silently dropped out once."""
-
- def test_the_scan_does_not_query_per_row(self) -> None:
- from importlib import import_module
-
- from products.feature_flags.backend.models.feature_flag import FeatureFlag
-
- migration = import_module("products.feature_flags.backend.migrations.0015_clamp_rollout_percentages_over_100")
- for i in range(25):
- FeatureFlag.objects.create(
- team=self.team,
- created_by=self.user,
- key=f"counted-{i}",
- filters={
- "groups": [],
- "multivariate": {
- "variants": [
- {"key": "a", "name": "", "rollout_percentage": 60},
- {"key": "b", "name": "", "rollout_percentage": 60},
- ]
- },
- },
- )
-
- with CaptureQueriesContext(connection) as captured:
- migration.clamp_rollout_percentages_over_100(global_apps, None)
-
- selects = [q["sql"] for q in captured.captured_queries if q["sql"].lstrip().upper().startswith("SELECT")]
- # One batch of up to 500, then one empty batch that ends the loop. A per-row refetch
- # would add one SELECT for every flag scanned.
- assert len(selects) == 2, "\n".join(selects)
diff --git a/products/field_notes/backend/migrations/0001_squash_2026_09_07_initial.py b/products/field_notes/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..d078136f275a
--- /dev/null
+++ b/products/field_notes/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,113 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("field_notes", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="FieldNote",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("comment", models.TextField(help_text="The note the user wrote about the element.")),
+ (
+ "field_note_status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("acknowledged", "Acknowledged"),
+ ("resolved", "Resolved"),
+ ("dismissed", "Dismissed"),
+ ],
+ default="pending",
+ help_text="Lifecycle of the field note as an agent works through it.",
+ max_length=20,
+ ),
+ ),
+ (
+ "resolution",
+ models.TextField(
+ blank=True,
+ help_text="Optional note left by the agent when acknowledging, resolving, or dismissing the field note.",
+ null=True,
+ ),
+ ),
+ ("url", models.TextField(help_text="Full URL of the page the field note was made on.")),
+ (
+ "host",
+ models.CharField(
+ help_text="Hostname of the page (e.g. app.example.com), used to scope field notes to a site.",
+ max_length=255,
+ ),
+ ),
+ ("pathname", models.TextField(blank=True, help_text="Path portion of the URL.", null=True)),
+ ("selector", models.TextField(help_text="CSS selector that locates the element on the page.")),
+ (
+ "element_text",
+ models.TextField(blank=True, help_text="Visible text of the element, if any.", null=True),
+ ),
+ (
+ "element_chain",
+ models.TextField(
+ blank=True,
+ help_text="Serialized autocapture-style element chain from the element up to the document root.",
+ null=True,
+ ),
+ ),
+ (
+ "element_context",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Structured element metadata (inferred selectors, attributes, component hints).",
+ ),
+ ),
+ (
+ "viewport",
+ models.JSONField(
+ blank=True,
+ help_text="Viewport size when the field note was made, as {width, height} in pixels.",
+ null=True,
+ ),
+ ),
+ (
+ "screenshot_url",
+ models.TextField(
+ blank=True, help_text="URL of an uploaded screenshot captured with the field note.", null=True
+ ),
+ ),
+ (
+ "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={
+ "db_table": "posthog_field_note",
+ "indexes": [
+ models.Index(fields=["team_id", "field_note_status"], name="field_note_team_status_idx"),
+ models.Index(fields=["team_id", "host"], name="field_note_team_host_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/field_notes/backend/migrations/max_migration.txt b/products/field_notes/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/field_notes/backend/migrations/max_migration.txt
+++ b/products/field_notes/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/growth/backend/migrations/0001_squash_2026_09_07_initial.py b/products/growth/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..366228586b68
--- /dev/null
+++ b/products/growth/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,270 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("growth", "0001_initial_migration"),
+ ("growth", "0002_organizationenrichment"),
+ ("growth", "0003_enrichmentsignupsnapshot"),
+ ("growth", "0004_organizationenrichmentfetch"),
+ ("growth", "0005_enrichmentlabelresult_enrichmentpromptconfig"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ProductPushCampaign",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("product_key", models.CharField(max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("scheduled", "Scheduled"),
+ ("active", "Active"),
+ ("adopted", "Adopted"),
+ ("skipped", "Skipped"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="scheduled",
+ max_length=16,
+ ),
+ ),
+ ("position", models.PositiveIntegerField(default=0)),
+ (
+ "scheduled_for",
+ models.DateField(
+ blank=True,
+ help_text="Don't start before this date. Overrides the signup grace period and the between-campaigns cooldown (an explicit human decision), but never the one-active-campaign-per-org invariant. Empty = next available slot.",
+ null=True,
+ ),
+ ),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("ends_at", models.DateTimeField(blank=True, null=True)),
+ ("ended_at", models.DateTimeField(blank=True, null=True)),
+ ("source", models.CharField(choices=[("auto", "Auto"), ("tam", "TAM")], default="auto", max_length=8)),
+ (
+ "reason_text",
+ models.TextField(
+ blank=True, help_text="Custom copy for the in-app promo card. Empty = default copy.", null=True
+ ),
+ ),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="product_push_campaigns",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Product push campaign",
+ "verbose_name_plural": "Product push campaigns",
+ "indexes": [
+ models.Index(fields=["organization", "status"], name="growth_push_org_status"),
+ models.Index(fields=["status", "ends_at"], name="growth_push_status_ends_at"),
+ models.Index(fields=["status", "scheduled_for"], name="growth_push_status_sched"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("status", "active")),
+ fields=("organization",),
+ name="uniq_active_product_push_per_org",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("status__in", ["scheduled", "active"])),
+ fields=("organization", "product_key"),
+ name="uniq_pending_product_push_per_org_product",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationEnrichment",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("data", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "organization",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="enrichment_record",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EnrichmentSignupSnapshot",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="enrichment_signup_snapshot",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="OrganizationEnrichmentFetch",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("provider", models.CharField(max_length=64)),
+ ("fetched_at", models.DateTimeField(auto_now_add=True)),
+ ("is_recheck", models.BooleanField(default=False)),
+ ("payload", models.JSONField(default=dict)),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="enrichment_fetches",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["organization", "fetched_at"], name="growth_enrich_fetch_org_time")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EnrichmentPromptConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=128)),
+ ("version", models.CharField(max_length=128)),
+ ("prompt_text", models.TextField()),
+ ("model", models.CharField(max_length=128)),
+ ("input_fields", models.JSONField(default=list)),
+ ("output_fields", models.JSONField(default=list)),
+ ("is_active", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("name", "version"), name="growth_prompt_config_name_version"),
+ models.UniqueConstraint(
+ condition=models.Q(("is_active", True)),
+ fields=("name",),
+ name="growth_prompt_config_one_active",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="EnrichmentLabelResult",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("label_name", models.CharField(max_length=128)),
+ ("prompt_version", models.CharField(max_length=128)),
+ ("prompt_hash", models.CharField(max_length=72)),
+ ("model", models.CharField(max_length=128)),
+ ("output", models.JSONField(default=dict)),
+ ("inputs", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "fetch",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="label_results",
+ to="growth.organizationenrichmentfetch",
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="enrichment_label_results",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["label_name", "prompt_version"], name="growth_label_result_version")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization", "label_name", "prompt_version", "fetch"),
+ name="growth_label_result_uniq",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/growth/dags/tests/test_ai_enrichment.py b/products/growth/dags/tests/test_ai_enrichment.py
index af6d65302b61..0613ff59ca14 100644
--- a/products/growth/dags/tests/test_ai_enrichment.py
+++ b/products/growth/dags/tests/test_ai_enrichment.py
@@ -20,6 +20,12 @@ _OUTPUT_FIELDS = [{"key": "is_ai", "type": "boolean", "description": ""}]
class _EnrichmentDagTestCase(BaseTest):
+ def setUp(self):
+ super().setUp()
+ # ensure_migration_defaults seeds an active ai_pilled config during
+ # test DB setup; these tests own the full config table.
+ EnrichmentPromptConfig.objects.all().delete()
+
def _config(self, **overrides: Any) -> EnrichmentPromptConfig:
params: dict[str, Any] = {
"name": "test_label",
diff --git a/products/legal_documents/backend/migrations/0001_squash_2026_09_07_initial.py b/products/legal_documents/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..b6e4d36e49f9
--- /dev/null
+++ b/products/legal_documents/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,77 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("legal_documents", "0001_initial_migration"),
+ ("legal_documents", "0002_legaldocument_pandadoc_integration"),
+ ("legal_documents", "0003_legaldocument_drop_signed_document_url"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="LegalDocument",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "document_type",
+ models.CharField(
+ choices=[("BAA", "Business Associate Agreement"), ("DPA", "Data Processing Agreement")],
+ max_length=8,
+ ),
+ ),
+ ("company_name", models.CharField(max_length=255)),
+ ("company_address", models.CharField(max_length=512)),
+ ("representative_email", models.EmailField(max_length=254)),
+ (
+ "status",
+ models.CharField(
+ choices=[("submitted_for_signature", "Submitted for signature"), ("signed", "Signed")],
+ default="submitted_for_signature",
+ max_length=32,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="legal_documents",
+ to="posthog.organization",
+ ),
+ ),
+ ("pandadoc_document_id", models.CharField(blank=True, db_index=True, max_length=64)),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("organization", "document_type"), name="unique_legal_document_per_org_and_type"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/links/backend/migrations/0001_squash_2026_09_07_initial.py b/products/links/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..cec00de58dbb
--- /dev/null
+++ b/products/links/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,69 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("links", "0001_migrate_links_models")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Link",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("redirect_url", models.URLField(max_length=2048)),
+ (
+ "short_link_domain",
+ models.CharField(help_text="Domain where the short link is hosted, e.g. hog.gg", max_length=255),
+ ),
+ (
+ "short_code",
+ models.CharField(
+ help_text="The unique code/path that identifies the short link, e.g. 'abc123'", max_length=255
+ ),
+ ),
+ ("description", models.TextField(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
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ help_text="Team that owns this link",
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_link",
+ "indexes": [
+ models.Index(fields=["short_link_domain", "short_code"], name="domain_short_code_idx"),
+ models.Index(fields=["team_id"], name="team_id_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("short_link_domain", "short_code"), name="unique_short_link_domain_short_code"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/links/backend/migrations/max_migration.txt b/products/links/backend/migrations/max_migration.txt
index 4134647c375e..6903cd5e3dc2 100644
--- a/products/links/backend/migrations/max_migration.txt
+++ b/products/links/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_migrate_links_models
+0001_squash_2026_09_07_initial
diff --git a/products/live_debugger/backend/migrations/0001_squash_2026_09_07_initial.py b/products/live_debugger/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..2280b5e685c6
--- /dev/null
+++ b/products/live_debugger/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,47 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("live_debugger", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="LiveDebuggerBreakpoint",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("repository", models.TextField(blank=True, null=True)),
+ ("filename", models.TextField()),
+ ("line_number", models.PositiveIntegerField()),
+ ("enabled", models.BooleanField(default=True)),
+ ("condition", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_livedebuggerbreakpoint",
+ "managed": True,
+ "indexes": [models.Index(fields=["team_id", "repository"], name="live_debug_team_repo_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "repository", "filename", "line_number"),
+ name="unique_breakpoint_per_line_per_file_per_repo_per_team",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/live_debugger/backend/migrations/max_migration.txt b/products/live_debugger/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/live_debugger/backend/migrations/max_migration.txt
+++ b/products/live_debugger/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/llm_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/llm_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..2f784f547341
--- /dev/null
+++ b/products/llm_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,47 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("llm_analytics", "0001_initial_migration"),
+ ("llm_analytics", "0002_evaluation"),
+ ("llm_analytics", "0003_evaluation_add_config_fields"),
+ ("llm_analytics", "0004_evaluation_migrate_config_data"),
+ ("llm_analytics", "0005_evaluation_make_config_required"),
+ ("llm_analytics", "0006_remove_evaluation_prompt"),
+ ("llm_analytics", "0007_drop_evaluation_prompt_column"),
+ ("llm_analytics", "0008_llmproviderkey_evaluationconfig"),
+ ("llm_analytics", "0009_rename_llm_analyti_team_pr_idx_llm_analyti_team_id_a78410_idx"),
+ ("llm_analytics", "0010_llmmodelconfiguration"),
+ ("llm_analytics", "0011_add_evaluation_model_configuration_index"),
+ ("llm_analytics", "0012_migrate_evaluation_model_configs"),
+ ("llm_analytics", "0013_add_openrouter_provider"),
+ ("llm_analytics", "0014_clusteringconfig"),
+ ("llm_analytics", "0015_add_fireworks_provider"),
+ ("llm_analytics", "0016_alter_evaluation_evaluation_type"),
+ ("llm_analytics", "0017_clusteringjob"),
+ ("llm_analytics", "0018_migrate_clustering_configs_to_jobs"),
+ ("llm_analytics", "0019_rename_default_clustering_jobs"),
+ ("llm_analytics", "0020_scoredefinition"),
+ ("llm_analytics", "0021_tracereview_and_scores"),
+ ("llm_analytics", "0022_reviewqueue_reviewqueueitem_and_more"),
+ ("llm_analytics", "0023_evaluation_status"),
+ ("llm_analytics", "0024_evaluation_status_backfill"),
+ ("llm_analytics", "0025_evaluation_reports"),
+ ("llm_analytics", "0026_llmskill_llmskillfile"),
+ ("llm_analytics", "0027_increase_skill_description_max_length"),
+ ("llm_analytics", "0028_clusteringjob_evaluation_level"),
+ ("llm_analytics", "0029_add_azure_openai_provider"),
+ ("llm_analytics", "0030_create_default_evaluation_clustering_jobs"),
+ ("llm_analytics", "0031_add_together_provider"),
+ ("llm_analytics", "0032_tagger"),
+ ("llm_analytics", "0033_release_to_ai_observability"),
+ ]
+
+ initial = True
+
+ dependencies = []
+
+ operations = []
diff --git a/products/llm_analytics/backend/migrations/max_migration.txt b/products/llm_analytics/backend/migrations/max_migration.txt
index c227c65cc9ae..6903cd5e3dc2 100644
--- a/products/llm_analytics/backend/migrations/max_migration.txt
+++ b/products/llm_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0033_release_to_ai_observability
+0001_squash_2026_09_07_initial
diff --git a/products/logs/backend/migrations/0001_squash_2026_09_07_initial.py b/products/logs/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..3eb93477788e
--- /dev/null
+++ b/products/logs/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,393 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+import products.logs.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("logs", "0001_initial"),
+ ("logs", "0002_logsview"),
+ ("logs", "0003_alter_logsalertconfiguration_state"),
+ ("logs", "0004_logsalertevent"),
+ ("logs", "0005_logsalertevent_kind"),
+ ("logs", "0006_alter_logsalertconfiguration_check_interval_minutes"),
+ ("logs", "0007_backfill_check_interval_minutes"),
+ ("logs", "0008_logsalertevent_logs_alert_event_alert_ts_idx"),
+ ("logs", "0009_logsexclusionrule"),
+ ("logs", "0010_logsalertconfiguration_first_enabled_at"),
+ ("logs", "0011_backfill_first_enabled_at"),
+ ("logs", "0012_alter_logsalertevent_kind"),
+ ("logs", "0013_alter_logsalertconfiguration_threshold_count"),
+ ("logs", "0014_teamlogsconfig"),
+ ("logs", "0015_teamlogsconfig_logs_session_id_attribute_keys"),
+ ("logs", "0016_logsview_columns"),
+ ("logs", "0017_logsmetricrule"),
+ ("logs", "0018_teamlogsconfig_logs_distinct_id_attribute_keys"),
+ ("logs", "0019_backfill_logs_distinct_id_attribute_keys"),
+ ("logs", "0020_logsretentionrule"),
+ ("logs", "0021_logsalertconfiguration_schedule_restriction"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="LogsAlertConfiguration",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("enabled", models.BooleanField(default=True)),
+ ("filters", models.JSONField(default=dict)),
+ ("threshold_count", models.PositiveIntegerField(default=100)),
+ (
+ "threshold_operator",
+ models.CharField(choices=[("above", "Above"), ("below", "Below")], default="above", max_length=10),
+ ),
+ ("window_minutes", models.PositiveIntegerField(default=5)),
+ ("check_interval_minutes", models.PositiveIntegerField(default=5)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("not_firing", "Not firing"),
+ ("firing", "Firing"),
+ ("pending_resolve", "Pending resolve"),
+ ("errored", "Errored"),
+ ("snoozed", "Snoozed"),
+ ("broken", "Broken"),
+ ],
+ default="not_firing",
+ max_length=20,
+ ),
+ ),
+ ("evaluation_periods", models.PositiveIntegerField(default=1)),
+ ("datapoints_to_alarm", models.PositiveIntegerField(default=1)),
+ ("cooldown_minutes", models.PositiveIntegerField(default=0)),
+ ("snooze_until", models.DateTimeField(blank=True, null=True)),
+ ("next_check_at", models.DateTimeField(blank=True, null=True)),
+ ("last_notified_at", models.DateTimeField(blank=True, null=True)),
+ ("last_checked_at", models.DateTimeField(blank=True, null=True)),
+ ("consecutive_failures", models.PositiveIntegerField(default=0)),
+ (
+ "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")),
+ ("first_enabled_at", models.DateTimeField(blank=True, null=True)),
+ ("schedule_restriction", models.JSONField(blank=True, default=None, null=True)),
+ ],
+ options={
+ "db_table": "logs_logsalertconfiguration",
+ "indexes": [
+ models.Index(fields=["team_id", "next_check_at", "enabled"], name="logs_alert_scheduler_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsView",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(max_length=400)),
+ ("filters", models.JSONField(default=dict)),
+ ("pinned", models.BooleanField(default=False)),
+ (
+ "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")),
+ ("columns", models.JSONField(default=None, null=True)),
+ ],
+ options={
+ "db_table": "logs_logsview",
+ "indexes": [models.Index(fields=["team_id", "-created_at"], name="logs_view_team_created_idx")],
+ "unique_together": {("team", "short_id")},
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsExclusionRule",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("enabled", models.BooleanField(default=False)),
+ (
+ "priority",
+ models.PositiveIntegerField(
+ default=0,
+ help_text="Lower values run first; first matching rule wins. Ties use created_at ascending (same as ingestion query order).",
+ ),
+ ),
+ (
+ "rule_type",
+ models.CharField(
+ choices=[
+ ("severity_sampling", "Severity-based reduction"),
+ ("path_drop", "Path exclusion"),
+ ("rate_limit", "Rate limit"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("scope_service", models.CharField(blank=True, max_length=512, null=True)),
+ ("scope_path_pattern", models.CharField(blank=True, max_length=1024, null=True)),
+ ("scope_attribute_filters", models.JSONField(default=list)),
+ ("config", models.JSONField(default=dict)),
+ ("version", models.PositiveIntegerField(default=1)),
+ (
+ "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={
+ "db_table": "logs_logsexclusionrule",
+ "indexes": [
+ models.Index(fields=["team_id", "enabled", "priority"], name="logs_exclusion_team_en_pr_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamLogsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "logs_distinct_id_attribute_key",
+ models.CharField(db_default="posthogDistinctId", default="posthogDistinctId", max_length=200),
+ ),
+ (
+ "logs_session_id_attribute_keys",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=200),
+ db_default=models.Value("{posthogSessionId}"),
+ default=products.logs.backend.models.default_logs_session_id_attribute_keys,
+ size=None,
+ ),
+ ),
+ (
+ "logs_distinct_id_attribute_keys",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=200),
+ db_default=models.Value("{posthogDistinctId}"),
+ default=products.logs.backend.models.default_logs_distinct_id_attribute_keys,
+ size=None,
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsMetricRule",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("metric_name", models.CharField(max_length=200)),
+ ("enabled", models.BooleanField(default=False)),
+ ("filter_group", models.JSONField(blank=True, default=None, null=True)),
+ ("value_attribute", models.CharField(blank=True, max_length=512, null=True)),
+ (
+ "group_by",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=512), blank=True, default=list, size=None
+ ),
+ ),
+ ("version", models.PositiveIntegerField(default=1)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "logs_logsmetricrule",
+ "indexes": [models.Index(fields=["team_id", "enabled"], name="logs_metric_team_enabled_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "metric_name"), name="logs_metric_rule_team_metric_uniq")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsRetentionRule",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("enabled", models.BooleanField(default=False)),
+ (
+ "priority",
+ models.PositiveIntegerField(
+ default=0,
+ help_text="Lower values run first; first matching rule wins. Ties use created_at ascending (same as ingestion query order).",
+ ),
+ ),
+ ("config", models.JSONField(default=dict)),
+ ("version", models.PositiveIntegerField(default=1)),
+ (
+ "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={
+ "db_table": "logs_logsretentionrule",
+ "indexes": [
+ models.Index(fields=["team_id", "enabled", "priority"], name="logs_retention_team_en_pr_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsAlertCheck",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("result_count", models.PositiveIntegerField(blank=True, null=True)),
+ ("threshold_breached", models.BooleanField()),
+ ("state_before", models.CharField(max_length=20)),
+ ("state_after", models.CharField(max_length=20)),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("query_duration_ms", models.PositiveIntegerField(blank=True, null=True)),
+ (
+ "alert",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="checks",
+ to="logs.logsalertconfiguration",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "logs_logsalertcheck",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LogsAlertEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("result_count", models.PositiveIntegerField(blank=True, null=True)),
+ ("threshold_breached", models.BooleanField()),
+ ("state_before", models.CharField(max_length=20)),
+ ("state_after", models.CharField(max_length=20)),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("query_duration_ms", models.PositiveIntegerField(blank=True, null=True)),
+ (
+ "alert",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="events",
+ to="logs.logsalertconfiguration",
+ ),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("check", "Check"),
+ ("reset", "Reset"),
+ ("enable", "Enable"),
+ ("disable", "Disable"),
+ ("snooze", "Snooze"),
+ ("unsnooze", "Unsnooze"),
+ ("threshold_change", "Threshold change"),
+ ("broken_config", "Broken config"),
+ ],
+ default="check",
+ max_length=32,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "logs_logsalertevent",
+ "indexes": [models.Index(fields=["alert", "-created_at"], name="logs_alert_event_alert_ts_idx")],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/managed_migrations/backend/migrations/0001_squash_2026_09_07_initial.py b/products/managed_migrations/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..3037d69137bf
--- /dev/null
+++ b/products/managed_migrations/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,59 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [("managed_migrations", "0001_migrate_managed_migrations_models")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="BatchImport",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_by_id", models.IntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("lease_id", models.TextField(blank=True, null=True)),
+ ("leased_until", models.DateTimeField(blank=True, null=True)),
+ (
+ "status",
+ models.TextField(
+ choices=[
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ("paused", "Paused"),
+ ("running", "Running"),
+ ],
+ default="running",
+ ),
+ ),
+ ("status_message", models.TextField(blank=True, null=True)),
+ ("display_status_message", models.TextField(blank=True, null=True)),
+ ("state", models.JSONField(blank=True, null=True)),
+ ("import_config", models.JSONField()),
+ ("secrets", posthog.helpers.encrypted_fields.EncryptedJSONStringField()),
+ ("backoff_attempt", models.IntegerField(default=0)),
+ ("backoff_until", models.DateTimeField(blank=True, null=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_batchimport",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/managed_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py b/products/managed_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..2735e7998ee4
--- /dev/null
+++ b/products/managed_warehouse/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,149 @@
+# Generated by Django 5.2.17
+
+import django.db.models.manager
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("managed_warehouse", "0001_migrate_managed_warehouse_models"),
+ ("managed_warehouse", "0002_managedwarehousesourcejob"),
+ ("managed_warehouse", "0003_remove_duckgres_batch_sink_state"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="DuckgresServer",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("host", models.CharField(max_length=255)),
+ ("port", models.IntegerField(default=5432)),
+ ("flight_port", models.IntegerField(default=8815)),
+ ("database", models.CharField(default="ducklake", max_length=255)),
+ ("username", models.CharField(max_length=255)),
+ ("password", posthog.helpers.encrypted_fields.EncryptedTextField(max_length=500)),
+ ("catalog_host", models.CharField(blank=True, max_length=255, null=True)),
+ ("catalog_port", models.IntegerField(default=5432)),
+ ("catalog_database", models.CharField(default="ducklake", max_length=255)),
+ ("catalog_username", models.CharField(blank=True, max_length=255, null=True)),
+ (
+ "catalog_password",
+ posthog.helpers.encrypted_fields.EncryptedTextField(blank=True, max_length=500, null=True),
+ ),
+ ("bucket", models.CharField(blank=True, max_length=255, null=True)),
+ ("bucket_region", models.CharField(blank=True, default=None, max_length=50, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="duckgres_server",
+ to="posthog.organization",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Duckgres server",
+ "verbose_name_plural": "Duckgres servers",
+ "db_table": "posthog_duckgresserver",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ManagedWarehouseSourceJob",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("environment_id", models.BigIntegerField()),
+ ("schema_id", models.UUIDField()),
+ ("source_job_id", models.CharField(max_length=400)),
+ ("attempt_id", models.CharField(max_length=500)),
+ (
+ "workflow_type",
+ models.CharField(choices=[("copy", "Copy"), ("register", "Register")], max_length=16),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("running", "Running"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ("skipped", "Skipped"),
+ ("stale", "Stale"),
+ ],
+ max_length=16,
+ ),
+ ),
+ ("workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("workflow_run_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("started_at", models.DateTimeField()),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("latest_error", models.TextField(blank=True, null=True)),
+ (
+ "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,
+ related_name="managed_warehouse_source_jobs",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_managedwarehousesourcejob",
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(
+ fields=["team", "environment_id", "schema_id", "-started_at"], name="mw_source_job_latest_idx"
+ )
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "environment_id", "schema_id", "workflow_type", "attempt_id"),
+ name="unique_managed_warehouse_source_job_attempt",
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/marketing_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/marketing_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..7002878decdd
--- /dev/null
+++ b/products/marketing_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,61 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("marketing_analytics", "0001_add_marketing_analytics_goal_mapping")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="MarketingAnalyticsGoalMapping",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "schema_map",
+ models.JSONField(
+ blank=True, default=dict, help_text="UTM field mappings for data warehouse goals", null=True
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "core_event",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="marketing_goal_mappings",
+ to="posthog.coreevent",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="marketing_analytics_goal_mappings",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_marketinganalyticsgoalmapping",
+ "verbose_name": "Marketing Analytics Goal Mapping",
+ "verbose_name_plural": "Marketing Analytics Goal Mappings",
+ "ordering": ["created_at"],
+ "unique_together": {("team", "core_event")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/marketing_analytics/backend/migrations/max_migration.txt b/products/marketing_analytics/backend/migrations/max_migration.txt
index 8587b9fee8a3..6903cd5e3dc2 100644
--- a/products/marketing_analytics/backend/migrations/max_migration.txt
+++ b/products/marketing_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_add_marketing_analytics_goal_mapping
+0001_squash_2026_09_07_initial
diff --git a/products/mcp_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/mcp_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..87d42bbafb56
--- /dev/null
+++ b/products/mcp_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,155 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("mcp_analytics", "0001_initial"),
+ ("mcp_analytics", "0002_mcpsession"),
+ ("mcp_analytics", "0003_mcpsession_tool_call_count"),
+ ("mcp_analytics", "0004_mcpintentclustersnapshot"),
+ ("mcp_analytics", "0005_alter_mcpsession_duration_seconds_and_more"),
+ ("mcp_analytics", "0006_alter_mcpsession_distinct_id_and_more"),
+ ("mcp_analytics", "0007_alter_mcpsession_options_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="MCPAnalyticsSubmission",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[("feedback", "Feedback"), ("missing_capability", "Missing capability")], max_length=32
+ ),
+ ),
+ ("goal", models.TextField()),
+ ("summary", models.TextField()),
+ (
+ "category",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("results", "Results"),
+ ("usability", "Usability"),
+ ("bug", "Bug"),
+ ("docs", "Docs"),
+ ("other", "Other"),
+ ],
+ default="",
+ max_length=32,
+ ),
+ ),
+ ("blocked", models.BooleanField(blank=True, null=True)),
+ ("attempted_tool", models.CharField(blank=True, default="", max_length=200)),
+ ("mcp_client_name", models.CharField(blank=True, default="", max_length=200)),
+ ("mcp_client_version", models.CharField(blank=True, default="", max_length=100)),
+ ("mcp_protocol_version", models.CharField(blank=True, default="", max_length=50)),
+ ("mcp_transport", models.CharField(blank=True, default="", max_length=50)),
+ ("mcp_session_id", models.CharField(blank=True, default="", max_length=200)),
+ ("mcp_trace_id", models.CharField(blank=True, default="", max_length=200)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_mcp_analytics_submission",
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(fields=["team", "kind", "-created_at"], name="posthog_mcp_team_id_ceb7c0_idx"),
+ models.Index(fields=["team", "attempted_tool"], name="posthog_mcp_team_id_a7ea04_idx"),
+ models.Index(fields=["team", "mcp_session_id"], name="posthog_mcp_team_id_f1ad57_idx"),
+ models.Index(fields=["team", "mcp_trace_id"], name="posthog_mcp_team_id_457610_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPSession",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("session_id", models.CharField(max_length=64)),
+ ("intent", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_mcp_session",
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "session_id"), name="unique_mcp_session")],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPIntentClusterSnapshot",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="mcp_intent_cluster_snapshot",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("idle", "Idle"), ("computing", "Computing"), ("error", "Error")],
+ default="idle",
+ max_length=16,
+ ),
+ ),
+ ("error_message", models.TextField(blank=True, default="")),
+ ("clusters", models.JSONField(default=dict)),
+ ("last_computed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "last_computed_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_mcp_analytics_intent_cluster_snapshot",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/mcp_registry/backend/migrations/0001_squash_2026_09_07_initial.py b/products/mcp_registry/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..f8b28215bff1
--- /dev/null
+++ b/products/mcp_registry/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,238 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("mcp_registry", "0001_initial")]
+
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="MCPRankingRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("version", models.CharField(max_length=100)),
+ ("params", models.JSONField(blank=True, default=dict)),
+ (
+ "status",
+ models.CharField(
+ choices=[("running", "Running"), ("completed", "Completed"), ("failed", "Failed")],
+ default="running",
+ max_length=20,
+ ),
+ ),
+ ("error", models.TextField(blank=True, default="")),
+ ("server_count", models.IntegerField(default=0)),
+ ("computed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ],
+ options={
+ "db_table": "mcp_registry_ranking_run",
+ "indexes": [models.Index(fields=["version", "-created_at"], name="mcp_registr_version_f53ab8_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPRegistryServer",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("registry_name", models.CharField(blank=True, default="", max_length=400)),
+ ("display_name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("canonical_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("remotes", models.JSONField(blank=True, default=list)),
+ ("packages", models.JSONField(blank=True, default=list)),
+ ("repository_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("website_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("listed_in_registry", models.BooleanField(default=False)),
+ ("registry_meta", models.JSONField(blank=True, default=dict)),
+ ("is_measured", models.BooleanField(default=False)),
+ ("measured_public", models.BooleanField(default=False)),
+ (
+ "liveness",
+ models.CharField(
+ choices=[
+ ("alive_open", "Alive, no auth required"),
+ ("alive_auth", "Alive, behind auth"),
+ ("alive_protocol", "Alive, protocol-level error"),
+ ("dead", "Dead"),
+ ("not_mcp", "Responds, but not an MCP server"),
+ ("package_only", "No hosted remote, package install only"),
+ ("unprobed", "Not probed yet"),
+ ],
+ default="unprobed",
+ max_length=20,
+ ),
+ ),
+ (
+ "auth_method",
+ models.CharField(
+ choices=[
+ ("none", "No auth"),
+ ("oauth", "OAuth"),
+ ("api_key", "API key"),
+ ("unknown", "Unknown"),
+ ],
+ default="unknown",
+ max_length=20,
+ ),
+ ),
+ ("last_probed_at", models.DateTimeField(blank=True, null=True)),
+ ("probe_detail", models.CharField(blank=True, default="", max_length=200)),
+ ("mcp_store_template_id", models.UUIDField(blank=True, null=True)),
+ ("connect_overrides", models.JSONField(blank=True, default=dict)),
+ ("supports_agent_provisioning", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "db_table": "mcp_registry_server",
+ "indexes": [
+ models.Index(fields=["listed_in_registry"], name="mcp_registr_listed__c8e64b_idx"),
+ models.Index(fields=["is_measured"], name="mcp_registr_is_meas_b12741_idx"),
+ models.Index(fields=["liveness"], name="mcp_registr_livenes_3dac66_idx"),
+ models.Index(fields=["last_probed_at"], name="mcp_registr_last_pr_0a386c_idx"),
+ models.Index(fields=["canonical_url"], name="mcp_registr_canonic_63116d_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("registry_name", ""), _negated=True),
+ fields=("registry_name",),
+ name="unique_registry_name_when_set",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPRankingScore",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("score", models.FloatField()),
+ ("components", models.JSONField(blank=True, default=dict)),
+ (
+ "run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scores",
+ to="mcp_registry.mcprankingrun",
+ ),
+ ),
+ (
+ "server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="scores",
+ to="mcp_registry.mcpregistryserver",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_registry_ranking_score",
+ "indexes": [models.Index(fields=["run", "-score"], name="mcp_registr_run_id_abf0dc_idx")],
+ "constraints": [models.UniqueConstraint(fields=("run", "server"), name="unique_score_per_run_server")],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPMeasuredStats",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("team_id", models.IntegerField()),
+ ("server_name", models.CharField(max_length=400)),
+ ("window_days", models.IntegerField()),
+ ("calls", models.BigIntegerField(default=0)),
+ ("sessions", models.BigIntegerField(default=0)),
+ ("errors", models.BigIntegerField(default=0)),
+ ("error_rate_pct", models.FloatField(default=0.0)),
+ ("intent_coverage_pct", models.FloatField(default=0.0)),
+ ("distinct_tools", models.IntegerField(default=0)),
+ ("harness_count", models.IntegerField(default=0)),
+ ("tool_stats", models.JSONField(blank=True, default=list)),
+ (
+ "link_method",
+ models.CharField(
+ choices=[
+ ("override", "Known-link override"),
+ ("url", "Remote URL match"),
+ ("exact_name", "Exact name match"),
+ ("standalone", "No registry match, standalone row"),
+ ],
+ max_length=20,
+ ),
+ ),
+ ("link_candidates", models.JSONField(blank=True, default=list)),
+ ("computed_at", models.DateTimeField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="measured_stats",
+ to="mcp_registry.mcpregistryserver",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name_plural": "MCP measured stats",
+ "db_table": "mcp_registry_measured_stats",
+ "indexes": [models.Index(fields=["server"], name="mcp_registr_server__35565b_idx")],
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "server_name"), name="unique_measured_source")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPRegistryTool",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("input_schema", models.JSONField(blank=True, default=dict)),
+ (
+ "source",
+ models.CharField(
+ choices=[("tools_list", "Probed tools/list"), ("analytics", "MCP Analytics usage")],
+ max_length=20,
+ ),
+ ),
+ ("last_seen_at", models.DateTimeField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tools",
+ to="mcp_registry.mcpregistryserver",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_registry_tool",
+ "constraints": [models.UniqueConstraint(fields=("server", "name"), name="unique_tool_per_server")],
+ "indexes": [],
+ },
+ ),
+ ]
diff --git a/products/mcp_store/backend/migrations/0001_squash_2026_09_07_initial.py b/products/mcp_store/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..40903e496d4b
--- /dev/null
+++ b/products/mcp_store/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,889 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("mcp_store", "0001_initial"),
+ ("mcp_store", "0002_mcpserverinstallation_is_enabled_mcpoauthstate"),
+ ("mcp_store", "0003_alter_mcpoauthstate_install_source"),
+ ("mcp_store", "0004_rename_twig_callback_url_to_posthog_code_callback_url"),
+ ("mcp_store", "0005_remove_oauth_provider_kind"),
+ ("mcp_store", "0006_mcpservertemplate_installation_fields_and_tools"),
+ ("mcp_store", "0007_migrate_mcp_creds_to_per_installation"),
+ ("mcp_store", "0008_drop_legacy_mcpserver"),
+ ("mcp_store", "0009_drop_mcpserver_created_by_fk"),
+ ("mcp_store", "0010_mcpservertemplate_category_and_docs_url"),
+ ("mcp_store", "0011_normalize_mcp_template_icon_keys"),
+ ("mcp_store", "0012_alter_mcpserverinstallation_unique_together_and_more"),
+ ("mcp_store", "0013_alter_mcpservertemplate_category_db_default"),
+ ("mcp_store", "0014_mcpservertemplate_icon_domain"),
+ ("mcp_store", "0015_backfill_mcp_template_icon_domains"),
+ ("mcp_store", "0016_mcp_gateway_models"),
+ ("mcp_store", "0017_backfill_gateway_servers"),
+ ("mcp_store", "0018_bind_agent_access_credential"),
+ ("mcp_store", "0019_allow_member_agent_access"),
+ ("mcp_store", "0020_default_servers_enabled"),
+ ("mcp_store", "0021_mcpserverinstallationtool_annotations"),
+ ("mcp_store", "0022_mcpserviceaccountserveraccess_user"),
+ ("mcp_store", "0023_backfill_agent_access_user"),
+ ("mcp_store", "0024_personal_agent_server_access"),
+ ("mcp_store", "0025_drop_old_agent_server_access"),
+ ("mcp_store", "0026_agent_grant_scope"),
+ ("mcp_store", "0027_gateway_server_auth_type"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="MCPServerTemplate",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("url", models.URLField(max_length=2048, unique=True)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "auth_type",
+ models.CharField(
+ choices=[("api_key", "API Key"), ("oauth", "OAuth")], default="oauth", max_length=20
+ ),
+ ),
+ ("icon_key", models.CharField(blank=True, default="", max_length=100)),
+ ("oauth_issuer_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("oauth_metadata", models.JSONField(blank=True, default=dict)),
+ ("oauth_credentials", posthog.helpers.encrypted_fields.EncryptedJSONField(blank=True, default=dict)),
+ ("is_active", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "category",
+ models.CharField(
+ choices=[
+ ("business", "Business Operations"),
+ ("data", "Data & Analytics"),
+ ("design", "Design & Content"),
+ ("dev", "Developer Tools & APIs"),
+ ("infra", "Infrastructure"),
+ ("productivity", "Productivity & Collaboration"),
+ ],
+ db_default="dev",
+ default="dev",
+ max_length=20,
+ ),
+ ),
+ ("docs_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("icon_domain", models.CharField(blank=True, default="", max_length=253)),
+ ],
+ options={
+ "db_table": "mcp_store_mcpservertemplate",
+ "indexes": [models.Index(fields=["is_active"], name="mcp_store_m_is_acti_be2a56_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPOrgRule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "applies_to",
+ models.CharField(
+ choices=[("everyone", "Everyone"), ("members", "Members"), ("agents", "Agents")],
+ default="everyone",
+ max_length=20,
+ ),
+ ),
+ (
+ "effect",
+ models.CharField(
+ choices=[("needs_approval", "Require approval"), ("do_not_use", "Block")],
+ default="do_not_use",
+ max_length=20,
+ ),
+ ),
+ ("tool_pattern", models.CharField(blank=True, default="", max_length=400)),
+ ("enabled", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="org_rules",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcporgrule",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPServiceAccount",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("description", models.TextField(blank=True, default="")),
+ ("handle", models.CharField(max_length=200)),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("paused", "Paused")], default="active", max_length=20
+ ),
+ ),
+ ("token_hash", models.CharField(max_length=128, unique=True)),
+ ("token_mask", models.CharField(blank=True, default="", max_length=64)),
+ ("last_active_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="mcp_service_accounts",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcpserviceaccount",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "handle"), name="uniq_service_account_handle_per_team")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamMCPGatewayConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("allow_custom_servers", models.BooleanField(default=True)),
+ (
+ "member_default_preset",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("allow", "Allow all"),
+ ("user", "Member decides"),
+ ("ask", "Ask for destructive"),
+ ("block", "Block destructive"),
+ ],
+ default="",
+ max_length=20,
+ ),
+ ),
+ (
+ "agent_default_preset",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("allow", "Allow all"),
+ ("user", "Member decides"),
+ ("ask", "Ask for destructive"),
+ ("block", "Block destructive"),
+ ],
+ default="",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="mcp_gateway_config",
+ to="posthog.team",
+ ),
+ ),
+ ("allow_member_agent_access", models.BooleanField(default=True)),
+ ("default_servers_enabled", models.BooleanField(default=True)),
+ ],
+ options={
+ "db_table": "mcp_store_teammcpgatewayconfig",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPGatewayServer",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=200)),
+ ("url", models.URLField(max_length=2048)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "category",
+ models.CharField(
+ choices=[
+ ("business", "Business Operations"),
+ ("data", "Data & Analytics"),
+ ("design", "Design & Content"),
+ ("dev", "Developer Tools & APIs"),
+ ("infra", "Infrastructure"),
+ ("productivity", "Productivity & Collaboration"),
+ ],
+ default="dev",
+ max_length=20,
+ ),
+ ),
+ ("is_team_enabled", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="gateway_servers",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "template",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="gateway_servers",
+ to="mcp_store.mcpservertemplate",
+ ),
+ ),
+ (
+ "auth_type",
+ models.CharField(
+ blank=True,
+ choices=[("api_key", "API Key"), ("oauth", "OAuth")],
+ db_default="",
+ default="",
+ max_length=20,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcpgatewayserver",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "url"), name="uniq_gateway_server_per_team_url")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPServerInstallation",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("display_name", models.CharField(blank=True, default="", max_length=200)),
+ ("url", models.URLField(default="", max_length=2048)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "auth_type",
+ models.CharField(
+ choices=[("api_key", "API Key"), ("oauth", "OAuth")], default="oauth", max_length=20
+ ),
+ ),
+ (
+ "sensitive_configuration",
+ posthog.helpers.encrypted_fields.EncryptedJSONField(blank=True, default=dict),
+ ),
+ (
+ "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")),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="mcp_server_installations",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("is_enabled", models.BooleanField(default=True)),
+ ("oauth_issuer_url", models.URLField(blank=True, default="", max_length=2048)),
+ ("oauth_metadata", models.JSONField(blank=True, default=dict)),
+ (
+ "template",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="installations",
+ to="mcp_store.mcpservertemplate",
+ ),
+ ),
+ (
+ "scope",
+ models.CharField(
+ choices=[("personal", "Personal"), ("shared", "Shared")],
+ db_default="personal",
+ default="personal",
+ max_length=20,
+ ),
+ ),
+ ("last_used_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "gateway_server",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="installations",
+ to="mcp_store.mcpgatewayserver",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcpserverinstallation",
+ "unique_together": set(),
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("scope", "personal")),
+ fields=("team", "user", "url"),
+ name="uniq_personal_install",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("scope", "shared")), fields=("team", "url"), name="uniq_shared_install"
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPMemberServerRevocation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "gateway_server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="member_revocations",
+ to="mcp_store.mcpgatewayserver",
+ ),
+ ),
+ (
+ "revoked_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcpmemberserverrevocation",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("gateway_server", "user"), name="uniq_member_server_revocation")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPToolPolicy",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("tool_name", models.CharField(max_length=200)),
+ (
+ "scope_type",
+ models.CharField(
+ choices=[("team", "Team default"), ("member", "Member"), ("agent", "Agent")], max_length=20
+ ),
+ ),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("approved", "Approved"),
+ ("needs_approval", "Needs approval"),
+ ("do_not_use", "Do not use"),
+ ],
+ default="needs_approval",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "gateway_server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tool_policies",
+ to="mcp_store.mcpgatewayserver",
+ ),
+ ),
+ (
+ "scope_service_account",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tool_policies",
+ to="mcp_store.mcpserviceaccount",
+ ),
+ ),
+ (
+ "scope_user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcptoolpolicy",
+ "indexes": [
+ models.Index(fields=["gateway_server", "scope_type"], name="mcp_store_m_gateway_d897e6_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("scope_type", "team")),
+ fields=("gateway_server", "tool_name"),
+ name="uniq_team_tool_policy",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("scope_type", "member")),
+ fields=("gateway_server", "tool_name", "scope_user"),
+ name="uniq_member_tool_policy",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("scope_type", "agent")),
+ fields=("gateway_server", "tool_name", "scope_service_account"),
+ name="uniq_agent_tool_policy",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("scope_service_account__isnull", True),
+ ("scope_type", "team"),
+ ("scope_user__isnull", True),
+ ),
+ models.Q(
+ ("scope_service_account__isnull", True),
+ ("scope_type", "member"),
+ ("scope_user__isnull", False),
+ ),
+ models.Q(
+ ("scope_service_account__isnull", False),
+ ("scope_type", "agent"),
+ ("scope_user__isnull", True),
+ ),
+ _connector="OR",
+ ),
+ name="tool_policy_scope_matches_type",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPOAuthState",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("token_hash", models.CharField(db_index=True, max_length=64, unique=True)),
+ (
+ "install_source",
+ models.CharField(
+ choices=[("posthog", "posthog"), ("twig", "twig"), ("posthog-code", "posthog-code")],
+ default="posthog",
+ max_length=20,
+ ),
+ ),
+ ("pkce_verifier", models.CharField(blank=True, default="", max_length=255)),
+ ("expires_at", models.DateTimeField()),
+ ("consumed_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
+ ),
+ ),
+ (
+ "installation",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_states",
+ to="mcp_store.mcpserverinstallation",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("posthog_code_callback_url", models.TextField(blank=True, db_column="twig_callback_url", default="")),
+ (
+ "template",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oauth_states",
+ to="mcp_store.mcpservertemplate",
+ ),
+ ),
+ ("web_return_path", models.TextField(blank=True, db_default="", default="")),
+ ],
+ options={
+ "db_table": "mcp_store_mcpoauthstate",
+ "indexes": [
+ models.Index(fields=["expires_at"], name="mcp_store_m_expires_cb1be9_idx"),
+ models.Index(fields=["consumed_at"], name="mcp_store_m_consume_aafa37_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPServerInstallationTool",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("tool_name", models.CharField(max_length=200)),
+ ("display_name", models.CharField(blank=True, default="", max_length=200)),
+ ("description", models.TextField(blank=True, default="")),
+ ("input_schema", models.JSONField(blank=True, default=dict)),
+ (
+ "approval_state",
+ models.CharField(
+ choices=[
+ ("approved", "Approved"),
+ ("needs_approval", "Needs approval"),
+ ("do_not_use", "Do not use"),
+ ],
+ default="needs_approval",
+ max_length=20,
+ ),
+ ),
+ ("last_seen_at", models.DateTimeField()),
+ ("removed_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
+ ),
+ ),
+ (
+ "installation",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tools",
+ to="mcp_store.mcpserverinstallation",
+ ),
+ ),
+ ("annotations", models.JSONField(blank=True, default=dict)),
+ ],
+ options={
+ "db_table": "mcp_store_mcpserverinstallationtool",
+ "indexes": [
+ models.Index(fields=["installation", "approval_state"], name="mcp_store_m_install_2b5d15_idx"),
+ models.Index(fields=["installation", "removed_at"], name="mcp_store_m_install_5a3d5e_idx"),
+ ],
+ "constraints": [],
+ "unique_together": {("installation", "tool_name")},
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPAuditEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("actor_label", models.CharField(blank=True, default="", max_length=254)),
+ ("server_name", models.CharField(blank=True, default="", max_length=200)),
+ ("tool_name", models.CharField(blank=True, default="", max_length=200)),
+ (
+ "decision",
+ models.CharField(
+ choices=[
+ ("auto", "Auto-approved"),
+ ("approved", "Approved"),
+ ("pending", "Awaiting approval"),
+ ("blocked", "Blocked"),
+ ],
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "actor_user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "installation",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="mcp_store.mcpserverinstallation",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "gateway_server",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="audit_events",
+ to="mcp_store.mcpgatewayserver",
+ ),
+ ),
+ (
+ "actor_service_account",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="audit_events",
+ to="mcp_store.mcpserviceaccount",
+ ),
+ ),
+ (
+ "credential_owner",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("grant_scope", models.CharField(blank=True, db_default="", default="", max_length=20)),
+ ],
+ options={
+ "db_table": "mcp_store_mcpauditevent",
+ "indexes": [
+ models.Index(fields=["team", "-created_at"], name="mcp_store_m_team_id_e98417_idx"),
+ models.Index(fields=["team", "decision", "-created_at"], name="mcp_store_m_team_id_79feb4_idx"),
+ models.Index(
+ fields=["team", "actor_service_account", "-created_at"], name="mcp_store_m_team_id_161c46_idx"
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MCPServiceAccountServerAccess",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "gateway_server",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="agent_access",
+ to="mcp_store.mcpgatewayserver",
+ ),
+ ),
+ (
+ "granted_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "service_account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="server_access",
+ to="mcp_store.mcpserviceaccount",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "installation",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="agent_grants",
+ to="mcp_store.mcpserverinstallation",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scope",
+ models.CharField(
+ choices=[("personal", "Personal"), ("team", "Team")],
+ db_default="personal",
+ default="personal",
+ max_length=20,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "mcp_store_mcpserviceaccountserveraccess",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("service_account", "gateway_server", "user"), name="uniq_agent_server_access_per_user"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/messaging/backend/migrations/0001_squash_2026_09_07_initial.py b/products/messaging/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..7c1512360163
--- /dev/null
+++ b/products/messaging/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,122 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("messaging", "0001_migrate_messaging_models")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="MessageCategory",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("key", models.CharField(max_length=64)),
+ ("name", models.CharField(max_length=128)),
+ ("description", models.TextField(blank=True, default="")),
+ ("public_description", models.TextField(blank=True, default="")),
+ (
+ "category_type",
+ models.CharField(
+ choices=[("marketing", "Marketing"), ("transactional", "Transactional")],
+ default="marketing",
+ max_length=32,
+ ),
+ ),
+ (
+ "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={
+ "verbose_name_plural": "message categories",
+ "db_table": "posthog_messagecategory",
+ "unique_together": {("team", "key")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MessageRecipientPreference",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("identifier", models.CharField(max_length=512)),
+ ("preferences", models.JSONField(default=dict)),
+ (
+ "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={
+ "db_table": "posthog_messagerecipientpreference",
+ "unique_together": {("team", "identifier")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="MessageTemplate",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("content", models.JSONField(default=dict)),
+ ("type", models.CharField(blank=True, default="email", max_length=24)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "message_category",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="messaging.messagecategory",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_messagetemplate",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/notebooks/backend/migrations/0001_squash_2026_09_07_initial.py b/products/notebooks/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..a953f4f50671
--- /dev/null
+++ b/products/notebooks/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,268 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("notebooks", "0001_migrate_notebooks_models"),
+ ("notebooks", "0002_add_kernel_runtime"),
+ ("notebooks", "0003_add_kernel_timeouts"),
+ ("notebooks", "0004_resourcenotebook_account"),
+ ("notebooks", "0005_resourcenotebook_account_indexes"),
+ ("notebooks", "0006_resourcenotebook_account_unique_constraint"),
+ ("notebooks", "0007_notebooknoderun"),
+ ("notebooks", "0008_kernelruntime_server_connect_token_and_more"),
+ ("notebooks", "0009_notebooknoderun_code"),
+ ("notebooks", "0010_notebooknoderun_node_type"),
+ ("notebooks", "0011_alter_notebooknoderun_status"),
+ ("notebooks", "0012_kernelruntime_frames_and_more"),
+ ("notebooks", "0013_notebooknoderun_connection_id_and_more"),
+ ("notebooks", "0014_notebook_variables"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("customer_analytics", "0046_usercustomeranalyticsconfig"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Notebook",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("title", models.CharField(blank=True, max_length=256, null=True)),
+ ("content", models.JSONField(blank=True, default=None, null=True)),
+ ("text_content", models.TextField(blank=True, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "visibility",
+ models.CharField(
+ choices=[("internal", "internal"), ("default", "default")], default="default", max_length=20
+ ),
+ ),
+ ("version", models.IntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_notebooks",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("kernel_cpu_cores", models.FloatField(blank=True, null=True)),
+ ("kernel_memory_gb", models.FloatField(blank=True, null=True)),
+ ("kernel_idle_timeout_seconds", models.IntegerField(blank=True, null=True)),
+ ("variables", models.JSONField(blank=True, default=None, null=True)),
+ ],
+ options={
+ "db_table": "posthog_notebook",
+ "indexes": [],
+ "constraints": [],
+ "unique_together": {("team", "short_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="ResourceNotebook",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("group", models.IntegerField(blank=True, db_column="group_id", null=True)),
+ (
+ "notebook",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="resources", to="notebooks.notebook"
+ ),
+ ),
+ (
+ "account",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="notebooks",
+ to="customer_analytics.account",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_resourcenotebook",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("group__isnull", False)),
+ fields=("notebook", "group"),
+ name="unique_notebook_group",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("account__isnull", False)),
+ fields=("notebook", "account"),
+ name="unique_notebook_account",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("group__isnull", False), ("account__isnull", True)),
+ models.Q(("group__isnull", True), ("account__isnull", False)),
+ _connector="OR",
+ ),
+ name="exactly_one_notebook_related_resource",
+ ),
+ ],
+ "unique_together": {("notebook", "group", "account")},
+ },
+ ),
+ migrations.CreateModel(
+ name="KernelRuntime",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("notebook_short_id", models.CharField(max_length=12)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_used_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("starting", "starting"),
+ ("running", "running"),
+ ("stopped", "stopped"),
+ ("timed_out", "timed_out"),
+ ("discarded", "discarded"),
+ ("error", "error"),
+ ],
+ default="starting",
+ max_length=20,
+ ),
+ ),
+ (
+ "backend",
+ models.CharField(
+ choices=[("modal", "modal"), ("docker", "docker")], default="docker", max_length=20
+ ),
+ ),
+ ("kernel_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("kernel_pid", models.IntegerField(blank=True, null=True)),
+ ("connection_file", models.TextField(blank=True, null=True)),
+ ("last_error", models.TextField(blank=True, null=True)),
+ ("sandbox_id", models.CharField(blank=True, max_length=128, null=True)),
+ (
+ "notebook",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="notebooks.notebook"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ("server_connect_token", models.TextField(blank=True, null=True)),
+ ("server_url", models.TextField(blank=True, null=True)),
+ ("frames", models.JSONField(blank=True, default=None, null=True)),
+ ("frames_run_created_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_kernelruntime",
+ "indexes": [
+ models.Index(
+ fields=["team", "notebook_short_id", "user", "status"], name="posthog_ker_team_id_934f49_idx"
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="NotebookNodeRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("node_id", models.CharField(max_length=128)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("running", "running"),
+ ("done", "done"),
+ ("failed", "failed"),
+ ("interrupted", "interrupted"),
+ ],
+ default="running",
+ max_length=20,
+ ),
+ ),
+ ("envelope", models.JSONField(blank=True, default=None, null=True)),
+ ("result_id", models.UUIDField(blank=True, null=True)),
+ ("error", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("notebook", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="notebooks.notebook")),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("code", models.TextField(blank=True, default="")),
+ (
+ "node_type",
+ models.CharField(
+ choices=[("hogql", "hogql"), ("python", "python"), ("duckdb", "duckdb")],
+ default="hogql",
+ max_length=20,
+ ),
+ ),
+ ("kernel_runtime_id", models.UUIDField(blank=True, null=True)),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("connection_id", models.UUIDField(blank=True, null=True)),
+ ("send_raw_query", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "db_table": "posthog_notebooknoderun",
+ "indexes": [
+ models.Index(fields=["team", "notebook", "node_id"], name="posthog_not_team_id_764c87_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py b/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..ecb1af482fd3
--- /dev/null
+++ b/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,92 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0017_kernelruntime_provisioned_cpu_cores_and_more"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_resourcenotebook_account_id_idx"\n ON "posthog_resourcenotebook" ("account_id");\n ',
+ reverse_sql="",
+ ),
+ migrations.RunSQL(
+ sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_resourcenotebook_notebook_id_group_id_acc_7a017f67_uniq"\n ON "posthog_resourcenotebook" (\n "notebook_id",\n "group_id",\n "account_id"\n );\n ',
+ reverse_sql="",
+ ),
+ ]
diff --git a/products/notebooks/backend/migrations/max_migration.txt b/products/notebooks/backend/migrations/max_migration.txt
index 36ffd37f26de..814d850ec43c 100644
--- a/products/notebooks/backend/migrations/max_migration.txt
+++ b/products/notebooks/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0017_kernelruntime_provisioned_cpu_cores_and_more
+0019_squash_2026_09_07_schema_addons
diff --git a/products/notifications/backend/migrations/0001_squash_2026_09_07_initial.py b/products/notifications/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..dbdf4279ab8f
--- /dev/null
+++ b/products/notifications/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,203 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.notifications.backend.facade.enums
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("notifications", "0001_initial"),
+ ("notifications", "0002_rename_urgent_to_critical"),
+ ("notifications", "0003_notificationevent_source_id_and_more"),
+ ("notifications", "0004_alter_notificationevent_notification_type"),
+ ("notifications", "0005_alter_notificationevent_notification_type"),
+ ("notifications", "0006_alter_notificationevent_notification_type"),
+ ("notifications", "0007_alter_notificationevent_notification_type"),
+ ("notifications", "0008_alter_notificationevent_notification_type"),
+ ("notifications", "0009_alter_notificationevent_notification_type"),
+ ("notifications", "0010_alter_notificationevent_notification_type"),
+ ("notifications", "0011_alter_notificationevent_notification_type"),
+ ("notifications", "0012_alter_notificationevent_notification_type"),
+ ("notifications", "0013_notificationevent_metadata"),
+ ("notifications", "0014_alter_notificationevent_notification_type"),
+ ("notifications", "0015_alter_notificationevent_notification_type"),
+ ("notifications", "0016_alter_notificationevent_notification_type"),
+ ("notifications", "0017_notificationevent_archivable_notificationarchivestate"),
+ ("notifications", "0018_alter_notificationevent_notification_type"),
+ ("notifications", "0019_remove_notificationevent_archivable"),
+ ("notifications", "0020_alter_notificationevent_notification_type"),
+ ("notifications", "0021_alter_notificationevent_notification_type"),
+ ("notifications", "0022_add_notification_idempotency_key"),
+ ("notifications", "0023_add_notification_idempotency_key_index"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="NotificationEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "notification_type",
+ models.CharField(
+ choices=[
+ ("comment_mention", "COMMENT_MENTION"),
+ ("alert_firing", "ALERT_FIRING"),
+ ("issue_assigned", "ISSUE_ASSIGNED"),
+ ("approval_requested", "APPROVAL_REQUESTED"),
+ ("approval_resolved", "APPROVAL_RESOLVED"),
+ ("experiment_concluded", "EXPERIMENT_CONCLUDED"),
+ ("pipeline_failure", "PIPELINE_FAILURE"),
+ ("project_created", "PROJECT_CREATED"),
+ ("usage_spike", "USAGE_SPIKE"),
+ ("reminder", "REMINDER"),
+ ("web_analytics_digest", "WEB_ANALYTICS_DIGEST"),
+ ("achievement_unlocked", "ACHIEVEMENT_UNLOCKED"),
+ ("subscription_nudge", "SUBSCRIPTION_NUDGE"),
+ ("email_reputation", "EMAIL_REPUTATION"),
+ ("materialization_failure", "MATERIALIZATION_FAILURE"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "priority",
+ models.CharField(
+ choices=[("normal", "NORMAL"), ("critical", "CRITICAL")],
+ default=products.notifications.backend.facade.enums.Priority["NORMAL"],
+ max_length=16,
+ ),
+ ),
+ ("title", models.CharField(max_length=255)),
+ ("body", models.TextField(blank=True, default="")),
+ ("resource_type", models.CharField(blank=True, max_length=64, null=True)),
+ ("resource_id", models.CharField(blank=True, default="", max_length=64)),
+ ("source_url", models.CharField(blank=True, default="", max_length=512)),
+ (
+ "target_type",
+ models.CharField(
+ choices=[
+ ("user", "USER"),
+ ("team", "TEAM"),
+ ("organization", "ORGANIZATION"),
+ ("role", "ROLE"),
+ ],
+ max_length=16,
+ ),
+ ),
+ ("target_id", models.CharField(max_length=64)),
+ ("resolved_user_ids", models.JSONField(default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("source_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("source_type", models.CharField(blank=True, max_length=64, null=True)),
+ ("metadata", models.JSONField(blank=True, default=None, null=True)),
+ ("idempotency_key", models.CharField(blank=True, max_length=128, null=True)),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(fields=["organization", "-created_at"], name="notificatio_organiz_e0c00e_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("idempotency_key__isnull", False), ("team__isnull", False)),
+ fields=("team", "idempotency_key"),
+ name="notification_event_team_idempotency_key_uniq",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("idempotency_key__isnull", False), ("team__isnull", True)),
+ fields=("organization", "idempotency_key"),
+ name="notification_event_organization_idempotency_key_uniq",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="NotificationReadState",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "notification_event",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="read_states",
+ to="notifications.notificationevent",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="notification_read_states",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("notification_event", "user"), name="unique_read_state_per_user")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="NotificationArchiveState",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "notification_event",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="archive_states",
+ to="notifications.notificationevent",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="notification_archive_states",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("notification_event", "user"), name="unique_archive_state_per_user")
+ ],
+ "indexes": [],
+ },
+ ),
+ ]
diff --git a/products/posthog_ai/backend/migrations/0001_squash_2026_09_07_initial.py b/products/posthog_ai/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..fd47df851ee1
--- /dev/null
+++ b/products/posthog_ai/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,423 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.posthog_ai.backend.models.assistant
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("posthog_ai", "0001_initial"),
+ ("posthog_ai", "0002_migrate_posthog_ai_models"),
+ ("posthog_ai", "0003_conversation_topic"),
+ ("posthog_ai", "0004_conversation_agent_runtime_conversation_task_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="AgentMemory",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("contents", models.TextField(blank=True, default="")),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="agent_memories", to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="agent_memories",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "id"], name="posthog_ai__team_id_6610ac_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Conversation",
+ fields=[
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[("idle", "Idle"), ("in_progress", "In progress"), ("canceling", "Canceling")],
+ default="idle",
+ max_length=20,
+ ),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("assistant", "Assistant"),
+ ("tool_call", "Tool call"),
+ ("deep_research", "Deep research"),
+ ("slack", "Slack"),
+ ],
+ default="assistant",
+ max_length=20,
+ ),
+ ),
+ (
+ "title",
+ models.CharField(blank=True, help_text="Title of the conversation.", max_length=250, null=True),
+ ),
+ (
+ "is_internal",
+ models.BooleanField(
+ default=False,
+ help_text="Whether this conversation was created during an impersonated session (e.g., by support agents). Internal conversations are hidden from customers.",
+ null=True,
+ ),
+ ),
+ (
+ "slack_thread_key",
+ models.CharField(
+ blank=True,
+ help_text="Unique key for Slack thread: '{workspace_id}:{channel}:{thread_ts}'",
+ max_length=200,
+ null=True,
+ ),
+ ),
+ (
+ "slack_workspace_domain",
+ models.CharField(
+ blank=True,
+ help_text="Slack workspace subdomain (e.g. 'posthog' for posthog.slack.com)",
+ max_length=100,
+ null=True,
+ ),
+ ),
+ (
+ "approval_decisions",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Stores approval card metadata for dangerous operations (payload lives in checkpoint). Format: {proposal_id: {decision_status: 'pending' | 'approved' | 'rejected' | 'auto_rejected', tool_name: str, preview: str, ...}}",
+ ),
+ ),
+ (
+ "messages_json",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Stored messages for non-LangGraph modes (e.g., sandbox).",
+ null=True,
+ ),
+ ),
+ (
+ "sandbox_task_id",
+ models.UUIDField(
+ blank=True, help_text="Deprecated. Permanent link to Task for sandbox conversations.", null=True
+ ),
+ ),
+ (
+ "sandbox_run_id",
+ models.UUIDField(
+ blank=True,
+ help_text="Deprecated. Permanent link to current TaskRun for sandbox conversations.",
+ null=True,
+ ),
+ ),
+ ("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)),
+ (
+ "topic",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("web_analytics", "Web analytics"),
+ ("product_analytics", "Product analytics"),
+ ("session_replay", "Session replay"),
+ ("surveys", "Surveys"),
+ ("feature_flags", "Feature flags"),
+ ("experiments", "Experiments"),
+ ("error_tracking", "Error tracking"),
+ ("data_warehouse", "Data warehouse"),
+ ("other", "Other"),
+ ],
+ help_text="Product domain the conversation is about, classified from the first question.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ (
+ "agent_runtime",
+ models.CharField(
+ choices=[("langgraph", "LangGraph"), ("sandbox", "Sandbox")],
+ db_index=True,
+ default="langgraph",
+ help_text="Runtime that owns this conversation for its whole life. Stamped at create time from the phai-sandbox-mode flag; never re-evaluated.",
+ max_length=16,
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ blank=True,
+ help_text="The products/tasks Task backing a sandbox conversation. One Task per conversation for its whole life.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.task",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_conversation",
+ "indexes": [models.Index(fields=["updated_at"], name="ee_conversa_updated_19e4e6_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("slack_thread_key__isnull", False)),
+ fields=("team", "slack_thread_key"),
+ name="unique_team_slack_thread_key",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="CoreMemory",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "text",
+ models.TextField(default="", help_text="Dumped core memory where facts are separated by newlines."),
+ ),
+ ("initial_text", models.TextField(default="", help_text="Scraped memory about the business.")),
+ (
+ "scraping_status",
+ models.CharField(
+ blank=True,
+ choices=[("pending", "Pending"), ("completed", "Completed"), ("skipped", "Skipped")],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("scraping_started_at", models.DateTimeField(null=True)),
+ ("team", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "ee_corememory",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ 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.uuidt.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.")),
+ (
+ "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")),
+ (
+ "conversation",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="artifacts",
+ to="posthog_ai.conversation",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_agentartifact",
+ "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"),
+ ],
+ "constraints": [models.UniqueConstraint(fields=("team", "short_id"), name="unique_team_short_id")],
+ },
+ ),
+ migrations.CreateModel(
+ name="ConversationCheckpoint",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.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="posthog_ai.conversationcheckpoint",
+ ),
+ ),
+ (
+ "thread",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="checkpoints",
+ to="posthog_ai.conversation",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_conversationcheckpoint",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("id", "checkpoint_ns", "thread"), name="unique_checkpoint")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ConversationCheckpointBlob",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.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).',
+ ),
+ ),
+ (
+ "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="posthog_ai.conversationcheckpoint",
+ ),
+ ),
+ (
+ "thread",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="blobs",
+ to="posthog_ai.conversation",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_conversationcheckpointblob",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("thread_id", "checkpoint_ns", "channel", "version"), name="unique_checkpoint_blob"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ConversationCheckpointWrite",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.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="posthog_ai.conversationcheckpoint",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "ee_conversationcheckpointwrite",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("checkpoint_id", "task_id", "idx"), name="unique_checkpoint_write")
+ ],
+ },
+ ),
+ ]
diff --git a/products/posthog_ai/backend/migrations/max_migration.txt b/products/posthog_ai/backend/migrations/max_migration.txt
index bc5d9e976d92..6903cd5e3dc2 100644
--- a/products/posthog_ai/backend/migrations/max_migration.txt
+++ b/products/posthog_ai/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0004_conversation_agent_runtime_conversation_task_and_more
+0001_squash_2026_09_07_initial
diff --git a/products/product_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/product_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..29f79b6108a1
--- /dev/null
+++ b/products/product_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,202 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("product_analytics", "0001_migrate_product_analytics_models"),
+ ("product_analytics", "0002_delete_insightcachingstate"),
+ ("product_analytics", "0003_drop_insightcachingstate_table"),
+ ("product_analytics", "0004_delete_revenue_analytics_insights"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("dashboards", "0015_dashboard_customization"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Insight",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("derived_name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.CharField(blank=True, max_length=400, null=True)),
+ ("filters", models.JSONField(default=dict)),
+ ("filters_hash", models.CharField(blank=True, max_length=400, null=True)),
+ ("query", models.JSONField(blank=True, null=True)),
+ ("query_metadata", models.JSONField(blank=True, null=True)),
+ ("order", models.IntegerField(blank=True, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("saved", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True, null=True)),
+ ("refreshing", models.BooleanField(default=False)),
+ ("is_sample", models.BooleanField(default=False)),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("favorited", models.BooleanField(default=False)),
+ ("refresh_attempt", models.IntegerField(blank=True, null=True)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("last_refresh", models.DateTimeField(blank=True, null=True)),
+ ("layouts", models.JSONField(default=dict)),
+ ("color", models.CharField(blank=True, max_length=400, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("type", models.CharField(blank=True, max_length=400, null=True)),
+ ("funnel", models.IntegerField(blank=True, null=True)),
+ (
+ "deprecated_tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ (
+ "deprecated_tags_v2",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32),
+ blank=True,
+ db_column="tags",
+ default=None,
+ null=True,
+ size=None,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, 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.CASCADE,
+ related_name="items",
+ to="dashboards.dashboard",
+ ),
+ ),
+ (
+ "dive_dashboard",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="dashboards.dashboard"
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_insights",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_dashboarditem",
+ "indexes": [
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["query_metadata"], name="dashboarditem_query_metadata", opclasses=["jsonb_ops"]
+ ),
+ models.Index(
+ condition=models.Q(("deleted", False)),
+ fields=["team_id", "-last_modified_at"],
+ name="dashboarditem_team_lmod_idx",
+ ),
+ ],
+ "constraints": [],
+ "unique_together": {("team", "short_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="InsightVariable",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("code_name", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("String", "String"),
+ ("Number", "Number"),
+ ("Boolean", "Boolean"),
+ ("List", "List"),
+ ("Date", "Date"),
+ ],
+ max_length=128,
+ ),
+ ),
+ ("default_value", models.JSONField(blank=True, null=True)),
+ ("values", models.JSONField(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
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("is_multi", models.BooleanField(db_default=False, default=False)),
+ ("values_query", models.TextField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_insightvariable",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="InsightViewed",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("last_viewed_at", models.DateTimeField()),
+ (
+ "insight",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="product_analytics.insight"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_insightviewed",
+ "indexes": [
+ models.Index(
+ fields=["team_id", "user_id", "-last_viewed_at"], name="posthog_ins_team_id_339ee0_idx"
+ ),
+ models.Index(fields=["insight_id", "-last_viewed_at"], name="insightviewed_insight_lva_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user", "insight"), name="posthog_unique_insightviewed")
+ ],
+ },
+ ),
+ ]
diff --git a/products/product_tours/backend/migrations/0001_squash_2026_09_07_initial.py b/products/product_tours/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..0b1c364b7868
--- /dev/null
+++ b/products/product_tours/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,104 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("product_tours", "0001_initial"),
+ ("product_tours", "0002_producttour_auto_launch"),
+ ("product_tours", "0003_producttour_linked_surveys"),
+ ("product_tours", "0004_producttour_linked_flag"),
+ ("product_tours", "0005_producttour_draft_content"),
+ ("product_tours", "0006_alter_producttour_linked_surveys"),
+ ("product_tours", "0007_migrate_feature_flags_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("feature_flags", "0014_clean_flag_filters_inert_violations"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("surveys", "0005_migrate_product_analytics_models"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ProductTour",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("content", models.JSONField(blank=True, default=dict)),
+ ("start_date", models.DateTimeField(blank=True, null=True)),
+ ("end_date", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("archived", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="product_tours_created",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "internal_targeting_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="product_tours_internal_targeting_flag",
+ related_query_name="product_tour_internal_targeting_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="product_tours",
+ related_query_name="product_tour",
+ to="posthog.team",
+ ),
+ ),
+ ("auto_launch", models.BooleanField(default=False)),
+ (
+ "linked_surveys",
+ models.ManyToManyField(
+ blank=True, related_name="product_tours", related_query_name="product_tour", to="surveys.survey"
+ ),
+ ),
+ (
+ "linked_flag",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="product_tours_linked_flag",
+ related_query_name="product_tour_linked_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ ("draft_content", models.JSONField(blank=True, default=None, null=True)),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "archived"], name="product_tou_team_id_7f7a1a_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("archived", False)),
+ fields=("team", "name"),
+ name="unique_product_tour_name_per_team",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/product_tours/backend/migrations/max_migration.txt b/products/product_tours/backend/migrations/max_migration.txt
index 38261dd9b38e..6903cd5e3dc2 100644
--- a/products/product_tours/backend/migrations/max_migration.txt
+++ b/products/product_tours/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0007_migrate_feature_flags_models
+0001_squash_2026_09_07_initial
diff --git a/products/pulse/backend/migrations/0001_squash_2026_09_07_initial.py b/products/pulse/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..52062e03f96c
--- /dev/null
+++ b/products/pulse/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,307 @@
+# Generated by Django 5.2.17
+
+import django.db.models.manager
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.pulse.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [("pulse", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("annotations", "0003_annotation_hidden_in_user_interface"),
+ ("dashboards", "0015_dashboard_customization"),
+ ("experiments", "0033_teamexperimentsconfig_precomputation_enabled_set_by"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ 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.uuidt.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",
+ "indexes": [],
+ "constraints": [],
+ },
+ 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.uuidt.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",
+ "indexes": [
+ models.Index(
+ condition=models.Q(("status", "generating")),
+ fields=["updated_at"],
+ name="pulse_brief_generating_idx",
+ )
+ ],
+ "constraints": [],
+ },
+ 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.uuidt.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",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "fingerprint"), name="pulse_opp_team_fp_unique")
+ ],
+ },
+ 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.uuidt.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",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/reminders/backend/migrations/0001_squash_2026_09_07_initial.py b/products/reminders/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..5974fd9e9efd
--- /dev/null
+++ b/products/reminders/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,114 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("reminders", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Reminder",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("title", models.CharField(max_length=255)),
+ ("message", models.TextField(blank=True, default="")),
+ ("resource_type", models.CharField(blank=True, max_length=50, null=True)),
+ ("resource_id", models.CharField(blank=True, max_length=200, null=True)),
+ ("scheduled_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "recurrence_interval",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("daily", "Daily"),
+ ("weekly", "Weekly"),
+ ("monthly", "Monthly"),
+ ("yearly", "Yearly"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("cron_expression", models.CharField(blank=True, max_length=100, null=True)),
+ ("timezone", models.CharField(default="UTC", max_length=64)),
+ ("end_date", models.DateTimeField(blank=True, null=True)),
+ ("next_fire_at", models.DateTimeField(blank=True, null=True)),
+ ("last_fired_at", models.DateTimeField(blank=True, null=True)),
+ ("failure_count", models.IntegerField(default=0)),
+ ("last_error", models.TextField(blank=True, null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("completed", "Completed"), ("errored", "Errored")],
+ default="active",
+ max_length=20,
+ ),
+ ),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "organization",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.organization"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ condition=models.Q(("deleted", False), ("status", "active")),
+ fields=["next_fire_at"],
+ name="reminders_active_due_idx",
+ )
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("cron_expression__isnull", True),
+ ("recurrence_interval__isnull", True),
+ ("scheduled_at__isnull", False),
+ ),
+ models.Q(
+ ("cron_expression__isnull", True),
+ ("recurrence_interval__isnull", False),
+ ("scheduled_at__isnull", True),
+ ),
+ models.Q(
+ ("cron_expression__isnull", False),
+ ("recurrence_interval__isnull", True),
+ ("scheduled_at__isnull", True),
+ ),
+ _connector="OR",
+ ),
+ name="reminders_schedule_exactly_one",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/reminders/backend/migrations/max_migration.txt b/products/reminders/backend/migrations/max_migration.txt
index cbab66dde92a..6903cd5e3dc2 100644
--- a/products/reminders/backend/migrations/max_migration.txt
+++ b/products/reminders/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0001_squash_2026_09_07_initial
diff --git a/products/replay/backend/migrations/0001_squash_2026_09_07_initial.py b/products/replay/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..8f9e4fa8285b
--- /dev/null
+++ b/products/replay/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,71 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("replay", "0001_migrate_replay_models"), ("replay", "0002_remove_session_summary_models")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ExportedRecording",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("session_id", models.CharField(max_length=200)),
+ ("reason", models.TextField()),
+ ("export_location", models.CharField(blank=True, max_length=1000, null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("running", "Running"),
+ ("complete", "Complete"),
+ ("failed", "Failed"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("error_message", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="exported_recordings",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="exported_recordings",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_exportedrecording",
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/replay_vision/backend/migrations/0001_squash_2026_09_07_initial.py b/products/replay_vision/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..97689a03a580
--- /dev/null
+++ b/products/replay_vision/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,1230 @@
+# Generated by Django 5.2.17
+
+import django.core.validators
+import django.db.models.manager
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.replay_vision.backend.models.replay_scanner
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("replay_vision", "0001_initial"),
+ ("replay_vision", "0002_rename_replaylensobservation_replayobservation_and_more"),
+ ("replay_vision", "0003_remove_replayobservation_lens_config_snapshot_and_more"),
+ ("replay_vision", "0004_replayobservation_lens_result"),
+ ("replay_vision", "0005_alter_replaylens_model"),
+ ("replay_vision", "0006_rename_lens_to_scanner"),
+ ("replay_vision", "0007_add_ineligible_status"),
+ ("replay_vision", "0008_drop_indexer"),
+ ("replay_vision", "0009_drop_indexer_choice"),
+ ("replay_vision", "0010_replayscanner_last_seen_session_id"),
+ ("replay_vision", "0011_backfill_monitor_verdict"),
+ ("replay_vision", "0012_replayquotagrant"),
+ ("replay_vision", "0013_replayscanner_estimated_at_and_more"),
+ ("replay_vision", "0014_visionaction_visionactionrun_and_more"),
+ ("replay_vision", "0015_alter_visionaction_selection"),
+ ("replay_vision", "0016_alter_visionaction_selection"),
+ ("replay_vision", "0017_replayobservationusage"),
+ ("replay_vision", "0018_backfill_replay_observation_usage"),
+ ("replay_vision", "0019_replayobservation_distinct_id_and_more"),
+ ("replay_vision", "0020_replayobservation_recording_subject_email"),
+ ("replay_vision", "0021_replayobservation_scanner_created_idx"),
+ ("replay_vision", "0022_alter_replayscanner_last_swept_at"),
+ ("replay_vision", "0023_visionactionrun_observation_ids"),
+ ("replay_vision", "0024_visionaction_max_observations"),
+ ("replay_vision", "0025_alter_replayobservation_error_reason"),
+ ("replay_vision", "0026_replayscanner_sampling_mode"),
+ ("replay_vision", "0027_replayobservationlabel"),
+ ("replay_vision", "0028_replayscannerpromptsuggestion"),
+ ("replay_vision", "0029_visionaction_is_scanner_digest"),
+ ("replay_vision", "0030_vision_action_unique_scanner_digest"),
+ ("replay_vision", "0031_replayobservationusage_team_id"),
+ ("replay_vision", "0032_replayobservationusage_rlou_created_team_idx"),
+ ("replay_vision", "0033_backfill_replayobservationusage_team_id"),
+ ("replay_vision", "0034_alter_replayscanner_model"),
+ ("replay_vision", "0035_remap_scanner_models"),
+ ("replay_vision", "0036_replayobservationusage_credits_and_more"),
+ ("replay_vision", "0037_backfill_replayobservationusage_credits"),
+ ("replay_vision", "0038_redenominate_quota_grants_to_credits"),
+ ("replay_vision", "0039_alter_replayquotagrant_amount"),
+ ("replay_vision", "0040_replayobservation_rlo_team_in_flight_idx"),
+ ("replay_vision", "0041_strip_summarizer_emits_embeddings"),
+ ("replay_vision", "0042_alter_replayobservation_triggered_by_and_more"),
+ ("replay_vision", "0043_replayscannerpromptsuggestion_evaluation"),
+ ("replay_vision", "0044_replayscanner_feedback_themes"),
+ ("replay_vision", "0045_visionaction_alert_config_alter_visionaction_mode"),
+ ("replay_vision", "0046_alter_visionaction_alert_config"),
+ ("replay_vision", "0047_alter_visionaction_alert_config"),
+ ("replay_vision", "0048_alter_visionaction_alert_config"),
+ ("replay_vision", "0049_replayscannerpromptsuggestion_base_config_and_more"),
+ ("replay_vision", "0050_replayobservation_created_task_id"),
+ ("replay_vision", "0051_alter_replayscanner_model"),
+ ("replay_vision", "0052_remap_scanner_models"),
+ ("replay_vision", "0053_alter_replayscanner_model"),
+ ("replay_vision", "0054_revert_remapped_preview_scanners"),
+ ("replay_vision", "0055_alter_replayscanner_model"),
+ ("replay_vision", "0056_alter_replayobservation_help_texts"),
+ ("replay_vision", "0057_closed_beta_launch_reset"),
+ ("replay_vision", "0058_delete_replayquotagrant"),
+ ("replay_vision", "0059_replayscanner_origin"),
+ ("replay_vision", "0060_replayscanner_origin_indexes"),
+ ("replay_vision", "0061_replayscanner_drop_legacy_name_constraint"),
+ ("replay_vision", "0062_replayscanner_experiment_targeting"),
+ ("replay_vision", "0063_alter_replayobservation_triggered_by_and_more"),
+ ("replay_vision", "0064_replayobservation_backfill_index"),
+ ("replay_vision", "0065_replayscannerbackfill_skipped_count_and_more"),
+ ("replay_vision", "0066_replayscanner_last_deep_swept_at"),
+ ("replay_vision", "0067_scanner_credit_limit"),
+ ("replay_vision", "0068_scanner_usage_scanner_id_index"),
+ ("replay_vision", "0069_validate_replay_scanner_credit_limit_positive"),
+ ("replay_vision", "0070_backfill_usage_scanner_id"),
+ ("replay_vision", "0071_replayscanner_sweep_read_bytes_by_hour_and_more"),
+ ("replay_vision", "0072_replayscanner_limit_notified_period_start"),
+ ("replay_vision", "0073_rebackfill_usage_scanner_id"),
+ ("replay_vision", "0074_observation_session_group_keys"),
+ ("replay_vision", "0075_alter_replayscanner_model"),
+ ("replay_vision", "0076_remap_scanner_models_gemini_3_7"),
+ ("replay_vision", "0077_replayscanner_deep_sweep_fields"),
+ ("replay_vision", "0078_migrate_deep_sweep_watermark"),
+ ("replay_vision", "0079_replayscanner_primed_at"),
+ ("replay_vision", "0080_backfill_primed_at"),
+ ("replay_vision", "0081_callable_choices"),
+ ("replay_vision", "0082_admission_budget_cache"),
+ ("replay_vision", "0083_visionalertconfiguration_visionalertevent_and_more"),
+ ("replay_vision", "0084_observation_window_index"),
+ ("replay_vision", "0085_alter_replayobservation_error_reason"),
+ ("replay_vision", "0086_remove_visionactionrun_vision_action_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ReplayScanner",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "name",
+ models.CharField(
+ blank=True,
+ help_text="Human-readable name, unique within the team. Empty for inline scanners, which aren't named.",
+ max_length=255,
+ ),
+ ),
+ (
+ "description",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Free-form description for the scanner management UI. Not used by the model.",
+ ),
+ ),
+ (
+ "query",
+ models.JSONField(
+ default=dict,
+ help_text="Persisted `posthog.schema.RecordingsQuery` shape; date_from/date_to stripped on save.",
+ ),
+ ),
+ (
+ "sampling_rate",
+ models.FloatField(
+ default=1.0,
+ help_text="0..1 random downsample applied after the query matches.",
+ validators=[
+ django.core.validators.MinValueValidator(0.0),
+ django.core.validators.MaxValueValidator(1.0),
+ ],
+ ),
+ ),
+ ("provider", models.CharField(choices=[("google", "Google")], default="google", max_length=32)),
+ (
+ "model",
+ models.CharField(
+ choices=products.replay_vision.backend.models.replay_scanner.scanner_model_choices,
+ max_length=64,
+ ),
+ ),
+ ("emits_signals", models.BooleanField(default=False)),
+ (
+ "last_swept_at",
+ models.DateTimeField(
+ default=products.replay_vision.backend.models.replay_scanner.initial_watermark,
+ help_text="Watermark for the scanner schedule's last fire; mirrors Temporal schedule state for recovery.",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ (
+ "enabled",
+ models.BooleanField(
+ default=True,
+ help_text="When false, the reconciler removes the scanner's Temporal schedule. On-demand triggers still work.",
+ ),
+ ),
+ (
+ "scanner_type",
+ models.CharField(
+ choices=[
+ ("monitor", "Monitor"),
+ ("classifier", "Classifier"),
+ ("scorer", "Scorer"),
+ ("summarizer", "Summarizer"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "scanner_config",
+ models.JSONField(default=dict, help_text="Type-specific configuration; always includes `prompt`."),
+ ),
+ (
+ "scanner_version",
+ models.PositiveIntegerField(
+ default=1,
+ help_text="Increments on every config-changing save. Observations snapshot the version that produced them.",
+ ),
+ ),
+ (
+ "last_seen_session_id",
+ models.CharField(
+ blank=True,
+ db_default="",
+ default="",
+ help_text="Keyset tiebreaker; set when the last batch saturated so the next sweep resumes past session_end ties.",
+ max_length=200,
+ ),
+ ),
+ (
+ "estimated_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the estimate was last computed. Refreshed on config saves and by the sweep when stale.",
+ null=True,
+ ),
+ ),
+ (
+ "estimated_monthly_observations",
+ models.PositiveIntegerField(
+ blank=True,
+ help_text="Latest projected observations/month for this scanner; enabled scanners are summed org-wide for the quota prognosis.",
+ null=True,
+ ),
+ ),
+ (
+ "sampling_mode",
+ models.CharField(
+ choices=[("focused", "Focused"), ("balanced", "Balanced"), ("comprehensive", "Comprehensive")],
+ default="comprehensive",
+ help_text="Quality pre-filter applied before random sampling. focused = top sessions by surfacing score, balanced = drops the lowest-quality sessions, comprehensive = no filter.",
+ max_length=20,
+ ),
+ ),
+ (
+ "feedback_themes",
+ models.JSONField(
+ blank=True,
+ help_text="AI summary of the team's written thumbs-down feedback into recurring failure modes.",
+ null=True,
+ ),
+ ),
+ (
+ "origin",
+ models.CharField(
+ choices=[("configured", "Configured"), ("inline", "Inline")],
+ db_default="configured",
+ default="configured",
+ help_text="Whether a user saved this scanner or an inline scan minted it. See `ScannerOrigin`.",
+ max_length=16,
+ ),
+ ),
+ (
+ "inline_key",
+ models.CharField(
+ blank=True,
+ db_default="",
+ default="",
+ help_text="Config fingerprint an inline scan resolves by. Empty for configured scanners.",
+ max_length=64,
+ ),
+ ),
+ (
+ "experiment_targeting",
+ models.JSONField(
+ blank=True, help_text="The experiment this scanner's targeting watches, if any.", null=True
+ ),
+ ),
+ (
+ "credit_limit",
+ models.PositiveIntegerField(
+ blank=True,
+ help_text="Optional cap on this scanner's own credit spend per billing period. Null means no scanner-level cap.",
+ null=True,
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ (
+ "sweep_read_bytes_by_hour",
+ models.JSONField(
+ blank=True,
+ help_text="Total ClickHouse read bytes per hour bucket (ISO hour -> bytes) across every pass, maintained by the read-metering workflow. Reporting only: each pass throttles on its own bucket.",
+ null=True,
+ ),
+ ),
+ (
+ "sweep_throttle_factor_override",
+ models.PositiveSmallIntegerField(
+ blank=True,
+ help_text="Manual cadence-stretch multiplier for the frequent sweep; overrides its computed read-budget throttle. 1 disables throttling; null means automatic. Does not affect the deep catch-up pass, which stretches on its own spend.",
+ null=True,
+ ),
+ ),
+ (
+ "limit_notified_period_start",
+ models.DateTimeField(
+ blank=True,
+ help_text="Billing period start this scanner was last reported as having reached its credit limit. Keeps the notification to one per period.",
+ null=True,
+ ),
+ ),
+ (
+ "deep_attempted_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the deep pass last started; its cadence gates on this rather than on progress, so a cut-short pass still waits out its interval.",
+ null=True,
+ ),
+ ),
+ (
+ "deep_read_bytes_by_hour",
+ models.JSONField(
+ blank=True,
+ help_text="ClickHouse read bytes per hour bucket for the deep catch-up pass only; drives its own cadence stretch independently of the frequent sweep.",
+ null=True,
+ ),
+ ),
+ (
+ "deep_seen_session_id",
+ models.CharField(
+ blank=True,
+ db_default="",
+ default="",
+ help_text="Keyset tiebreaker paired with deep_swept_through, because a watermark moved without its tiebreaker skips every session tied at that timestamp.",
+ max_length=200,
+ ),
+ ),
+ (
+ "deep_swept_through",
+ models.DateTimeField(
+ blank=True,
+ help_text="Watermark for the full-events-lookback catch-up pass; null until the first regular sweep seeds it.",
+ null=True,
+ ),
+ ),
+ (
+ "fast_read_bytes_by_hour",
+ models.JSONField(
+ blank=True,
+ help_text="ClickHouse read bytes per hour bucket for the frequent sweep's own queries; drives its throttle, so backfill and catch-up reads do not stretch the cadence users see.",
+ null=True,
+ ),
+ ),
+ (
+ "primed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the one-off priming pass over recent recordings ran; null until the first sweep primes the scanner.",
+ null=True,
+ ),
+ ),
+ (
+ "admission_budget_period_start",
+ models.DateTimeField(
+ blank=True,
+ help_text="Billing period the cached admission budget belongs to. A period mismatch forces a refresh.",
+ null=True,
+ ),
+ ),
+ (
+ "admission_budget_refreshed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the admission budget was last recomputed from the spend aggregates. Null until the first capped admission.",
+ null=True,
+ ),
+ ),
+ (
+ "admission_budget_used",
+ models.IntegerField(
+ blank=True,
+ help_text="Credits counted against credit_limit at the last admission-budget refresh: settled receipts, in-flight reservations, and running evaluations.",
+ null=True,
+ ),
+ ),
+ (
+ "admission_credits_since_refresh",
+ models.PositiveIntegerField(
+ default=0,
+ help_text="Credits admitted since the last admission-budget refresh. Every refresh resets this to the admitting cost, or to zero on a refusal.",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "enabled"], name="rl_team_enabled_idx"),
+ models.Index(
+ condition=models.Q(("origin", "inline")), fields=["created_at"], name="rl_inline_created_idx"
+ ),
+ ],
+ "constraints": [
+ models.CheckConstraint(
+ condition=models.Q(("sampling_rate__gte", 0.0), ("sampling_rate__lte", 1.0)),
+ name="replay_scanner_sampling_rate_range",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("inline_key", ""), ("origin", "configured")),
+ models.Q(("origin", "inline"), models.Q(("inline_key", ""), _negated=True)),
+ _connector="OR",
+ ),
+ name="replay_scanner_inline_key_matches_origin",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("origin", "configured")),
+ fields=("team", "name"),
+ name="replay_scanner_unique_configured_team_name",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("origin", "inline")),
+ fields=("team", "inline_key"),
+ name="replay_scanner_unique_team_inline_key",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("credit_limit__isnull", True), ("credit_limit__gte", 1), _connector="OR"),
+ name="replay_scanner_credit_limit_positive",
+ ),
+ ],
+ "base_manager_name": "all_origins",
+ },
+ managers=[
+ ("objects", django.db.models.manager.Manager()),
+ ("all_origins", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ReplayObservationUsage",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "observation_id",
+ models.UUIDField(
+ help_text="The observation this receipt accounts for (plain id, no FK).", unique=True
+ ),
+ ),
+ (
+ "observation_created_at",
+ models.DateTimeField(
+ help_text="The observation's created_at; the monthly quota window filters on this."
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "organization",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="replay_observation_usage",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "team_id",
+ models.BigIntegerField(
+ help_text="The observation's team; the per-team billing usage report groups on this (plain id, no FK).",
+ null=True,
+ ),
+ ),
+ (
+ "credits",
+ models.PositiveIntegerField(
+ help_text="Credits billed for this observation (1 credit = $0.01), frozen at success time so price changes never reprice history.",
+ null=True,
+ ),
+ ),
+ (
+ "model",
+ models.CharField(
+ help_text="Model id frozen from the observation's scanner_snapshot; kept for audit and re-pricing analysis.",
+ max_length=64,
+ null=True,
+ ),
+ ),
+ (
+ "scanner_id",
+ models.UUIDField(
+ help_text="The scanner that produced this observation. Per-scanner credit limits aggregate on this (plain id, no FK).",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ fields=["organization", "observation_created_at"], name="replay_visi_organiz_a84ed4_idx"
+ ),
+ models.Index(fields=["created_at", "team_id"], name="rlou_created_team_idx"),
+ models.Index(
+ condition=models.Q(("scanner_id__isnull", False)),
+ fields=["scanner_id", "observation_created_at"],
+ name="rlou_scanner_created_idx",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReplayScannerPromptSuggestion",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "suggested_prompt",
+ models.TextField(help_text="The full rewritten prompt, ready to apply to the scanner."),
+ ),
+ (
+ "base_prompt",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="The scanner prompt this suggestion was generated against, for diffing.",
+ ),
+ ),
+ (
+ "rationale",
+ models.TextField(
+ blank=True, default="", help_text="What the rewrite changed and why, grounded in the ratings."
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("applied", "Applied"),
+ ("dismissed", "Dismissed"),
+ ("superseded", "Superseded"),
+ ("no_change", "No change"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ (
+ "based_on_up",
+ models.PositiveIntegerField(default=0, help_text="Thumbs-up ratings the suggestion was based on."),
+ ),
+ (
+ "based_on_down",
+ models.PositiveIntegerField(
+ default=0, help_text="Thumbs-down ratings the suggestion was based on."
+ ),
+ ),
+ ("labels_fingerprint", models.CharField(blank=True, default="", max_length=64)),
+ (
+ "scanner_version",
+ models.PositiveIntegerField(
+ default=0, help_text="The scanner version whose prompt this suggestion was generated against."
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("applied_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "applied_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scanner",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="prompt_suggestions",
+ to="replay_vision.replayscanner",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "evaluation",
+ models.JSONField(
+ blank=True,
+ help_text="Test-before-apply results: the suggested prompt re-run against rated sessions.",
+ null=True,
+ ),
+ ),
+ (
+ "base_config",
+ models.JSONField(
+ blank=True,
+ help_text="The scanner config this suggestion was generated against, for diffing.",
+ null=True,
+ ),
+ ),
+ (
+ "changes",
+ models.JSONField(
+ blank=True,
+ default=list,
+ help_text="Typed per-field diff entries: field, kind, op, before, after, rationale.",
+ ),
+ ),
+ (
+ "suggested_config",
+ models.JSONField(
+ blank=True, help_text="The full proposed scanner config, ready to apply.", null=True
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReplayScannerBackfill",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "window_start",
+ models.DateTimeField(help_text="Inclusive lower bound of the historical window to scan."),
+ ),
+ (
+ "window_end",
+ models.DateTimeField(help_text="Exclusive upper bound of the window; clamped to now at creation."),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("running", "Running"),
+ ("paused_quota", "Paused (quota)"),
+ ("completed", "Completed"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="running",
+ max_length=16,
+ ),
+ ),
+ (
+ "scanner_snapshot",
+ models.JSONField(
+ help_text="Frozen scanner config at creation; see `temporal.types.BackfillScannerSnapshot`."
+ ),
+ ),
+ (
+ "credits_per_observation",
+ models.PositiveIntegerField(
+ help_text="Per-observation credit price frozen at creation from the snapshot model."
+ ),
+ ),
+ ("cursor_end_time", models.DateTimeField(blank=True, null=True)),
+ ("cursor_session_id", models.CharField(blank=True, default="", max_length=200)),
+ (
+ "total_count",
+ models.PositiveIntegerField(
+ help_text="Unobserved candidates enumerated at creation; the ceiling is total_count x credits_per_observation."
+ ),
+ ),
+ ("dispatched_count", models.PositiveIntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "finished_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When the backfill reached a terminal status (completed or cancelled).",
+ null=True,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scanner",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="backfills",
+ to="replay_vision.replayscanner",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "skipped_count",
+ models.PositiveIntegerField(
+ default=0,
+ help_text="Candidates the walk stepped over because this scanner had already tried them. Counted at creation but never dispatched, so progress and remaining spend both have to account for them.",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "created_at"], name="rvb_team_created_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("status__in", ["running", "paused_quota"])),
+ fields=("scanner",),
+ name="rvb_one_active_per_scanner",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(("window_start__lt", models.F("window_end"))),
+ name="rvb_window_start_before_end",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="VisionAlertConfiguration",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ ("enabled", models.BooleanField(default=True)),
+ ("kind", models.CharField(choices=[("metric", "Metric"), ("match", "Match")], max_length=10)),
+ (
+ "selection",
+ models.JSONField(
+ default=dict,
+ help_text="Observation filter over succeeded scans: verdict (list[str]), tags (list[str]), min_score/max_score (float).",
+ ),
+ ),
+ (
+ "metric",
+ models.CharField(
+ blank=True,
+ choices=[("count", "Count matching observations"), ("avg_score", "Average score")],
+ default="count",
+ max_length=20,
+ ),
+ ),
+ (
+ "direction",
+ models.CharField(
+ blank=True,
+ choices=[("above", "At or above"), ("below", "At or below")],
+ default="above",
+ max_length=10,
+ ),
+ ),
+ ("threshold", models.FloatField(blank=True, null=True)),
+ ("window_days", models.PositiveSmallIntegerField(default=1)),
+ ("check_interval_minutes", models.PositiveIntegerField(default=60)),
+ (
+ "state",
+ models.CharField(
+ choices=[
+ ("not_firing", "Not firing"),
+ ("firing", "Firing"),
+ ("pending_resolve", "Pending resolve"),
+ ("errored", "Errored"),
+ ("snoozed", "Snoozed"),
+ ("broken", "Broken"),
+ ],
+ default="not_firing",
+ max_length=20,
+ ),
+ ),
+ ("consecutive_failures", models.PositiveIntegerField(default=0)),
+ ("last_notified_at", models.DateTimeField(blank=True, null=True)),
+ ("last_checked_at", models.DateTimeField(blank=True, null=True)),
+ ("first_enabled_at", models.DateTimeField(blank=True, null=True)),
+ ("snooze_until", models.DateTimeField(blank=True, null=True)),
+ ("next_check_at", models.DateTimeField(blank=True, null=True)),
+ ("evaluation_periods", models.PositiveSmallIntegerField(default=1)),
+ ("datapoints_to_alarm", models.PositiveSmallIntegerField(default=1)),
+ ("cooldown_minutes", models.PositiveIntegerField(default=0)),
+ ("schedule_restriction", models.JSONField(blank=True, default=None, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scanner",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="alerts",
+ to="replay_vision.replayscanner",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ condition=models.Q(("enabled", True), ("kind", "metric")),
+ fields=["next_check_at"],
+ name="vision_alert_scheduler_idx",
+ ),
+ models.Index(fields=["team", "scanner", "kind", "enabled"], name="vision_alert_hook_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "name"), name="vision_alert_unique_team_name"),
+ models.CheckConstraint(
+ condition=models.Q(
+ ("kind", "metric"),
+ models.Q(
+ ("state", "not_firing"), ("consecutive_failures", 0), ("next_check_at__isnull", True)
+ ),
+ _connector="OR",
+ ),
+ name="vision_alert_match_kind_stateless",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("kind", "metric"), ("threshold__isnull", False)),
+ models.Q(("kind", "match"), ("threshold__isnull", True)),
+ _connector="OR",
+ ),
+ name="vision_alert_metric_kind_threshold",
+ ),
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ReplayObservation",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "session_id",
+ models.CharField(help_text="Session recording id this scanner was applied to.", max_length=200),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "Pending"),
+ ("running", "Running"),
+ ("succeeded", "Succeeded"),
+ ("failed", "Failed"),
+ ("ineligible", "Ineligible"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ (
+ "error_reason",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Populated on terminal non-success statuses; formatted as `kind:human-readable message`. For `ineligible`, kind is one of no_recording / too_short / too_inactive / too_long / no_events / no_snapshots / too_large. For `failed`, kind is one of provider_transient / provider_rejected / rasterization_failed / validation_failed / infra_transient / internal_error / orphaned.",
+ ),
+ ),
+ (
+ "workflow_id",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Temporal workflow id; used for progress queries and reaper reconciliation.",
+ max_length=255,
+ ),
+ ),
+ (
+ "triggered_by",
+ models.CharField(
+ choices=[
+ ("schedule", "Schedule"),
+ ("on_demand", "On demand"),
+ ("retry", "Retry"),
+ ("backfill", "Backfill"),
+ ],
+ help_text="What started this observation: a per-scanner schedule fire, an explicit /observe/ call, a retry of a failed or ineligible observation, or a historical backfill.",
+ max_length=16,
+ ),
+ ),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ (
+ "triggered_by_user",
+ models.ForeignKey(
+ blank=True,
+ help_text="Populated for on-demand and retry triggers; null for schedule-driven observations.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "scanner",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="observations",
+ to="replay_vision.replayscanner",
+ ),
+ ),
+ (
+ "scanner_snapshot",
+ models.JSONField(
+ default=dict,
+ help_text="Frozen view of the scanner at observation-create time; see `temporal.types.ScannerSnapshot`.",
+ ),
+ ),
+ (
+ "scanner_result",
+ models.JSONField(
+ default=dict,
+ help_text="Result data persisted on success (model output, signals count); see `temporal.types.ScannerResult`.",
+ ),
+ ),
+ (
+ "distinct_id",
+ models.CharField(
+ blank=True,
+ help_text="Distinct id of the person in the recorded session (the subject), resolved from session metadata.",
+ max_length=400,
+ null=True,
+ ),
+ ),
+ (
+ "session_started_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="Start time of the recorded session; copied from session metadata so downstream steps don't re-query.",
+ null=True,
+ ),
+ ),
+ (
+ "recording_subject_email",
+ models.TextField(
+ blank=True,
+ help_text="Email of the recording subject at scan time; denormalized so the list can filter and sort on it.",
+ null=True,
+ ),
+ ),
+ (
+ "created_task_id",
+ models.UUIDField(
+ blank=True,
+ help_text="PostHog Task minted from this observation's finding. Repeat create_task calls return this id instead of creating a duplicate.",
+ null=True,
+ ),
+ ),
+ (
+ "backfill",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ help_text="Backfill run that dispatched this observation; null for live, on-demand, and retry triggers.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="observations",
+ to="replay_vision.replayscannerbackfill",
+ ),
+ ),
+ (
+ "session_group_keys",
+ models.JSONField(
+ blank=True,
+ help_text="Group keys the recorded session's events carry, keyed by group type index (e.g. {'0': 'acme-inc'}). Resolved at scan time so the emitted event can be attributed to the group without re-querying.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "created_at"], name="rlo_team_created_idx"),
+ models.Index(
+ condition=models.Q(("workflow_id", ""), _negated=True),
+ fields=["workflow_id"],
+ name="rlo_workflow_id_idx",
+ ),
+ models.Index(fields=["scanner", "status"], name="rlo_scanner_status_idx"),
+ models.Index(fields=["scanner", "created_at"], name="rlo_scanner_created_idx"),
+ models.Index(
+ condition=models.Q(("status__in", ("pending", "running"))),
+ fields=["team", "scanner"],
+ name="rlo_team_in_flight_idx",
+ ),
+ models.Index(
+ condition=models.Q(("backfill__isnull", False)), fields=["backfill"], name="rlo_backfill_idx"
+ ),
+ models.Index(
+ condition=models.Q(("status", "succeeded")),
+ fields=["scanner", "completed_at"],
+ name="rlo_scanner_completed_idx",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("scanner", "session_id"), name="replay_observation_unique_scanner_session"
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("completed_at__isnull", True), ("status__in", ["pending", "running"])),
+ models.Q(
+ ("completed_at__isnull", False), ("status__in", ["succeeded", "failed", "ineligible"])
+ ),
+ _connector="OR",
+ ),
+ name="replay_observation_completed_at_matches_status",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="VisionAlertEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("check", "Check"),
+ ("reset", "Reset"),
+ ("enable", "Enable"),
+ ("disable", "Disable"),
+ ("snooze", "Snooze"),
+ ("unsnooze", "Unsnooze"),
+ ("threshold_change", "Threshold change"),
+ ],
+ default="check",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("metric_value", models.FloatField(blank=True, null=True)),
+ ("threshold_breached", models.BooleanField(default=False)),
+ ("state_before", models.CharField(max_length=20)),
+ ("state_after", models.CharField(max_length=20)),
+ ("error_message", models.TextField(blank=True, null=True)),
+ (
+ "alert",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="events",
+ to="replay_vision.visionalertconfiguration",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["alert", "-created_at"], name="vision_alert_evt_alert_ts_idx"),
+ models.Index(fields=["created_at"], name="vision_alert_evt_created_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReplayObservationLabel",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "is_correct",
+ models.BooleanField(help_text="True if the scanner scored this session correctly, false if not."),
+ ),
+ (
+ "feedback",
+ models.TextField(
+ blank=True,
+ default="",
+ help_text="Why the scanner got it wrong / what it should have concluded. Empty for correct labels.",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "observation",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="label",
+ to="replay_vision.replayobservation",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="VisionAlertMatch",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("delivered_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "alert",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="matches",
+ to="replay_vision.visionalertconfiguration",
+ ),
+ ),
+ (
+ "observation",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="replay_vision.replayobservation",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ condition=models.Q(("delivered_at__isnull", True)),
+ fields=["alert", "created_at"],
+ name="vision_alert_match_drain_idx",
+ ),
+ models.Index(fields=["delivered_at"], name="vision_alert_match_cleanup_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("alert", "observation"), name="vision_alert_match_unique")
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/replay_vision/backend/migrations/0014_visionaction_visionactionrun_and_more.py b/products/replay_vision/backend/migrations/0014_visionaction_visionactionrun_and_more.py
index 7c3df05c5fc6..fc87d39fb319 100644
--- a/products/replay_vision/backend/migrations/0014_visionaction_visionactionrun_and_more.py
+++ b/products/replay_vision/backend/migrations/0014_visionaction_visionactionrun_and_more.py
@@ -12,7 +12,6 @@ class Migration(migrations.Migration):
dependencies = [
("posthog", "1224_columnconfiguration_properties"),
("replay_vision", "0013_replayscanner_estimated_at_and_more"),
- ("workflows", "0008_teamworkflowsconfig"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
diff --git a/products/replay_vision/backend/migrations/0029_visionaction_is_scanner_digest.py b/products/replay_vision/backend/migrations/0029_visionaction_is_scanner_digest.py
index 1e73dd11904e..7d13b1bd4c54 100644
--- a/products/replay_vision/backend/migrations/0029_visionaction_is_scanner_digest.py
+++ b/products/replay_vision/backend/migrations/0029_visionaction_is_scanner_digest.py
@@ -8,7 +8,6 @@ class Migration(migrations.Migration):
dependencies = [
("posthog", "1247_oauthaccesstoken_token_idx"),
("replay_vision", "0028_replayscannerpromptsuggestion"),
- ("workflows", "0008_teamworkflowsconfig"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
diff --git a/products/replay_vision/backend/migrations/0091_squash_2026_09_07_schema_addons.py b/products/replay_vision/backend/migrations/0091_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..fb37892a9c24
--- /dev/null
+++ b/products/replay_vision/backend/migrations/0091_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,94 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_constraint
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0089_replayscanner_search_suggestions"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="replayscanner",
+ name="replay_scanner_inline_key_matches_origin",
+ ),
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="replayscanner",
+ name="replay_scanner_credit_limit_positive",
+ ),
+ ]
diff --git a/products/replay_vision/backend/migrations/max_migration.txt b/products/replay_vision/backend/migrations/max_migration.txt
index 5e6eed74cd9b..f2e7ba728913 100644
--- a/products/replay_vision/backend/migrations/max_migration.txt
+++ b/products/replay_vision/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0089_replayscanner_search_suggestions
+0091_squash_2026_09_07_schema_addons
diff --git a/products/review_hog/backend/migrations/0001_squash_2026_09_07_initial.py b/products/review_hog/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..edcc0898aaa5
--- /dev/null
+++ b/products/review_hog/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,309 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("review_hog", "0001_initial"),
+ ("review_hog", "0002_alter_reviewreportartefact_type"),
+ ("review_hog", "0003_alter_reviewreportartefact_type"),
+ ("review_hog", "0004_alter_reviewreportartefact_type"),
+ ("review_hog", "0005_reviewreport_published_head_sha"),
+ ("review_hog", "0006_reviewskillconfig"),
+ ("review_hog", "0007_alter_reviewreportartefact_type"),
+ ("review_hog", "0008_reviewusersettings"),
+ ("review_hog", "0009_reviewreport_acting_user"),
+ ("review_hog", "0010_remove_reviewreport_unique_review_report_per_pr_and_more"),
+ ("review_hog", "0011_reviewreport_reviewhog_rpt_recent_idx"),
+ ("review_hog", "0012_alter_reviewreportartefact_type"),
+ ("review_hog", "0013_reviewreportartefact_head_sha"),
+ ("review_hog", "0014_reviewreport_completed_head_sha"),
+ ("review_hog", "0015_reviewreport_status_comment_edited_at_and_more"),
+ ("review_hog", "0016_reviewreport_reviewhog_rpt_team_recent_idx"),
+ ("review_hog", "0017_alter_reviewusersettings_urgency_threshold"),
+ ("review_hog", "0018_backfill_urgency_threshold_to_consider"),
+ ("review_hog", "0019_reviewreport_author_login_and_more"),
+ ("review_hog", "0020_alter_reviewreportartefact_type"),
+ ("review_hog", "0021_reviewreport_published_urgency_thresholds"),
+ ("review_hog", "0022_reviewreport_outcomes_emitted_at"),
+ ("review_hog", "0023_reviewreport_unclassified_idx"),
+ ("review_hog", "0024_reviewreport_published_head_shas"),
+ ("review_hog", "0025_reviewusersettings_stamphog_review_inbox_prs"),
+ ("review_hog", "0026_reviewreport_review_initial_permission_mode_and_more"),
+ ("review_hog", "0027_alter_reviewreportartefact_type"),
+ ("review_hog", "0028_reviewusersettings_resolve_comments"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ReviewReport",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("repository", models.CharField(max_length=255)),
+ ("pr_number", models.IntegerField(blank=True, null=True)),
+ ("pr_url", models.TextField(blank=True)),
+ ("head_branch", models.CharField(max_length=255)),
+ ("base_branch", models.CharField(max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("idle", "Idle"), ("closed", "Closed")],
+ default="active",
+ max_length=20,
+ ),
+ ),
+ ("run_count", models.IntegerField(default=0)),
+ ("last_run_at", models.DateTimeField(blank=True, null=True)),
+ ("head_sha", models.CharField(blank=True, max_length=64, null=True)),
+ ("last_seen_comment_id", models.BigIntegerField(blank=True, null=True)),
+ ("report_markdown", models.TextField(blank=True, default="")),
+ ("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,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("published_head_sha", models.CharField(blank=True, max_length=64, null=True)),
+ (
+ "acting_user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("signal_report_id", models.UUIDField(blank=True, null=True)),
+ ("trigger_source", models.CharField(default="manual", max_length=20)),
+ ("completed_head_sha", models.CharField(blank=True, max_length=64, null=True)),
+ ("status_comment_edited_at", models.DateTimeField(blank=True, null=True)),
+ ("status_comment_id", models.BigIntegerField(blank=True, null=True)),
+ ("author_login", models.CharField(blank=True, max_length=255, null=True)),
+ ("run_urgency_threshold", models.CharField(blank=True, max_length=20, null=True)),
+ ("published_urgency_thresholds", models.JSONField(blank=True, null=True)),
+ ("outcomes_emitted_at", models.DateTimeField(blank=True, null=True)),
+ ("published_head_shas", models.JSONField(blank=True, null=True)),
+ ("review_initial_permission_mode", models.CharField(blank=True, max_length=32, null=True)),
+ ("review_model", models.CharField(blank=True, max_length=128, null=True)),
+ ("review_reasoning_effort", models.CharField(blank=True, max_length=32, null=True)),
+ ("review_runtime_adapter", models.CharField(blank=True, max_length=32, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "status"], name="reviewhog_rpt_team_status_idx"),
+ models.Index(fields=["team", "acting_user", "-last_run_at"], name="reviewhog_rpt_recent_idx"),
+ models.Index(fields=["signal_report_id"], name="reviewhog_rpt_signal_rpt_idx"),
+ models.Index(fields=["team", "-last_run_at"], name="reviewhog_rpt_team_recent_idx"),
+ models.Index(
+ condition=models.Q(
+ ("outcomes_emitted_at__isnull", True),
+ ("pr_number__isnull", False),
+ ("published_head_sha__isnull", False),
+ ),
+ fields=["team", "-updated_at"],
+ name="reviewhog_rpt_unclassified_idx",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("pr_number__isnull", False)),
+ fields=("team", "repository", "pr_number"),
+ name="unique_review_report_per_pr",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("pr_number__isnull", True)),
+ fields=("team", "repository", "head_branch"),
+ name="unique_review_report_per_branch",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReviewSkillConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("skill_name", models.CharField(max_length=200)),
+ ("enabled", models.BooleanField(db_default=True, default=True)),
+ ("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,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team", "user", "enabled"], name="reviewhog_skillcfg_lookup_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "skill_name"), name="uniq_review_skill_config_per_user"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReviewUserSettings",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("review_inbox_prs", models.BooleanField(db_default=False, default=False)),
+ ("review_labeled_prs", models.BooleanField(db_default=True, default=True)),
+ (
+ "urgency_threshold",
+ models.CharField(
+ choices=[("consider", "Consider"), ("should_fix", "Should Fix"), ("must_fix", "Must Fix")],
+ db_default="consider",
+ default="consider",
+ max_length=20,
+ ),
+ ),
+ ("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,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("stamphog_review_inbox_prs", models.BooleanField(db_default=False, default=False)),
+ ("resolve_comments", models.BooleanField(db_default=True, default=True)),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user"), name="uniq_review_user_settings_per_user")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ReviewReportArtefact",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("issue_finding", "Issue Finding"),
+ ("validation_verdict", "Validation Verdict"),
+ ("finding_outcome", "Finding Outcome"),
+ ("thread_verdict", "Thread Verdict"),
+ ("task_run", "Task Run"),
+ ("commit", "Commit"),
+ ("code_reference", "Code Reference"),
+ ("note", "Note"),
+ ("chunk_set", "Chunk Set"),
+ ("perspective_selection", "Perspective Selection"),
+ ("perspective_result", "Perspective Result"),
+ ("pr_snapshot", "Pr Snapshot"),
+ ],
+ max_length=100,
+ ),
+ ),
+ ("content", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "report",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="artefacts",
+ to="review_hog.reviewreport",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.task",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("head_sha", models.CharField(blank=True, max_length=64, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["report"], name="reviewhog_art_report_idx"),
+ models.Index(fields=["report", "type"], name="reviewhog_art_rpt_type_idx"),
+ models.Index(fields=["report", "type", "-created_at"], name="reviewhog_art_rpt_type_ct_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/signals/backend/migrations/0001_squash_2026_09_07_initial.py b/products/signals/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..cc9f4f408df5
--- /dev/null
+++ b/products/signals/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,1114 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.core.validators
+import django.db.models.manager
+import django.db.models.deletion
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.signals.backend.enums
+import products.signals.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("signals", "0001_initial"),
+ ("signals", "0002_signalreport_clustering_fields"),
+ ("signals", "0003_alter_signalreport_status_and_more"),
+ ("signals", "0004_alter_content_type"),
+ ("signals", "0005_signalreportartefact_report_idx"),
+ ("signals", "0006_signal_source_config"),
+ ("signals", "0007_backfill_signal_source_config"),
+ ("signals", "0008_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0009_add_new_signal_report_statuses"),
+ ("signals", "0010_add_data_import_signal_source_choices"),
+ ("signals", "0011_add_error_tracking_signal_types"),
+ ("signals", "0012_signalreport_run_count_and_more"),
+ ("signals", "0013_signalreport_suggested_reviewers"),
+ ("signals", "0014_signalreportartefact_report_type_idx"),
+ ("signals", "0015_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0016_signalautonomyconfig_alter_signalreportartefact_type"),
+ ("signals", "0017_add_resolved_signal_report_status"),
+ ("signals", "0018_alter_signalreportartefact_type"),
+ ("signals", "0019_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0020_signaluserautonomyconfig_slack_notification_fields"),
+ ("signals", "0021_add_signals_scout_source"),
+ ("signals", "0022_add_signal_scout_models"),
+ ("signals", "0023_signalscoutrun_summary"),
+ ("signals", "0024_signalprojectprofile"),
+ ("signals", "0025_signalteamconfig_default_slack_notification_channel"),
+ ("signals", "0026_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0027_migrate_posthog_ai_models"),
+ ("signals", "0028_reshape_scout_config_per_scout"),
+ ("signals", "0029_wipe_legacy_scout_configs"),
+ ("signals", "0030_alter_signalscoutconfig_run_interval_minutes"),
+ ("signals", "0031_alter_signalscoutconfig_emit"),
+ ("signals", "0032_signalteamconfig_autostart_base_branches"),
+ ("signals", "0033_signalscoutrun_emitted_count_and_more"),
+ ("signals", "0034_signalscoutemission"),
+ ("signals", "0035_signalteamconfig_default_autostart_priority_p2"),
+ ("signals", "0036_signalteamconfig_backfill_default_autostart_p2"),
+ ("signals", "0037_signalscoutemission_tags"),
+ ("signals", "0038_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0039_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0040_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0041_alter_signalscoutconfig_run_interval_minutes"),
+ ("signals", "0042_signalreport_status_before_suppression"),
+ ("signals", "0043_signalreporttask_rel_idx"),
+ ("signals", "0044_alter_signalscoutconfig_run_interval_minutes"),
+ ("signals", "0045_signalteamconfig_default_autostart_priority_p4"),
+ ("signals", "0046_signalteamconfig_backfill_default_autostart_p4"),
+ ("signals", "0047_signalreportartefact_updated_at_and_more"),
+ ("signals", "0048_signalreportartefact_latest_index"),
+ ("signals", "0049_turn_on_scout_source_by_default"),
+ ("signals", "0050_alter_signalscoutconfig_run_interval_minutes"),
+ ("signals", "0051_signalscoutrun_emitted_report_ids"),
+ ("signals", "0052_signalscoutrun_edited_report_ids"),
+ ("signals", "0053_alter_signalreportartefact_type"),
+ ("signals", "0054_alter_signalsourceconfig_source_type"),
+ ("signals", "0055_alter_signalsourceconfig_source_product"),
+ ("signals", "0056_alter_signalreportartefact_type"),
+ ("signals", "0057_signalreportrefund"),
+ ("signals", "0058_signalreport_billing_exempt_reason"),
+ ("signals", "0059_alter_signalreportrefund_report"),
+ ("signals", "0060_signalreportrefund_period_bounds"),
+ ("signals", "0061_signalteamconfig_autostart_enabled"),
+ ("signals", "0062_add_analytics_anomaly_investigation_source"),
+ ("signals", "0063_alter_signalreportartefact_type"),
+ ("signals", "0064_alter_signalsourceconfig_source_product"),
+ ("signals", "0065_alter_signalsourceconfig_source_product"),
+ ("signals", "0066_alter_signalsourceconfig_source_product_and_more"),
+ ("signals", "0067_signalscoutconfig_run_cron_schedule"),
+ ("signals", "0068_signalscoutrun_metadata"),
+ ("signals", "0069_signalrepositoryareaactivity"),
+ ("signals", "0070_signalscoutconfig_output_destinations"),
+ ("signals", "0071_signalscoutnote"),
+ ("signals", "0072_signalscoutnote_origin"),
+ ("signals", "0073_signal_scout_run_report_id_gin_indexes"),
+ ("signals", "0074_signalreport_charts"),
+ ("signals", "0075_alter_signalsourceconfig_source_product"),
+ ("signals", "0076_signalscoutnote_discussion_origin"),
+ ("signals", "0077_signalscoutconfig_status"),
+ ("signals", "0078_backfill_scout_status"),
+ ("signals", "0079_signalscoutconfig_consecutive_failure_count"),
+ ("signals", "0080_reconcile_scout_status_enabled"),
+ ("signals", "0081_scout_status_constraints"),
+ ("signals", "0082_validate_scout_status_constraints"),
+ ("signals", "0083_signalscoutconfig_auto_pause_exempt"),
+ ("signals", "0084_signalscoutconfig_network_access"),
+ ("signals", "0085_signalscoutnote_feedback_origin"),
+ ("signals", "0086_signalscoutconfig_structured_output_schema"),
+ ("signals", "0087_signalscoutconfig_tags"),
+ ("signals", "0088_signalscoutconfig_model"),
+ ("signals", "0089_signalreportaction"),
+ ("signals", "0090_signal_scout_run_recent_idx"),
+ ("signals", "0091_signalscoutconfig_mcp_gateway_server_ids"),
+ ("signals", "0092_remove_per_evaluation_signal_source"),
+ ("signals", "0093_delete_per_evaluation_source_configs"),
+ ("signals", "0094_delete_session_analysis_source_configs"),
+ ("signals", "0095_signalreportcanvas"),
+ ("signals", "0096_signal_report_canvas_generation"),
+ ("signals", "0097_signalreport_first_visible_at_and_more"),
+ ("signals", "0098_signalreport_first_visible_index"),
+ ("signals", "0099_backfill_first_visible_at"),
+ ("signals", "0100_callable_choices"),
+ ("signals", "0101_signalscoutconfig_source_id_and_more"),
+ ("signals", "0102_signalscoutconfig_source_idx"),
+ ("signals", "0103_remove_signalreportcanvasgeneration_report_and_more"),
+ ("signals", "0104_signalreport_suggested_prompts"),
+ ("signals", "0105_signalscratchpad_expires_at"),
+ ("signals", "0106_signalreportartefact_channel"),
+ ("signals", "0107_signalreportartefact_channel_index"),
+ ("signals", "0108_signalscratchpad_created_by_identity"),
+ ("signals", "0109_signal_scout_suggestion_set"),
+ ("signals", "0110_signalreportartefact_team_type_recent_idx"),
+ ("signals", "0111_signalreport_signals_researched"),
+ ("signals", "0113_signalreport_inbox_notified_at"),
+ ("signals", "0114_signalscoutnote_reviewer_correction_origin"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("posthog_ai", "0004_conversation_agent_runtime_conversation_task_and_more"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="SignalReport",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("potential", "Potential"),
+ ("candidate", "Candidate"),
+ ("in_progress", "In Progress"),
+ ("pending_input", "Pending Input"),
+ ("ready", "Ready"),
+ ("resolved", "Resolved"),
+ ("failed", "Failed"),
+ ("deleted", "Deleted"),
+ ("suppressed", "Suppressed"),
+ ],
+ default="potential",
+ max_length=20,
+ ),
+ ),
+ ("total_weight", models.FloatField(default=0.0)),
+ ("signal_count", models.IntegerField(default=0)),
+ ("signals_at_run", models.IntegerField(default=0)),
+ ("title", models.TextField(blank=True, null=True)),
+ ("summary", models.TextField(blank=True, null=True)),
+ ("error", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("promoted_at", models.DateTimeField(blank=True, null=True)),
+ ("last_run_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "conversation",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog_ai.conversation",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "cluster_centroid",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.FloatField(),
+ blank=True,
+ help_text="Embedding centroid for this report's video segment cluster",
+ null=True,
+ size=None,
+ ),
+ ),
+ ("cluster_centroid_updated_at", models.DateTimeField(blank=True, null=True)),
+ ("relevant_user_count", models.IntegerField(blank=True, null=True)),
+ ("run_count", models.IntegerField(default=0)),
+ (
+ "status_before_suppression",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("potential", "Potential"),
+ ("candidate", "Candidate"),
+ ("in_progress", "In Progress"),
+ ("pending_input", "Pending Input"),
+ ("ready", "Ready"),
+ ("resolved", "Resolved"),
+ ("failed", "Failed"),
+ ("deleted", "Deleted"),
+ ("suppressed", "Suppressed"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "billing_exempt_reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("posthog_health_check", "PostHog health check"),
+ ("posthog_onboarding", "PostHog onboarding"),
+ ("posthog_system", "PostHog system"),
+ ],
+ max_length=30,
+ null=True,
+ ),
+ ),
+ ("charts", models.JSONField(blank=True, db_default=[], default=list)),
+ ("first_visible_at", models.DateTimeField(blank=True, null=True)),
+ ("suggested_prompts", models.JSONField(blank=True, db_default=[], default=list)),
+ ("signals_researched", models.IntegerField(blank=True, null=True)),
+ ("inbox_notified_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "status", "promoted_at"], name="signals_sig_team_id_9cf061_idx"),
+ models.Index(fields=["team", "created_at"], name="signals_sig_team_id_84c1a8_idx"),
+ models.Index(
+ condition=models.Q(("first_visible_at__isnull", False)),
+ fields=["team", "first_visible_at"],
+ name="signals_report_first_visible",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalSourceConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "source_product",
+ models.CharField(
+ choices=products.signals.backend.enums.signal_source_product_choices, max_length=100
+ ),
+ ),
+ (
+ "source_type",
+ models.CharField(
+ choices=products.signals.backend.models.signal_source_type_choices, max_length=100
+ ),
+ ),
+ ("enabled", models.BooleanField(default=True)),
+ ("config", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "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,
+ related_name="signal_source_configs",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "source_product", "source_type"), name="unique_team_source_product_type"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalEmissionRecord",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("source_product", models.CharField(max_length=100)),
+ ("source_type", models.CharField(max_length=100)),
+ ("source_id", models.CharField(max_length=200)),
+ ("emitted_at", models.DateTimeField()),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["team", "source_product", "source_type"], name="signals_emission_lookup_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "source_product", "source_type", "source_id"),
+ name="unique_signal_emission_record",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalTeamConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_team_config",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "default_autostart_priority",
+ models.CharField(
+ choices=[("P0", "P0"), ("P1", "P1"), ("P2", "P2"), ("P3", "P3"), ("P4", "P4")],
+ default="P4",
+ max_length=2,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("default_slack_notification_channel", models.CharField(blank=True, max_length=255, null=True)),
+ ("autostart_base_branches", models.JSONField(blank=True, default=dict)),
+ ("autostart_enabled", models.BooleanField(blank=True, null=True)),
+ (
+ "max_reports_per_day",
+ models.PositiveIntegerField(
+ blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)]
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal team config",
+ "verbose_name_plural": "Signal team configs",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalUserAutonomyConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "user",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_autonomy_config",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "autostart_priority",
+ models.CharField(
+ blank=True,
+ choices=[("P0", "P0"), ("P1", "P1"), ("P2", "P2"), ("P3", "P3"), ("P4", "P4")],
+ max_length=2,
+ null=True,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "slack_notification_integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ ("slack_notification_channel", models.CharField(blank=True, max_length=255, null=True)),
+ (
+ "slack_notification_min_priority",
+ models.CharField(
+ blank=True,
+ choices=[("P0", "P0"), ("P1", "P1"), ("P2", "P2"), ("P3", "P3"), ("P4", "P4")],
+ max_length=2,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal user autonomy config",
+ "verbose_name_plural": "Signal user autonomy configs",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalScoutConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("enabled", models.BooleanField(db_default=True, default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_scout_configs",
+ to="posthog.team",
+ ),
+ ),
+ ("emit", models.BooleanField(db_default=True, default=True)),
+ (
+ "enabled_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("last_run_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "run_interval_minutes",
+ models.PositiveIntegerField(
+ db_default=1440,
+ default=1440,
+ validators=[
+ django.core.validators.MinValueValidator(30),
+ django.core.validators.MaxValueValidator(43200),
+ ],
+ ),
+ ),
+ ("skill_name", models.CharField(max_length=200)),
+ ("run_cron_schedule", models.CharField(blank=True, max_length=100, null=True)),
+ ("schedule_changed_at", models.DateTimeField(blank=True, null=True)),
+ ("output_destinations", models.JSONField(db_default={}, default=dict)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("active", "Active"),
+ ("pending_pause", "Pending pause"),
+ ("paused_by_system", "Paused by system"),
+ ("paused_by_user", "Paused by user"),
+ ],
+ db_default="active",
+ default="active",
+ max_length=20,
+ ),
+ ),
+ (
+ "pause_reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("no_output", "No output"),
+ ("ignored", "Ignored"),
+ ("repeated_failures", "Repeated failures"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ("status_changed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "status_changed_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("consecutive_failure_count", models.PositiveIntegerField(db_default=0, default=0)),
+ ("auto_pause_exempt", models.BooleanField(db_default=False, default=False)),
+ (
+ "network_access",
+ models.CharField(
+ choices=[("trusted", "Trusted domains only"), ("full", "Full")],
+ db_default="trusted",
+ default="trusted",
+ max_length=20,
+ ),
+ ),
+ ("structured_output_schema", models.JSONField(blank=True, null=True)),
+ (
+ "tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=50), blank=True, default=list, null=True, size=None
+ ),
+ ),
+ ("model", models.CharField(blank=True, max_length=200, null=True)),
+ ("mcp_gateway_server_ids", models.JSONField(db_default=[], default=list)),
+ ("source_id", models.CharField(blank=True, max_length=200, null=True)),
+ (
+ "source_product",
+ models.CharField(
+ blank=True,
+ choices=products.signals.backend.enums.signal_source_product_choices,
+ max_length=100,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal scout config",
+ "verbose_name_plural": "Signal scout configs",
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(fields=["team", "source_product", "source_id"], name="scout_config_source_idx")
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "skill_name"), name="unique_scout_config_per_team_skill"),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("enabled", True), ("status__in", ["active", "pending_pause"])),
+ models.Q(("enabled", False), ("status__in", ["paused_by_system", "paused_by_user"])),
+ _connector="OR",
+ ),
+ name="scout_config_enabled_matches_status",
+ ),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(
+ ("pause_reason__isnull", False), ("status__in", ["pending_pause", "paused_by_system"])
+ ),
+ models.Q(("pause_reason__isnull", True), ("status__in", ["active", "paused_by_user"])),
+ _connector="OR",
+ ),
+ name="scout_config_pause_reason_matches_status",
+ ),
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalProjectProfile",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("computed_at", models.DateTimeField(auto_now_add=True)),
+ ("expires_at", models.DateTimeField()),
+ ("source_version", models.CharField(max_length=40)),
+ ("payload", models.JSONField(blank=True, default=dict)),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_project_profiles",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal project profile",
+ "verbose_name_plural": "Signal project profiles",
+ "default_manager_name": "all_teams",
+ "indexes": [models.Index(fields=["team", "-computed_at"], name="signal_proj_profile_recent_idx")],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalRepositoryAreaActivity",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("repository", models.CharField(max_length=400)),
+ ("area", models.CharField(blank=True, max_length=400)),
+ ("contributors", models.JSONField(blank=True, default=list)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("refreshed_at", models.DateTimeField(blank=True, null=True)),
+ ("last_used_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_repo_area_activities",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal repository area activity",
+ "verbose_name_plural": "Signal repository area activities",
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "repository", "area"), name="signal_repo_area_activity_uniq"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalScoutNote",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("skill_name", models.CharField(blank=True, db_default="", default="", max_length=200)),
+ ("content", models.TextField()),
+ ("expires_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_scout_notes",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "origin",
+ models.CharField(
+ choices=[
+ ("human", "Left directly"),
+ ("report_dismissal", "Derived from inbox dismissal feedback"),
+ ("report_discussion", "Derived from inbox discussion feedback"),
+ ("report_feedback", "Derived from inbox report feedback"),
+ ("report_reviewer_correction", "Derived from an inbox reviewer correction"),
+ ],
+ db_default="human",
+ default="human",
+ max_length=32,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal scout note",
+ "verbose_name_plural": "Signal scout notes",
+ "default_manager_name": "all_teams",
+ "indexes": [models.Index(fields=["team", "-created_at"], name="signal_scout_note_recent_idx")],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalScoutSuggestionSet",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("items", models.JSONField(blank=True, default=list)),
+ (
+ "status",
+ models.CharField(
+ choices=[("fresh", "Fresh"), ("stale", "Stale"), ("failed", "Failed"), ("empty", "Empty")],
+ db_default="empty",
+ default="empty",
+ max_length=16,
+ ),
+ ),
+ ("generated_at", models.DateTimeField(blank=True, null=True)),
+ ("task_run_id", models.UUIDField(blank=True, null=True)),
+ ("model", models.CharField(blank=True, db_default="", default="", max_length=200)),
+ ("fleet_snapshot", models.JSONField(blank=True, default=list)),
+ ("last_requested_at", models.DateTimeField(blank=True, null=True)),
+ ("last_completed_at", models.DateTimeField(blank=True, null=True)),
+ ("consecutive_failures", models.PositiveIntegerField(db_default=0, default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal scout suggestion set",
+ "verbose_name_plural": "Signal scout suggestion sets",
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalReportArtefact",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=products.signals.backend.models.signal_report_artefact_type_choices, max_length=100
+ ),
+ ),
+ ("content", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "report",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="artefacts", to="signals.signalreport"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.task",
+ ),
+ ),
+ (
+ "channel",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.channel",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ models.Index(fields=["report"], name="signals_sig_report__idx"),
+ models.Index(fields=["report", "type"], name="signals_sig_report_type_idx"),
+ models.Index(fields=["report", "type", "-created_at"], name="signals_sig_rpt_type_ct_idx"),
+ models.Index(fields=["channel"], name="signals_sig_channel_idx"),
+ models.Index(fields=["team", "type", "-created_at"], name="signals_sig_team_type_ct_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalReportTask",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "report",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="report_tasks",
+ to="signals.signalreport",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="signal_report_tasks", to="tasks.task"
+ ),
+ ),
+ ("relationship", models.CharField(blank=True, max_length=200, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ],
+ options={
+ "verbose_name": "Signal report task",
+ "verbose_name_plural": "Signal report tasks",
+ "indexes": [models.Index(fields=["report", "relationship"], name="signals_report_task_rel_idx")],
+ "constraints": [models.UniqueConstraint(fields=("report", "task"), name="unique_signal_report_task")],
+ },
+ ),
+ migrations.CreateModel(
+ name="SignalReportRefund",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "reason",
+ models.CharField(
+ choices=[
+ ("pr_incorrect", "PR incorrect"),
+ ("pr_not_useful", "PR not useful"),
+ ("duplicate", "Duplicate"),
+ ("other", "Other"),
+ ],
+ max_length=20,
+ ),
+ ),
+ ("note", models.TextField(blank=True)),
+ (
+ "billing_path",
+ models.CharField(choices=[("excluded", "Excluded"), ("credited", "Credited")], max_length=10),
+ ),
+ ("credits", models.IntegerField()),
+ ("pr_url", models.TextField()),
+ ("pr_run_created_at", models.DateTimeField()),
+ ("credit_amount_usd", models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
+ ("billing_synced_at", models.DateTimeField(blank=True, null=True)),
+ ("billing_sync_error", models.TextField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "report",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.RESTRICT, related_name="refund", to="signals.signalreport"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("period_start", models.DateTimeField(blank=True, null=True)),
+ ("period_end", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "verbose_name": "Signal report refund",
+ "verbose_name_plural": "Signal report refunds",
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(fields=["team", "billing_path", "pr_run_created_at"], name="signals_refund_path_idx")
+ ],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalReportAction",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("type", models.CharField(choices=[("view", "View"), ("feedback", "Feedback")], max_length=20)),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("count", models.PositiveIntegerField(default=1)),
+ ("first_at", models.DateTimeField(auto_now_add=True)),
+ ("last_at", models.DateTimeField()),
+ (
+ "report",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="actions", to="signals.signalreport"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Signal report action",
+ "verbose_name_plural": "Signal report actions",
+ "default_manager_name": "all_teams",
+ "constraints": [
+ models.UniqueConstraint(fields=("report", "user", "type"), name="signals_report_action_identity")
+ ],
+ "indexes": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalScoutRun",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("skill_name", models.CharField(max_length=200)),
+ ("skill_version", models.IntegerField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "task_run",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE, related_name="signal_scout_run", to="tasks.taskrun"
+ ),
+ ),
+ (
+ "scout_config",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="runs",
+ to="signals.signalscoutconfig",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="signal_scout_runs", to="posthog.team"
+ ),
+ ),
+ ("summary", models.TextField(blank=True, db_default="", default="")),
+ ("emitted_count", models.IntegerField(db_default=0, default=0, null=True)),
+ ("emitted_finding_ids", models.JSONField(blank=True, db_default=[], default=list, null=True)),
+ ("emitted_report_ids", models.JSONField(blank=True, db_default=[], default=list, null=True)),
+ ("edited_report_ids", models.JSONField(blank=True, db_default=[], default=list, null=True)),
+ ("metadata", models.JSONField(blank=True, db_default={}, default=dict, null=True)),
+ ],
+ options={
+ "verbose_name": "Signal scout run",
+ "verbose_name_plural": "Signal scout runs",
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(fields=["team", "skill_name"], name="signal_scout_run_skill_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["emitted_report_ids"], name="signal_scout_run_emitted_idx"
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["edited_report_ids"], name="signal_scout_run_edited_idx"
+ ),
+ models.Index(fields=["team", "skill_name", "-created_at"], name="signal_scout_run_recent_idx"),
+ ],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalScratchpad",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("key", models.CharField(max_length=300)),
+ ("content", models.TextField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by_run",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="scratchpads_created",
+ to="signals.signalscoutrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_scratchpads",
+ to="posthog.team",
+ ),
+ ),
+ ("expires_at", models.DateTimeField(blank=True, null=True)),
+ ("created_by_identity", models.CharField(blank=True, max_length=64, null=True)),
+ ],
+ options={
+ "verbose_name": "Signal scratchpad",
+ "verbose_name_plural": "Signal scratchpads",
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "key"), name="signal_scratchpad_unique_team_key")
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="SignalScoutEmission",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("finding_id", models.CharField(max_length=200)),
+ ("description", models.TextField()),
+ ("weight", models.FloatField()),
+ ("confidence", models.FloatField()),
+ ("severity", models.CharField(blank=True, max_length=20, null=True)),
+ ("source_id", models.CharField(max_length=200)),
+ ("emitted_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "scout_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="emissions",
+ to="signals.signalscoutrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="signal_scout_emissions",
+ to="posthog.team",
+ ),
+ ),
+ ("tags", models.JSONField(blank=True, default=list)),
+ ],
+ options={
+ "verbose_name": "Signal scout emission",
+ "verbose_name_plural": "Signal scout emissions",
+ "default_manager_name": "all_teams",
+ "indexes": [models.Index(fields=["team", "scout_run"], name="signal_scout_emission_run_idx")],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/signals/backend/migrations/0119_squash_2026_09_07_schema_addons.py b/products/signals/backend/migrations/0119_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..7e64770708ba
--- /dev/null
+++ b/products/signals/backend/migrations/0119_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,94 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_constraint
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("signals", "0117_drop_signalscoutconfig_team_id_fk_idx"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="signalscoutconfig",
+ name="scout_config_enabled_matches_status",
+ ),
+ posthog.migration_helpers.not_valid_constraint.ValidateConstraint(
+ model_name="signalscoutconfig",
+ name="scout_config_pause_reason_matches_status",
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 87c58640a65f..ec9ded6c2549 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0117_drop_signalscoutconfig_team_id_fk_idx
+0119_squash_2026_09_07_schema_addons
diff --git a/products/skills/backend/migrations/0001_squash_2026_09_07_initial.py b/products/skills/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..538106a5c70f
--- /dev/null
+++ b/products/skills/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,130 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("skills", "0001_adopt_skills_models"),
+ ("skills", "0002_llmskill_category"),
+ ("skills", "0003_backfill_scout_category"),
+ ("skills", "0004_llmskillowner"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="LLMSkill",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=64)),
+ ("description", models.CharField(max_length=4096)),
+ ("body", models.TextField()),
+ ("license", models.CharField(blank=True, default="", max_length=255)),
+ ("compatibility", models.CharField(blank=True, default="", max_length=500)),
+ ("allowed_tools", models.JSONField(blank=True, default=list)),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("version", models.PositiveIntegerField(default=1)),
+ ("is_latest", models.BooleanField(default=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "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")),
+ ("category", models.CharField(blank=True, db_default="", default="", max_length=64)),
+ ],
+ options={
+ "db_table": "llm_analytics_llmskill",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("team", "name", "version"),
+ name="unique_llm_skill_version_per_team",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("is_latest", True)),
+ fields=("team", "name"),
+ name="unique_llm_skill_latest_per_team",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMSkillOwner",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("skill_name", models.CharField(max_length=64)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_llmskillowner",
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "skill_name", "user"), name="unique_llm_skill_owner")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="LLMSkillFile",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("path", models.CharField(max_length=500)),
+ ("content", models.TextField()),
+ ("content_type", models.CharField(default="text/plain", max_length=100)),
+ (
+ "skill",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="files", to="skills.llmskill"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "llm_analytics_llmskillfile",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("skill", "path"), name="unique_skill_file_path")],
+ },
+ ),
+ ]
diff --git a/products/slack_app/backend/migrations/0001_squash_2026_09_07_initial.py b/products/slack_app/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..9d785c1c396a
--- /dev/null
+++ b/products/slack_app/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,212 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("slack_app", "0001_initial"),
+ ("slack_app", "0002_slackuserprofilecache_is_admin_and_more"),
+ ("slack_app", "0003_slacksettings"),
+ ("slack_app", "0004_slackuserprofilecache_refreshed_at"),
+ ("slack_app", "0005_slackchannel"),
+ ("slack_app", "0006_slackthreadtaskmapping_latest_actor_slack_user_id"),
+ ("slack_app", "0007_slackuserprofilecache_is_bot"),
+ ("slack_app", "0008_slackthreadtaskmapping_last_forwarded_ts"),
+ ("slack_app", "0009_slacksettings_ai_settings"),
+ ("slack_app", "0010_slacksettings_default_integration_nullable"),
+ ("slack_app", "0011_slacksettings_permission_modes"),
+ ("slack_app", "0012_slackthreadtaskmapping_workspace_created_idx"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="SlackUserProfileCache",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_user_id", models.CharField(max_length=64)),
+ ("email", models.EmailField(blank=True, max_length=254, null=True)),
+ ("display_name", models.CharField(blank=True, default="", max_length=255)),
+ ("real_name", models.CharField(blank=True, default="", max_length=255)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "integration",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_user_profile_cache",
+ to="posthog.integration",
+ ),
+ ),
+ ("is_admin", models.BooleanField(db_default=False, default=False)),
+ ("is_owner", models.BooleanField(db_default=False, default=False)),
+ ("refreshed_at", models.DateTimeField(blank=True, null=True)),
+ ("is_bot", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("integration", "slack_user_id"), name="uniq_slack_user_profile_cache_integration_user"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SlackThreadTaskMapping",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_workspace_id", models.CharField(max_length=64)),
+ ("channel", models.CharField(max_length=64)),
+ ("thread_ts", models.CharField(max_length=64)),
+ ("mentioning_slack_user_id", models.CharField(max_length=64)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "integration",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_thread_task_mappings",
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_thread_mappings",
+ to="tasks.task",
+ ),
+ ),
+ (
+ "task_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_thread_mappings",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_thread_task_mappings",
+ to="posthog.team",
+ ),
+ ),
+ ("latest_actor_slack_user_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("last_forwarded_ts", models.CharField(blank=True, max_length=64, null=True)),
+ ],
+ options={
+ "indexes": [
+ models.Index(
+ fields=["slack_workspace_id", "created_at"],
+ include=("team_id",),
+ name="slack_thr_map_ws_created_idx",
+ )
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("integration", "channel", "thread_ts"), name="uniq_slack_thread_task_mapping"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SlackSettings",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_workspace_id", models.CharField(max_length=64)),
+ ("slack_user_id", models.CharField(blank=True, max_length=64, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "default_integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="slack_settings_as_default",
+ to="posthog.integration",
+ ),
+ ),
+ ("ai_preferences", models.JSONField(blank=True, null=True)),
+ (
+ "permission_modes",
+ models.JSONField(
+ blank=True,
+ help_text="Per-integration permission mode for Slack-started agent runs, keyed by integration id.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("slack_user_id__isnull", False)),
+ fields=("slack_workspace_id", "slack_user_id"),
+ name="uniq_slack_settings_per_user",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("slack_user_id__isnull", True)),
+ fields=("slack_workspace_id",),
+ name="uniq_slack_settings_per_workspace",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SlackChannel",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("slack_workspace_id", models.CharField(max_length=64)),
+ ("slack_channel_id", models.CharField(max_length=64)),
+ ("approved_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "approved_by",
+ models.ForeignKey(
+ blank=True,
+ help_text="The PostHog user who clicked Approve. Carries the email and audit trail.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="approved_slack_channels",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("slack_workspace_id", "slack_channel_id"), name="uniq_slack_channel"
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ ]
diff --git a/products/stamphog/backend/migrations/0001_squash_2026_09_07_initial.py b/products/stamphog/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..f7daa84f8fa4
--- /dev/null
+++ b/products/stamphog/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,299 @@
+# Generated by Django 5.2.17
+
+import django.db.models.manager
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.stamphog.backend.facade.enums
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("stamphog", "0001_initial"),
+ ("stamphog", "0002_digest_audiences_and_summaries"),
+ ("stamphog", "0003_digest_runs_record_their_destination"),
+ ("stamphog", "0004_backfill_digest_run_destinations"),
+ ]
+
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="DigestRun",
+ fields=[
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("pending", "pending"), ("completed", "completed"), ("failed", "failed")],
+ default=products.stamphog.backend.facade.enums.DigestRunStatus["PENDING"],
+ max_length=32,
+ ),
+ ),
+ ("pr_count", models.IntegerField(default=0)),
+ ("summary", models.JSONField(default=dict)),
+ ("slack_message_ts", models.CharField(blank=True, max_length=32)),
+ ("error", models.TextField(blank=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("posted_at", models.DateTimeField(null=True)),
+ ("audience_key", models.CharField(db_default="", default="", max_length=255)),
+ ("slack_channel_id", models.CharField(db_default="", default="", max_length=64)),
+ ("slack_channel_name", models.CharField(blank=True, db_default="", default="", max_length=255)),
+ (
+ "resolution_source",
+ models.CharField(
+ choices=[
+ ("manual", "manual"),
+ ("slack_name_match", "slack_name_match"),
+ ("stamphog_config", "stamphog_config"),
+ ("owners_contact", "owners_contact"),
+ ],
+ db_default="slack_name_match",
+ default=products.stamphog.backend.facade.enums.ChannelResolutionSource["SLACK_NAME_MATCH"],
+ max_length=32,
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="StamphogRepoConfig",
+ fields=[
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("provider", models.CharField(default="github", max_length=32)),
+ ("repository", models.CharField(max_length=255)),
+ ("enabled", models.BooleanField(default=True)),
+ ("installation_id", models.CharField(max_length=64)),
+ ("digest_enabled", models.BooleanField(default=False)),
+ (
+ "review_mode",
+ models.CharField(
+ choices=[("all", "all"), ("label", "label")],
+ default=products.stamphog.backend.facade.enums.ReviewMode["ALL"],
+ max_length=16,
+ ),
+ ),
+ ("trigger_label", models.CharField(default="stamphog", max_length=100)),
+ ("connected_by_user_id", models.BigIntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "default_manager_name": "all_teams",
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "repository"), name="unique_stamphog_repo_per_team"),
+ models.UniqueConstraint(
+ condition=models.Q(("installation_id", ""), _negated=True),
+ fields=("provider", "installation_id", "repository"),
+ name="unique_stamphog_installation_repo",
+ ),
+ ],
+ "indexes": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="PullRequest",
+ fields=[
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("pr_number", models.IntegerField()),
+ ("title", models.CharField(blank=True, max_length=512)),
+ ("author_login", models.CharField(blank=True, max_length=255)),
+ ("pr_url", models.CharField(blank=True, max_length=512)),
+ ("head_branch", models.CharField(blank=True, max_length=255)),
+ ("body_excerpt", models.TextField(blank=True)),
+ ("merged_at", models.DateTimeField(null=True)),
+ ("merge_commit_sha", models.CharField(blank=True, max_length=64)),
+ ("additions", models.IntegerField(default=0)),
+ ("deletions", models.IntegerField(default=0)),
+ ("changed_files", models.IntegerField(default=0)),
+ ("audience_key", models.CharField(blank=True, max_length=255)),
+ ("posted_comment_id", models.BigIntegerField(null=True)),
+ ("payload_updated_at", models.DateTimeField(null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "digest_run",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="pull_requests",
+ to="stamphog.digestrun",
+ ),
+ ),
+ (
+ "repo_config",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="pull_requests",
+ to="stamphog.stamphogrepoconfig",
+ ),
+ ),
+ ("summary_line", models.CharField(blank=True, default="", max_length=200)),
+ ],
+ options={
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(
+ condition=models.Q(("digest_run__isnull", True)),
+ fields=["team_id", "audience_key", "merged_at"],
+ name="stamphog_pr_pending_digest",
+ )
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team_id", "repo_config", "pr_number"), name="unique_stamphog_pull_request"
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ReviewRun",
+ fields=[
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("head_sha", models.CharField(max_length=64)),
+ ("delivery_id", models.CharField(max_length=64, null=True, unique=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("queued", "queued"),
+ ("gated", "gated"),
+ ("reviewing", "reviewing"),
+ ("completed", "completed"),
+ ("failed", "failed"),
+ ("superseded", "superseded"),
+ ],
+ default=products.stamphog.backend.facade.enums.ReviewRunStatus["QUEUED"],
+ max_length=32,
+ ),
+ ),
+ (
+ "verdict",
+ models.CharField(
+ choices=[
+ ("none", "none"),
+ ("approved", "approved"),
+ ("refused", "refused"),
+ ("escalate", "escalate"),
+ ("wait", "wait"),
+ ("error", "error"),
+ ],
+ default=products.stamphog.backend.facade.enums.ReviewVerdict["NONE"],
+ max_length=32,
+ ),
+ ),
+ ("gate_result", models.JSONField(null=True)),
+ ("output", models.JSONField(default=dict)),
+ ("error", models.TextField(blank=True)),
+ ("verdict_posted_at", models.DateTimeField(null=True)),
+ ("posted_review_id", models.BigIntegerField(null=True)),
+ ("approval_dismissed_at", models.DateTimeField(null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("completed_at", models.DateTimeField(null=True)),
+ (
+ "pull_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="review_runs",
+ to="stamphog.pullrequest",
+ ),
+ ),
+ ("change_summary", models.CharField(blank=True, default="", max_length=200)),
+ ],
+ options={
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="PullRequestAudience",
+ fields=[
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("audience_key", models.CharField(max_length=255)),
+ (
+ "reason",
+ models.CharField(
+ choices=[("authored", "authored"), ("repo_declared", "repo_declared"), ("owned", "owned")],
+ max_length=32,
+ ),
+ ),
+ ("owned_files", models.JSONField(default=list)),
+ ("owned_file_count", models.IntegerField(default=0)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "digest_run",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="audiences",
+ to="stamphog.digestrun",
+ ),
+ ),
+ (
+ "pull_request",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="audiences", to="stamphog.pullrequest"
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(fields=["team_id", "audience_key", "digest_run"], name="stamphog_audience_claim")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team_id", "pull_request", "audience_key"), name="unique_stamphog_pr_audience"
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/streamlit_apps/backend/migrations/0001_squash_2026_09_07_initial.py b/products/streamlit_apps/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..495bd39e8f26
--- /dev/null
+++ b/products/streamlit_apps/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,133 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+
+
+class Migration(migrations.Migration):
+ replaces = [("streamlit_apps", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="StreamlitApp",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(max_length=255)),
+ ("description", models.TextField(blank=True, default="")),
+ ("cpu_cores", models.FloatField(default=0.5)),
+ ("memory_gb", models.FloatField(default=1)),
+ ("restart_count", models.PositiveIntegerField(default=0)),
+ ("deleted", models.BooleanField(default=False)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "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": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("team", "short_id"),
+ name="streamlit_apps_app_unique_active_short_id_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="StreamlitAppVersion",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("version_number", models.PositiveIntegerField()),
+ ("zip_file", models.CharField(max_length=500)),
+ ("zip_hash", models.CharField(max_length=64)),
+ ("snapshot_id", models.CharField(blank=True, max_length=255, null=True)),
+ ("snapshot_created_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "app",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="versions",
+ to="streamlit_apps.streamlitapp",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-version_number"],
+ "unique_together": {("app", "version_number")},
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="StreamlitAppSandbox",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("sandbox_id", models.CharField(max_length=255)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("starting", "Starting"),
+ ("running", "Running"),
+ ("stopping", "Stopping"),
+ ("stopped", "Stopped"),
+ ("error", "Error"),
+ ],
+ default="starting",
+ max_length=20,
+ ),
+ ),
+ ("last_error", models.TextField(blank=True, default="")),
+ ("started_at", models.DateTimeField(blank=True, null=True)),
+ ("last_activity_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "app",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sandbox",
+ to="streamlit_apps.streamlitapp",
+ ),
+ ),
+ (
+ "version",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="streamlit_apps.streamlitappversion",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/streamlit_apps/backend/migrations/0004_squash_2026_09_07_finalize_fks.py b/products/streamlit_apps/backend/migrations/0004_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..0e782fdda769
--- /dev/null
+++ b/products/streamlit_apps/backend/migrations/0004_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,29 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("streamlit_apps", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0003_alter_streamlitapp_options_and_more"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="streamlitapp",
+ name="active_version",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="streamlit_apps.streamlitappversion",
+ ),
+ ),
+ ]
diff --git a/products/streamlit_apps/backend/migrations/max_migration.txt b/products/streamlit_apps/backend/migrations/max_migration.txt
index 00c4c804b9fb..bde7efb4f341 100644
--- a/products/streamlit_apps/backend/migrations/max_migration.txt
+++ b/products/streamlit_apps/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0003_alter_streamlitapp_options_and_more
+0004_squash_2026_09_07_finalize_fks
diff --git a/products/surveys/backend/migrations/0001_squash_2026_09_07_initial.py b/products/surveys/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..94f1f97e56d5
--- /dev/null
+++ b/products/surveys/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,241 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("surveys", "0001_initial"),
+ ("surveys", "0002_action_fk_repoint"),
+ ("surveys", "0003_survey_base_language_alter_survey_questions"),
+ ("surveys", "0004_migrate_feature_flags_models"),
+ ("surveys", "0005_migrate_product_analytics_models"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("actions", "0001_migrate_actions_models"),
+ ("feature_flags", "0014_clean_flag_filters_inert_violations"),
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ("product_analytics", "0005_insightvariable_is_multi_and_more"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Survey",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True)),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("popover", "popover"),
+ ("widget", "widget"),
+ ("external_survey", "external survey"),
+ ("api", "api"),
+ ],
+ max_length=40,
+ ),
+ ),
+ ("conditions", models.JSONField(blank=True, null=True)),
+ (
+ "questions",
+ models.JSONField(
+ blank=True,
+ help_text='\n The `array` of questions included in the survey. Each question must conform to one of the defined question types: Basic, Link, Rating, or Multiple Choice.\n\n Basic (open-ended question)\n - `id`: The question ID\n - `type`: `open`\n - `question`: The text of the question.\n - `description`: Optional description of the question.\n - `descriptionContentType`: Content type of the description (`html` or `text`).\n - `optional`: Whether the question is optional (`boolean`).\n - `buttonText`: Text displayed on the submit button.\n - `branching`: Branching logic for the question. See branching types below for details.\n\n Link (a question with a link)\n - `id`: The question ID\n - `type`: `link`\n - `question`: The text of the question.\n - `description`: Optional description of the question.\n - `descriptionContentType`: Content type of the description (`html` or `text`).\n - `optional`: Whether the question is optional (`boolean`).\n - `buttonText`: Text displayed on the submit button.\n - `link`: The URL associated with the question.\n - `branching`: Branching logic for the question. See branching types below for details.\n\n Rating (a question with a rating scale)\n - `id`: The question ID\n - `type`: `rating`\n - `question`: The text of the question.\n - `description`: Optional description of the question.\n - `descriptionContentType`: Content type of the description (`html` or `text`).\n - `optional`: Whether the question is optional (`boolean`).\n - `buttonText`: Text displayed on the submit button.\n - `display`: Display style of the rating (`number` or `emoji`).\n - `scale`: The scale of the rating (`number`).\n - `lowerBoundLabel`: Label for the lower bound of the scale.\n - `upperBoundLabel`: Label for the upper bound of the scale.\n - `isNpsQuestion`: Whether the question is an NPS rating.\n - `branching`: Branching logic for the question. See branching types below for details.\n\n Multiple choice\n - `id`: The question ID\n - `type`: `single_choice` or `multiple_choice`\n - `question`: The text of the question.\n - `description`: Optional description of the question.\n - `descriptionContentType`: Content type of the description (`html` or `text`).\n - `optional`: Whether the question is optional (`boolean`).\n - `buttonText`: Text displayed on the submit button.\n - `choices`: An array of choices for the question.\n - `shuffleOptions`: Whether to shuffle the order of the choices (`boolean`).\n - `hasOpenChoice`: Whether the question allows an open-ended response (`boolean`).\n - `branching`: Branching logic for the question. See branching types below for details.\n\n Branching logic can be one of the following types:\n\n Next question: Proceeds to the next question\n ```json\n {\n "type": "next_question"\n }\n ```\n\n End: Ends the survey, optionally displaying a confirmation message.\n ```json\n {\n "type": "end"\n }\n ```\n\n Response-based: Branches based on the response values. Available for the `rating` and `single_choice` question types.\n ```json\n {\n "type": "response_based",\n "responseValues": {\n "responseKey": "value"\n }\n }\n ```\n\n Specific question: Proceeds to a specific question by index.\n ```json\n {\n "type": "specific_question",\n "index": 2\n }\n ```\n\n Translations: Each question can include inline translations.\n - `translations`: Object mapping language codes to translated fields.\n - Language codes: Canonical BCP-47-ish strings (e.g., "es", "es-MX", "zh-CN"). Aliases like "english" or "default" are rejected. The survey\'s `base_language` (default "en") declares the language of the untranslated text and cannot also appear as a translation key.\n - Translatable fields: `question`, `description`, `buttonText`, `choices`, `lowerBoundLabel`, `upperBoundLabel`, `link`\n\n Example with translations:\n ```json\n {\n "id": "uuid",\n "type": "rating",\n "question": "How satisfied are you?",\n "lowerBoundLabel": "Not satisfied",\n "upperBoundLabel": "Very satisfied",\n "translations": {\n "es": {\n "question": "¿Qué tan satisfecho estás?",\n "lowerBoundLabel": "No satisfecho",\n "upperBoundLabel": "Muy satisfecho"\n },\n "fr": {\n "question": "Dans quelle mesure êtes-vous satisfait?"\n }\n }\n }\n ```\n ',
+ null=True,
+ ),
+ ),
+ ("appearance", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("start_date", models.DateTimeField(null=True)),
+ ("end_date", models.DateTimeField(null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("archived", models.BooleanField(default=False)),
+ ("responses_limit", models.PositiveIntegerField(null=True)),
+ ("response_sampling_start_date", models.DateTimeField(blank=True, null=True)),
+ (
+ "response_sampling_interval_type",
+ models.CharField(
+ blank=True,
+ choices=[("day", "day"), ("week", "week"), ("month", "month")],
+ default="week",
+ max_length=6,
+ null=True,
+ ),
+ ),
+ ("response_sampling_interval", models.PositiveIntegerField(blank=True, null=True)),
+ ("response_sampling_limit", models.PositiveIntegerField(blank=True, null=True)),
+ ("response_sampling_daily_limits", models.JSONField(blank=True, null=True)),
+ ("iteration_count", models.PositiveIntegerField(null=True)),
+ ("iteration_frequency_days", models.PositiveIntegerField(null=True)),
+ (
+ "iteration_start_dates",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.DateTimeField(null=True), blank=True, default=None, null=True, size=None
+ ),
+ ),
+ ("current_iteration", models.PositiveIntegerField(null=True)),
+ ("current_iteration_start_date", models.DateTimeField(null=True)),
+ (
+ "schedule",
+ models.CharField(
+ blank=True,
+ choices=[("once", "once"), ("recurring", "recurring"), ("always", "always")],
+ default="once",
+ max_length=40,
+ null=True,
+ ),
+ ),
+ ("enable_partial_responses", models.BooleanField(default=False, null=True)),
+ ("enable_iframe_embedding", models.BooleanField(default=False)),
+ ("headline_summary", models.TextField(blank=True, null=True)),
+ ("headline_response_count", models.PositiveIntegerField(blank=True, null=True)),
+ ("question_summaries", models.JSONField(blank=True, null=True)),
+ ("form_content", models.JSONField(blank=True, null=True)),
+ ("translations", models.JSONField(blank=True, null=True)),
+ (
+ "is_publicly_shareable",
+ models.BooleanField(
+ blank=True,
+ help_text="Allow this survey to be accessed via public URL (https://app.posthog.com/surveys/[survey_id]) without authentication",
+ null=True,
+ ),
+ ),
+ ("actions", models.ManyToManyField(to="actions.action")),
+ (
+ "created_by",
+ models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys",
+ related_query_name="survey",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "internal_response_sampling_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys_internal_response_sampling_flag",
+ related_query_name="surveys_internal_response_sampling_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "internal_targeting_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys_internal_targeting_flag",
+ related_query_name="survey_internal_targeting_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "linked_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys_linked_flag",
+ related_query_name="survey_linked_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "linked_insight",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys_linked_insight",
+ related_query_name="survey_linked_insight",
+ to="product_analytics.insight",
+ ),
+ ),
+ (
+ "targeting_flag",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="surveys_targeting_flag",
+ related_query_name="survey_targeting_flag",
+ to="feature_flags.featureflag",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="surveys",
+ related_query_name="survey",
+ to="posthog.team",
+ ),
+ ),
+ ("base_language", models.CharField(default="en", max_length=20)),
+ ],
+ options={
+ "db_table": "posthog_survey",
+ "indexes": [],
+ "constraints": [models.UniqueConstraint(fields=("team", "name"), name="unique survey name for team")],
+ },
+ ),
+ migrations.CreateModel(
+ name="SurveyResponseArchive",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "response_uuid",
+ models.UUIDField(help_text="UUID of the ClickHouse event representing the survey response"),
+ ),
+ ("archived_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "survey",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="response_archives",
+ related_query_name="response_archive",
+ to="surveys.survey",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="survey_response_archives",
+ related_query_name="survey_response_archive",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_surveyresponsearchive",
+ "indexes": [
+ models.Index(fields=["survey", "team"], name="posthog_sur_survey__f78fc7_idx"),
+ models.Index(fields=["team", "response_uuid"], name="posthog_sur_team_id_2c59a2_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "response_uuid"), name="unique_archived_response_per_team")
+ ],
+ },
+ ),
+ ]
diff --git a/products/surveys/backend/migrations/max_migration.txt b/products/surveys/backend/migrations/max_migration.txt
index 5eb66bf5118e..6903cd5e3dc2 100644
--- a/products/surveys/backend/migrations/max_migration.txt
+++ b/products/surveys/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0005_migrate_product_analytics_models
+0001_squash_2026_09_07_initial
diff --git a/products/tasks/backend/migrations/0001_squash_2026_09_07_initial.py b/products/tasks/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..775bf79d08cd
--- /dev/null
+++ b/products/tasks/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,2225 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.utils.timezone
+import django.db.models.deletion
+import django.db.models.fields.json
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+import products.tasks.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("tasks", "0001_initial"),
+ ("tasks", "0002_agentdefinition_taskworkflow_workflowstage_and_more"),
+ ("tasks", "0003_simplify_workflow_remove_transitions"),
+ ("tasks", "0004_remove_status_field"),
+ ("tasks", "0005_workflowstage_agent_name_alter_workflowstage_agent"),
+ ("tasks", "0006_remove_workflowstage_agent_alter_task_workflow_and_more"),
+ ("tasks", "0007_sandboxsnapshot"),
+ ("tasks", "0008_task_task_number"),
+ ("tasks", "0009_task_created_by"),
+ ("tasks", "0010_alter_task_current_stage_alter_task_github_branch_and_more"),
+ ("tasks", "0011_taskrun_stage_alter_task_current_stage_and_more"),
+ ("tasks", "0012_taskrun_log_storage_path_alter_taskrun_log"),
+ ("tasks", "0013_taskrun_artifacts"),
+ ("tasks", "0014_make_fields_nullable_before_removal"),
+ ("tasks", "0015_alter_taskworkflow_unique_together_and_more"),
+ ("tasks", "0016_task_soft_delete"),
+ ("tasks", "0017_taskrun_environment_alter_taskrun_status"),
+ ("tasks", "0018_alter_taskrun_status"),
+ ("tasks", "0019_remove_taskrun_log_storage_path"),
+ ("tasks", "0020_sandbox_environment"),
+ ("tasks", "0021_alter_task_origin_product"),
+ ("tasks", "0022_codeinvite_codeinviteredemption"),
+ ("tasks", "0023_alter_codeinvite_id_alter_codeinviteredemption_id"),
+ ("tasks", "0024_task_title_manually_set"),
+ ("tasks", "0025_task_internal"),
+ ("tasks", "0026_task_signal_report_alter_task_origin_product"),
+ ("tasks", "0027_task_signal_report_idx"),
+ ("tasks", "0028_sandboxenvironment_internal"),
+ ("tasks", "0029_task_ci_prompt"),
+ ("tasks", "0030_taskautomation"),
+ ("tasks", "0031_task_github_user_integration"),
+ ("tasks", "0032_task_archived_archived_at"),
+ ("tasks", "0033_task_archived_idx"),
+ ("tasks", "0034_taskpresence"),
+ ("tasks", "0035_task_origin_product_signals_scout"),
+ ("tasks", "0036_taskrun_output_pr_url_idx"),
+ ("tasks", "0037_codeworkflowconfig_codeprsnapshot_codeworkstream"),
+ ("tasks", "0038_task_origin_product_conversations_support"),
+ ("tasks", "0039_codeprsnapshot_head_branch"),
+ ("tasks", "0040_alter_task_origin_product"),
+ ("tasks", "0041_taskrun_created_at_idx"),
+ ("tasks", "0042_task_list_perf_indexes"),
+ ("tasks", "0043_alter_task_origin_product"),
+ ("tasks", "0044_alter_task_origin_product"),
+ ("tasks", "0045_channel_task_channel_taskthreadmessage"),
+ ("tasks", "0046_task_channel_feed_index"),
+ ("tasks", "0047_alter_task_origin_product"),
+ ("tasks", "0048_task_state"),
+ ("tasks", "0049_taskthreadmessagemention"),
+ ("tasks", "0050_backfill_thread_message_mentions"),
+ ("tasks", "0051_sandboxcustomimage_sandboxenvironment_custom_image_and_more"),
+ ("tasks", "0052_sandboxcustomimage_private_and_more"),
+ ("tasks", "0053_sandboxcustomimage_build_log"),
+ ("tasks", "0054_taskrun_wizard_branch_idx"),
+ ("tasks", "0055_task_artifact_registry"),
+ ("tasks", "0056_alter_task_origin_product"),
+ ("tasks", "0057_channelfeedmessage"),
+ ("tasks", "0058_taskthreadmessage_agent_fields"),
+ ("tasks", "0059_taskrun_imported_mcp_servers"),
+ ("tasks", "0060_taskrun_relayed_mcp_servers"),
+ ("tasks", "0061_task_runtime"),
+ ("tasks", "0062_sandbox_custom_image_base_reference"),
+ ("tasks", "0063_loop_looptrigger_loopfire"),
+ ("tasks", "0064_task_loop_index"),
+ ("tasks", "0065_looptrigger_completed_at"),
+ ("tasks", "0066_loopfire_trigger_set_null"),
+ ("tasks", "0067_loop_creator"),
+ ("tasks", "0068_loop_creator_backfill"),
+ ("tasks", "0069_remove_code_home_models"),
+ ("tasks", "0070_sandboxsession"),
+ ("tasks", "0071_alter_origin_product_mcp_analytics"),
+ ("tasks", "0072_loop_skill_bundles"),
+ ("tasks", "0073_task_activity"),
+ ("tasks", "0074_task_session"),
+ ("tasks", "0075_task_pin"),
+ ("tasks", "0076_taskrun_task_run_sd_branch_idx"),
+ ("tasks", "0077_taskartifact_export_asset_id"),
+ ("tasks", "0078_task_repositories"),
+ ("tasks", "0079_backfill_task_repositories"),
+ ("tasks", "0080_channel_repository_configuration"),
+ ("tasks", "0081_channelcontextgeneration_channelinstructions_and_more"),
+ ("tasks", "0082_task_client_provenance"),
+ ("tasks", "0083_taskcommentactivity"),
+ ("tasks", "0084_sandboxsession_provider_cpu_usage"),
+ ("tasks", "0085_sandboxsession_cpu_attribution_usage"),
+ ("tasks", "0086_clear_disconnected_channel_repositories"),
+ ("tasks", "0087_tasksearchdocument"),
+ ("tasks", "0088_backfill_task_search_documents"),
+ ("tasks", "0089_taskrun_queued_at"),
+ ("tasks", "0090_alter_origin_product_signals_chat"),
+ ("tasks", "0091_task_last_activity_at"),
+ ("tasks", "0092_backfill_task_last_activity_at"),
+ ("tasks", "0093_task_last_activity_default"),
+ ("tasks", "0094_task_last_activity_indexes"),
+ ("tasks", "0095_remove_task_automation"),
+ ("tasks", "0096_taskworkflowdispatch"),
+ ("tasks", "0097_sandboxsession_billed_cpu_usage"),
+ ("tasks", "0098_task_hog_flow_id_task_origin_key_and_more"),
+ ("tasks", "0099_task_workflow_indexes"),
+ ("tasks", "0100_alter_loop_origin_product_and_more"),
+ ("tasks", "0101_agentpeermessage"),
+ ("tasks", "0102_channel_system_role"),
+ ("tasks", "0103_callable_choices"),
+ ("tasks", "0104_desktop_beta_terms_acceptance"),
+ ("tasks", "0105_taskrun_webhook_lookup_indexes"),
+ ("tasks", "0106_sandboxsession_sandbox_backend"),
+ ("tasks", "0107_remove_code_invites_from_state"),
+ ("tasks", "0108_channel_auto_archive_after_days"),
+ ("tasks", "0109_taskrun_origin_product"),
+ ("tasks", "0110_backfill_taskrun_origin_product"),
+ ("tasks", "0111_taskrun_status_env_origin_idx"),
+ ("tasks", "0112_taskrun_terminal_updated_idx"),
+ ("tasks", "0113_task_team_live_list_indexes"),
+ ("tasks", "0114_taskrun_autovacuum_scale_factor"),
+ ("tasks", "0115_teamtasksconfig_usertasksconfig"),
+ ("tasks", "0116_drop_task_session_storage_key_like_index"),
+ ("tasks", "0117_task_set_null_cascade_indexes"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Channel",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("name", models.CharField(max_length=128)),
+ (
+ "channel_type",
+ models.CharField(
+ choices=[("public", "Public"), ("personal", "Personal")], default="public", max_length=16
+ ),
+ ),
+ ("deleted", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "github_integration",
+ models.ForeignKey(
+ blank=True,
+ limit_choices_to={"kind": "github"},
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "repositories",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255),
+ blank=True,
+ db_default=[],
+ default=list,
+ help_text="GitHub repositories inherited by new tasks in this channel",
+ size=None,
+ ),
+ ),
+ (
+ "system_role",
+ models.CharField(
+ blank=True, choices=[("personal", "Personal"), ("general", "General")], max_length=16, null=True
+ ),
+ ),
+ (
+ "auto_archive_after_days",
+ models.PositiveSmallIntegerField(
+ blank=True,
+ help_text="Archive inactive tasks in this channel after this many days. Null disables automatic archiving.",
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_channel",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("channel_type", "public"), ("deleted", False)),
+ fields=("team", "name"),
+ name="task_channel_team_name_public_unique",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("channel_type", "personal"), ("deleted", False)),
+ fields=("team", "created_by"),
+ name="task_channel_team_user_personal_unique",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="Loop",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "visibility",
+ models.CharField(
+ choices=[("personal", "Personal"), ("team", "Team")], default="personal", max_length=16
+ ),
+ ),
+ ("instructions", models.TextField()),
+ ("runtime_adapter", models.CharField(max_length=32)),
+ ("model", models.CharField(blank=True, default="", max_length=128)),
+ ("reasoning_effort", models.CharField(blank=True, max_length=32, null=True)),
+ ("repositories", models.JSONField(blank=True, default=list)),
+ ("enabled", models.BooleanField(default=True)),
+ (
+ "overlap_policy",
+ models.CharField(
+ choices=[("skip", "Skip"), ("allow", "Allow"), ("cancel_previous", "Cancel previous")],
+ default="skip",
+ max_length=32,
+ ),
+ ),
+ ("behaviors", models.JSONField(blank=True, default=dict)),
+ ("connectors", models.JSONField(blank=True, default=dict)),
+ ("notifications", models.JSONField(blank=True, default=dict)),
+ ("context_target", models.JSONField(blank=True, default=dict)),
+ (
+ "internal",
+ models.BooleanField(
+ default=False,
+ help_text="If true, this loop is for internal use and should not be exposed to end users.",
+ ),
+ ),
+ (
+ "origin_product",
+ models.CharField(
+ choices=products.tasks.backend.models.task_origin_product_choices,
+ default="user_created",
+ help_text="Which product or flow created this loop.",
+ max_length=32,
+ ),
+ ),
+ ("last_run_at", models.DateTimeField(blank=True, null=True)),
+ ("last_run_status", models.CharField(blank=True, max_length=32, null=True)),
+ ("last_error", models.TextField(blank=True, null=True)),
+ ("consecutive_failures", models.PositiveIntegerField(default=0)),
+ ("disabled_reason", models.CharField(blank=True, max_length=64, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "creator",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("skill_bundles", models.JSONField(blank=True, default=list)),
+ (
+ "client_provenance",
+ models.CharField(
+ blank=True,
+ choices=[("posthog_desktop", "PostHog Desktop")],
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_loop",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SandboxSnapshot",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "external_id",
+ models.CharField(
+ blank=True, help_text="Snapshot ID from external provider.", max_length=255, unique=True
+ ),
+ ),
+ (
+ "repos",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255),
+ default=list,
+ help_text="List of repositories in format 'org/repo'",
+ size=None,
+ ),
+ ),
+ (
+ "metadata",
+ models.JSONField(blank=True, default=dict, help_text="Additional metadata for the snapshot."),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("in_progress", "In Progress"), ("complete", "Complete"), ("error", "Error")],
+ default="in_progress",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="snapshots",
+ to="posthog.integration",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_sandbox_snapshot",
+ "indexes": [
+ models.Index(fields=["integration", "status", "-created_at"], name="posthog_san_integra_93cdea_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="DesktopBetaTermsAcceptance",
+ fields=[
+ (
+ "organization",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.organization",
+ ),
+ ),
+ ("accepted_by_user_id", models.BigIntegerField()),
+ ("accepted_at", models.DateTimeField(auto_now_add=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamTasksConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="+",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("ai_run_preferences", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserTasksConfig",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("ai_run_preferences", models.JSONField(blank=True, null=True)),
+ ("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,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user"), name="user_tasks_config_team_user_unique")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ChannelFeedMessage",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ (
+ "author_kind",
+ models.CharField(
+ choices=[("human", "Human"), ("system", "System"), ("agent", "Agent")],
+ default="system",
+ max_length=16,
+ ),
+ ),
+ ("event", models.CharField(max_length=64)),
+ ("payload", models.JSONField(blank=True, default=dict)),
+ ("content", models.TextField(blank=True, default="")),
+ ("deleted", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "author",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "channel",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="feed_messages", to="tasks.channel"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_channel_feed_message",
+ "indexes": [models.Index(fields=["channel", "created_at"], name="task_channel_feed_msg_created")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ChannelContextGeneration",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("task_id", models.UUIDField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "channel",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="context_generation",
+ to="tasks.channel",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_channel_context_generation",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ChannelInstructions",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("content", models.TextField()),
+ ("version", models.PositiveIntegerField(default=1)),
+ ("is_latest", models.BooleanField(default=True)),
+ ("deleted", models.BooleanField(default=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "channel",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="instruction_versions",
+ to="tasks.channel",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_channel_instructions",
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False)),
+ fields=("channel", "version"),
+ name="unique_channel_instructions_version",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("is_latest", True)),
+ fields=("channel",),
+ name="unique_channel_instructions_latest",
+ ),
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ChannelStar",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "channel",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="stars", to="tasks.channel"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_channel_star",
+ "constraints": [
+ models.UniqueConstraint(fields=("channel", "user"), name="unique_channel_star_per_user")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="Task",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("title", models.CharField(max_length=255)),
+ ("description", models.TextField()),
+ (
+ "origin_product",
+ models.CharField(choices=products.tasks.backend.models.task_origin_product_choices, max_length=20),
+ ),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "github_integration",
+ models.ForeignKey(
+ blank=True,
+ help_text="GitHub integration for this task",
+ limit_choices_to={"kind": "github"},
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog.integration",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("task_number", models.IntegerField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "json_schema",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="JSON schema for the task. This is used to validate the output of the task.",
+ null=True,
+ ),
+ ),
+ ("repository", models.CharField(blank=True, max_length=255, null=True)),
+ ("deleted", models.BooleanField(blank=True, default=False, null=True)),
+ ("deleted_at", models.DateTimeField(blank=True, null=True)),
+ ("title_manually_set", models.BooleanField(default=False)),
+ (
+ "internal",
+ models.BooleanField(
+ default=False,
+ help_text="If true, this task is for internal use and should not be exposed to end users.",
+ ),
+ ),
+ (
+ "ci_prompt",
+ models.TextField(
+ blank=True,
+ help_text="Custom prompt for CI fixes. If blank, a default prompt will be used.",
+ null=True,
+ ),
+ ),
+ (
+ "github_user_integration",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ help_text="User-scoped GitHub integration used for user-authored task runs",
+ limit_choices_to={"kind": "github"},
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog.userintegration",
+ ),
+ ),
+ (
+ "archived",
+ models.BooleanField(
+ default=False,
+ help_text="If true, the task is hidden from default list responses. Used by PostHog Desktop clients to share archive state across desktop and mobile.",
+ ),
+ ),
+ ("archived_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "channel",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="tasks",
+ to="tasks.channel",
+ ),
+ ),
+ ("state", models.JSONField(blank=True, default=dict, null=True)),
+ (
+ "runtime",
+ models.CharField(
+ choices=[("acp", "ACP"), ("pi", "Pi")],
+ db_default="acp",
+ default="acp",
+ help_text="Agent protocol/harness driving this task's runs.",
+ max_length=10,
+ ),
+ ),
+ (
+ "loop",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="tasks",
+ to="tasks.loop",
+ ),
+ ),
+ (
+ "repositories",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255),
+ blank=True,
+ db_default=[],
+ default=list,
+ help_text="GitHub repositories available to this task",
+ size=None,
+ ),
+ ),
+ (
+ "client_provenance",
+ models.CharField(
+ blank=True,
+ choices=[("posthog_desktop", "PostHog Desktop")],
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ("last_activity_at", models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True)),
+ ("hog_flow_id", models.UUIDField(blank=True, null=True)),
+ ("origin_key", models.CharField(blank=True, max_length=128, null=True)),
+ ],
+ options={
+ "db_table": "posthog_task",
+ "managed": True,
+ "indexes": [
+ models.Index(fields=["team", "-created_at", "-id"], name="posthog_task_team_created_idx"),
+ models.Index(
+ fields=["team", "created_by", "-created_at", "-id"], name="posthog_task_team_creator_idx"
+ ),
+ models.Index(fields=["channel", "-created_at"], name="posthog_task_channel_feed_idx"),
+ models.Index(fields=["loop"], name="posthog_task_loop_idx"),
+ models.Index(fields=["team", "-last_activity_at", "-id"], name="posthog_task_team_activity_idx"),
+ models.Index(fields=["channel", "-last_activity_at"], name="posthog_task_chan_activity_idx"),
+ models.Index(fields=["hog_flow_id", "-created_at"], name="posthog_task_hog_flow_idx"),
+ models.Index(
+ condition=models.Q(("deleted", False)),
+ fields=["team", "internal", "archived", "-created_at", "-id"],
+ name="posthog_task_team_live_crt_idx",
+ ),
+ models.Index(
+ condition=models.Q(("deleted", False)),
+ fields=["team", "internal", "archived", "-last_activity_at", "-id"],
+ name="posthog_task_team_live_act_idx",
+ ),
+ models.Index(fields=["created_by"], name="posthog_task_creator_idx"),
+ models.Index(fields=["github_user_integration"], name="posthog_task_gh_user_int_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("origin_key__isnull", False)),
+ fields=("team", "origin_key"),
+ name="posthog_task_origin_key_uniq",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LoopTrigger",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ (
+ "type",
+ models.CharField(
+ choices=[("schedule", "Schedule"), ("github", "GitHub"), ("api", "API")], max_length=16
+ ),
+ ),
+ ("enabled", models.BooleanField(default=True)),
+ ("config", models.JSONField(default=dict)),
+ ("github_integration_id", models.BigIntegerField(blank=True, null=True)),
+ ("repository", models.CharField(blank=True, max_length=512, null=True)),
+ (
+ "event_types",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=32), blank=True, null=True, size=None
+ ),
+ ),
+ (
+ "schedule_sync_status",
+ models.CharField(
+ blank=True,
+ choices=[("pending", "Pending"), ("synced", "Synced"), ("failed", "Failed")],
+ max_length=16,
+ null=True,
+ ),
+ ),
+ ("last_fired_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "loop",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="triggers", to="tasks.loop"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_task_loop_trigger",
+ "indexes": [
+ models.Index(fields=["github_integration_id", "repository"], name="task_loop_trigger_gh_repo_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskPresence",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("last_seen_at", models.DateTimeField(auto_now=True)),
+ ("expires_at", models.DateTimeField(db_index=True)),
+ (
+ "task",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tasks.task"),
+ ),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="+", to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "push_token",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.userpushtoken"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_presence",
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("task", "push_token"), name="task_presence_task_push_token_unique")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SandboxCustomImage",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("name", models.CharField(max_length=255)),
+ ("description", models.TextField(blank=True, default="")),
+ (
+ "spec",
+ models.JSONField(
+ blank=True, default=dict, help_text="Declarative image spec (see SandboxImageSpec schema)."
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("draft", "Draft"),
+ ("scanning", "Scanning"),
+ ("scan_failed", "Scan Failed"),
+ ("building", "Building"),
+ ("build_failed", "Build Failed"),
+ ("ready", "Ready"),
+ ("archived", "Archived"),
+ ],
+ default="draft",
+ max_length=20,
+ ),
+ ),
+ ("version", models.PositiveIntegerField(default=0, help_text="Incremented on each successful build.")),
+ (
+ "modal_image_name",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Published Modal named-image reference (name:tag) for the latest successful build.",
+ max_length=255,
+ ),
+ ),
+ (
+ "scan_result",
+ models.JSONField(blank=True, default=dict, help_text="Latest security scan verdict and findings."),
+ ),
+ (
+ "error",
+ models.TextField(
+ blank=True, default="", help_text="Failure detail for scan_failed/build_failed states."
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "builder_task",
+ models.ForeignKey(
+ blank=True,
+ help_text="The image-builder agent task whose conversation produced this image's spec.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.task",
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "private",
+ models.BooleanField(
+ default=False,
+ help_text="If true, only the creator can see and use this image. Otherwise visible to the whole team.",
+ ),
+ ),
+ (
+ "repository",
+ models.CharField(
+ blank=True,
+ default="",
+ help_text="Optional 'org/repo' the builder session clones to verify the image can bring up its dependencies.",
+ max_length=255,
+ ),
+ ),
+ (
+ "build_log",
+ models.TextField(
+ blank=True, default="", help_text="Sanitized tail of the latest Modal build output."
+ ),
+ ),
+ (
+ "base_image_reference",
+ models.CharField(
+ blank=True,
+ help_text="Immutable VM base image reference used for the latest successful build.",
+ max_length=255,
+ null=True,
+ ),
+ ),
+ (
+ "base_image_refresh_reference",
+ models.CharField(
+ blank=True,
+ help_text="VM base image reference most recently queued for an automatic refresh.",
+ max_length=255,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_sandbox_custom_image",
+ "indexes": [
+ models.Index(fields=["team", "status", "-created_at"], name="posthog_san_team_id_eb6697_idx")
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskSession",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("object_storage_key", models.CharField(blank=True, max_length=512, null=True, unique=True)),
+ ("content_sha256", models.CharField(blank=True, max_length=64, null=True)),
+ ("size", models.PositiveIntegerField(default=0)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "organization",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="task_sessions",
+ to="tasks.task",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_session",
+ "indexes": [
+ models.Index(fields=["organization", "-updated_at"], name="task_session_org_updated_idx"),
+ models.Index(fields=["team", "-updated_at"], name="task_session_team_updated_idx"),
+ models.Index(fields=["task", "-updated_at"], name="task_session_task_updated_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskPin",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("pinned_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "task",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tasks.task"),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_pin",
+ "indexes": [models.Index(fields=["user", "-pinned_at"], name="task_pin_user_pinned_idx")],
+ "constraints": [models.UniqueConstraint(fields=("user", "task"), name="task_pin_user_task_unique")],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskCommentActivity",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("activity_at", models.DateTimeField()),
+ ("read_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("mention", "Mention"),
+ ("thread_reply", "Thread reply"),
+ ("owned_item_comment", "Owned item comment"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "comment",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.comment",
+ ),
+ ),
+ (
+ "root_comment",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.comment",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tasks.task"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_comment_activity",
+ "indexes": [
+ models.Index(fields=["team", "user", "activity_at", "id"], name="task_comment_activity_feed"),
+ models.Index(
+ condition=models.Q(("read_at__isnull", True)),
+ fields=["team", "user"],
+ name="task_comment_activity_unread",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user", "comment"), name="task_comment_activity_unique")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="LoopFire",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("fire_key", models.CharField(max_length=512)),
+ ("outcome_reason", models.CharField(blank=True, max_length=64, null=True)),
+ ("outcome_task_id", models.UUIDField(blank=True, null=True)),
+ ("outcome_task_run_id", models.UUIDField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "loop",
+ models.ForeignKey(
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="fires",
+ to="tasks.loop",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "loop_trigger",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="fires",
+ to="tasks.looptrigger",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_loop_fire",
+ "indexes": [models.Index(fields=["loop", "created_at"], name="task_loop_fire_loop_ct_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("loop_trigger__isnull", False)),
+ fields=("loop_trigger", "fire_key"),
+ name="task_loop_fire_trigger_key_unique",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("loop_trigger__isnull", True)),
+ fields=("loop", "fire_key"),
+ name="task_loop_fire_loop_key_unique",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="SandboxEnvironment",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ (
+ "network_access_level",
+ models.CharField(
+ choices=[("trusted", "Trusted"), ("full", "Full"), ("custom", "Custom")],
+ default="full",
+ max_length=20,
+ ),
+ ),
+ (
+ "allowed_domains",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255),
+ blank=True,
+ default=list,
+ help_text="List of allowed domains for custom network access",
+ size=None,
+ ),
+ ),
+ (
+ "include_default_domains",
+ models.BooleanField(
+ default=False, help_text="Whether to include default trusted domains (GitHub, npm, PyPI)"
+ ),
+ ),
+ (
+ "repositories",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255),
+ blank=True,
+ default=list,
+ help_text="List of repositories this environment applies to (format: org/repo)",
+ size=None,
+ ),
+ ),
+ (
+ "environment_variables",
+ posthog.helpers.encrypted_fields.EncryptedJSONStringField(
+ blank=True,
+ default=dict,
+ help_text="Encrypted environment variables for sandbox execution",
+ null=True,
+ ),
+ ),
+ (
+ "private",
+ models.BooleanField(
+ default=True,
+ help_text="If true, only the creator can see this environment. Otherwise visible to whole team.",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "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")),
+ (
+ "internal",
+ models.BooleanField(
+ default=False,
+ help_text="If true, this environment is for internal use (e.g. signals pipeline) and should not be exposed to end users.",
+ ),
+ ),
+ (
+ "custom_image",
+ models.ForeignKey(
+ blank=True,
+ help_text="Custom base image for this environment's sandboxes (Modal VM runtime only)",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.sandboxcustomimage",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_sandbox_environment",
+ "indexes": [models.Index(fields=["team", "created_by"], name="posthog_san_team_id_817c0d_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskRun",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ (
+ "branch",
+ models.CharField(blank=True, help_text="Branch name for the run", max_length=255, null=True),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("not_started", "Not Started"),
+ ("queued", "Queued"),
+ ("in_progress", "In Progress"),
+ ("completed", "Completed"),
+ ("failed", "Failed"),
+ ("cancelled", "Cancelled"),
+ ],
+ default="not_started",
+ max_length=20,
+ ),
+ ),
+ (
+ "error_message",
+ models.TextField(blank=True, help_text="Error message if execution failed", null=True),
+ ),
+ (
+ "output",
+ models.JSONField(
+ blank=True, help_text="Run output data (e.g., PR URL, commit SHA, etc.)", null=True
+ ),
+ ),
+ (
+ "state",
+ models.JSONField(
+ blank=True, default=dict, help_text="Run state data for resuming or tracking execution state"
+ ),
+ ),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "task",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="runs", to="tasks.task"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "stage",
+ models.CharField(
+ blank=True,
+ help_text="Current stage for this run (e.g., 'research', 'plan', 'build')",
+ max_length=100,
+ null=True,
+ ),
+ ),
+ (
+ "artifacts",
+ models.JSONField(
+ blank=True, default=list, help_text="List of artifacts uploaded to S3 for this run."
+ ),
+ ),
+ (
+ "environment",
+ models.CharField(
+ choices=[("local", "Local"), ("cloud", "Cloud")],
+ default="cloud",
+ help_text="Execution environment",
+ max_length=10,
+ ),
+ ),
+ (
+ "imported_mcp_servers",
+ posthog.helpers.encrypted_fields.EncryptedJSONStringField(
+ blank=True,
+ default=None,
+ help_text="Client-imported MCP server configs (type/name/url/headers) to make available in the sandbox",
+ null=True,
+ ),
+ ),
+ (
+ "relayed_mcp_servers",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Names of desktop-only MCP servers the creating client relays into this run (docs/cloud-mcp-relay.md). Names only — configuration never crosses the wire.",
+ null=True,
+ ),
+ ),
+ (
+ "active_task_session",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="active_runs",
+ to="tasks.tasksession",
+ ),
+ ),
+ ("queued_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "origin_product",
+ models.CharField(
+ blank=True,
+ choices=products.tasks.backend.models.task_origin_product_choices,
+ db_default="",
+ default="",
+ max_length=20,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_run",
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(
+ django.db.models.fields.json.KeyTransform("pr_url", "output"),
+ condition=models.Q(("output__pr_url__isnull", False)),
+ name="task_run_output_pr_url_idx",
+ ),
+ models.Index(fields=["created_at"], name="task_run_created_at_idx"),
+ models.Index(fields=["task", "-created_at", "-id"], name="task_run_task_created_idx"),
+ models.Index(
+ condition=models.Q(("stage__isnull", False)),
+ fields=["team", "stage", "task"],
+ name="task_run_team_stage_task_idx",
+ ),
+ models.Index(
+ django.db.models.fields.json.KeyTransform("wizard_head_branch", "state"),
+ condition=models.Q(("state__wizard_head_branch__isnull", False)),
+ name="task_run_wizard_branch_idx",
+ ),
+ models.Index(
+ django.db.models.fields.json.KeyTransform("self_driving_head_branch", "state"),
+ condition=models.Q(("state__self_driving_head_branch__isnull", False)),
+ name="task_run_sd_branch_idx",
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ django.contrib.postgres.indexes.OpClass(
+ django.db.models.fields.json.KeyTransform("verified_pr_urls", "state"),
+ name="jsonb_path_ops",
+ ),
+ name="task_run_verified_pr_urls_idx",
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ django.contrib.postgres.indexes.OpClass(
+ django.db.models.fields.json.KeyTransform("head_branches", "output"), name="jsonb_path_ops"
+ ),
+ name="task_run_head_branches_idx",
+ ),
+ models.Index(
+ condition=models.Q(("branch__isnull", False)), fields=["branch"], name="task_run_branch_idx"
+ ),
+ models.Index(
+ fields=["status", "environment", "origin_product"], name="task_run_status_env_origin_idx"
+ ),
+ models.Index(
+ condition=models.Q(("status__in", ["completed", "failed", "cancelled"])),
+ fields=["updated_at"],
+ include=("status", "environment", "origin_product"),
+ name="task_run_terminal_updated_idx",
+ ),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskThreadMessage",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("content", models.TextField()),
+ ("forwarded_to_agent_at", models.DateTimeField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "author",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "forwarded_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "forwarded_run",
+ models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="thread_messages", to="tasks.task"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "author_kind",
+ models.CharField(
+ choices=[("human", "Human"), ("system", "System"), ("agent", "Agent")],
+ default="human",
+ max_length=16,
+ ),
+ ),
+ ("event", models.CharField(blank=True, default="", max_length=64)),
+ ("payload", models.JSONField(blank=True, default=dict)),
+ ],
+ options={
+ "db_table": "posthog_task_thread_message",
+ "indexes": [models.Index(fields=["task", "created_at"], name="task_thread_msg_task_created")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskArtifact",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=255)),
+ (
+ "artifact_type",
+ models.CharField(
+ choices=[
+ ("slack_message", "Slack message"),
+ ("slack_canvas", "Slack canvas"),
+ ("document", "Document"),
+ ("spreadsheet", "Spreadsheet"),
+ ("dashboard", "Dashboard"),
+ ("file", "File"),
+ ("github_pr", "GitHub PR"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "adapter",
+ models.CharField(
+ choices=[
+ ("slack_message", "Slack message"),
+ ("slack_canvas", "Slack canvas"),
+ ("slack_file", "Slack file"),
+ ("document_connector", "Document connector"),
+ ("github_pr", "GitHub PR"),
+ ],
+ max_length=32,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("failed", "Failed")],
+ db_default="active",
+ default="active",
+ max_length=16,
+ ),
+ ),
+ (
+ "location",
+ models.JSONField(
+ db_default=models.Value("{}"), default=dict, help_text="Adapter-specific location data."
+ ),
+ ),
+ (
+ "metadata",
+ models.JSONField(
+ db_default=models.Value("{}"), default=dict, help_text="Adapter-specific artifact metadata."
+ ),
+ ),
+ (
+ "versions",
+ models.JSONField(
+ db_default=models.Value("[]"), default=list, help_text="Chronological artifact versions."
+ ),
+ ),
+ ("current_version", models.PositiveIntegerField(db_default=1, default=1)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="living_artifacts", to="tasks.task"
+ ),
+ ),
+ (
+ "task_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="living_artifacts", to="tasks.taskrun"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ("export_asset_id", models.BigIntegerField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_task_artifact",
+ "indexes": [
+ models.Index(fields=["team", "task", "-updated_at"], name="task_artifact_team_task_idx"),
+ models.Index(fields=["team", "task_run", "-updated_at"], name="task_artifact_team_run_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="SandboxSession",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "sandbox_id",
+ models.CharField(
+ help_text="Provider sandbox id (e.g. Modal object id)", max_length=255, unique=True
+ ),
+ ),
+ (
+ "origin_product",
+ models.CharField(
+ blank=True,
+ choices=products.tasks.backend.models.task_origin_product_choices,
+ help_text="Task origin at provision time, denormalized for per-origin aggregation",
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "prewarmed",
+ models.BooleanField(default=False, help_text="Sandbox was provisioned ahead of any user demand"),
+ ),
+ (
+ "vm_runtime",
+ models.BooleanField(
+ default=False, help_text="Modal VM runtime rather than gVisor (billed differently)"
+ ),
+ ),
+ ("cpu_cores", models.FloatField(help_text="CPU core limit")),
+ ("memory_gb", models.FloatField(help_text="Memory limit in GiB")),
+ ("ttl_seconds", models.IntegerField(help_text="Hard TTL after which the provider kills the sandbox")),
+ ("burstable", models.BooleanField(default=False)),
+ (
+ "cpu_request_cores",
+ models.FloatField(blank=True, help_text="Reserved CPU floor when burstable", null=True),
+ ),
+ (
+ "memory_request_mb",
+ models.IntegerField(blank=True, help_text="Reserved memory floor when burstable", null=True),
+ ),
+ (
+ "created_at",
+ models.DateTimeField(default=django.utils.timezone.now, help_text="Sandbox provisioned"),
+ ),
+ (
+ "ttl_expires_at",
+ models.DateTimeField(help_text="Absolute provider kill deadline (creation boundary + TTL)"),
+ ),
+ (
+ "user_attributed_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="Start of the user-attributable window; NULL while (pre)warm and unclaimed",
+ null=True,
+ ),
+ ),
+ (
+ "last_user_activity_at",
+ models.DateTimeField(
+ blank=True, help_text="Most recent user message routed to this sandbox's run", null=True
+ ),
+ ),
+ (
+ "ended_at",
+ models.DateTimeField(
+ blank=True, help_text="Sandbox destroyed; NULL rows are clamped to ttl_expires_at", null=True
+ ),
+ ),
+ (
+ "ended_reason",
+ models.CharField(
+ blank=True, choices=[("cleanup", "Cleanup"), ("reaped", "Reaped")], max_length=20, null=True
+ ),
+ ),
+ (
+ "task_run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="sandbox_sessions", to="tasks.taskrun"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "client_provenance",
+ models.CharField(
+ blank=True,
+ choices=[("posthog_desktop", "PostHog Desktop")],
+ editable=False,
+ max_length=32,
+ null=True,
+ ),
+ ),
+ (
+ "provider_cpu_usage_usec",
+ models.PositiveBigIntegerField(
+ blank=True,
+ help_text="Cumulative provider CPU time sampled immediately before sandbox cleanup",
+ null=True,
+ ),
+ ),
+ (
+ "provider_usage_measured_at",
+ models.DateTimeField(blank=True, help_text="When provider resource usage was sampled", null=True),
+ ),
+ (
+ "provider_cpu_usage_attribution_measured_at",
+ models.DateTimeField(
+ blank=True, help_text="When provider CPU usage was sampled at user attribution", null=True
+ ),
+ ),
+ (
+ "provider_cpu_usage_attribution_usec",
+ models.PositiveBigIntegerField(
+ blank=True,
+ help_text="Cumulative provider CPU time sampled when user attribution starts",
+ null=True,
+ ),
+ ),
+ (
+ "provider_billed_cpu_usage_attribution_usec",
+ models.PositiveBigIntegerField(
+ blank=True,
+ help_text="Estimated billed CPU time sampled when user attribution starts",
+ null=True,
+ ),
+ ),
+ (
+ "provider_billed_cpu_usage_usec",
+ models.PositiveBigIntegerField(
+ blank=True,
+ help_text="Estimated billed CPU time sampled immediately before sandbox cleanup",
+ null=True,
+ ),
+ ),
+ (
+ "sandbox_backend",
+ models.CharField(
+ blank=True,
+ help_text="Provider backend (e.g. hogland); NULL for Modal. Hogland's TTL is idle, not absolute",
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_sandbox_session",
+ "indexes": [
+ models.Index(fields=["ended_at"], name="sandbox_session_ended_at_idx"),
+ models.Index(
+ condition=models.Q(("ended_at__isnull", True)),
+ fields=["ttl_expires_at"],
+ name="sandbox_session_open_ttl_idx",
+ ),
+ models.Index(fields=["team", "user_attributed_at"], name="sandbox_session_team_attr_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskSearchDocument",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("task", "Task"),
+ ("pull_request", "Pull request"),
+ ("artifact", "Artifact"),
+ ("channel", "Channel"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("source_key", models.CharField(max_length=512)),
+ ("title", models.CharField(max_length=512)),
+ ("subtitle", models.CharField(blank=True, default="", max_length=512)),
+ ("search_text", models.TextField()),
+ (
+ "exact_identifiers",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=512), blank=True, default=list, size=None
+ ),
+ ),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "channel",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.channel",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="tasks.task",
+ ),
+ ),
+ (
+ "task_run",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_search_document",
+ "indexes": [
+ models.Index(fields=["team", "kind"], name="task_search_doc_team_kind_idx"),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["exact_identifiers"], name="task_search_doc_exact_gin"
+ ),
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["search_text"], name="task_search_doc_text_trgm", opclasses=["gin_trgm_ops"]
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "kind", "source_key"), name="task_search_doc_source_unique")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskWorkflowDispatch",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("workflow_id", models.CharField(max_length=512)),
+ (
+ "dispatch_kind",
+ models.CharField(choices=[("create", "create"), ("restart", "restart")], max_length=16),
+ ),
+ ("enqueued_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("payload", models.JSONField(default=dict)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "pending"),
+ ("claimed", "claimed"),
+ ("accepted", "accepted"),
+ ("dead", "dead"),
+ ],
+ default="pending",
+ max_length=16,
+ ),
+ ),
+ ("attempt_count", models.PositiveIntegerField(default=0)),
+ ("next_attempt_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("claimed_by", models.CharField(blank=True, default="", max_length=128)),
+ ("lease_expires_at", models.DateTimeField(blank=True, null=True)),
+ ("accepted_at", models.DateTimeField(blank=True, null=True)),
+ ("last_error", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "task_run",
+ models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="workflow_dispatches",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_taskworkflowdispatch",
+ "indexes": [
+ models.Index(
+ condition=models.Q(("status", "pending")), fields=["next_attempt_at"], name="twd_pending_due"
+ ),
+ models.Index(
+ condition=models.Q(("status", "claimed")), fields=["lease_expires_at"], name="twd_claimed_lease"
+ ),
+ models.Index(fields=["team", "created_at"], name="twd_team_created"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("task_run", "dispatch_kind"), name="uniq_dispatch_per_run_kind"),
+ models.CheckConstraint(
+ condition=models.Q(
+ models.Q(("accepted_at__isnull", False), ("status", "accepted")),
+ models.Q(models.Q(("status", "accepted"), _negated=True), ("accepted_at__isnull", True)),
+ _connector="OR",
+ ),
+ name="accepted_at_iff_accepted",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="AgentPeerMessage",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("content", models.TextField()),
+ ("artifact_ids", models.JSONField(blank=True, default=list)),
+ (
+ "outcome",
+ models.CharField(
+ choices=[
+ ("accepted", "Accepted"),
+ ("signaled", "Signaled"),
+ ("delivered", "Delivered"),
+ ("rejected", "Rejected"),
+ ("target_finished", "Target finished"),
+ ("delivery_failed", "Delivery failed"),
+ ],
+ default="accepted",
+ max_length=20,
+ ),
+ ),
+ ("failure_phase", models.CharField(blank=True, default="", max_length=50)),
+ ("failure_detail", models.TextField(blank=True, default="")),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "sender_run",
+ models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="sent_peer_messages",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "sender_user",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "target_run",
+ models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="received_peer_messages",
+ to="tasks.taskrun",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_agent_peer_message",
+ "indexes": [
+ models.Index(fields=["target_run", "outcome", "created_at"], name="peer_msg_target_outcome_idx"),
+ models.Index(fields=["sender_run", "created_at"], name="peer_msg_sender_created_idx"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskThreadMessageMention",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("created_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "mentioned_user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "message",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="mentions",
+ to="tasks.taskthreadmessage",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tasks.task"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_thread_message_mention",
+ "indexes": [
+ models.Index(fields=["team", "mentioned_user", "created_at"], name="task_mention_team_user_created")
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("message", "mentioned_user"), name="task_mention_message_user_unique"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="TaskActivity",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "kind",
+ models.CharField(
+ choices=[
+ ("created", "Created"),
+ ("mention", "Mention"),
+ ("message", "Message"),
+ ("awaiting_input", "Awaiting input"),
+ ("completed", "Completed"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("activity_at", models.DateTimeField()),
+ ("read_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "message",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="activity_rows",
+ to="tasks.taskthreadmessage",
+ ),
+ ),
+ (
+ "task",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="tasks.task"),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_task_activity",
+ "indexes": [
+ models.Index(fields=["team", "user", "activity_at", "id"], name="task_activity_feed_idx"),
+ models.Index(
+ condition=models.Q(("read_at__isnull", True)),
+ fields=["team", "user"],
+ name="task_activity_unread_idx",
+ ),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user", "task"), name="task_activity_user_task_unique")
+ ],
+ },
+ ),
+ ]
diff --git a/products/tasks/backend/migrations/0026_task_signal_report_alter_task_origin_product.py b/products/tasks/backend/migrations/0026_task_signal_report_alter_task_origin_product.py
index 85e16075a820..34388156dbe6 100644
--- a/products/tasks/backend/migrations/0026_task_signal_report_alter_task_origin_product.py
+++ b/products/tasks/backend/migrations/0026_task_signal_report_alter_task_origin_product.py
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ("signals", "0011_add_error_tracking_signal_types"),
("tasks", "0025_task_internal"),
]
diff --git a/products/tasks/backend/migrations/0063_loop_looptrigger_loopfire.py b/products/tasks/backend/migrations/0063_loop_looptrigger_loopfire.py
index b053755f2a92..7626bd07b4ee 100644
--- a/products/tasks/backend/migrations/0063_loop_looptrigger_loopfire.py
+++ b/products/tasks/backend/migrations/0063_loop_looptrigger_loopfire.py
@@ -12,7 +12,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "1256_userproductlist_default_reason"),
- ("signals", "0062_add_analytics_anomaly_investigation_source"),
("tasks", "0062_sandbox_custom_image_base_reference"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
diff --git a/products/tasks/backend/migrations/0098_task_hog_flow_id_task_origin_key_and_more.py b/products/tasks/backend/migrations/0098_task_hog_flow_id_task_origin_key_and_more.py
index 125a37af4df4..d513d30639f6 100644
--- a/products/tasks/backend/migrations/0098_task_hog_flow_id_task_origin_key_and_more.py
+++ b/products/tasks/backend/migrations/0098_task_hog_flow_id_task_origin_key_and_more.py
@@ -7,7 +7,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("posthog", "1305_alter_identityproviderconfig_saml_relay_state_and_more"),
- ("signals", "0094_delete_session_analysis_source_configs"),
("tasks", "0097_sandboxsession_billed_cpu_usage"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
diff --git a/products/tasks/backend/migrations/0121_squash_2026_09_07_finalize_fks.py b/products/tasks/backend/migrations/0121_squash_2026_09_07_finalize_fks.py
new file mode 100644
index 000000000000..95f369d5b176
--- /dev/null
+++ b/products/tasks/backend/migrations/0121_squash_2026_09_07_finalize_fks.py
@@ -0,0 +1,46 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+import posthog.migration_helpers.squash_idempotent
+
+
+class Migration(migrations.Migration):
+ initial = True
+
+ dependencies = [
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0120_backfill_canvas_search_documents"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="loop",
+ name="sandbox_environment",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="tasks.sandboxenvironment",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddFieldIfMissing(
+ model_name="task",
+ name="signal_report",
+ field=models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="task",
+ to="signals.signalreport",
+ ),
+ ),
+ posthog.migration_helpers.squash_idempotent.AddIndexIfMissing(
+ model_name="task",
+ index=models.Index(fields=["signal_report"], name="posthog_task_signal_report_idx"),
+ ),
+ ]
diff --git a/products/tasks/backend/migrations/max_migration.txt b/products/tasks/backend/migrations/max_migration.txt
index a4e3db9225f9..3a56801bfe11 100644
--- a/products/tasks/backend/migrations/max_migration.txt
+++ b/products/tasks/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0120_backfill_canvas_search_documents
+0121_squash_2026_09_07_finalize_fks
diff --git a/products/tracing/backend/migrations/0001_squash_2026_09_07_initial.py b/products/tracing/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..678514581d6a
--- /dev/null
+++ b/products/tracing/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,58 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [("tracing", "0001_initial")]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="TracingView",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(max_length=400)),
+ ("filters", models.JSONField(default=dict)),
+ ("pinned", 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={
+ "db_table": "tracing_tracingview",
+ "indexes": [models.Index(fields=["team_id", "-created_at"], name="tracing_view_team_created_idx")],
+ "unique_together": {("team", "short_id")},
+ "constraints": [],
+ },
+ ),
+ ]
diff --git a/products/tracing/backend/migrations/0004_squash_2026_09_07_schema_addons.py b/products/tracing/backend/migrations/0004_squash_2026_09_07_schema_addons.py
new file mode 100644
index 000000000000..d21cdd7d6391
--- /dev/null
+++ b/products/tracing/backend/migrations/0004_squash_2026_09_07_schema_addons.py
@@ -0,0 +1,100 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations
+
+import posthog.migration_helpers.not_valid_foreign_key
+
+
+class Migration(migrations.Migration):
+ initial = True
+ atomic = False
+
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ ("actions", "0001_squash_2026_09_07_initial"),
+ ("ai_observability", "0044_squash_2026_09_07_finalize_fks"),
+ ("alerts", "0004_squash_2026_09_07_finalize_fks"),
+ ("analytics_platform", "0001_squash_2026_09_07_initial"),
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("approvals", "0001_squash_2026_09_07_initial"),
+ ("autoresearch", "0001_squash_2026_09_07_initial"),
+ ("batch_exports", "0001_squash_2026_09_07_initial"),
+ ("billing_alerts", "0001_squash_2026_09_07_initial"),
+ ("business_knowledge", "0001_squash_2026_09_07_initial"),
+ ("canvas", "0017_squash_2026_09_07_finalize_fks"),
+ ("cdp", "0001_squash_2026_09_07_initial"),
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("context_layer", "0001_squash_2026_09_07_initial"),
+ ("conversations", "0001_squash_2026_09_07_initial"),
+ ("customer_analytics", "0050_squash_2026_09_07_finalize_fks"),
+ ("dashboards", "0017_squash_2026_09_07_finalize_fks"),
+ ("data_catalog", "0001_squash_2026_09_07_initial"),
+ ("data_modeling", "0034_squash_2026_09_07_finalize_fks"),
+ ("data_quality", "0001_squash_2026_09_07_initial"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("data_warehouse", "0001_squash_2026_09_07_initial"),
+ ("early_access_features", "0001_squash_2026_09_07_initial"),
+ ("ee", "0061_squash_2026_09_07_finalize_fks"),
+ ("endpoints", "0001_squash_2026_09_07_initial"),
+ ("error_tracking", "0001_squash_2026_09_07_initial"),
+ ("event_definitions", "0001_squash_2026_09_07_initial"),
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("exports", "0001_squash_2026_09_07_initial"),
+ ("feature_flags", "0018_squash_2026_09_07_finalize_fks"),
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("growth", "0001_squash_2026_09_07_initial"),
+ ("legal_documents", "0001_squash_2026_09_07_initial"),
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("logs", "0001_squash_2026_09_07_initial"),
+ ("managed_migrations", "0001_squash_2026_09_07_initial"),
+ ("managed_warehouse", "0001_squash_2026_09_07_initial"),
+ ("marketing_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_analytics", "0001_squash_2026_09_07_initial"),
+ ("mcp_registry", "0001_squash_2026_09_07_initial"),
+ ("mcp_store", "0001_squash_2026_09_07_initial"),
+ ("messaging", "0001_squash_2026_09_07_initial"),
+ ("notebooks", "0001_squash_2026_09_07_initial"),
+ ("notifications", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1344_squash_2026_09_07_finalize_fks"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ ("product_analytics", "0001_squash_2026_09_07_initial"),
+ ("product_tours", "0001_squash_2026_09_07_initial"),
+ ("pulse", "0001_squash_2026_09_07_initial"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ("replay", "0001_squash_2026_09_07_initial"),
+ ("replay_vision", "0001_squash_2026_09_07_initial"),
+ ("review_hog", "0001_squash_2026_09_07_initial"),
+ ("signals", "0001_squash_2026_09_07_initial"),
+ ("skills", "0001_squash_2026_09_07_initial"),
+ ("slack_app", "0001_squash_2026_09_07_initial"),
+ ("stamphog", "0001_squash_2026_09_07_initial"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ ("surveys", "0001_squash_2026_09_07_initial"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ ("tracing", "0001_squash_2026_09_07_initial"),
+ ("tracing", "0002_teamtracingconfig"),
+ ("user_interviews", "0001_squash_2026_09_07_initial"),
+ ("visual_review", "0001_squash_2026_09_07_initial"),
+ ("warehouse_sources", "0001_squash_2026_09_07_initial"),
+ ("web_analytics", "0001_squash_2026_09_07_initial"),
+ ("wizard", "0001_squash_2026_09_07_initial"),
+ ("workflows", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="tracingview",
+ name="tracingview_team_id_fk",
+ column="team_id",
+ to_table="posthog_team",
+ to_column="id",
+ ),
+ posthog.migration_helpers.not_valid_foreign_key.AddForeignKeyNotValid(
+ model_name="tracingview",
+ name="tracingview_created_by_id_fk",
+ column="created_by_id",
+ to_table="posthog_user",
+ to_column="id",
+ ),
+ ]
diff --git a/products/tracing/backend/migrations/max_migration.txt b/products/tracing/backend/migrations/max_migration.txt
index 2baeba77da03..575a4a91bf31 100644
--- a/products/tracing/backend/migrations/max_migration.txt
+++ b/products/tracing/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0002_teamtracingconfig
+0004_squash_2026_09_07_schema_addons
diff --git a/products/user_interviews/backend/migrations/0001_squash_2026_09_07_initial.py b/products/user_interviews/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..4cd1745a8d6e
--- /dev/null
+++ b/products/user_interviews/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,182 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+import django.contrib.postgres.indexes
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+import products.user_interviews.backend.models
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("user_interviews", "0001_initial"),
+ ("user_interviews", "0002_userinterviewtopic"),
+ ("user_interviews", "0003_intervieweecontext"),
+ ("user_interviews", "0004_userinterview_vapi_fields"),
+ ("user_interviews", "0005_remove_userinterviewtopic_interviewee_cohort_state"),
+ ("user_interviews", "0006_userinterviewtopic_invite_fields"),
+ ("user_interviews", "0007_userinterview_classifications"),
+ ("user_interviews", "0008_userinterview_user_interview_classif_gin"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="UserInterviewTopic",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "interviewee_emails",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(
+ max_length=254,
+ validators=[products.user_interviews.backend.models.EmailWithDisplayNameValidator()],
+ ),
+ blank=True,
+ default=list,
+ size=None,
+ ),
+ ),
+ (
+ "interviewee_distinct_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=400), blank=True, default=list, size=None
+ ),
+ ),
+ ("topic", models.TextField()),
+ ("agent_context", models.TextField(blank=True, default="")),
+ (
+ "questions",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(), blank=True, default=list, size=None
+ ),
+ ),
+ (
+ "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")),
+ ("invite_subject", models.CharField(blank=True, db_default="", default="", max_length=255)),
+ ("invite_message", models.TextField(blank=True, db_default="", default="")),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="UserInterview",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "interviewee_emails",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(
+ max_length=254,
+ validators=[products.user_interviews.backend.models.EmailWithDisplayNameValidator()],
+ ),
+ default=list,
+ size=None,
+ ),
+ ),
+ ("transcript", models.TextField(blank=True)),
+ ("summary", models.TextField(blank=True)),
+ (
+ "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")),
+ ("call_metadata", models.JSONField(blank=True, default=dict)),
+ ("interviewee_identifier", models.CharField(blank=True, default="", max_length=400)),
+ ("recording_url", models.URLField(blank=True, default="", max_length=2048)),
+ (
+ "topic",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="interviews",
+ to="user_interviews.userinterviewtopic",
+ ),
+ ),
+ (
+ "classifications",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(
+ choices=[("abandoned", "Abandoned"), ("off-topic", "Off-topic")], max_length=20
+ ),
+ blank=True,
+ default=list,
+ size=None,
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ django.contrib.postgres.indexes.GinIndex(
+ fields=["classifications"], name="user_interview_classif_gin"
+ )
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="IntervieweeContext",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("interviewee_identifier", models.CharField(max_length=400)),
+ ("agent_context", models.TextField()),
+ (
+ "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")),
+ (
+ "topic",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="interviewee_contexts",
+ to="user_interviews.userinterviewtopic",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("topic", "interviewee_identifier"), name="unique_interviewee_per_topic"
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/visual_review/backend/migrations/0001_squash_2026_09_07_initial.py b/products/visual_review/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..c612770b9236
--- /dev/null
+++ b/products/visual_review/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,390 @@
+# Generated by Django 5.2.17
+
+import uuid
+
+import django.db.models.manager
+import django.db.models.deletion
+from django.db import migrations, models
+
+import products.visual_review.backend.facade.enums
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("visual_review", "0001_initial"),
+ ("visual_review", "0002_add_team_id_to_child_models"),
+ ("visual_review", "0003_backfill_team_id"),
+ ("visual_review", "0004_add_enable_pr_comments"),
+ ("visual_review", "0005_tolerated_hashes"),
+ ("visual_review", "0006_quarantined_identifiers"),
+ ("visual_review", "0007_tolerated_hash_diff_percentage"),
+ ("visual_review", "0008_add_artifact_thumbnail"),
+ ("visual_review", "0009_add_ssim_score_and_change_kind"),
+ ("visual_review", "0010_backfill_change_kind_and_ssim"),
+ ("visual_review", "0011_alter_artifact_managers_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="Repo",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ ("repo_external_id", models.BigIntegerField()),
+ ("repo_full_name", models.CharField(max_length=255)),
+ ("baseline_file_paths", models.JSONField(blank=True, default=dict)),
+ ("signing_keys", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("enable_pr_comments", models.BooleanField(default=False)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("team_id", "repo_external_id"), name="unique_repo_per_team")
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="Artifact",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("content_hash", models.CharField(db_index=True, max_length=128)),
+ ("storage_path", models.CharField(max_length=1024)),
+ ("width", models.PositiveIntegerField(blank=True, null=True)),
+ ("height", models.PositiveIntegerField(blank=True, null=True)),
+ ("size_bytes", models.PositiveIntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "repo",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="artifacts", to="visual_review.repo"
+ ),
+ ),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "thumbnail",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="visual_review.artifact"
+ ),
+ ),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [
+ models.UniqueConstraint(fields=("repo", "content_hash"), name="unique_artifact_hash_per_repo")
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="Run",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("pending", "pending"),
+ ("processing", "processing"),
+ ("completed", "completed"),
+ ("failed", "failed"),
+ ],
+ default=products.visual_review.backend.facade.enums.RunStatus["PENDING"],
+ max_length=20,
+ ),
+ ),
+ ("run_type", models.CharField(default="other", max_length=64)),
+ ("commit_sha", models.CharField(max_length=40)),
+ ("branch", models.CharField(max_length=255)),
+ ("pr_number", models.PositiveIntegerField(blank=True, null=True)),
+ ("approved", models.BooleanField(default=False)),
+ ("approved_at", models.DateTimeField(blank=True, null=True)),
+ ("approved_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("total_snapshots", models.PositiveIntegerField(default=0)),
+ ("changed_count", models.PositiveIntegerField(default=0)),
+ ("new_count", models.PositiveIntegerField(default=0)),
+ ("removed_count", models.PositiveIntegerField(default=0)),
+ ("error_message", models.TextField(blank=True)),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("completed_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "repo",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="runs", to="visual_review.repo"
+ ),
+ ),
+ (
+ "superseded_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="supersedes",
+ to="visual_review.run",
+ ),
+ ),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "purpose",
+ models.CharField(
+ choices=[("review", "review"), ("observe", "observe")], default="review", max_length=20
+ ),
+ ),
+ (
+ "review_decision",
+ models.CharField(
+ choices=[
+ ("pending", "pending"),
+ ("human_approved", "human_approved"),
+ ("auto_approved", "auto_approved"),
+ ("agent_approved", "agent_approved"),
+ ("rejected", "rejected"),
+ ],
+ default="pending",
+ max_length=20,
+ ),
+ ),
+ ("tolerated_match_count", models.PositiveIntegerField(default=0)),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ "indexes": [
+ models.Index(
+ fields=["repo", "branch", "run_type", "superseded_by"], name="run_branch_type_current"
+ ),
+ models.Index(fields=["repo", "pr_number"], name="run_repo_pr"),
+ models.Index(fields=["commit_sha"], name="run_commit_sha"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("superseded_by__isnull", True)),
+ fields=("repo", "branch", "run_type"),
+ name="unique_latest_run_per_group",
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="QuarantinedIdentifier",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ ("identifier", models.CharField(max_length=512)),
+ ("run_type", models.CharField(max_length=64)),
+ ("reason", models.CharField(max_length=255)),
+ (
+ "source",
+ models.CharField(
+ choices=[("human", "human"), ("agent", "agent"), ("auto", "auto")],
+ default="human",
+ max_length=10,
+ ),
+ ),
+ ("expires_at", models.DateTimeField(blank=True, null=True)),
+ ("created_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "repo",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="quarantined_identifiers",
+ to="visual_review.repo",
+ ),
+ ),
+ ],
+ options={
+ "indexes": [models.Index(fields=["repo", "run_type", "identifier"], name="quarantine_lookup")],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ToleratedHash",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ ("identifier", models.CharField(max_length=512)),
+ ("baseline_hash", models.CharField(max_length=128)),
+ ("alternate_hash", models.CharField(max_length=128)),
+ (
+ "reason",
+ models.CharField(
+ choices=[("auto_threshold", "auto_threshold"), ("human", "human"), ("agent", "agent")],
+ max_length=20,
+ ),
+ ),
+ ("created_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "repo",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tolerated_hashes",
+ to="visual_review.repo",
+ ),
+ ),
+ (
+ "source_run",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="visual_review.run"
+ ),
+ ),
+ ("expires_at", models.DateTimeField(blank=True, null=True)),
+ ("diff_percentage", models.FloatField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [models.Index(fields=["repo", "identifier", "baseline_hash"], name="tolerated_lookup")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("repo", "identifier", "baseline_hash", "alternate_hash"), name="unique_tolerated_hash"
+ )
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="RunSnapshot",
+ fields=[
+ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ("identifier", models.CharField(max_length=512)),
+ ("current_hash", models.CharField(blank=True, max_length=128)),
+ ("baseline_hash", models.CharField(blank=True, max_length=128)),
+ ("current_width", models.PositiveIntegerField(blank=True, null=True)),
+ ("current_height", models.PositiveIntegerField(blank=True, null=True)),
+ (
+ "result",
+ models.CharField(
+ choices=[
+ ("unchanged", "unchanged"),
+ ("changed", "changed"),
+ ("new", "new"),
+ ("removed", "removed"),
+ ],
+ default=products.visual_review.backend.facade.enums.SnapshotResult["UNCHANGED"],
+ max_length=20,
+ ),
+ ),
+ ("diff_percentage", models.FloatField(blank=True, null=True)),
+ ("diff_pixel_count", models.PositiveIntegerField(blank=True, null=True)),
+ (
+ "review_state",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("pending", "pending"),
+ ("approved", "approved"),
+ ("tolerated", "tolerated"),
+ ("rejected", "rejected"),
+ ],
+ default="",
+ max_length=20,
+ ),
+ ),
+ ("reviewed_at", models.DateTimeField(blank=True, null=True)),
+ ("reviewed_by_id", models.BigIntegerField(blank=True, null=True)),
+ ("review_comment", models.TextField(blank=True)),
+ ("approved_hash", models.CharField(blank=True, max_length=128)),
+ ("metadata", models.JSONField(blank=True, default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "baseline_artifact",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="baseline_snapshots",
+ to="visual_review.artifact",
+ ),
+ ),
+ (
+ "current_artifact",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="current_snapshots",
+ to="visual_review.artifact",
+ ),
+ ),
+ (
+ "diff_artifact",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="diff_snapshots",
+ to="visual_review.artifact",
+ ),
+ ),
+ (
+ "run",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="snapshots", to="visual_review.run"
+ ),
+ ),
+ ("team_id", models.BigIntegerField(db_index=True)),
+ (
+ "classification_reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("exact", "exact"),
+ ("tolerated_hash", "tolerated_hash"),
+ ("below_threshold", "below_threshold"),
+ ],
+ default="",
+ max_length=20,
+ ),
+ ),
+ (
+ "tolerated_hash_match",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="matched_snapshots",
+ to="visual_review.toleratedhash",
+ ),
+ ),
+ ("is_quarantined", models.BooleanField(default=False)),
+ ("change_kind", models.CharField(blank=True, default="", max_length=24)),
+ ("ssim_score", models.FloatField(blank=True, null=True)),
+ ("diff_metadata", models.JSONField(blank=True, default=dict)),
+ ],
+ options={
+ "indexes": [
+ models.Index(fields=["run", "result"], name="snapshot_run_result"),
+ models.Index(fields=["run", "review_state"], name="snapshot_run_review_state"),
+ models.Index(fields=["identifier"], name="snapshot_identifier"),
+ models.Index(fields=["current_hash"], name="snapshot_current_hash"),
+ models.Index(fields=["baseline_hash"], name="snapshot_baseline_hash"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("run", "identifier"), name="unique_snapshot_identifier_per_run")
+ ],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/0001_squash_2026_09_07_initial.py b/products/warehouse_sources/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..e28194f4b372
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,958 @@
+# Generated by Django 5.2.17
+
+import datetime
+
+import django.db.models.manager
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+import products.warehouse_sources.backend.facade.types
+import products.warehouse_sources.backend.models.pending_source_credential
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("warehouse_sources", "0001_migrate_warehouse_sources_models"),
+ ("warehouse_sources", "0002_alter_externaldatasource_source_type"),
+ ("warehouse_sources", "0003_alter_externaldatasource_source_type"),
+ ("warehouse_sources", "0004_alter_externaldatasource_source_type"),
+ ("warehouse_sources", "0005_alter_externaldatasource_source_type"),
+ ("warehouse_sources", "0006_pending_source_credential"),
+ ("warehouse_sources", "0007_alter_externaldatasource_source_type"),
+ ("warehouse_sources", "0008_alter_pendingsourcecredential_source_type"),
+ ("warehouse_sources", "0009_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0010_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0011_externaldataschema_last_error_notified_at"),
+ ("warehouse_sources", "0012_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0013_externaldataschema_s3_folder_name"),
+ ("warehouse_sources", "0014_backfill_externaldataschema_s3_folder_name"),
+ ("warehouse_sources", "0015_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0016_externaldataschema_row_filters"),
+ ("warehouse_sources", "0017_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0018_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0019_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0020_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0021_backfill_externaldataschema_s3_folder_name_gap"),
+ ("warehouse_sources", "0022_repair_s3_folder_name_table_names"),
+ ("warehouse_sources", "0023_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0024_alter_externaldataschema_sync_type"),
+ ("warehouse_sources", "0025_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0026_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0027_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0028_externaldatasource_direct_query_enabled"),
+ ("warehouse_sources", "0029_backfill_externaldatasource_direct_query_enabled"),
+ ("warehouse_sources", "0030_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0031_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0032_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0033_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0034_add_warehouse_column_annotation"),
+ ("warehouse_sources", "0035_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0036_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0037_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0038_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0039_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0040_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0041_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0042_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0043_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0044_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0045_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0046_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0047_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0048_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0049_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0050_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0051_warehousecolumnstatistics"),
+ ("warehouse_sources", "0052_backfill_google_ads_incremental_lookback"),
+ ("warehouse_sources", "0053_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0054_custom_oauth2_integration"),
+ ("warehouse_sources", "0055_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0056_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0057_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0058_externaldataschemaoomevent"),
+ ("warehouse_sources", "0059_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0060_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0061_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0062_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0063_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0064_datawarehousetable_column_order"),
+ ("warehouse_sources", "0065_alter_externaldatasource_created_via"),
+ ("warehouse_sources", "0066_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0067_direct_query_enabled_default_false"),
+ ("warehouse_sources", "0068_backfill_direct_query_enabled_false"),
+ ("warehouse_sources", "0069_alter_externaldatasource_created_via"),
+ ("warehouse_sources", "0070_fix_stripe_incremental_fields"),
+ ("warehouse_sources", "0071_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0072_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0073_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0074_externaldatasource_api_version"),
+ ("warehouse_sources", "0075_backfill_externaldatasource_api_version"),
+ ("warehouse_sources", "0076_externaldataschema_api_version"),
+ ("warehouse_sources", "0077_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0078_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0079_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0080_externaldatasource_auto_sync_new_schemas_and_more"),
+ ("warehouse_sources", "0081_repin_klaviyo_api_version"),
+ ("warehouse_sources", "0082_crisp_source"),
+ ("warehouse_sources", "0083_kommo_source"),
+ ("warehouse_sources", "0084_axiom_plivo_source"),
+ ("warehouse_sources", "0085_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0086_sleekplan_source"),
+ ("warehouse_sources", "0087_repin_pipedrive_api_version_v2"),
+ ("warehouse_sources", "0088_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0089_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0090_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0091_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0092_repin_lightspeed_retail_api_version"),
+ ("warehouse_sources", "0093_externaldatajob_latest_run_idx"),
+ ("warehouse_sources", "0094_externaldatajob_updated_at_idx"),
+ ("warehouse_sources", "0095_migrate_resend_job_inputs_to_auth_method"),
+ ("warehouse_sources", "0096_printavo_source"),
+ ("warehouse_sources", "0097_meltwater_source"),
+ ("warehouse_sources", "0098_usercom_source"),
+ ("warehouse_sources", "0099_latitude_source"),
+ ("warehouse_sources", "0100_workato_source"),
+ ("warehouse_sources", "0101_sideshift_source"),
+ ("warehouse_sources", "0102_ducklake_source"),
+ ("warehouse_sources", "0103_starburst_source"),
+ ("warehouse_sources", "0104_easybill_source"),
+ ("warehouse_sources", "0105_repin_harvey_api_version_v2"),
+ ("warehouse_sources", "0106_repin_clockodo_api_version"),
+ ("warehouse_sources", "0107_repin_marketstack_api_version_v2"),
+ ("warehouse_sources", "0108_pin_zendesk_sunshine_v1"),
+ ("warehouse_sources", "0109_repin_ably_api_version_v2"),
+ ("warehouse_sources", "0110_pin_shipstation_null_api_version_to_v1"),
+ ("warehouse_sources", "0111_repin_zonka_feedback_api_version"),
+ ("warehouse_sources", "0112_scaffold_eight_requested_sources"),
+ ("warehouse_sources", "0113_scaffold_three_requested_sources"),
+ ("warehouse_sources", "0114_scaffold_seven_requested_sources"),
+ ("warehouse_sources", "0115_scaffold_four_requested_sources"),
+ ("warehouse_sources", "0116_google_merchant_center_source"),
+ ("warehouse_sources", "0117_scaffold_three_requested_sources"),
+ ("warehouse_sources", "0118_scaffold_sevalla_source"),
+ ("warehouse_sources", "0119_scaffold_motion_source"),
+ ("warehouse_sources", "0120_fix_sentry_events_incremental_field"),
+ ("warehouse_sources", "0121_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0122_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0123_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0124_rename_planetscale_source_type_to_mysql"),
+ ("warehouse_sources", "0125_oom_event_workload_evidence"),
+ ("warehouse_sources", "0126_oom_created_idx"),
+ ("warehouse_sources", "0127_pin_qualys_vmdr_null_api_version_to_2_0"),
+ ("warehouse_sources", "0128_repin_adobe_analytics_api_version_2_0"),
+ ("warehouse_sources", "0129_pin_openweather_v2_5"),
+ ("warehouse_sources", "0130_repin_loop_returns_api_version"),
+ ("warehouse_sources", "0131_pin_leadfeeder_null_api_version_to_v1"),
+ ("warehouse_sources", "0132_repin_google_ads_api_version"),
+ ("warehouse_sources", "0133_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0134_scaffold_two_requested_sources"),
+ ("warehouse_sources", "0135_alter_externaldatasource_source_type_and_more"),
+ ("warehouse_sources", "0136_scaffold_three_requested_sources"),
+ ("warehouse_sources", "0137_scaffold_hootsuite_source"),
+ ("warehouse_sources", "0138_scaffold_wisprflow_source"),
+ ("warehouse_sources", "0139_repin_linkedin_ads_api_version"),
+ ("warehouse_sources", "0140_scaffold_samcart_source"),
+ ("warehouse_sources", "0141_scaffold_ironsource_ads_source"),
+ ("warehouse_sources", "0142_scaffold_microsoft_excel_source"),
+ ("warehouse_sources", "0143_add_schema_history_start"),
+ ("warehouse_sources", "0144_add_profound_source"),
+ ("warehouse_sources", "0145_add_airwallex_source"),
+ ("warehouse_sources", "0146_add_polymarket_source"),
+ ("warehouse_sources", "0147_add_kalshi_source"),
+ ("warehouse_sources", "0148_repin_qualys_vmdr_api_version_4_0"),
+ ("warehouse_sources", "0149_datawarehousetable_created_via"),
+ ("warehouse_sources", "0150_repin_bloomerang_api_version"),
+ ("warehouse_sources", "0151_repin_linkedin_ads_api_version"),
+ ("warehouse_sources", "0152_callable_choices"),
+ ("warehouse_sources", "0153_repin_meta_ads_api_version"),
+ ("warehouse_sources", "0154_repin_mem0_api_version"),
+ ("warehouse_sources", "0155_repin_github_api_version"),
+ ("warehouse_sources", "0156_externaldatajob_pipeline_status_finished_idx"),
+ ("warehouse_sources", "0157_reset_plausible_page_breakdowns"),
+ ("warehouse_sources", "0158_migrate_shopify_job_inputs_to_auth_method"),
+ ("warehouse_sources", "0159_externaldatajob_destination_ids_and_more"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="DataWarehouseCredential",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("access_key", posthog.helpers.encrypted_fields.EncryptedTextField(max_length=500)),
+ ("access_secret", posthog.helpers.encrypted_fields.EncryptedTextField(max_length=500)),
+ (
+ "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={
+ "db_table": "posthog_datawarehousecredential",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataSource",
+ 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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("source_id", models.CharField(max_length=400)),
+ ("connection_id", models.CharField(max_length=400)),
+ ("destination_id", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "sync_frequency",
+ models.CharField(
+ blank=True,
+ choices=[("day", "Daily"), ("week", "Weekly"), ("month", "Monthly")],
+ default="day",
+ max_length=128,
+ ),
+ ),
+ ("status", models.CharField(max_length=400)),
+ (
+ "source_type",
+ models.CharField(
+ choices=products.warehouse_sources.backend.facade.types.external_data_source_type_choices,
+ max_length=128,
+ ),
+ ),
+ ("job_inputs", posthog.helpers.encrypted_fields.EncryptedJSONField(blank=True, null=True)),
+ ("connection_metadata", models.JSONField(blank=True, default=dict, null=True)),
+ ("are_tables_created", models.BooleanField(default=False)),
+ ("prefix", models.CharField(blank=True, max_length=100, null=True)),
+ ("description", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "created_via",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("web", "web"),
+ ("api", "api"),
+ ("mcp", "mcp"),
+ ("wizard", "wizard"),
+ ("self_driving", "self_driving"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ (
+ "access_method",
+ models.CharField(
+ choices=[("warehouse", "warehouse"), ("direct", "direct")], default="warehouse", max_length=32
+ ),
+ ),
+ ("revenue_analytics_enabled", models.BooleanField(blank=True, default=False, null=True)),
+ (
+ "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")),
+ ("direct_query_enabled", models.BooleanField(default=False)),
+ ("api_version", models.CharField(blank=True, max_length=128, null=True)),
+ ("auto_sync_new_schemas", models.BooleanField(default=False)),
+ ("auto_sync_schema_patterns", models.JSONField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_externaldatasource",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="PendingSourceCredential",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "source_type",
+ models.CharField(
+ choices=products.warehouse_sources.backend.facade.types.external_data_source_type_choices,
+ max_length=128,
+ ),
+ ),
+ ("payload", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ (
+ "expires_at",
+ models.DateTimeField(
+ default=products.warehouse_sources.backend.models.pending_source_credential.pending_credential_default_expiry
+ ),
+ ),
+ (
+ "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={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataDestination",
+ fields=[
+ ("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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ (
+ "type",
+ models.CharField(
+ choices=[
+ ("PostHogWarehouse", "PostHog warehouse"),
+ ("Redshift", "Redshift"),
+ ("Snowflake", "Snowflake"),
+ ("BigQuery", "BigQuery"),
+ ("Postgres", "Postgres"),
+ ("Databricks", "Databricks"),
+ ("AzureBlob", "Azure Blob"),
+ ("S3", "S3"),
+ ],
+ max_length=64,
+ ),
+ ),
+ ("name", models.CharField(max_length=400)),
+ (
+ "config",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Non-secret shape config: target database/schema/dataset, bucket and prefix, file format.",
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "integration",
+ models.ForeignKey(
+ blank=True,
+ help_text="Credentials for this destination. Null for the PostHog warehouse.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="posthog.integration",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_externaldatadestination",
+ "indexes": [
+ models.Index(fields=["team", "type"], name="wsd_team_type_idx"),
+ models.Index(fields=["updated_at"], name="wsd_dest_updated_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("deleted", False), ("type", "PostHogWarehouse")),
+ fields=("team",),
+ name="wsd_one_warehouse_dest_per_team",
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="DataWarehouseTable",
+ 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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=128)),
+ (
+ "format",
+ models.CharField(
+ choices=[
+ ("CSV", "CSV"),
+ ("CSVWithNames", "CSVWithNames"),
+ ("Parquet", "Parquet"),
+ ("JSONEachRow", "JSON"),
+ ("Delta", "Delta"),
+ ("DeltaS3Wrapper", "DeltaS3Wrapper"),
+ ],
+ max_length=128,
+ ),
+ ),
+ ("url_pattern", models.CharField(max_length=500)),
+ ("queryable_folder", models.CharField(blank=True, max_length=500, null=True)),
+ (
+ "columns",
+ models.JSONField(
+ blank=True,
+ default=dict,
+ help_text="Dict of all columns with Clickhouse type (including Nullable())",
+ null=True,
+ ),
+ ),
+ ("options", models.JSONField(blank=True, default=dict)),
+ (
+ "row_count",
+ models.IntegerField(help_text="How many rows are currently synced in this table", null=True),
+ ),
+ (
+ "size_in_s3_mib",
+ models.FloatField(help_text="The object size in S3 for this table in MiB", null=True),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "credential",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="warehouse_sources.datawarehousecredential",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "external_data_source",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ (
+ "column_order",
+ models.JSONField(
+ blank=True,
+ default=None,
+ help_text="Ordered column names capturing physical/SELECT order (columns jsonb loses key order). Not user-facing.",
+ null=True,
+ ),
+ ),
+ (
+ "created_via",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("web", "web"),
+ ("api", "api"),
+ ("mcp", "mcp"),
+ ("wizard", "wizard"),
+ ("self_driving", "self_driving"),
+ ("source", "source"),
+ ("materialized_view", "materialized_view"),
+ ("demo", "demo"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_datawarehousetable",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="CustomOAuth2Integration",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("config", models.JSONField(default=dict)),
+ ("sensitive_config", posthog.helpers.encrypted_fields.EncryptedJSONField(default=dict)),
+ ("errors", models.TextField(blank=True, default="")),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "external_data_source",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="custom_oauth2_integrations",
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("external_data_source__isnull", False)),
+ fields=("team", "external_data_source"),
+ name="unique_custom_oauth2_integration_per_source",
+ )
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataSourceDestination",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("enabled", models.BooleanField(db_default=True, default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "destination",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="source_links",
+ to="warehouse_sources.externaldatadestination",
+ ),
+ ),
+ (
+ "source",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="destination_links",
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_externaldatasourcedestination",
+ "indexes": [models.Index(fields=["updated_at"], name="wsd_src_link_updated_idx")],
+ "constraints": [models.UniqueConstraint(fields=("source", "destination"), name="wsd_source_dest_uniq")],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataSchema",
+ 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.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("label", models.CharField(blank=True, max_length=400, null=True)),
+ ("should_sync", models.BooleanField(default=True)),
+ (
+ "latest_error",
+ models.TextField(
+ blank=True, help_text="The latest error that occurred when syncing this schema.", null=True
+ ),
+ ),
+ ("status", models.CharField(blank=True, max_length=400, null=True)),
+ ("last_synced_at", models.DateTimeField(blank=True, null=True)),
+ (
+ "sync_type",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("full_refresh", "full_refresh"),
+ ("incremental", "incremental"),
+ ("append", "append"),
+ ("webhook", "webhook"),
+ ("cdc", "cdc"),
+ ("xmin", "xmin"),
+ ],
+ max_length=128,
+ null=True,
+ ),
+ ),
+ ("sync_type_config", models.JSONField(blank=True, default=dict)),
+ (
+ "sync_frequency",
+ models.CharField(
+ blank=True,
+ choices=[("day", "Daily"), ("week", "Weekly"), ("month", "Monthly")],
+ default="day",
+ max_length=128,
+ null=True,
+ ),
+ ),
+ (
+ "sync_frequency_interval",
+ models.DurationField(blank=True, default=datetime.timedelta(seconds=21600), null=True),
+ ),
+ (
+ "sync_time_of_day",
+ models.TimeField(blank=True, help_text="Time of day to run the sync (UTC)", null=True),
+ ),
+ ("initial_sync_complete", models.BooleanField(default=False)),
+ ("enabled_columns", models.JSONField(blank=True, default=None, null=True)),
+ ("description", models.CharField(blank=True, max_length=1000, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "source",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="schemas",
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ (
+ "last_error_notified_at",
+ models.DateTimeField(
+ blank=True,
+ help_text="When this schema's failure was last included in a failure digest email.",
+ null=True,
+ ),
+ ),
+ ("s3_folder_name", models.CharField(blank=True, max_length=400, null=True)),
+ ("row_filters", models.JSONField(blank=True, default=None, null=True)),
+ ("api_version", models.CharField(blank=True, max_length=128, null=True)),
+ ("history_start", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_externaldataschema",
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="WarehouseColumnAnnotation",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("column_name", models.CharField(blank=True, default="", max_length=400)),
+ ("description", models.TextField()),
+ (
+ "description_source",
+ models.CharField(
+ choices=[
+ ("canonical", "Canonical"),
+ ("ai_generated", "AI generated"),
+ ("user_edited", "User edited"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ("ai_model", models.CharField(blank=True, max_length=128, null=True)),
+ ("is_user_edited", models.BooleanField(default=False)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="column_annotations",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("table", "column_name"), name="unique_table_column_annotation")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="WarehouseColumnStatistics",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("column_name", models.CharField(max_length=400)),
+ ("column_type", models.CharField(blank=True, default="", max_length=400)),
+ ("row_count", models.BigIntegerField(null=True)),
+ ("null_count", models.BigIntegerField(null=True)),
+ ("null_fraction", models.FloatField(null=True)),
+ ("min_value", models.TextField(blank=True, null=True)),
+ ("max_value", models.TextField(blank=True, null=True)),
+ ("has_min_max", models.BooleanField(default=False)),
+ ("computed_at", models.DateTimeField(null=True)),
+ ("computed_for_delta_version", models.BigIntegerField(null=True)),
+ ("stats_basis", models.CharField(default="delta_log", max_length=32)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "table",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="column_statistics",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("table", "column_name"), name="unique_table_column_statistics")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataJob",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("status", models.CharField(max_length=400)),
+ ("rows_synced", models.BigIntegerField(blank=True, null=True)),
+ (
+ "latest_error",
+ models.TextField(help_text="The latest error that occurred during this run.", null=True),
+ ),
+ ("workflow_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("workflow_run_id", models.CharField(blank=True, max_length=400, null=True)),
+ (
+ "pipeline_version",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("v1-dlt-sync", "v1-dlt-sync"),
+ ("v2-non-dlt", "v2-non-dlt"),
+ ("v3-kafka-s3", "v3-kafka-s3"),
+ ],
+ max_length=400,
+ null=True,
+ ),
+ ),
+ ("billable", models.BooleanField(blank=True, default=True, null=True)),
+ ("finished_at", models.DateTimeField(blank=True, null=True)),
+ ("storage_delta_mib", models.FloatField(blank=True, default=0, null=True)),
+ (
+ "schema_snapshot",
+ models.JSONField(
+ blank=True,
+ help_text="Snapshot of the ExternalDataSchema at the time this job was created.",
+ null=True,
+ ),
+ ),
+ (
+ "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")),
+ (
+ "schema",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ to="warehouse_sources.externaldataschema",
+ ),
+ ),
+ (
+ "pipeline",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="jobs",
+ to="warehouse_sources.externaldatasource",
+ ),
+ ),
+ ("destination_ids", models.JSONField(blank=True, db_default=[], default=list)),
+ ],
+ options={
+ "db_table": "posthog_externaldatajob",
+ "indexes": [
+ models.Index(
+ fields=["team", "pipeline", "status", "-created_at"], name="idx_extdatajob_latest_run"
+ ),
+ models.Index(fields=["updated_at"], name="idx_extdatajob_updated_at"),
+ models.Index(fields=["pipeline", "status", "finished_at"], name="idx_extdatajob_pipe_stat_fin"),
+ ],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="ExternalDataSchemaOOMEvent",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("run_id", models.CharField(blank=True, max_length=400, null=True)),
+ ("host", models.CharField(blank=True, max_length=400, null=True)),
+ ("gap_seconds", models.FloatField(blank=True, null=True)),
+ (
+ "schema",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="oom_events",
+ to="warehouse_sources.externaldataschema",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ("self_phase", models.CharField(blank=True, max_length=32, null=True)),
+ ("self_report_age_at_death_seconds", models.FloatField(blank=True, null=True)),
+ ("self_peak_buffer_bytes", models.BigIntegerField(blank=True, null=True)),
+ ("co_tenant_correlated_max_peak_buffer_bytes", models.BigIntegerField(blank=True, null=True)),
+ ("co_tenant_report_count", models.IntegerField(blank=True, null=True)),
+ ],
+ options={
+ "default_manager_name": "all_teams",
+ "indexes": [
+ models.Index(fields=["schema", "created_at"], name="dwh_oom_schema_created_idx"),
+ models.Index(fields=["created_at", "schema", "team"], name="dwh_oom_created_idx"),
+ ],
+ "constraints": [],
+ },
+ managers=[
+ ("all_teams", django.db.models.manager.Manager()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="ExternalDataSchemaDestination",
+ fields=[
+ ("updated_at", models.DateTimeField(auto_now=True, null=True)),
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("enabled", models.BooleanField(db_default=True, default=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "destination",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="schema_links",
+ to="warehouse_sources.externaldatadestination",
+ ),
+ ),
+ (
+ "schema",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="destination_links",
+ to="warehouse_sources.externaldataschema",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_externaldataschemadestination",
+ "indexes": [models.Index(fields=["updated_at"], name="wsd_schema_link_upd_idx")],
+ "constraints": [models.UniqueConstraint(fields=("schema", "destination"), name="wsd_schema_dest_uniq")],
+ },
+ ),
+ ]
diff --git a/products/web_analytics/backend/migrations/0001_squash_2026_09_07_initial.py b/products/web_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..9597ed4bd301
--- /dev/null
+++ b/products/web_analytics/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,266 @@
+# Generated by Django 5.2.17
+
+import django.utils.timezone
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.utils
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("web_analytics", "0001_initial"),
+ ("web_analytics", "0002_add_achievements_models"),
+ ("web_analytics", "0003_webanalyticsinteraction"),
+ ("web_analytics", "0004_rename_achievement_track_keys"),
+ ("web_analytics", "0005_savedheatmap_block_consent_modals"),
+ ("web_analytics", "0006_webanalyticsuserconfig"),
+ ("web_analytics", "0007_savedheatmap_is_prewarm"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="SavedHeatmap",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("url", models.URLField(max_length=2000)),
+ (
+ "data_url",
+ models.URLField(blank=True, help_text="URL for fetching heatmap data", max_length=2000, null=True),
+ ),
+ ("target_widths", models.JSONField(default=list)),
+ (
+ "type",
+ models.CharField(
+ choices=[("screenshot", "Screenshot"), ("iframe", "Iframe"), ("recording", "Recording")],
+ default="screenshot",
+ max_length=20,
+ ),
+ ),
+ (
+ "status",
+ models.CharField(
+ choices=[("processing", "Processing"), ("completed", "Completed"), ("failed", "Failed")],
+ default="processing",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("exception", models.TextField(blank=True, null=True)),
+ ("deleted", models.BooleanField(default=False)),
+ (
+ "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")),
+ ("block_consent_modals", models.BooleanField(default=False)),
+ ("is_prewarm", models.BooleanField(db_default=False, default=False)),
+ ],
+ options={
+ "db_table": "posthog_heatmapsaved",
+ "indexes": [
+ models.Index(fields=["team", "url"], name="posthog_hea_team_id_7540ce_idx"),
+ models.Index(fields=["status"], name="posthog_hea_status_851064_idx"),
+ models.Index(fields=["deleted"], name="posthog_hea_deleted_9942b0_idx"),
+ ],
+ "constraints": [],
+ "unique_together": {("team", "short_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="WebAnalyticsFilterPreset",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("short_id", models.CharField(blank=True, default=posthog.utils.generate_short_id, max_length=12)),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True)),
+ ("pinned", models.BooleanField(default=False)),
+ ("deleted", models.BooleanField(default=False)),
+ ("filters", models.JSONField(default=dict)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("last_modified_at", models.DateTimeField(default=django.utils.timezone.now)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ (
+ "last_modified_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="modified_web_analytics_filter_presets",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "db_table": "posthog_webanalyticsfilterpreset",
+ "indexes": [models.Index(fields=["deleted", "-last_modified_at"], name="wa_preset_del_mod_idx")],
+ "constraints": [],
+ "unique_together": {("team", "short_id")},
+ },
+ ),
+ migrations.CreateModel(
+ name="WebAnalyticsAchievementProgress",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("track_key", models.CharField(max_length=64)),
+ ("current_stage", models.PositiveSmallIntegerField(default=0)),
+ ("progress_value", models.BigIntegerField(default=0)),
+ ("state", models.JSONField(default=dict)),
+ ("last_computed_at", models.DateTimeField(blank=True, null=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "user",
+ models.ForeignKey(
+ blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_webanalyticsachievementprogress",
+ "indexes": [models.Index(fields=["team", "user"], name="wa_ach_team_user_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ condition=models.Q(("user__isnull", False)),
+ fields=("team", "user", "track_key"),
+ name="unique_user_track_progress",
+ ),
+ models.UniqueConstraint(
+ condition=models.Q(("user__isnull", True)),
+ fields=("team", "track_key"),
+ name="unique_team_track_progress",
+ ),
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="WebAnalyticsVisit",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("visit_date", models.DateField()),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("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={
+ "db_table": "posthog_webanalyticsvisit",
+ "indexes": [models.Index(fields=["team", "user", "visit_date"], name="wa_visit_team_user_date_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "visit_date"), name="unique_web_analytics_visit_per_day"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="WebAnalyticsInteraction",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("kind", models.CharField(choices=[("data", "data"), ("recording", "recording")], max_length=32)),
+ ("count", models.BigIntegerField(default=0)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("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={
+ "db_table": "posthog_webanalyticsinteraction",
+ "indexes": [models.Index(fields=["team", "user", "kind"], name="wa_interaction_team_user_idx")],
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("team", "user", "kind"), name="unique_web_analytics_interaction_per_kind"
+ )
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="WebAnalyticsUserConfig",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("achievements_opt_out", models.BooleanField(default=False)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_webanalyticsuserconfig",
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "user"), name="unique_web_analytics_user_config")
+ ],
+ "indexes": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HeatmapSnapshot",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("width", models.IntegerField()),
+ ("content", models.BinaryField(null=True)),
+ ("content_location", models.TextField(blank=True, max_length=1000, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "heatmap",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="snapshots",
+ to="web_analytics.savedheatmap",
+ ),
+ ),
+ ],
+ options={
+ "db_table": "posthog_heatmapsnapshot",
+ "indexes": [models.Index(fields=["heatmap", "width"], name="posthog_hea_heatmap_9543e8_idx")],
+ "constraints": [],
+ "unique_together": {("heatmap", "width")},
+ },
+ ),
+ ]
diff --git a/products/wizard/backend/migrations/0001_squash_2026_09_07_initial.py b/products/wizard/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..b686c9169597
--- /dev/null
+++ b/products/wizard/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,85 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("wizard", "0001_initial_wizard_session"),
+ ("wizard", "0002_wizardsession_team_wf_start_idx"),
+ ("wizard", "0003_wizardsession_pending_input"),
+ ("wizard", "0004_wizardsession_created_by"),
+ ("wizard", "0005_wizardsession_handoff_text"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="WizardSession",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
+ ),
+ ("session_id", models.CharField(max_length=255)),
+ ("workflow_id", models.CharField(max_length=255)),
+ ("skill_id", models.CharField(max_length=255)),
+ ("started_at", models.DateTimeField()),
+ (
+ "run_phase",
+ models.CharField(
+ choices=[
+ ("idle", "idle"),
+ ("running", "running"),
+ ("completed", "completed"),
+ ("error", "error"),
+ ],
+ max_length=50,
+ ),
+ ),
+ ("tasks", models.JSONField(default=list)),
+ ("event_plan", models.JSONField(blank=True, null=True)),
+ ("error", models.JSONField(blank=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "team",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="posthog.team"),
+ ),
+ ("pending_input", models.JSONField(blank=True, null=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("handoff_text", models.TextField(blank=True, null=True)),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [
+ models.Index(
+ fields=["team", "workflow_id", "skill_id", "-started_at"], name="wizard_wiza_team_id_ddd1dc_idx"
+ ),
+ models.Index(fields=["team", "workflow_id", "-started_at"], name="wizard_sess_team_wf_start_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "session_id"), name="unique_wizard_session_per_team")
+ ],
+ },
+ ),
+ ]
diff --git a/products/workflows/backend/migrations/0001_squash_2026_09_07_initial.py b/products/workflows/backend/migrations/0001_squash_2026_09_07_initial.py
new file mode 100644
index 000000000000..a2c8e459eb2e
--- /dev/null
+++ b/products/workflows/backend/migrations/0001_squash_2026_09_07_initial.py
@@ -0,0 +1,335 @@
+# Generated by Django 5.2.17
+
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+import posthog.helpers.encrypted_fields
+
+
+class Migration(migrations.Migration):
+ replaces = [
+ ("workflows", "0001_hogflowbatchjob"),
+ ("workflows", "0002_hogflowbatchjob_scheduled_at"),
+ ("workflows", "0003_hogflowschedule"),
+ ("workflows", "0004_normalize_legacy_schedule_triggers"),
+ ("workflows", "0005_remove_hogflowbatchjob_scheduled_at"),
+ ("workflows", "0006_drop_hogflowbatchjob_scheduled_at_column"),
+ ("workflows", "0007_migrate_hog_flow_models"),
+ ("workflows", "0008_teamworkflowsconfig"),
+ ("workflows", "0009_hogflow_action_redirects"),
+ ("workflows", "0010_email_reputation_snapshot"),
+ ("workflows", "0011_hogflowrevision"),
+ ("workflows", "0012_hogflow_encrypted_inputs"),
+ ("workflows", "0013_teamworkflowsconfig_email_tracking_consent_mode"),
+ ("workflows", "0014_teamworkflowsconfig_email_sending_suspended_at_and_more"),
+ ("workflows", "0015_delete_emailreputationsnapshot"),
+ ("workflows", "0016_drop_emailreputationsnapshot_fk"),
+ ("workflows", "0017_drop_emailreputationsnapshot_table"),
+ ("workflows", "0018_teamworkflowsconfig_ses_tenant_state"),
+ ("workflows", "0019_hogflow_email_sending_rate_limit"),
+ ("workflows", "0020_teamworkflowsconfig_email_sending_tier_and_more"),
+ ("workflows", "0021_backfill_internal_event_triggers"),
+ ]
+
+ initial = True
+
+ dependencies = [
+ ("posthog", "1340_drop_userproductlist_reason_columns"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="HogFlow",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(blank=True, max_length=400, null=True)),
+ ("description", models.TextField(blank=True, default="")),
+ ("version", models.IntegerField(default=1)),
+ (
+ "status",
+ models.CharField(
+ choices=[("draft", "Draft"), ("active", "Active"), ("archived", "Archived")],
+ default="draft",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("trigger", models.JSONField(default=dict)),
+ ("trigger_masking", models.JSONField(blank=True, null=True)),
+ ("conversion", models.JSONField(blank=True, null=True)),
+ (
+ "exit_condition",
+ models.CharField(
+ choices=[
+ ("exit_on_conversion", "Conversion"),
+ ("exit_on_trigger_not_matched", "Trigger Not Matched"),
+ ("exit_on_trigger_not_matched_or_conversion", "Trigger Not Matched Or Conversion"),
+ ("exit_only_at_end", "Only At End"),
+ ],
+ default="exit_on_conversion",
+ max_length=100,
+ ),
+ ),
+ ("edges", models.JSONField(default=dict)),
+ ("actions", models.JSONField(default=dict)),
+ ("abort_action", models.CharField(blank=True, max_length=400, null=True)),
+ ("variables", models.JSONField(blank=True, default=list, null=True)),
+ ("billable_action_types", models.JSONField(blank=True, default=list, null=True)),
+ ("draft", models.JSONField(blank=True, null=True)),
+ ("draft_updated_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
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ("action_redirects", models.JSONField(blank=True, null=True)),
+ (
+ "draft_encrypted_inputs",
+ posthog.helpers.encrypted_fields.EncryptedJSONStringField(blank=True, null=True),
+ ),
+ ("encrypted_inputs", posthog.helpers.encrypted_fields.EncryptedJSONStringField(blank=True, null=True)),
+ ("email_sending_rate_limit", models.JSONField(blank=True, null=True)),
+ ],
+ options={
+ "db_table": "posthog_hogflow",
+ "indexes": [
+ models.Index(fields=["status", "team"], name="posthog_hog_status_53a054_idx"),
+ models.Index(fields=["version", "team"], name="posthog_hog_version_c1677f_idx"),
+ ],
+ "constraints": [
+ models.UniqueConstraint(fields=("team", "version", "id"), name="unique_version_per_flow")
+ ],
+ },
+ ),
+ migrations.CreateModel(
+ name="HogFlowTemplate",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("name", models.CharField(max_length=400)),
+ ("description", models.TextField(blank=True, default="")),
+ ("image_url", models.CharField(blank=True, max_length=8201, null=True)),
+ (
+ "tags",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=255), blank=True, default=list, size=None
+ ),
+ ),
+ (
+ "scope",
+ models.CharField(
+ choices=[("team", "Only team"), ("organization", "Organization"), ("global", "Global")],
+ max_length=24,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ ("trigger", models.JSONField(default=dict)),
+ ("trigger_masking", models.JSONField(blank=True, null=True)),
+ ("conversion", models.JSONField(blank=True, null=True)),
+ (
+ "exit_condition",
+ models.CharField(
+ choices=[
+ ("exit_on_conversion", "Conversion"),
+ ("exit_on_trigger_not_matched", "Trigger Not Matched"),
+ ("exit_on_trigger_not_matched_or_conversion", "Trigger Not Matched Or Conversion"),
+ ("exit_only_at_end", "Only At End"),
+ ],
+ default="exit_on_conversion",
+ max_length=100,
+ ),
+ ),
+ ("edges", models.JSONField(default=dict)),
+ ("actions", models.JSONField(default=dict)),
+ ("abort_action", models.CharField(blank=True, max_length=400, null=True)),
+ ("variables", models.JSONField(blank=True, default=list, null=True)),
+ (
+ "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={
+ "db_table": "hogflow_templates",
+ "indexes": [models.Index(fields=["team"], name="hogflow_tem_team_id_cb8b2b_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="TeamWorkflowsConfig",
+ fields=[
+ (
+ "team",
+ models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ("capture_workflows_engagement_events", models.BooleanField(default=False)),
+ (
+ "email_tracking_consent_mode",
+ models.CharField(
+ choices=[("off", "Off"), ("opt_out", "Opt Out"), ("opt_in", "Opt In")],
+ default="off",
+ max_length=16,
+ ),
+ ),
+ ("email_sending_suspended_at", models.DateTimeField(blank=True, null=True)),
+ ("email_sending_suspension_reason", models.TextField(blank=True, default="")),
+ (
+ "ses_tenant_reputation_impact",
+ models.CharField(blank=True, db_default="", default="", max_length=32),
+ ),
+ ("ses_tenant_sending_status", models.CharField(blank=True, db_default="", default="", max_length=32)),
+ ("ses_tenant_state_synced_at", models.DateTimeField(blank=True, null=True)),
+ ("email_sending_tier", models.IntegerField(db_default=0, default=0)),
+ ("email_sending_tier_pinned", models.BooleanField(db_default=False, default=False)),
+ ("email_sending_tier_updated_at", models.DateTimeField(blank=True, null=True)),
+ ("email_sending_tier_demoted_at", models.DateTimeField(blank=True, null=True)),
+ ],
+ options={
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HogFlowBatchJob",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("hog_flow", models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to="workflows.hogflow")),
+ ("variables", models.JSONField(default=dict)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("waiting", "Waiting"),
+ ("queued", "Queued"),
+ ("active", "Active"),
+ ("completed", "Completed"),
+ ("cancelled", "Cancelled"),
+ ("failed", "Failed"),
+ ],
+ default="queued",
+ max_length=20,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to="posthog.team")),
+ ("filters", models.JSONField(default=dict)),
+ ],
+ options={
+ "indexes": [models.Index(fields=["team"], name="workflows_h_team_id_cacc51_idx")],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HogFlowSchedule",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("rrule", models.TextField()),
+ ("starts_at", models.DateTimeField()),
+ ("timezone", models.CharField(default="UTC", max_length=64)),
+ ("variables", models.JSONField(default=dict)),
+ (
+ "status",
+ models.CharField(
+ choices=[("active", "Active"), ("paused", "Paused"), ("completed", "Completed")],
+ default="active",
+ max_length=20,
+ ),
+ ),
+ ("next_run_at", models.DateTimeField(blank=True, db_index=True, null=True)),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ ("updated_at", models.DateTimeField(auto_now=True)),
+ (
+ "hog_flow",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="schedules", to="workflows.hogflow"
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "abstract": False,
+ "indexes": [],
+ "constraints": [],
+ },
+ ),
+ migrations.CreateModel(
+ name="HogFlowRevision",
+ fields=[
+ (
+ "id",
+ models.UUIDField(default=posthog.uuidt.UUIDT, editable=False, primary_key=True, serialize=False),
+ ),
+ ("version", models.IntegerField(help_text="Workflow version this snapshot was published as.")),
+ (
+ "content",
+ models.JSONField(
+ help_text="Full snapshot of the workflow's content fields (actions, edges, trigger, etc.) at this version."
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ (
+ "hog_flow",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, related_name="revisions", to="workflows.hogflow"
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(fields=("hog_flow", "version"), name="unique_hogflow_revision_version")
+ ],
+ "indexes": [],
+ },
+ ),
+ ]
diff --git a/pyproject.toml b/pyproject.toml
index 14150cc951df..0076294fb4fb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -230,7 +230,9 @@ dev = [
"djangorestframework-stubs~=3.16.0",
"faker==17.5.0",
"fakeredis[lua]==2.23.3",
+ "flameprof~=0.4",
"hypothesis~=6.151.9",
+ "pyinstrument~=5.1",
"pytest-rerunfailures~=16.1",
"freezegun==1.5.5",
"grpcio-tools~=1.71.0",
@@ -492,6 +494,12 @@ ignore_errors = true
module = "posthog.hogql.grammar.*"
ignore_errors = true
+# Profiling code from the nextgensquash tooling — pyinstrument/py-spy
+# wrappers do dynamic method swaps that don't fit the static stubs.
+[[tool.mypy.overrides]]
+module = "posthog.management.migration_profiling.*"
+ignore_errors = true
+
[[tool.mypy.overrides]]
module = "posthog.tasks.*"
disallow_untyped_defs = true
diff --git a/uv.lock b/uv.lock
index b1d2b9aa24fd..279ca058dc20 100644
--- a/uv.lock
+++ b/uv.lock
@@ -2421,6 +2421,12 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b5/36/7fb70f04bf00bc646cd5bb45aa9eddb15e19437a28b8fb2b4a5249fac770/filelock-3.20.3-py3-none-any.whl", hash = "sha256:4b0dda527ee31078689fc205ec4f1c1bf7d56cf88b6dc9426c4f230e46c2dce1", size = 16701, upload-time = "2026-01-09T17:55:04.334Z" },
]
+[[package]]
+name = "flameprof"
+version = "0.4"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/c0/e7/114f6710d31854b694598f577f9eac49d7f38b7fb8a55e86e2d3f848fd1c/flameprof-0.4.tar.gz", hash = "sha256:dbc86d4190cbbba624f1e0a40f44d9db96138e27534d83c8ef42d420857875a3", size = 7865, upload-time = "2018-12-25T09:28:48.554Z" }
+
[[package]]
name = "flatbuffers"
version = "25.12.19"
@@ -5750,6 +5756,7 @@ dev = [
{ name = "djangorestframework-stubs" },
{ name = "faker" },
{ name = "fakeredis", extra = ["lua"] },
+ { name = "flameprof" },
{ name = "freezegun" },
{ name = "grpcio-tools" },
{ name = "hogli" },
@@ -5767,6 +5774,7 @@ dev = [
{ name = "protoletariat" },
{ name = "pyarrow" },
{ name = "pyarrow-stubs" },
+ { name = "pyinstrument" },
{ name = "pytest" },
{ name = "pytest-aiohttp" },
{ name = "pytest-asyncio" },
@@ -6030,6 +6038,7 @@ dev = [
{ name = "djangorestframework-stubs", specifier = "~=3.16.0" },
{ name = "faker", specifier = "==17.5.0" },
{ name = "fakeredis", extras = ["lua"], specifier = "==2.23.3" },
+ { name = "flameprof", specifier = "~=0.4" },
{ name = "freezegun", specifier = "==1.5.5" },
{ name = "grpcio-tools", specifier = "~=1.71.0" },
{ name = "hogli", editable = "tools/hogli" },
@@ -6047,6 +6056,7 @@ dev = [
{ name = "protoletariat", specifier = "~=3.3.10" },
{ name = "pyarrow", specifier = "==23.0.1" },
{ name = "pyarrow-stubs", specifier = "==20.0.0.20260625" },
+ { name = "pyinstrument", specifier = "~=5.1" },
{ name = "pytest", specifier = "~=8.4.2" },
{ name = "pytest-aiohttp", specifier = "~=1.1.0" },
{ name = "pytest-asyncio", specifier = "~=1.3.0" },
@@ -6562,6 +6572,22 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size = 1231151, upload-time = "2026-03-29T13:29:30.038Z" },
]
+[[package]]
+name = "pyinstrument"
+version = "5.1.3"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/a0/05/5b79b16712f9b7c497f2137868908e5d38646a8ef7871d6008801e6e18a3/pyinstrument-5.1.3.tar.gz", hash = "sha256:93dc5576fa90bb267c46d864712329e8e057f51a6b15d0b4f917558d82066ba7", size = 262250, upload-time = "2026-07-29T17:18:39.748Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/0c/37/5b9b4341a62fcb80206c8d179d8dfc6fe5574eed24c9035c44913430542e/pyinstrument-5.1.3-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:4d53b7f120d2643161c1508bcef2789009dca9565360d6e6b06bf598d29b246b", size = 126759, upload-time = "2026-07-29T17:17:50.119Z" },
+ { url = "https://files.pythonhosted.org/packages/54/bf/b0de56cf307f27d4ab459db8c0a05e1b660acf55b23b1ae810c830d9c235/pyinstrument-5.1.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7077446b490c73b6c1fbb4324c409f841914c032667ad395b8658c0bf742727b", size = 119829, upload-time = "2026-07-29T17:17:51.5Z" },
+ { url = "https://files.pythonhosted.org/packages/45/c5/bf2ff35d059a0ab2d61659ca7deb085daea41da39bde2c1b93f628ac8628/pyinstrument-5.1.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:06c26c65a4cd5699c7c3a7f41f372e9785d511ff0113ec39723c7bf0340e989c", size = 145216, upload-time = "2026-07-29T17:17:52.723Z" },
+ { url = "https://files.pythonhosted.org/packages/10/e3/1bc53c5fe87872fbd446191d115b2860366842f5699f6173ff6a1eddfbf6/pyinstrument-5.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d4551c8fee6586f3ef01712d4dffcb9c38ae79d1dbc16fe9416e8ec60c88158c", size = 144041, upload-time = "2026-07-29T17:17:54.008Z" },
+ { url = "https://files.pythonhosted.org/packages/f4/c8/4b17e9e44bf192733e63ba679dcaff936cc5dfb8575ca8f961dcd19609d9/pyinstrument-5.1.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:7021c95837d37dee2c05c4aa6ad7cf73ecc9b4c2bf040ce58897a9fcdaa36d8f", size = 144056, upload-time = "2026-07-29T17:17:55.4Z" },
+ { url = "https://files.pythonhosted.org/packages/01/f5/b05f1b1754aed92674a25083b8409a043755d49720bdc7e6319261b9fb6e/pyinstrument-5.1.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bdef704955e2dbbcf2b3f3dd574847996ff4cf1f2fb3a9c847e7c2e7182b6a19", size = 143702, upload-time = "2026-07-29T17:17:56.688Z" },
+ { url = "https://files.pythonhosted.org/packages/2e/1a/9e969ec59679f786aa9148642231c33324280e91d9ac2803687ea7c3b24b/pyinstrument-5.1.3-cp313-cp313-win32.whl", hash = "sha256:6e2b51ac576fdad9e2988636eee827c285de8c890867d305f9ebf7ce95f98bd0", size = 120749, upload-time = "2026-07-29T17:17:58.167Z" },
+ { url = "https://files.pythonhosted.org/packages/41/58/a2ad5dabb859634b60e17ddf3d3ab4c8ecd8d1ce1595392017c9480949aa/pyinstrument-5.1.3-cp313-cp313-win_amd64.whl", hash = "sha256:b4e48616d28606bf3c4b04d4369582c7802b23b38eacc62d7ea88f0145673387", size = 121493, upload-time = "2026-07-29T17:17:59.468Z" },
+]
+
[[package]]
name = "pyjwt"
version = "2.12.1"