: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
# Generated by Django 4.2.29 on 2026-03-18 13:42
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
import posthog.models.utils
import products.notifications.backend.facade.enums
class Migration(migrations.Migration):
initial = True
dependencies = [
("posthog", "1053_backfill_experiment_saved_metric_uuids"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="NotificationEvent",
fields=[
(
"id",
models.UUIDField(
default=posthog.models.utils.uuid7,
editable=False,
primary_key=True,
serialize=False,
),
),
(
"notification_type",
models.CharField(
choices=[
("comment_mention", "COMMENT_MENTION"),
("alert_firing", "ALERT_FIRING"),
("approval_requested", "APPROVAL_REQUESTED"),
("approval_resolved", "APPROVAL_RESOLVED"),
("pipeline_failure", "PIPELINE_FAILURE"),
("issue_assigned", "ISSUE_ASSIGNED"),
],
max_length=32,
),
),
(
"priority",
models.CharField(
choices=[("normal", "NORMAL"), ("urgent", "URGENT")],
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",
),
),
],
options={
"ordering": ["-created_at"],
},
),
migrations.CreateModel(
name="NotificationReadState",
fields=[
(
"id",
models.UUIDField(
default=posthog.models.utils.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,
),
),
],
),
migrations.AddConstraint(
model_name="notificationreadstate",
constraint=models.UniqueConstraint(
fields=("notification_event", "user"), name="unique_read_state_per_user"
),
),
migrations.AddIndex(
model_name="notificationevent",
index=models.Index(
fields=["organization", "-created_at"],
name="notificatio_organiz_e0c00e_idx",
),
),
]