# Generated by Django 5.1.4 on 2025-02-09 23:10

import django.db.models.deletion
import tinymce.models
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("bookshelf", "0023_delete_basebookdocument"),
        (
            "metadata",
            "0024_remove_genericdocument_tags_delete_decoderdocument_and_more",
        ),
        ("repository", "0001_initial"),
        ("roster", "0036_delete_rollingstockdocument"),
    ]

    operations = [
        migrations.CreateModel(
            name="InvoiceDocument",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=128)),
                ("creation_time", models.DateTimeField(auto_now_add=True)),
                ("updated_time", models.DateTimeField(auto_now=True)),
                ("private", models.BooleanField(default=True, editable=False)),
                ("date", models.DateField()),
                ("file", models.FileField(upload_to="files/invoices/")),
                ("notes", tinymce.models.HTMLField(blank=True)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.RemoveField(
            model_name="basebookdocument",
            name="book",
        ),
        migrations.AlterModelOptions(
            name="decoderdocument",
            options={},
        ),
        migrations.AlterModelOptions(
            name="genericdocument",
            options={"verbose_name_plural": "Generic documents"},
        ),
        migrations.AlterModelOptions(
            name="rollingstockdocument",
            options={},
        ),
        migrations.AlterField(
            model_name="bookdocument",
            name="file",
            field=models.FileField(upload_to="files/"),
        ),
        migrations.AlterField(
            model_name="catalogdocument",
            name="file",
            field=models.FileField(upload_to="files/"),
        ),
        migrations.AlterField(
            model_name="decoderdocument",
            name="decoder",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="document",
                to="metadata.decoder",
            ),
        ),
        migrations.AlterField(
            model_name="decoderdocument",
            name="file",
            field=models.FileField(upload_to="files/"),
        ),
        migrations.AlterField(
            model_name="genericdocument",
            name="file",
            field=models.FileField(upload_to="files/"),
        ),
        migrations.AlterField(
            model_name="genericdocument",
            name="tags",
            field=models.ManyToManyField(
                blank=True, related_name="document", to="metadata.tag"
            ),
        ),
        migrations.AlterField(
            model_name="rollingstockdocument",
            name="file",
            field=models.FileField(upload_to="files/"),
        ),
        migrations.AlterField(
            model_name="rollingstockdocument",
            name="rolling_stock",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="document",
                to="roster.rollingstock",
            ),
        ),
        migrations.AddConstraint(
            model_name="decoderdocument",
            constraint=models.UniqueConstraint(
                fields=("decoder", "file"), name="unique_decoder_file"
            ),
        ),
        migrations.AddConstraint(
            model_name="rollingstockdocument",
            constraint=models.UniqueConstraint(
                fields=("rolling_stock", "file"), name="unique_stock_file"
            ),
        ),
        migrations.AddField(
            model_name="invoicedocument",
            name="book",
            field=models.ManyToManyField(
                blank=True, related_name="invoice", to="bookshelf.book"
            ),
        ),
        migrations.AddField(
            model_name="invoicedocument",
            name="catalog",
            field=models.ManyToManyField(
                blank=True, related_name="invoice", to="bookshelf.catalog"
            ),
        ),
        migrations.AddField(
            model_name="invoicedocument",
            name="rolling_stock",
            field=models.ManyToManyField(
                blank=True, related_name="invoice", to="roster.rollingstock"
            ),
        ),
        migrations.AddField(
            model_name="invoicedocument",
            name="shop",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="metadata.shop",
            ),
        ),
        migrations.DeleteModel(
            name="BaseBookDocument",
        ),
    ]
