# Generated by Django 6.0 on 2025-12-08 17:47

import django.db.models.deletion
import ram.utils
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("bookshelf", "0025_magazine_magazineissue"),
        (
            "repository",
            "0003_alter_bookdocument_file_alter_catalogdocument_file_and_more",
        ),
    ]

    operations = [
        migrations.CreateModel(
            name="MagazineIssueDocument",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=128)),
                (
                    "file",
                    models.FileField(
                        storage=ram.utils.DeduplicatedStorage, upload_to="files/"
                    ),
                ),
                ("creation_time", models.DateTimeField(auto_now_add=True)),
                ("updated_time", models.DateTimeField(auto_now=True)),
                (
                    "private",
                    models.BooleanField(
                        default=False,
                        help_text="Document will be visible only to logged users",
                    ),
                ),
                (
                    "issue",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="document",
                        to="bookshelf.magazineissue",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Magazines documents",
                "constraints": [
                    models.UniqueConstraint(
                        fields=("issue", "file"), name="unique_issue_file"
                    )
                ],
            },
        ),
    ]
