0014_initial.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Generated by Django 5.0.7 on 2024-07-12 14:55
  2. import django.contrib.postgres.search
  3. import django.db.models.deletion
  4. import psqlextra.backend.migrations.operations.add_default_partition
  5. import psqlextra.backend.migrations.operations.create_partitioned_model
  6. import psqlextra.manager.manager
  7. import psqlextra.models.partitioned
  8. import psqlextra.types
  9. import uuid
  10. from django.db import migrations, models
  11. from glitchtip.model_utils import TestDefaultPartition
  12. class Migration(migrations.Migration):
  13. initial = True
  14. dependencies = [
  15. ("performance", "0013_alter_transactionevent_options_and_more"),
  16. ("projects", "0015_rename_label_projectkey_name_projectkey_is_active"),
  17. ]
  18. operations = [
  19. psqlextra.backend.migrations.operations.create_partitioned_model.PostgresCreatePartitionedModel(
  20. name="TransactionEvent",
  21. fields=[
  22. (
  23. "event_id",
  24. models.UUIDField(
  25. default=uuid.uuid4,
  26. editable=False,
  27. primary_key=True,
  28. serialize=False,
  29. ),
  30. ),
  31. ("trace_id", models.UUIDField(db_index=True)),
  32. (
  33. "start_timestamp",
  34. models.DateTimeField(
  35. db_index=True,
  36. help_text="Datetime reported by client as the time the measurement started",
  37. ),
  38. ),
  39. (
  40. "timestamp",
  41. models.DateTimeField(
  42. blank=True,
  43. help_text="Datetime reported by client as the time the measurement finished",
  44. null=True,
  45. ),
  46. ),
  47. (
  48. "duration",
  49. models.PositiveIntegerField(
  50. db_index=True, help_text="Milliseconds"
  51. ),
  52. ),
  53. (
  54. "data",
  55. models.JSONField(help_text="General event data that is searchable"),
  56. ),
  57. ("tags", models.JSONField(default=dict)),
  58. ],
  59. options={
  60. "ordering": ["-start_timestamp"],
  61. },
  62. partitioning_options={
  63. "method": psqlextra.types.PostgresPartitioningMethod["RANGE"],
  64. "key": ["start_timestamp"],
  65. },
  66. bases=(psqlextra.models.partitioned.PostgresPartitionedModel,),
  67. managers=[
  68. ("objects", psqlextra.manager.manager.PostgresManager()),
  69. ],
  70. ),
  71. TestDefaultPartition(
  72. model_name="TransactionEvent",
  73. name="default",
  74. ),
  75. migrations.CreateModel(
  76. name="TransactionGroup",
  77. fields=[
  78. (
  79. "id",
  80. models.BigAutoField(
  81. auto_created=True,
  82. primary_key=True,
  83. serialize=False,
  84. verbose_name="ID",
  85. ),
  86. ),
  87. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  88. ("transaction", models.CharField(max_length=1024)),
  89. ("op", models.CharField(max_length=255)),
  90. ("method", models.CharField(blank=True, max_length=255, null=True)),
  91. ("tags", models.JSONField(default=dict)),
  92. (
  93. "search_vector",
  94. django.contrib.postgres.search.SearchVectorField(
  95. editable=False, null=True
  96. ),
  97. ),
  98. (
  99. "project",
  100. models.ForeignKey(
  101. on_delete=django.db.models.deletion.CASCADE,
  102. to="projects.project",
  103. ),
  104. ),
  105. ],
  106. options={
  107. "unique_together": {("transaction", "project", "op", "method")},
  108. },
  109. ),
  110. migrations.AddField(
  111. model_name="transactionevent",
  112. name="group",
  113. field=models.ForeignKey(
  114. on_delete=django.db.models.deletion.CASCADE,
  115. to="performance.transactiongroup",
  116. ),
  117. ),
  118. ]