# Generated by Django 4.2.7 on 2023-12-20 12:07

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("wagtail_vector_index", "0001_initial"),
        ("pgvector", "0001_enable_pgvector_extension"),
    ]

    operations = [
        migrations.CreateModel(
            name="PgvectorEmbedding",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("vector", pgvector.django.VectorField()),
                (
                    "embedding_output_dimensions",
                    models.PositiveIntegerField(db_index=True),
                ),
                ("index_name", models.TextField()),
                (
                    "embedding",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="wagtail_vector_index.embedding",
                    ),
                ),
            ],
            options={
                "verbose_name": "pgvector embedding",
                "indexes": [
                    models.Index(
                        fields=["index_name"], name="pgvector_pg_index_n_9af56b_idx"
                    )
                ],
            },
        ),
        migrations.AddConstraint(
            model_name="pgvectorembedding",
            constraint=models.UniqueConstraint(
                fields=("embedding", "index_name", "embedding_output_dimensions"),
                name="unique_pgvector_embedding_per_index_and_dimensions",
            ),
        ),
    ]
