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.

2.8 KB
Raw Blame
# Generated by Django 5.2.17 on 2026-08-13 20:39

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):
    dependencies = [
        ("canvas", "0010_canvassourceversion_draft"),
        ("posthog", "1300_identityproviderconfig_saml_relay_state_unique"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        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",
                    ),
                ],
            },
        ),
    ]