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.

36 lines
1.0 KiB

  1. from django.db import migrations
  2. def update_label_type(apps, schema_editor):
  3. Label = apps.get_model('api', 'Label')
  4. for label in Label.objects.all():
  5. project_type = label.project.project_type
  6. if project_type.endswith('Classification'):
  7. label.task_type = 'Category'
  8. else:
  9. label.task_type = 'Span'
  10. label.save()
  11. # def move_relation_type_to_label(apps, schema_editor):
  12. # Label = apps.get_model('api', 'Label')
  13. # RelationTypes = apps.get_model('api', 'RelationTypes')
  14. # for relation_type in RelationTypes.objects.all():
  15. # Label.objects.create(
  16. # text=relation_type.name,
  17. # project=relation_type.project,
  18. # background_color=relation_type.color,
  19. # task_type='Relation'
  20. # )
  21. class Migration(migrations.Migration):
  22. dependencies = [
  23. ('api', '0020_label_task_type'),
  24. ]
  25. operations = [
  26. migrations.RunPython(update_label_type),
  27. # migrations.RunPython(move_relation_type_to_label),
  28. ]