0001_initial.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. # Generated by Django 5.0.2 on 2024-02-14 14:07
  2. import django.contrib.postgres.indexes
  3. import django.contrib.postgres.search
  4. import django.db.models.deletion
  5. import django.utils.timezone
  6. import psqlextra.backend.migrations.operations.create_partitioned_model
  7. import psqlextra.manager.manager
  8. import psqlextra.models.partitioned
  9. import psqlextra.types
  10. import uuid
  11. from django.conf import settings
  12. from django.db import migrations, models
  13. from glitchtip.model_utils import TestDefaultPartition
  14. class Migration(migrations.Migration):
  15. initial = True
  16. dependencies = [
  17. ("projects", "0014_auto_20240318_1449"),
  18. (
  19. "releases",
  20. "0001_squashed_0004_alter_release_id_alter_releasefile_id_and_more",
  21. ),
  22. migrations.swappable_dependency(settings.AUTH_USER_MODEL),
  23. ]
  24. operations = [
  25. migrations.CreateModel(
  26. name="Comment",
  27. fields=[
  28. (
  29. "id",
  30. models.BigAutoField(
  31. auto_created=True,
  32. primary_key=True,
  33. serialize=False,
  34. verbose_name="ID",
  35. ),
  36. ),
  37. ("created", models.DateTimeField(auto_now_add=True)),
  38. ("text", models.TextField(blank=True, null=True)),
  39. (
  40. "user",
  41. models.ForeignKey(
  42. null=True,
  43. on_delete=django.db.models.deletion.SET_NULL,
  44. related_name="+",
  45. to=settings.AUTH_USER_MODEL,
  46. ),
  47. ),
  48. ],
  49. options={
  50. "ordering": ("-created",),
  51. },
  52. ),
  53. migrations.CreateModel(
  54. name="Issue",
  55. fields=[
  56. (
  57. "id",
  58. models.BigAutoField(
  59. auto_created=True,
  60. primary_key=True,
  61. serialize=False,
  62. verbose_name="ID",
  63. ),
  64. ),
  65. ("is_deleted", models.BooleanField(default=False)),
  66. ("culprit", models.CharField(blank=True, max_length=1024, null=True)),
  67. ("is_public", models.BooleanField(default=False)),
  68. (
  69. "level",
  70. models.PositiveSmallIntegerField(
  71. choices=[
  72. (0, "sample"),
  73. (1, "debug"),
  74. (2, "info"),
  75. (3, "warning"),
  76. (4, "error"),
  77. (5, "fatal"),
  78. ],
  79. default=4,
  80. ),
  81. ),
  82. ("metadata", models.JSONField()),
  83. ("title", models.CharField(max_length=255)),
  84. (
  85. "type",
  86. models.PositiveSmallIntegerField(
  87. choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
  88. ),
  89. ),
  90. (
  91. "status",
  92. models.PositiveSmallIntegerField(
  93. choices=[(0, "unresolved"), (1, "resolved"), (2, "ignored")],
  94. default=0,
  95. ),
  96. ),
  97. ("short_id", models.PositiveIntegerField(null=True)),
  98. (
  99. "search_vector",
  100. django.contrib.postgres.search.SearchVectorField(
  101. default="", editable=False
  102. ),
  103. ),
  104. ("count", models.PositiveIntegerField(default=1, editable=False)),
  105. (
  106. "first_seen",
  107. models.DateTimeField(
  108. db_index=True, default=django.utils.timezone.now
  109. ),
  110. ),
  111. (
  112. "last_seen",
  113. models.DateTimeField(
  114. db_index=True, default=django.utils.timezone.now
  115. ),
  116. ),
  117. (
  118. "project",
  119. models.ForeignKey(
  120. on_delete=django.db.models.deletion.CASCADE,
  121. related_name="issues",
  122. to="projects.project",
  123. ),
  124. ),
  125. ],
  126. options={
  127. "base_manager_name": "objects",
  128. },
  129. ),
  130. psqlextra.backend.migrations.operations.create_partitioned_model.PostgresCreatePartitionedModel(
  131. name="IssueEvent",
  132. fields=[
  133. (
  134. "id",
  135. models.UUIDField(
  136. default=uuid.uuid4,
  137. editable=False,
  138. primary_key=True,
  139. serialize=False,
  140. ),
  141. ),
  142. (
  143. "type",
  144. models.PositiveSmallIntegerField(
  145. choices=[(0, "default"), (1, "error"), (2, "csp")], default=0
  146. ),
  147. ),
  148. (
  149. "timestamp",
  150. models.DateTimeField(help_text="Time at which event happened"),
  151. ),
  152. (
  153. "received",
  154. models.DateTimeField(
  155. help_text="Time at which GlitchTip accepted event"
  156. ),
  157. ),
  158. ("title", models.CharField(max_length=255)),
  159. ("transaction", models.CharField(max_length=200)),
  160. (
  161. "level",
  162. models.PositiveSmallIntegerField(
  163. choices=[
  164. (0, "sample"),
  165. (1, "debug"),
  166. (2, "info"),
  167. (3, "warning"),
  168. (4, "error"),
  169. (5, "fatal"),
  170. ],
  171. default=4,
  172. ),
  173. ),
  174. ("data", models.JSONField()),
  175. ("tags", models.JSONField()),
  176. (
  177. "issue",
  178. models.ForeignKey(
  179. on_delete=django.db.models.deletion.CASCADE,
  180. to="issue_events.issue",
  181. ),
  182. ),
  183. (
  184. "release",
  185. models.ForeignKey(
  186. blank=True,
  187. null=True,
  188. on_delete=django.db.models.deletion.SET_NULL,
  189. to="releases.release",
  190. ),
  191. ),
  192. ],
  193. options={},
  194. partitioning_options={
  195. "method": psqlextra.types.PostgresPartitioningMethod["RANGE"],
  196. "key": ["received"],
  197. },
  198. bases=(psqlextra.models.partitioned.PostgresPartitionedModel,),
  199. managers=[
  200. ("objects", psqlextra.manager.manager.PostgresManager()),
  201. ],
  202. ),
  203. migrations.AddIndex(
  204. model_name="issueevent",
  205. index=models.Index(
  206. fields=["issue", "-received"], name="issue_event_issue_i_3b4e7f_idx"
  207. ),
  208. ),
  209. TestDefaultPartition(
  210. model_name="IssueEvent",
  211. name="default",
  212. ),
  213. migrations.CreateModel(
  214. name="IssueHash",
  215. fields=[
  216. (
  217. "id",
  218. models.BigAutoField(
  219. auto_created=True,
  220. primary_key=True,
  221. serialize=False,
  222. verbose_name="ID",
  223. ),
  224. ),
  225. ("value", models.UUIDField(db_index=True)),
  226. (
  227. "issue",
  228. models.ForeignKey(
  229. on_delete=django.db.models.deletion.CASCADE,
  230. related_name="hashes",
  231. to="issue_events.issue",
  232. ),
  233. ),
  234. (
  235. "project",
  236. models.ForeignKey(
  237. on_delete=django.db.models.deletion.CASCADE,
  238. related_name="+",
  239. to="projects.project",
  240. ),
  241. ),
  242. ],
  243. ),
  244. psqlextra.backend.migrations.operations.create_partitioned_model.PostgresCreatePartitionedModel(
  245. name="IssueTag",
  246. fields=[
  247. (
  248. "id",
  249. models.BigAutoField(
  250. auto_created=True,
  251. primary_key=True,
  252. serialize=False,
  253. verbose_name="ID",
  254. ),
  255. ),
  256. ("date", models.DateTimeField()),
  257. ("count", models.PositiveIntegerField(default=1)),
  258. (
  259. "issue",
  260. models.ForeignKey(
  261. on_delete=django.db.models.deletion.CASCADE,
  262. to="issue_events.issue",
  263. ),
  264. ),
  265. ],
  266. partitioning_options={
  267. "method": psqlextra.types.PostgresPartitioningMethod["RANGE"],
  268. "key": ["date"],
  269. },
  270. bases=(psqlextra.models.partitioned.PostgresPartitionedModel,),
  271. managers=[
  272. ("objects", psqlextra.manager.manager.PostgresManager()),
  273. ],
  274. ),
  275. TestDefaultPartition(
  276. model_name="IssueTag",
  277. name="default",
  278. ),
  279. migrations.CreateModel(
  280. name="TagKey",
  281. fields=[
  282. ("id", models.AutoField(primary_key=True, serialize=False)),
  283. ("key", models.CharField(max_length=255, unique=True)),
  284. ],
  285. ),
  286. migrations.CreateModel(
  287. name="TagValue",
  288. fields=[
  289. (
  290. "id",
  291. models.BigAutoField(
  292. auto_created=True,
  293. primary_key=True,
  294. serialize=False,
  295. verbose_name="ID",
  296. ),
  297. ),
  298. ("value", models.CharField(max_length=255, unique=True)),
  299. ],
  300. ),
  301. migrations.AddField(
  302. model_name="comment",
  303. name="issue",
  304. field=models.ForeignKey(
  305. on_delete=django.db.models.deletion.CASCADE,
  306. related_name="comments",
  307. to="issue_events.issue",
  308. ),
  309. ),
  310. migrations.AddField(
  311. model_name="issuetag",
  312. name="tag_key",
  313. field=models.ForeignKey(
  314. on_delete=django.db.models.deletion.CASCADE, to="issue_events.tagkey"
  315. ),
  316. ),
  317. migrations.AddField(
  318. model_name="issuetag",
  319. name="tag_value",
  320. field=models.ForeignKey(
  321. on_delete=django.db.models.deletion.CASCADE, to="issue_events.tagvalue"
  322. ),
  323. ),
  324. migrations.CreateModel(
  325. name="UserReport",
  326. fields=[
  327. (
  328. "id",
  329. models.BigAutoField(
  330. auto_created=True,
  331. primary_key=True,
  332. serialize=False,
  333. verbose_name="ID",
  334. ),
  335. ),
  336. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  337. ("event_id", models.UUIDField()),
  338. ("name", models.CharField(max_length=128)),
  339. ("email", models.EmailField(max_length=254)),
  340. ("comments", models.TextField()),
  341. (
  342. "issue",
  343. models.ForeignKey(
  344. null=True,
  345. on_delete=django.db.models.deletion.CASCADE,
  346. to="issue_events.issue",
  347. ),
  348. ),
  349. (
  350. "project",
  351. models.ForeignKey(
  352. on_delete=django.db.models.deletion.CASCADE,
  353. related_name="+",
  354. to="projects.project",
  355. ),
  356. ),
  357. ],
  358. ),
  359. migrations.AddIndex(
  360. model_name="issue",
  361. index=django.contrib.postgres.indexes.GinIndex(
  362. fields=["search_vector"], name="issue_event_search__346c17_gin"
  363. ),
  364. ),
  365. migrations.AddConstraint(
  366. model_name="issue",
  367. constraint=models.UniqueConstraint(
  368. fields=("project", "short_id"), name="project_short_id_unique"
  369. ),
  370. ),
  371. migrations.AddConstraint(
  372. model_name="issuehash",
  373. constraint=models.UniqueConstraint(
  374. fields=("project", "value"), name="issue hash project"
  375. ),
  376. ),
  377. migrations.AddConstraint(
  378. model_name="issuetag",
  379. constraint=models.UniqueConstraint(
  380. fields=("issue", "date", "tag_key", "tag_value"),
  381. name="issue_tag_key_value_unique",
  382. ),
  383. ),
  384. migrations.AddConstraint(
  385. model_name="userreport",
  386. constraint=models.UniqueConstraint(
  387. fields=("project", "event_id"), name="project_event_unique"
  388. ),
  389. ),
  390. ]