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.

5.3 KB
Raw Blame
# Generated by Django 5.2.14 on 2026-06-15 14:58

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

import posthog.models.utils


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("posthog", "1219_filesystemfoldercontextgeneration"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    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.models.utils.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",
                    )
                ],
            },
        ),
    ]