0001_squashed_0010_auto_20210117_1543.py 8.8 KB

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