# Generated by Django 3.2.16 on 2022-12-05 07:00

from django.db import migrations, models
import uuid
import django_migration_linter as linter


def fill_org_uuid(apps, schema_editor):
    Organization = apps.get_model('user_management', 'Organization')
    orgs_to_update = []
    for org in Organization.objects.all():
        org.uuid = uuid.uuid4()
        orgs_to_update.append(org)
    Organization.objects.bulk_update(orgs_to_update, ["uuid"], batch_size=5000)


class Migration(migrations.Migration):

    dependencies = [
        ('user_management', '0005_rbac_permissions'),
    ]

    operations = [
        linter.IgnoreMigration(),
        migrations.AddField(
            model_name='organization',
            name='uuid',
            field=models.UUIDField(null=True),
        ),
        migrations.RunPython(fill_org_uuid, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='organization',
            name='uuid',
            field=models.UUIDField(default=uuid.uuid4, editable=False),
        ),
    ]
