0010_auto_20240712_1900.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Generated by Django 5.0.7 on 2024-07-12 19:00
  2. import django.db.models.deletion
  3. import django.utils.timezone
  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. from django.db import migrations, models
  10. from glitchtip.model_utils import TestDefaultPartition
  11. from .functions.partition import create_partitions
  12. class Migration(migrations.Migration):
  13. dependencies = [
  14. ("uptime", "0009_alter_monitor_interval_alter_monitor_monitor_type_and_more"),
  15. ("performance", "0014_initial"),
  16. ]
  17. operations = [
  18. psqlextra.backend.migrations.operations.create_partitioned_model.PostgresCreatePartitionedModel(
  19. name="MonitorCheck",
  20. fields=[
  21. (
  22. "id",
  23. models.BigAutoField(
  24. auto_created=True,
  25. primary_key=True,
  26. serialize=False,
  27. verbose_name="ID",
  28. ),
  29. ),
  30. ("is_up", models.BooleanField()),
  31. (
  32. "is_change",
  33. models.BooleanField(
  34. help_text="Indicates change to is_up status for associated monitor"
  35. ),
  36. ),
  37. (
  38. "start_check",
  39. models.DateTimeField(
  40. default=django.utils.timezone.now,
  41. help_text="Time when the start of this check was performed",
  42. ),
  43. ),
  44. (
  45. "reason",
  46. models.PositiveSmallIntegerField(
  47. blank=True,
  48. choices=[
  49. (0, "Unknown"),
  50. (1, "Timeout"),
  51. (2, "Wrong status code"),
  52. (3, "Expected response not found"),
  53. (4, "SSL error"),
  54. (5, "Network error"),
  55. ],
  56. default=0,
  57. null=True,
  58. ),
  59. ),
  60. (
  61. "response_time",
  62. models.PositiveIntegerField(
  63. blank=True, help_text="Reponse time in milliseconds", null=True
  64. ),
  65. ),
  66. ("data", models.JSONField(blank=True, null=True)),
  67. (
  68. "monitor",
  69. models.ForeignKey(
  70. on_delete=django.db.models.deletion.CASCADE,
  71. related_name="checks",
  72. to="uptime.monitor",
  73. ),
  74. ),
  75. ],
  76. options={
  77. "ordering": ("-start_check",),
  78. "indexes": [
  79. models.Index(
  80. fields=["monitor", "-start_check"],
  81. name="uptime_moni_monitor_a89b32_idx",
  82. ),
  83. models.Index(
  84. fields=["monitor", "is_change", "-start_check"],
  85. name="uptime_moni_monitor_b6d442_idx",
  86. ),
  87. ],
  88. },
  89. partitioning_options={
  90. "method": psqlextra.types.PostgresPartitioningMethod["RANGE"],
  91. "key": ["start_check"],
  92. },
  93. bases=(psqlextra.models.partitioned.PostgresPartitionedModel,),
  94. managers=[
  95. ("objects", psqlextra.manager.manager.PostgresManager()),
  96. ],
  97. ),
  98. TestDefaultPartition(
  99. model_name="MonitorCheck",
  100. name="default",
  101. ),
  102. migrations.RunPython(create_partitions, migrations.RunPython.noop),
  103. ]