# Generated by Django 2.2.11 on 2021-06-09 08:26

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

def set_division_for_existing_users(apps, schema_editor):
    User = apps.get_model("users", "user")
    users = User.objects.all()
    for user in users:
        user.division = user.district.division
        user.save()

class Migration(migrations.Migration):

    dependencies = [
        ('users', '0040_auto_20210606_1548'),
    ]

    operations = [
        migrations.AddField(
            model_name='user',
            name='division',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='users.Division'),
        ),
        migrations.AlterField(
            model_name='user',
            name='user_type',
            field=models.IntegerField(choices=[(2, 'Transportation'), (3, 'Pharmacist'), (5, 'Volunteer'), (9, 'StaffReadOnly'), (10, 'Staff'), (15, 'Doctor'), (20, 'Reserved'), (21, 'WardAdmin'), (23, 'LocalBodyAdmin'), (25, 'DistrictLabAdmin'), (29, 'DistrictReadOnlyAdmin'), (30, 'DistrictAdmin'), (31, 'DivisionLabAdmin'), (32, 'DivisionReadOnlyAdmin'), (33, 'DivisionAdmin'), (35, 'StateLabAdmin'), (39, 'StateReadOnlyAdmin'), (40, 'StateAdmin')]),
        ),
        migrations.RunPython(set_division_for_existing_users)
    ]
