# Generated by Django 5.2.13 on 2026-04-23 08:04

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("repository_analytics", "0001_create_vector_extension"),
    ]

    operations = [
        migrations.CreateModel(
            name="AccessEvent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
                ("user_agent", models.CharField(blank=True, max_length=512)),
                ("country", models.CharField(blank=True, max_length=2)),
                ("referrer", models.CharField(blank=True, max_length=500)),
                ("timestamp", models.DateTimeField(auto_now_add=True, db_index=True)),
            ],
            options={
                "ordering": ["-timestamp"],
            },
        ),
        migrations.CreateModel(
            name="AIDocumentInsight",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "kind",
                    models.CharField(
                        choices=[
                            ("summary", "Summary"),
                            ("classification", "Classification"),
                            ("metadata", "Metadata extraction"),
                        ],
                        db_index=True,
                        max_length=24,
                    ),
                ),
                ("payload", models.JSONField(default=dict)),
                ("confidence", models.FloatField(blank=True, null=True)),
                ("model_used", models.CharField(blank=True, max_length=64)),
                ("generated_at", models.DateTimeField(auto_now_add=True)),
                ("accepted_by_user", models.BooleanField(blank=True, null=True)),
            ],
            options={
                "ordering": ["-generated_at"],
            },
        ),
        migrations.CreateModel(
            name="DocumentEmbedding",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("chunk_index", models.PositiveIntegerField(default=0)),
                ("chunk_text", models.TextField(blank=True)),
                ("embedding", pgvector.django.vector.VectorField(dimensions=1536)),
                ("metadata", models.JSONField(blank=True, default=dict)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "ordering": ["document", "chunk_index"],
            },
        ),
        migrations.CreateModel(
            name="DownloadEvent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
                ("country", models.CharField(blank=True, max_length=2)),
                ("timestamp", models.DateTimeField(auto_now_add=True, db_index=True)),
            ],
            options={
                "ordering": ["-timestamp"],
            },
        ),
        migrations.CreateModel(
            name="ResearchTrend",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("period_start", models.DateField()),
                ("period_end", models.DateField()),
                (
                    "kind",
                    models.CharField(
                        choices=[
                            ("cluster", "Cluster"),
                            ("growth_area", "Growth area"),
                            ("gap", "Gap"),
                        ],
                        db_index=True,
                        max_length=16,
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True)),
                ("score", models.FloatField(default=0.0)),
                ("generated_at", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "ordering": ["-generated_at", "-score"],
            },
        ),
        migrations.CreateModel(
            name="SearchEvent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("query", models.TextField(blank=True)),
                ("filters", models.JSONField(blank=True, default=dict)),
                ("result_count", models.PositiveIntegerField(default=0)),
                ("timestamp", models.DateTimeField(auto_now_add=True, db_index=True)),
            ],
            options={
                "ordering": ["-timestamp"],
            },
        ),
        migrations.CreateModel(
            name="UsageRollup",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("period_start", models.DateField()),
                ("period_end", models.DateField()),
                (
                    "dimension",
                    models.CharField(
                        choices=[
                            ("collection", "Collection"),
                            ("document_type", "Document type"),
                            ("country", "Country"),
                            ("author", "Author"),
                            ("overall", "Overall"),
                        ],
                        max_length=24,
                    ),
                ),
                ("key", models.CharField(blank=True, max_length=160)),
                ("metrics", models.JSONField(blank=True, default=dict)),
                ("computed_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "ordering": ["-period_end", "dimension"],
            },
        ),
    ]
