0001_initial.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Generated by Django 3.1.4 on 2020-12-29 16:29
  2. from django.db import migrations, models
  3. import django.db.models.deletion
  4. import uuid
  5. from issues.migrations.sql.triggers import UPDATE_ISSUE_TRIGGER
  6. class Migration(migrations.Migration):
  7. initial = True
  8. dependencies = [
  9. ("releases", "0002_auto_20201227_1518"),
  10. ("issues", "0001_squashed_0010_auto_20210117_1543"),
  11. ]
  12. state_operations = [
  13. migrations.CreateModel(
  14. name="Event",
  15. fields=[
  16. (
  17. "event_id",
  18. models.UUIDField(
  19. default=uuid.uuid4,
  20. editable=False,
  21. primary_key=True,
  22. serialize=False,
  23. ),
  24. ),
  25. (
  26. "timestamp",
  27. models.DateTimeField(
  28. blank=True,
  29. help_text="Date created as claimed by client it came from",
  30. null=True,
  31. ),
  32. ),
  33. ("created", models.DateTimeField(auto_now_add=True, db_index=True)),
  34. ("data", models.JSONField()),
  35. (
  36. "issue",
  37. models.ForeignKey(
  38. help_text="Sentry calls this a group",
  39. on_delete=django.db.models.deletion.CASCADE,
  40. to="issues.issue",
  41. ),
  42. ),
  43. (
  44. "release",
  45. models.ForeignKey(
  46. blank=True,
  47. null=True,
  48. on_delete=django.db.models.deletion.SET_NULL,
  49. to="releases.release",
  50. ),
  51. ),
  52. ("tags", models.ManyToManyField(blank=True, to="events.EventTag")),
  53. ],
  54. options={"ordering": ["-created"],},
  55. ),
  56. migrations.CreateModel(
  57. name="EventTagKey",
  58. fields=[
  59. (
  60. "id",
  61. models.AutoField(
  62. auto_created=True,
  63. primary_key=True,
  64. serialize=False,
  65. verbose_name="ID",
  66. ),
  67. ),
  68. ("key", models.CharField(max_length=255, unique=True)),
  69. ],
  70. ),
  71. migrations.CreateModel(
  72. name="EventTag",
  73. fields=[
  74. (
  75. "id",
  76. models.AutoField(
  77. auto_created=True,
  78. primary_key=True,
  79. serialize=False,
  80. verbose_name="ID",
  81. ),
  82. ),
  83. ("value", models.CharField(max_length=225)),
  84. (
  85. "key",
  86. models.ForeignKey(
  87. on_delete=django.db.models.deletion.CASCADE,
  88. to="events.eventtagkey",
  89. ),
  90. ),
  91. ],
  92. options={"unique_together": {("key", "value")},},
  93. ),
  94. ]
  95. operations = [
  96. migrations.SeparateDatabaseAndState(state_operations=state_operations),
  97. migrations.RunSQL(
  98. sql=UPDATE_ISSUE_TRIGGER,
  99. reverse_sql="DROP TRIGGER IF EXISTS event_issue_update on issues_event; DROP FUNCTION IF EXISTS update_issue;",
  100. ),
  101. ]