# Generated by Django 4.2.1 on 2023-06-15 08:34

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
    ]

    operations = [
        migrations.CreateModel(
            name="ScribeSource",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("slug", models.SlugField(unique=True)),
                (
                    "data_type",
                    models.CharField(choices=[("C", "CSV")], default="C", max_length=1),
                ),
                (
                    "url",
                    models.CharField(
                        help_text="You can use strftime format. ex) https://example.com/%Y/%m/%d/",
                        max_length=100,
                    ),
                ),
                (
                    "target",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ScribeStore",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("slug", models.SlugField(unique=True)),
                ("url", models.URLField()),
                ("file", models.FileField(upload_to="scribe-store/store")),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("D", "Downloaded"),
                            ("L", "Loading"),
                            ("C", "Completed"),
                            ("X", "Deleted"),
                        ],
                        default="D",
                        max_length=1,
                    ),
                ),
                ("downloaded_at", models.DateTimeField(auto_now_add=True)),
                ("completed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "source",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="store_set",
                        to="scribe_store.scribesource",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ScribeRow",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("object_index", models.IntegerField()),
                ("data", models.JSONField()),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("C", "Created"),
                            ("U", "Updated"),
                            ("I", "Ignored"),
                            ("D", "Deleted"),
                            ("X", "Unknown"),
                        ],
                        default="X",
                        max_length=1,
                    ),
                ),
                ("object_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "store",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="row_set",
                        to="scribe_store.scribestore",
                    ),
                ),
            ],
        ),
    ]
