0001_initial.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # Generated by Django 4.2.7 on 2023-11-18 16:47
  2. from django.conf import settings
  3. import django.contrib.postgres.indexes
  4. import django.contrib.postgres.search
  5. from django.db import migrations, models
  6. import django.db.models.deletion
  7. import psqlextra.manager.manager
  8. import uuid
  9. class Migration(migrations.Migration):
  10. initial = True
  11. dependencies = [
  12. ("projects", "0013_merge_20231017_1350"),
  13. migrations.swappable_dependency(settings.AUTH_USER_MODEL),
  14. ]
  15. operations = [
  16. migrations.CreateModel(
  17. name="Issue",
  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. ("created", models.DateTimeField(auto_now_add=True)),
  29. ("culprit", models.CharField(blank=True, max_length=1024, null=True)),
  30. ("is_public", models.BooleanField(default=False)),
  31. (
  32. "level",
  33. models.PositiveSmallIntegerField(
  34. choices=[
  35. (0, "sample"),
  36. (1, "debug"),
  37. (2, "info"),
  38. (3, "warning"),
  39. (4, "error"),
  40. (5, "fatal"),
  41. ],
  42. default=4,
  43. ),
  44. ),
  45. ("metadata", models.JSONField()),
  46. ("title", models.CharField(max_length=255)),
  47. (
  48. "type",
  49. models.PositiveSmallIntegerField(
  50. choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
  51. ),
  52. ),
  53. (
  54. "status",
  55. models.PositiveSmallIntegerField(
  56. choices=[(0, "unresolved"), (1, "resolved"), (2, "ignored")],
  57. default=0,
  58. ),
  59. ),
  60. ("short_id", models.PositiveIntegerField(null=True)),
  61. (
  62. "project",
  63. models.ForeignKey(
  64. on_delete=django.db.models.deletion.CASCADE,
  65. related_name="issues",
  66. to="projects.project",
  67. ),
  68. ),
  69. ],
  70. ),
  71. migrations.CreateModel(
  72. name="IssueHash",
  73. fields=[
  74. (
  75. "id",
  76. models.BigAutoField(
  77. auto_created=True,
  78. primary_key=True,
  79. serialize=False,
  80. verbose_name="ID",
  81. ),
  82. ),
  83. ("value", models.UUIDField(db_index=True)),
  84. (
  85. "issue",
  86. models.ForeignKey(
  87. on_delete=django.db.models.deletion.CASCADE,
  88. related_name="hashes",
  89. to="issue_events.issue",
  90. ),
  91. ),
  92. (
  93. "project",
  94. models.ForeignKey(
  95. on_delete=django.db.models.deletion.CASCADE,
  96. related_name="+",
  97. to="projects.project",
  98. ),
  99. ),
  100. ],
  101. ),
  102. migrations.CreateModel(
  103. name="IssueEvent",
  104. fields=[
  105. (
  106. "id",
  107. models.UUIDField(
  108. default=uuid.uuid4,
  109. editable=False,
  110. primary_key=True,
  111. serialize=False,
  112. ),
  113. ),
  114. (
  115. "type",
  116. models.PositiveSmallIntegerField(
  117. choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
  118. ),
  119. ),
  120. (
  121. "timestamp",
  122. models.DateTimeField(help_text="Time at which event happened"),
  123. ),
  124. (
  125. "received",
  126. models.DateTimeField(
  127. help_text="Time at which GlitchTip accepted event"
  128. ),
  129. ),
  130. ("title", models.CharField(max_length=255)),
  131. ("transaction", models.CharField(max_length=200)),
  132. (
  133. "level",
  134. models.PositiveSmallIntegerField(
  135. choices=[
  136. (0, "sample"),
  137. (1, "debug"),
  138. (2, "info"),
  139. (3, "warning"),
  140. (4, "error"),
  141. (5, "fatal"),
  142. ],
  143. default=4,
  144. ),
  145. ),
  146. ("data", models.JSONField()),
  147. ("tags", models.JSONField()),
  148. (
  149. "issue",
  150. models.ForeignKey(
  151. on_delete=django.db.models.deletion.CASCADE,
  152. to="issue_events.issue",
  153. ),
  154. ),
  155. ],
  156. options={
  157. "abstract": False,
  158. "base_manager_name": "objects",
  159. },
  160. managers=[
  161. ("objects", psqlextra.manager.manager.PostgresManager()),
  162. ],
  163. ),
  164. migrations.CreateModel(
  165. name="Comment",
  166. fields=[
  167. (
  168. "id",
  169. models.BigAutoField(
  170. auto_created=True,
  171. primary_key=True,
  172. serialize=False,
  173. verbose_name="ID",
  174. ),
  175. ),
  176. ("created", models.DateTimeField(auto_now_add=True)),
  177. ("text", models.TextField(blank=True, null=True)),
  178. (
  179. "issue",
  180. models.ForeignKey(
  181. on_delete=django.db.models.deletion.CASCADE,
  182. related_name="comments",
  183. to="issue_events.issue",
  184. ),
  185. ),
  186. (
  187. "user",
  188. models.ForeignKey(
  189. null=True,
  190. on_delete=django.db.models.deletion.SET_NULL,
  191. related_name="+",
  192. to=settings.AUTH_USER_MODEL,
  193. ),
  194. ),
  195. ],
  196. options={
  197. "ordering": ("-created",),
  198. },
  199. ),
  200. migrations.CreateModel(
  201. name="IssueStats",
  202. fields=[
  203. (
  204. "issue",
  205. models.OneToOneField(
  206. on_delete=django.db.models.deletion.CASCADE,
  207. primary_key=True,
  208. serialize=False,
  209. to="issue_events.issue",
  210. ),
  211. ),
  212. (
  213. "search_vector",
  214. django.contrib.postgres.search.SearchVectorField(
  215. editable=False, null=True
  216. ),
  217. ),
  218. ("search_vector_created", models.DateTimeField(auto_now_add=True)),
  219. ("count", models.PositiveIntegerField(default=1, editable=False)),
  220. ("last_seen", models.DateTimeField(auto_now_add=True, db_index=True)),
  221. ],
  222. options={
  223. "indexes": [
  224. django.contrib.postgres.indexes.GinIndex(
  225. fields=["search_vector"], name="issue_event_search__0754e8_gin"
  226. )
  227. ],
  228. },
  229. ),
  230. migrations.AddConstraint(
  231. model_name="issuehash",
  232. constraint=models.UniqueConstraint(
  233. fields=("project", "value"), name="issue hash project"
  234. ),
  235. ),
  236. migrations.AlterUniqueTogether(
  237. name="issue",
  238. unique_together={("project", "short_id")},
  239. ),
  240. ]