from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
import djiki.models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Image",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                (
                    "name",
                    models.CharField(unique=True, max_length=128, verbose_name="Name"),
                ),
            ],
            options={
                "ordering": ("name",),
            },
            bases=(models.Model, djiki.models.Versioned),
        ),
        migrations.CreateModel(
            name="ImageRevision",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "description",
                    models.CharField(
                        max_length=400, verbose_name="Description", blank=True
                    ),
                ),
                ("file", models.FileField(upload_to=b"djimages/", verbose_name="File")),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        verbose_name="Author",
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True,
                    ),
                ),
                (
                    "image",
                    models.ForeignKey(
                        related_name="revisions",
                        to="djiki.Image",
                        on_delete=django.db.models.deletion.CASCADE,
                    ),
                ),
            ],
            options={
                "ordering": ("-created",),
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Page",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                (
                    "title",
                    models.CharField(unique=True, max_length=255, verbose_name="Title"),
                ),
            ],
            options={
                "ordering": ("title",),
            },
            bases=(models.Model, djiki.models.Versioned),
        ),
        migrations.CreateModel(
            name="PageRevision",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "description",
                    models.CharField(
                        max_length=400, verbose_name="Description", blank=True
                    ),
                ),
                ("content", models.TextField(verbose_name="Content", blank=True)),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        verbose_name="Author",
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True,
                    ),
                ),
                (
                    "page",
                    models.ForeignKey(
                        related_name="revisions",
                        to="djiki.Page",
                        on_delete=django.db.models.deletion.CASCADE,
                    ),
                ),
            ],
            options={
                "ordering": ("-created",),
                "abstract": False,
            },
        ),
    ]
