0008_transactionevent_duration.py 903 B

123456789101112131415161718192021222324252627282930313233
  1. # Generated by Django 4.0.4 on 2022-04-27 19:02
  2. import datetime
  3. from django.db import migrations, models
  4. from django.db.models import F
  5. def forwards_func(apps, schema_editor):
  6. TransactionEvent = apps.get_model("performance", "TransactionEvent")
  7. TransactionEvent.objects.update(duration=F("timestamp") - F("start_timestamp"))
  8. def reverse_func(apps, schema_editor):
  9. pass
  10. class Migration(migrations.Migration):
  11. dependencies = [
  12. (
  13. "performance",
  14. "0007_transactionevent_tags_transactiongroup_search_vector_and_more",
  15. ),
  16. ]
  17. operations = [
  18. migrations.AddField(
  19. model_name="transactionevent",
  20. name="duration",
  21. field=models.DurationField(db_index=True, default=datetime.timedelta(0)),
  22. preserve_default=False,
  23. ),
  24. migrations.RunPython(forwards_func, reverse_func),
  25. ]