# Generated by Django 4.2.20 on 2025-06-10 05:57

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import opencontractserver.corpuses.models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("corpuses", "0017_alter_corpus_preferred_embedder"),
    ]

    operations = [
        migrations.AddField(
            model_name="corpus",
            name="md_description",
            field=models.FileField(
                blank=True,
                help_text="Markdown description file for this corpus.",
                null=True,
                upload_to=opencontractserver.corpuses.models.calculate_description_filepath,
            ),
        ),
        migrations.CreateModel(
            name="CorpusDescriptionRevision",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("version", models.PositiveIntegerField()),
                ("diff", models.TextField(blank=True)),
                ("snapshot", models.TextField(blank=True, null=True)),
                ("checksum_base", models.CharField(blank=True, max_length=64)),
                ("checksum_full", models.CharField(blank=True, max_length=64)),
                (
                    "created",
                    models.DateTimeField(
                        db_index=True, default=django.utils.timezone.now
                    ),
                ),
                (
                    "author",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="corpus_revisions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "corpus",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="revisions",
                        to="corpuses.corpus",
                    ),
                ),
            ],
            options={
                "ordering": ("corpus_id", "version"),
                "indexes": [
                    models.Index(
                        fields=["corpus"], name="corpuses_co_corpus__dc1049_idx"
                    ),
                    models.Index(
                        fields=["author"], name="corpuses_co_author__fe4c23_idx"
                    ),
                    models.Index(
                        fields=["created"], name="corpuses_co_created_881ee0_idx"
                    ),
                ],
                "unique_together": {("corpus", "version")},
            },
        ),
    ]
