# Generated by Django 3.2.16 on 2022-12-27 21:34

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


def backfill_sitesettings(apps, schema_editor):
    db_alias = schema_editor.connection.alias
    group_model = apps.get_model("auth", "Group")
    editor_group = group_model.objects.using(db_alias).filter(name="editor").first()

    sitesettings_model = apps.get_model("bookwyrm", "SiteSettings")
    sitesettings_model.objects.update(default_user_auth_group=editor_group)


class Migration(migrations.Migration):

    dependencies = [
        ("bookwyrm", "0175_merge_0173_author_website_0174_merge_20230111_1523"),
    ]

    operations = [
        migrations.AddField(
            model_name="sitesettings",
            name="default_user_auth_group",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.RESTRICT,
                to="auth.group",
            ),
        ),
        migrations.RunPython(backfill_sitesettings, migrations.RunPython.noop),
    ]
