0010_auto_20240712_1900.py 3.7 KB

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