Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

6.1 KB
Raw Blame
# Generated by Django 4.2.30 on 2026-08-28 12:16

import uuid

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("account_v2", "0007_organization_restrict_connector_creation"),
    ]

    operations = [
        migrations.CreateModel(
            name="AgentKVKey",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("modified_at", models.DateTimeField(auto_now=True)),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("name", models.CharField(max_length=128)),
                ("description", models.CharField(blank=True, default="", max_length=512)),
                ("key", models.UUIDField(default=uuid.uuid4, unique=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="agent_kv_keys_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "modified_by",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        blank=True,
                        db_comment="Foreign key reference to the Organization model.",
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="account_v2.organization",
                    ),
                ),
            ],
            options={
                "db_table": "agent_kv_key",
            },
        ),
        migrations.CreateModel(
            name="AgentKVJob",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("modified_at", models.DateTimeField(auto_now=True)),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("task_id", models.UUIDField(blank=True, null=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("DISPATCHED", "Dispatched"),
                            ("RUNNING", "Running"),
                            ("COMPLETED", "Completed"),
                            ("FAILED", "Failed"),
                            ("CANCELLED", "Cancelled"),
                        ],
                        default="PENDING",
                        max_length=16,
                    ),
                ),
                ("stage", models.CharField(blank=True, default="", max_length=32)),
                ("stages", models.JSONField(blank=True, default=dict)),
                ("pages_total", models.IntegerField(blank=True, null=True)),
                ("input_ref", models.CharField(blank=True, default="", max_length=512)),
                ("result_ref", models.CharField(blank=True, default="", max_length=512)),
                ("usage_summary", models.JSONField(blank=True, null=True)),
                ("error", models.TextField(blank=True, default="")),
                ("dispatched_at", models.DateTimeField(blank=True, null=True)),
                ("completed_at", models.DateTimeField(blank=True, null=True)),
                ("expires_at", models.DateTimeField(blank=True, null=True)),
                ("tags", models.JSONField(blank=True, default=list)),
                ("custom_data", models.JSONField(blank=True, null=True)),
                ("webhook_url", models.URLField(blank=True, default="", max_length=1024)),
                (
                    "api_key",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="jobs",
                        to="agent_kv.agentkvkey",
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        blank=True,
                        db_comment="Foreign key reference to the Organization model.",
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="account_v2.organization",
                    ),
                ),
            ],
            options={
                "db_table": "agent_kv_job",
            },
        ),
        migrations.AddConstraint(
            model_name="agentkvkey",
            constraint=models.UniqueConstraint(
                fields=("name", "organization"), name="unique_agent_kv_key_name_per_org"
            ),
        ),
        migrations.AddIndex(
            model_name="agentkvjob",
            index=models.Index(
                fields=["organization", "status"], name="agent_kv_jo_organiz_9b6b97_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="agentkvjob",
            index=models.Index(
                fields=["expires_at"], name="agent_kv_jo_expires_5966b4_idx"
            ),
        ),
    ]