0001_initial.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Generated by Django 4.2.8 on 2023-12-27 19:06
  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. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  20. ('is_deleted', models.BooleanField(default=False)),
  21. ('culprit', models.CharField(blank=True, max_length=1024, null=True)),
  22. ('is_public', models.BooleanField(default=False)),
  23. ('level', models.PositiveSmallIntegerField(choices=[(0, 'sample'), (1, 'debug'), (2, 'info'), (3, 'warning'), (4, 'error'), (5, 'fatal')], default=4)),
  24. ('metadata', models.JSONField()),
  25. ('title', models.CharField(max_length=255)),
  26. ('type', models.PositiveSmallIntegerField(choices=[(0, 'default'), (1, 'error'), (2, 'csp')], default=0)),
  27. ('status', models.PositiveSmallIntegerField(choices=[(0, 'unresolved'), (1, 'resolved'), (2, 'ignored')], default=0)),
  28. ('short_id', models.PositiveIntegerField(null=True)),
  29. ('search_vector', django.contrib.postgres.search.SearchVectorField(default='', editable=False)),
  30. ('count', models.PositiveIntegerField(default=1, editable=False)),
  31. ('first_seen', models.DateTimeField(db_index=True)),
  32. ('last_seen', models.DateTimeField(db_index=True)),
  33. ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issues', to='projects.project')),
  34. ],
  35. options={
  36. 'base_manager_name': 'objects',
  37. },
  38. ),
  39. migrations.CreateModel(
  40. name='IssueHash',
  41. fields=[
  42. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  43. ('value', models.UUIDField(db_index=True)),
  44. ('issue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hashes', to='issue_events.issue')),
  45. ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='projects.project')),
  46. ],
  47. ),
  48. migrations.CreateModel(
  49. name='IssueEvent',
  50. fields=[
  51. ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
  52. ('type', models.PositiveSmallIntegerField(choices=[(0, 'default'), (1, 'error'), (2, 'csp')], default=0)),
  53. ('timestamp', models.DateTimeField(help_text='Time at which event happened')),
  54. ('received', models.DateTimeField(help_text='Time at which GlitchTip accepted event')),
  55. ('title', models.CharField(max_length=255)),
  56. ('transaction', models.CharField(max_length=200)),
  57. ('level', models.PositiveSmallIntegerField(choices=[(0, 'sample'), (1, 'debug'), (2, 'info'), (3, 'warning'), (4, 'error'), (5, 'fatal')], default=4)),
  58. ('data', models.JSONField()),
  59. ('tags', models.JSONField()),
  60. ('issue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='issue_events.issue')),
  61. ],
  62. options={
  63. 'abstract': False,
  64. 'base_manager_name': 'objects',
  65. },
  66. managers=[
  67. ('objects', psqlextra.manager.manager.PostgresManager()),
  68. ],
  69. ),
  70. migrations.CreateModel(
  71. name='Comment',
  72. fields=[
  73. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  74. ('created', models.DateTimeField(auto_now_add=True)),
  75. ('text', models.TextField(blank=True, null=True)),
  76. ('issue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='issue_events.issue')),
  77. ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
  78. ],
  79. options={
  80. 'ordering': ('-created',),
  81. },
  82. ),
  83. migrations.CreateModel(
  84. name='UserReport',
  85. fields=[
  86. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  87. ('created', models.DateTimeField(auto_now_add=True, db_index=True)),
  88. ('event_id', models.UUIDField()),
  89. ('name', models.CharField(max_length=128)),
  90. ('email', models.EmailField(max_length=254)),
  91. ('comments', models.TextField()),
  92. ('issue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='issue_events.issue')),
  93. ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='projects.project')),
  94. ],
  95. options={
  96. 'unique_together': {('project', 'event_id')},
  97. },
  98. ),
  99. migrations.AddConstraint(
  100. model_name='issuehash',
  101. constraint=models.UniqueConstraint(fields=('project', 'value'), name='issue hash project'),
  102. ),
  103. migrations.AddIndex(
  104. model_name='issue',
  105. index=django.contrib.postgres.indexes.GinIndex(fields=['search_vector'], name='issue_event_search__346c17_gin'),
  106. ),
  107. migrations.AlterUniqueTogether(
  108. name='issue',
  109. unique_together={('project', 'short_id')},
  110. ),
  111. ]