0001_initial.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Generated by Django 3.2.5 on 2021-08-04 17:27
  2. import datetime
  3. import django.db.models.deletion
  4. from django.db import migrations, models
  5. class Migration(migrations.Migration):
  6. initial = True
  7. dependencies = [
  8. (
  9. "organizations_ext",
  10. "0001_squashed_0003_alter_organization_id_alter_organization_users_and_more",
  11. ),
  12. (
  13. "environments",
  14. "0001_squashed_0003_alter_environment_id_alter_environmentproject_id",
  15. ),
  16. (
  17. "projects",
  18. "0001_squashed_0009_alter_project_id_alter_projectcounter_id_and_more",
  19. ),
  20. ]
  21. operations = [
  22. migrations.CreateModel(
  23. name="Monitor",
  24. fields=[
  25. (
  26. "id",
  27. models.BigAutoField(
  28. auto_created=True,
  29. primary_key=True,
  30. serialize=False,
  31. verbose_name="ID",
  32. ),
  33. ),
  34. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  35. (
  36. "monitor_type",
  37. models.CharField(
  38. choices=[
  39. ("ping", "Ping"),
  40. ("get", "GET"),
  41. ("post", "POST"),
  42. ("ssl", "SSL"),
  43. ("heartbeat", "Heartbeat"),
  44. ],
  45. default="ping",
  46. max_length=12,
  47. ),
  48. ),
  49. ("name", models.CharField(max_length=200)),
  50. ("url", models.URLField(blank=True)),
  51. ("expected_status", models.PositiveSmallIntegerField(default=200)),
  52. ("expected_body", models.CharField(blank=True, max_length=2000)),
  53. ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
  54. (
  55. "interval",
  56. models.DurationField(default=datetime.timedelta(seconds=60)),
  57. ),
  58. (
  59. "environment",
  60. models.ForeignKey(
  61. blank=True,
  62. null=True,
  63. on_delete=django.db.models.deletion.SET_NULL,
  64. to="environments.environment",
  65. ),
  66. ),
  67. (
  68. "organization",
  69. models.ForeignKey(
  70. on_delete=django.db.models.deletion.CASCADE,
  71. to="organizations_ext.organization",
  72. ),
  73. ),
  74. (
  75. "project",
  76. models.ForeignKey(
  77. blank=True,
  78. null=True,
  79. on_delete=django.db.models.deletion.SET_NULL,
  80. to="projects.project",
  81. ),
  82. ),
  83. ],
  84. options={
  85. "abstract": False,
  86. },
  87. ),
  88. migrations.CreateModel(
  89. name="MonitorCheck",
  90. fields=[
  91. (
  92. "id",
  93. models.BigAutoField(
  94. auto_created=True,
  95. primary_key=True,
  96. serialize=False,
  97. verbose_name="ID",
  98. ),
  99. ),
  100. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  101. ("is_up", models.BooleanField()),
  102. (
  103. "start_check",
  104. models.DateTimeField(
  105. help_text="Time when the start of this check was performed"
  106. ),
  107. ),
  108. (
  109. "reason",
  110. models.PositiveSmallIntegerField(
  111. blank=True,
  112. choices=[
  113. (0, "Unknown"),
  114. (1, "Timeout"),
  115. (2, "Wrong status code"),
  116. (3, "Expected response not found"),
  117. (4, "SSL Error"),
  118. ],
  119. default=0,
  120. null=True,
  121. ),
  122. ),
  123. ("response_time", models.DurationField(blank=True, null=True)),
  124. ("data", models.JSONField(blank=True, null=True)),
  125. (
  126. "monitor",
  127. models.ForeignKey(
  128. on_delete=django.db.models.deletion.CASCADE,
  129. related_name="checks",
  130. to="uptime.monitor",
  131. ),
  132. ),
  133. ],
  134. options={
  135. "ordering": ("-created",),
  136. },
  137. ),
  138. migrations.AddIndex(
  139. model_name="monitorcheck",
  140. index=models.Index(
  141. fields=["start_check", "monitor"], name="uptime_moni_start_c_6434f7_idx"
  142. ),
  143. ),
  144. ]