# Generated by Django 4.2.8 on 2023-12-10 18:25

from django.db import migrations, models


def migrate_public_mode(apps, schema_editor):
    User = apps.get_model("users", "User")
    User.objects.filter(mastodon_publish_public=True).update(post_public_mode=0)
    User.objects.filter(mastodon_publish_public=False).update(post_public_mode=1)


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0014_preference_mastodon_skip_relationship_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="preference",
            name="mastodon_repost_mode",
            field=models.PositiveSmallIntegerField(default=0),
        ),
        migrations.AddField(
            model_name="preference",
            name="post_public_mode",
            field=models.PositiveSmallIntegerField(default=0),
        ),
        # migrations.RunPython(migrate_public_mode),
        migrations.RunSQL(
            "UPDATE users_preference SET post_public_mode = 1 where mastodon_publish_public = false;"
        ),
        migrations.AlterField(
            model_name="preference",
            name="show_last_edit",
            field=models.PositiveSmallIntegerField(default=1),
        ),
        migrations.RemoveField(
            model_name="preference",
            name="mastodon_publish_public",
        ),
    ]
