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.

4.0 KB
Raw Blame
# Generated by Django 5.2

import django.utils.timezone
import django.db.models.deletion
import django.contrib.postgres.fields
import django.contrib.postgres.indexes
from django.db import migrations, models

import posthog.uuidt


class Migration(migrations.Migration):
    dependencies = [
        ("posthog", "1279_drop_duckgresserverteam_table"),
        ("tasks", "0086_clear_disconnected_channel_repositories"),
    ]

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