# Generated by Django 5.2.3 on 2025-09-24 15:26

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
    ]

    operations = [
        migrations.CreateModel(
            name="EmbeddingCache",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("content_hash", models.CharField(db_index=True, max_length=64)),
                ("embedding_transformer_id", models.CharField(max_length=255)),
                ("content", models.TextField()),
                ("embedding_vector", models.JSONField()),
                ("embedding_dimensions", models.IntegerField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "db_table": "django_ai_core_embedding_cache",
                "indexes": [
                    models.Index(
                        fields=["content_hash"], name="django_ai_c_content_23614e_idx"
                    ),
                    models.Index(
                        fields=["embedding_transformer_id"],
                        name="django_ai_c_embeddi_c9904c_idx",
                    ),
                    models.Index(
                        fields=["created_at"], name="django_ai_c_created_7b50d0_idx"
                    ),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("content_hash", "embedding_transformer_id"),
                        name="unique_embedding_cache",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="DocumentEmbedding",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("document_key", models.CharField(db_index=True, max_length=500)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "embedding_cache",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="document_mappings",
                        to="index.embeddingcache",
                    ),
                ),
            ],
            options={
                "db_table": "django_ai_core_chunk_embedding",
                "indexes": [
                    models.Index(
                        fields=["document_key"], name="django_ai_c_documen_5278f2_idx"
                    ),
                    models.Index(
                        fields=["created_at"], name="django_ai_c_created_4465bb_idx"
                    ),
                ],
                "unique_together": {("document_key", "embedding_cache")},
            },
        ),
        migrations.CreateModel(
            name="ModelSourceIndex",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("object_id", models.PositiveIntegerField()),
                ("index_name", models.CharField(max_length=255)),
                ("source_id", models.CharField(max_length=255)),
                ("indexed_at", models.DateTimeField(auto_now=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "indexes": [
                    models.Index(
                        fields=["content_type", "object_id"],
                        name="index_model_content_c06d1a_idx",
                    ),
                    models.Index(
                        fields=["index_name"], name="index_model_index_n_df67dd_idx"
                    ),
                    models.Index(
                        fields=["source_id"], name="index_model_source__3363c4_idx"
                    ),
                ],
                "unique_together": {
                    ("content_type", "object_id", "index_name", "source_id")
                },
            },
        ),
    ]
