# Generated by Django 4.1 on 2024-10-24 12:31

import django.db.models.deletion
from django.db import migrations, models
from pgvector.django import VectorExtension
from pgvector.django.indexes import HnswIndex
from pgvector.django.vector import VectorField


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("torque", "0048_rename_search_cache_dirty_wikiconfig_cache_dirty"),
    ]

    operations = [
        VectorExtension(),
        migrations.CreateModel(
            name="SemanticSearchCacheDocument",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("data", models.TextField()),
                (
                    "data_embedding",
                    VectorField(dimensions=768, null=True),
                ),
                (
                    "search_cache_document",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="semantic_documents",
                        to="torque.searchcachedocument",
                    ),
                ),
            ],
        ),
        migrations.AddIndex(
            model_name="semanticsearchcachedocument",
            index=HnswIndex(
                ef_construction=64,
                fields=["data_embedding"],
                m=16,
                name="data_embedding_index",
                opclasses=["vector_cosine_ops"],
            ),
        ),
    ]
