1 # Generated by Django 4.0.8 on 2025-07-22 13:13
3 from django.db import migrations, transaction
7 def gen_uuid(apps, schema_editor):
8 UserListItem = apps.get_model("social", "UserListItem")
9 while UserListItem.objects.filter(uuid__isnull=True).exists():
10 print(UserListItem.objects.filter(uuid__isnull=True).count(), 'rows left')
11 with transaction.atomic():
12 for row in UserListItem.objects.filter(uuid__isnull=True)[:1000]:
13 row.uuid = uuid.uuid4()
14 row.save(update_fields=["uuid"])
17 class Migration(migrations.Migration):
21 ('social', '0022_userlist_reported_timestamp_and_more'),
25 migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),