# SPDX-FileCopyrightText: 2017-present Tobias Kunze
# SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms

# Generated by Django 1.11.6 on 2017-10-23 05:27

from django.db import migrations


def populate_code(apps, schema_editor):
    from pretalx.common.models.mixins import GenerateCode

    User = apps.get_model("person", "User")
    for person in User.objects.all():
        person.code = GenerateCode.generate_code()
        person.save()


def empty_code(apps, schema_editor):
    User = apps.get_model("person", "User")
    User.objects.all().update(code=None)


class Migration(migrations.Migration):
    dependencies = [
        ("person", "0007_user_code"),
    ]

    operations = [
        migrations.RunPython(populate_code, empty_code),
    ]
