# Generated by Django 6.0.2 on 2026-04-17 07:04

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


class Migration(migrations.Migration):

    dependencies = [
        ("orgapy", "0007_delete_pushsubscription"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Document",
            fields=[
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                (
                    "type",
                    models.CharField(
                        choices=[("note", "Note"), ("sheet", "Sheet"), ("map", "Map")],
                        default="note",
                        max_length=5,
                    ),
                ),
                (
                    "nonce",
                    models.TextField(
                        blank=True,
                        default=orgapy.utils.generate_nonce,
                        max_length=12,
                        unique=True,
                    ),
                ),
                (
                    "date_creation",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "date_modification",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "date_access",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("date_deletion", models.DateTimeField(blank=True, null=True)),
                ("public", models.BooleanField(default=False)),
                ("pinned", models.BooleanField(default=False)),
                ("hidden", models.BooleanField(default=False)),
                ("deleted", models.BooleanField(default=False)),
                ("title", models.CharField(blank=True, max_length=255, null=True)),
                ("subtitle", models.TextField(blank=True, null=True)),
                ("content", models.TextField(blank=True, null=True)),
                ("config", models.TextField(blank=True, null=True)),
                ("source_type", models.CharField(max_length=5)),
                ("source_id", models.BigIntegerField()),
                (
                    "categories",
                    models.ManyToManyField(
                        blank=True, related_name="documents", to="orgapy.category"
                    ),
                ),
                (
                    "references",
                    models.ManyToManyField(
                        blank=True, related_name="referenced_in", to="orgapy.document"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-date_modification"],
            },
        ),
        migrations.AddField(
            model_name="project",
            name="document",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="orgapy.document",
            ),
        ),
    ]
