Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

3.2 KB
Raw Blame
# Generated by Django 5.2.17 on 2026-09-30 14:45

import django.db.models.manager
from django.db import migrations, models

import posthog.uuidt


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="DailyBriefing",
            fields=[
                ("team_id", models.BigIntegerField(db_index=True)),
                (
                    "id",
                    models.UUIDField(default=posthog.uuidt.uuid7, editable=False, primary_key=True, serialize=False),
                ),
                ("user_id", models.BigIntegerField()),
                ("local_day", models.DateField()),
                ("timezone", models.CharField(max_length=64)),
                (
                    "trigger",
                    models.CharField(
                        choices=[("scheduled", "scheduled"), ("first_open", "first_open"), ("refresh", "refresh")],
                        max_length=16,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("collecting", "collecting"),
                            ("writing", "writing"),
                            ("ready", "ready"),
                            ("failed", "failed"),
                        ],
                        default="collecting",
                        max_length=16,
                    ),
                ),
                ("facts", models.JSONField(default=dict)),
                ("content", models.JSONField(default=dict)),
                (
                    "writer",
                    models.CharField(choices=[("agent", "agent")], max_length=16, null=True),
                ),
                ("error", models.TextField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("ready_at", models.DateTimeField(blank=True, null=True)),
                ("last_viewed_at", models.DateTimeField(blank=True, null=True)),
            ],
            options={
                "abstract": False,
                "default_manager_name": "all_teams",
                "indexes": [
                    models.Index(
                        fields=["team_id", "user_id", "local_day", "-created_at"],
                        name="today_briefing_day_idx",
                    ),
                    models.Index(fields=["last_viewed_at"], name="today_briefing_viewed_idx"),
                    models.Index(
                        condition=models.Q(("status__in", ["collecting", "writing"])),
                        fields=["created_at"],
                        name="today_briefing_pending_idx",
                    ),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        condition=models.Q(("status__in", ["collecting", "writing"])),
                        fields=("team_id", "user_id", "local_day"),
                        name="today_briefing_one_pending",
                    )
                ],
            },
            managers=[
                ("all_teams", django.db.models.manager.Manager()),
            ],
        ),
    ]