0001_squashed_0010_auto_20210117_1543.py 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. # Generated by Django 3.1.5 on 2021-01-17 17:02
  2. import django.contrib.postgres.fields.jsonb
  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 django.utils.timezone
  8. import uuid
  9. class Migration(migrations.Migration):
  10. initial = True
  11. dependencies = [
  12. ("releases", "0002_auto_20201227_1518"),
  13. (
  14. "projects",
  15. "0001_squashed_0009_alter_project_id_alter_projectcounter_id_and_more",
  16. ),
  17. (
  18. "projects",
  19. "0001_squashed_0009_alter_project_id_alter_projectcounter_id_and_more",
  20. ),
  21. ]
  22. operations = [
  23. migrations.CreateModel(
  24. name="EventTag",
  25. fields=[
  26. (
  27. "id",
  28. models.AutoField(
  29. auto_created=True,
  30. primary_key=True,
  31. serialize=False,
  32. verbose_name="ID",
  33. ),
  34. ),
  35. ("key", models.CharField(max_length=255)),
  36. ("value", models.CharField(max_length=225)),
  37. ],
  38. ),
  39. migrations.CreateModel(
  40. name="Issue",
  41. fields=[
  42. (
  43. "id",
  44. models.AutoField(
  45. auto_created=True,
  46. primary_key=True,
  47. serialize=False,
  48. verbose_name="ID",
  49. ),
  50. ),
  51. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  52. ("culprit", models.CharField(blank=True, max_length=1024, null=True)),
  53. ("has_seen", models.BooleanField(default=False)),
  54. ("is_public", models.BooleanField(default=False)),
  55. (
  56. "level",
  57. models.PositiveSmallIntegerField(
  58. choices=[
  59. (0, "sample"),
  60. (1, "debug"),
  61. (2, "info"),
  62. (3, "warning"),
  63. (4, "error"),
  64. (5, "fatal"),
  65. ],
  66. default=0,
  67. ),
  68. ),
  69. ("metadata", django.contrib.postgres.fields.jsonb.JSONField()),
  70. ("title", models.CharField(max_length=255)),
  71. (
  72. "type",
  73. models.PositiveSmallIntegerField(
  74. choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
  75. ),
  76. ),
  77. (
  78. "status",
  79. models.PositiveSmallIntegerField(
  80. choices=[(0, "unresolved"), (1, "resolved"), (2, "ignored")],
  81. default=0,
  82. ),
  83. ),
  84. (
  85. "project",
  86. models.ForeignKey(
  87. on_delete=django.db.models.deletion.CASCADE,
  88. to="projects.project",
  89. ),
  90. ),
  91. ("count", models.PositiveIntegerField(default=1, editable=False)),
  92. (
  93. "last_seen",
  94. models.DateTimeField(
  95. auto_now_add=True, default=django.utils.timezone.now
  96. ),
  97. ),
  98. (
  99. "search_vector",
  100. django.contrib.postgres.search.SearchVectorField(
  101. editable=False, null=True
  102. ),
  103. ),
  104. ],
  105. options={
  106. "unique_together": {("title", "culprit", "project", "type")},
  107. },
  108. ),
  109. migrations.CreateModel(
  110. name="Event",
  111. fields=[
  112. (
  113. "event_id",
  114. models.UUIDField(
  115. default=uuid.uuid4,
  116. editable=False,
  117. primary_key=True,
  118. serialize=False,
  119. ),
  120. ),
  121. (
  122. "timestamp",
  123. models.DateTimeField(
  124. blank=True,
  125. help_text="Date created as claimed by client it came from",
  126. null=True,
  127. ),
  128. ),
  129. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  130. ("data", django.contrib.postgres.fields.jsonb.JSONField()),
  131. (
  132. "issue",
  133. models.ForeignKey(
  134. help_text="Sentry calls this a group",
  135. on_delete=django.db.models.deletion.CASCADE,
  136. to="issues.issue",
  137. ),
  138. ),
  139. ],
  140. options={
  141. "ordering": ["-created"],
  142. },
  143. ),
  144. migrations.AddIndex(
  145. model_name="issue",
  146. index=django.contrib.postgres.indexes.GinIndex(
  147. fields=["search_vector"], name="search_vector_idx"
  148. ),
  149. ),
  150. migrations.AddField(
  151. model_name="issue",
  152. name="short_id",
  153. field=models.PositiveIntegerField(null=True),
  154. ),
  155. migrations.AlterUniqueTogether(
  156. name="issue",
  157. unique_together={
  158. ("title", "culprit", "project", "type"),
  159. ("project", "short_id"),
  160. },
  161. ),
  162. migrations.RunSQL(
  163. sql="\nDROP TRIGGER IF EXISTS increment_project_counter on issues_issue;\n\nCREATE OR REPLACE FUNCTION increment_project_counter() RETURNS trigger AS $$\nDECLARE\n counter_value int;\nBEGIN\n INSERT INTO projects_projectcounter (value, project_id)\n VALUES (0, NEW.project_id)\n ON CONFLICT (project_id) DO UPDATE SET value = projects_projectcounter.value + 1\n RETURNING value into counter_value;\n NEW.short_id=counter_value;\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;;\n\nCREATE TRIGGER increment_project_counter BEFORE INSERT\nON issues_issue FOR EACH ROW EXECUTE PROCEDURE\nincrement_project_counter();\n",
  164. reverse_sql="DROP TRIGGER IF EXISTS increment_project_counter on issues_issue; DROP FUNCTION IF EXISTS increment_project_counter;",
  165. ),
  166. migrations.CreateModel(
  167. name="EventTagKey",
  168. fields=[
  169. (
  170. "id",
  171. models.AutoField(
  172. auto_created=True,
  173. primary_key=True,
  174. serialize=False,
  175. verbose_name="ID",
  176. ),
  177. ),
  178. ("key", models.CharField(max_length=255, unique=True)),
  179. ],
  180. ),
  181. migrations.AddField(
  182. model_name="event",
  183. name="tags",
  184. field=models.ManyToManyField(blank=True, to="issues.EventTag"),
  185. ),
  186. migrations.AlterField(
  187. model_name="eventtag",
  188. name="key",
  189. field=models.ForeignKey(
  190. on_delete=django.db.models.deletion.CASCADE, to="issues.eventtagkey"
  191. ),
  192. ),
  193. migrations.AlterUniqueTogether(
  194. name="eventtag",
  195. unique_together={("key", "value")},
  196. ),
  197. migrations.AlterField(
  198. model_name="event",
  199. name="data",
  200. field=models.JSONField(),
  201. ),
  202. migrations.AlterField(
  203. model_name="issue",
  204. name="metadata",
  205. field=models.JSONField(),
  206. ),
  207. migrations.AlterField(
  208. model_name="issue",
  209. name="last_seen",
  210. field=models.DateTimeField(auto_now_add=True, db_index=True),
  211. ),
  212. migrations.AddField(
  213. model_name="event",
  214. name="release",
  215. field=models.ForeignKey(
  216. blank=True,
  217. null=True,
  218. on_delete=django.db.models.deletion.SET_NULL,
  219. to="releases.release",
  220. ),
  221. ),
  222. migrations.SeparateDatabaseAndState(
  223. database_operations=[
  224. migrations.AlterModelTable(
  225. name="Event",
  226. table="events_event",
  227. ),
  228. migrations.AlterModelTable(
  229. name="EventTagKey",
  230. table="events_eventtagkey",
  231. ),
  232. migrations.AlterModelTable(
  233. name="EventTag",
  234. table="events_eventtag",
  235. ),
  236. ],
  237. state_operations=[
  238. migrations.DeleteModel(
  239. name="Event",
  240. ),
  241. migrations.DeleteModel(
  242. name="EventTagKey",
  243. ),
  244. migrations.DeleteModel(
  245. name="EventTag",
  246. ),
  247. ],
  248. ),
  249. migrations.AlterField(
  250. model_name="issue",
  251. name="type",
  252. field=models.PositiveSmallIntegerField(
  253. choices=[(0, "default"), (1, "error"), (2, "csp"), (3, "transaction")],
  254. default=0,
  255. ),
  256. ),
  257. ]