# Generated by Django 4.2.4 on 2023-08-23 06:39

from django.db import migrations, models

from promptgame.gameui import restrictions


def compute_default_for_existing_rows(apps, schema_editor):
    Account = apps.get_model("gameui", "Account")

    for account in Account.objects.iterator(chunk_size=128):
        account.restriction_id = restrictions.get_random_restriction_id()
        account.save()


class Migration(migrations.Migration):
    dependencies = [
        ("gameui", "0036_account_restriction_id"),
    ]

    operations = [
        # technically this is not safe reversal, but we don't care about
        # preserving the value of this field, so whatever
        migrations.RunPython(
            compute_default_for_existing_rows, reverse_code=lambda *args: None
        ),
        migrations.AlterField(
            model_name="account",
            name="restriction_id",
            field=models.CharField(
                choices=[
                    ("token_limit_50", "token_limit_50"),
                    ("common_1k_words", "common_1k_words"),
                    ("not_common_1k_words", "not_common_1k_words"),
                    ("no_vowels", "no_vowels"),
                    ("alphanumeric_no_vowels", "alphanumeric_no_vowels"),
                    ("valid_words_starts_with_s", "valid_words_starts_with_s"),
                    ("valid_words_starts_with_p", "valid_words_starts_with_p"),
                    ("valid_words_starts_with_c", "valid_words_starts_with_c"),
                    ("valid_words_starts_with_a", "valid_words_starts_with_a"),
                    ("valid_unique_words", "valid_unique_words"),
                    ("no_whitespace_any_characters", "no_whitespace_any_characters"),
                    ("no_whitespace_alphanum_punc", "no_whitespace_alphanum_punc"),
                    ("valid_no_related_words", "valid_no_related_words"),
                    ("valid_words_leq_length_5", "valid_words_leq_length_5"),
                    ("valid_words_geq_length_6", "valid_words_geq_length_6"),
                ],
                max_length=64,
            ),
        ),
    ]
