# Generated by Django 4.2.18 on 2025-01-26 07:58

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("documents", "0011_alter_document_page_count"),
        ("auth", "0012_alter_user_first_name_max_length"),
        ("annotations", "0025_relationship_analysis"),
    ]

    operations = [
        migrations.CreateModel(
            name="Note",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("backend_lock", models.BooleanField(default=False)),
                ("title", models.CharField(db_index=True, max_length=1024)),
                ("content", models.TextField(blank=True, default="")),
                ("is_public", models.BooleanField(default=False)),
                ("created", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "modified",
                    models.DateTimeField(blank=True, default=django.utils.timezone.now),
                ),
                (
                    "annotation",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="notes",
                        to="annotations.annotation",
                    ),
                ),
                (
                    "creator",
                    models.ForeignKey(
                        default=1,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "document",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notes",
                        to="documents.document",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="annotations.note",
                    ),
                ),
                (
                    "user_lock",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="locked_%(class)s_objects",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("created",),
                "permissions": (
                    ("permission_note", "permission note"),
                    ("publish_note", "publish note"),
                    ("create_note", "create note"),
                    ("read_note", "read note"),
                    ("update_note", "update note"),
                    ("remove_note", "delete note"),
                ),
            },
        ),
        migrations.CreateModel(
            name="NoteUserObjectPermission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "content_object",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="annotations.note",
                    ),
                ),
                (
                    "permission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="auth.permission",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
                "unique_together": {("user", "permission", "content_object")},
            },
        ),
        migrations.CreateModel(
            name="NoteGroupObjectPermission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "content_object",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="annotations.note",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="auth.group"
                    ),
                ),
                (
                    "permission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="auth.permission",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "unique_together": {("group", "permission", "content_object")},
            },
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(fields=["title"], name="annotations_title_04bc21_idx"),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["document"], name="annotations_documen_577369_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["annotation"], name="annotations_annotat_0dda8b_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["creator"], name="annotations_creator_93e9c2_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["created"], name="annotations_created_663e79_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["modified"], name="annotations_modifie_757cf2_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="note",
            index=models.Index(
                fields=["parent"], name="annotations_parent__8ae16c_idx"
            ),
        ),
    ]
