You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
729 B

  1. # Generated by Django 4.0.2 on 2022-05-12 02:28
  2. from django.db import migrations
  3. import uuid
  4. def gen_uuid(apps, schema_editor):
  5. Category = apps.get_model("labels", "Category")
  6. Span = apps.get_model("labels", "Span")
  7. Relation = apps.get_model("labels", "Relation")
  8. TextLabel = apps.get_model("labels", "TextLabel")
  9. for label in [Category, Span, Relation, TextLabel]:
  10. for row in label.objects.all():
  11. row.uuid = uuid.uuid4()
  12. row.save(update_fields=["uuid"])
  13. class Migration(migrations.Migration):
  14. dependencies = [
  15. ("labels", "0012_add_uuid_field"),
  16. ]
  17. operations = [
  18. migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),
  19. ]