0001_squashed_0010_alter_notification_issues.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Generated by Django 5.0.3 on 2024-03-15 14:05
  2. import django.db.models.deletion
  3. from django.db import migrations, models
  4. class Migration(migrations.Migration):
  5. replaces = [
  6. (
  7. "alerts",
  8. "0001_squashed_0007_alter_alertrecipient_id_alter_notification_id_and_more",
  9. ),
  10. ("alerts", "0008_alter_alertrecipient_recipient_type"),
  11. ("alerts", "0009_alter_alertrecipient_recipient_type"),
  12. ("alerts", "0010_alter_notification_issues"),
  13. ]
  14. initial = True
  15. dependencies = [
  16. ("issue_events", "0001_initial"),
  17. (
  18. "projects",
  19. "0001_squashed_0009_alter_project_id_alter_projectcounter_id_and_more",
  20. ),
  21. ]
  22. operations = [
  23. migrations.CreateModel(
  24. name="ProjectAlert",
  25. fields=[
  26. (
  27. "id",
  28. models.BigAutoField(
  29. auto_created=True,
  30. primary_key=True,
  31. serialize=False,
  32. verbose_name="ID",
  33. ),
  34. ),
  35. (
  36. "timespan_minutes",
  37. models.PositiveSmallIntegerField(blank=True, null=True),
  38. ),
  39. ("quantity", models.PositiveSmallIntegerField(blank=True, null=True)),
  40. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  41. (
  42. "project",
  43. models.ForeignKey(
  44. on_delete=django.db.models.deletion.CASCADE,
  45. to="projects.project",
  46. ),
  47. ),
  48. ("name", models.CharField(blank=True, max_length=255)),
  49. (
  50. "uptime",
  51. models.BooleanField(
  52. default=False,
  53. help_text="Send alert on any uptime monitor check failure",
  54. ),
  55. ),
  56. ],
  57. ),
  58. migrations.CreateModel(
  59. name="AlertRecipient",
  60. fields=[
  61. (
  62. "id",
  63. models.BigAutoField(
  64. auto_created=True,
  65. primary_key=True,
  66. serialize=False,
  67. verbose_name="ID",
  68. ),
  69. ),
  70. (
  71. "recipient_type",
  72. models.CharField(
  73. choices=[
  74. ("email", "Email"),
  75. ("webhook", "General Slack-compatible webhook"),
  76. ("discord", "Discord"),
  77. ("googlechat", "Google Chat webhook"),
  78. ],
  79. max_length=16,
  80. ),
  81. ),
  82. ("url", models.URLField(blank=True, max_length=2000)),
  83. (
  84. "alert",
  85. models.ForeignKey(
  86. on_delete=django.db.models.deletion.CASCADE,
  87. to="alerts.projectalert",
  88. ),
  89. ),
  90. ],
  91. options={
  92. "unique_together": {("alert", "recipient_type", "url")},
  93. },
  94. ),
  95. migrations.CreateModel(
  96. name="Notification",
  97. fields=[
  98. (
  99. "id",
  100. models.BigAutoField(
  101. auto_created=True,
  102. primary_key=True,
  103. serialize=False,
  104. verbose_name="ID",
  105. ),
  106. ),
  107. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  108. ("is_sent", models.BooleanField(default=False)),
  109. ("issues", models.ManyToManyField(to="issue_events.issue")),
  110. (
  111. "project_alert",
  112. models.ForeignKey(
  113. on_delete=django.db.models.deletion.CASCADE,
  114. to="alerts.projectalert",
  115. ),
  116. ),
  117. ],
  118. ),
  119. ]