# Generated by Django 4.2.4 on 2023-09-04 07:00

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import fediverser.apps.core.models
import model_utils.fields


class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="LemmyCommunity",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("name", models.CharField(max_length=255)),
            ],
            options={
                "verbose_name_plural": "Lemmy Communities",
            },
        ),
        migrations.CreateModel(
            name="LemmyInstance",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("domain", models.CharField(max_length=255, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="RedditAccount",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("username", models.CharField(max_length=60, unique=True)),
                (
                    "password",
                    models.CharField(
                        default=fediverser.apps.core.models.make_password,
                        help_text="Password for Lemmy mirror instance",
                        max_length=64,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="RedditCommunity",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("name", models.CharField(max_length=255, unique=True)),
            ],
            options={
                "verbose_name_plural": "Subreddits",
            },
        ),
        migrations.CreateModel(
            name="RedditSubmission",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="created"
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="modified"
                    ),
                ),
                ("id", models.CharField(max_length=16, primary_key=True, serialize=False)),
                ("url", models.URLField(db_index=True)),
                ("title", models.TextField()),
                ("selftext", models.TextField(blank=True, null=True)),
                ("selftext_html", models.TextField(blank=True, null=True)),
                ("media_only", models.BooleanField(default=False)),
                ("approved_at", models.DateTimeField(null=True)),
                ("banned_at", models.DateTimeField(null=True)),
                ("archived", models.BooleanField(default=False)),
                ("locked", models.BooleanField(default=False)),
                ("quarantined", models.BooleanField(default=False)),
                ("removed", models.BooleanField(default=False)),
                ("over_18", models.BooleanField(default=False)),
                (
                    "author",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="posts",
                        to="core.redditaccount",
                    ),
                ),
                (
                    "subreddit",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="posts",
                        to="core.redditcommunity",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="RedditComment",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="created"
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="modified"
                    ),
                ),
                ("id", models.CharField(max_length=16, primary_key=True, serialize=False)),
                ("permalink", models.URLField(db_index=True)),
                ("body", models.TextField(blank=True)),
                ("body_html", models.TextField(blank=True)),
                ("stickied", models.BooleanField(default=False)),
                ("edited", models.BooleanField(default=False)),
                ("distinguished", models.BooleanField(default=False)),
                (
                    "author",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="comments",
                        to="core.redditaccount",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="children",
                        to="core.redditcomment",
                    ),
                ),
                (
                    "submission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="comments",
                        to="core.redditsubmission",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="LemmyMirroredPost",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="created"
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="modified"
                    ),
                ),
                ("lemmy_post_id", models.PositiveIntegerField(db_index=True)),
                (
                    "lemmy_community",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="reddit_crossposts",
                        to="core.lemmycommunity",
                    ),
                ),
                (
                    "reddit_submission",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="lemmy_mirrored_posts",
                        to="core.redditsubmission",
                    ),
                ),
            ],
            options={
                "unique_together": {("reddit_submission", "lemmy_post_id")},
            },
        ),
        migrations.AddField(
            model_name="lemmycommunity",
            name="instance",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="communities",
                to="core.lemmyinstance",
            ),
        ),
        migrations.CreateModel(
            name="RedditToLemmyCommunity",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "lemmy_community",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="core.lemmycommunity"
                    ),
                ),
                (
                    "subreddit",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="core.redditcommunity"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Reddit to Lemmy Community Map",
                "unique_together": {("subreddit", "lemmy_community")},
            },
        ),
        migrations.CreateModel(
            name="LemmyMirroredComment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="created"
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now, editable=False, verbose_name="modified"
                    ),
                ),
                ("lemmy_comment_id", models.PositiveIntegerField(db_index=True)),
                (
                    "lemmy_mirrored_post",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="comments",
                        to="core.lemmymirroredpost",
                    ),
                ),
                (
                    "reddit_comment",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="lemmy_mirrored_comments",
                        to="core.redditcomment",
                    ),
                ),
            ],
            options={
                "unique_together": {("lemmy_mirrored_post", "lemmy_comment_id")},
            },
        ),
        migrations.AlterUniqueTogether(
            name="lemmycommunity",
            unique_together={("instance", "name")},
        ),
    ]
