mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-20 12:29:57 -06:00
Fix on previous commit (wrong unique index)
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
|
||||
def check_unique_together(apps, schema_editor):
|
||||
# manual check, allows for a pdb when this migration fails
|
||||
Event = apps.get_model('events', 'Event')
|
||||
|
||||
for index in [('project', 'event_id'), ('issue', 'ingest_order')]:
|
||||
values = Event.objects.values(*index).annotate(count=models.Count('id')).filter(count__gt=1)
|
||||
if values:
|
||||
raise ValueError(f"Duplicate event_id values found: {values}")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@@ -9,8 +20,9 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(check_unique_together),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='event',
|
||||
unique_together={('project', 'event_id'), ('project', 'ingest_order')},
|
||||
unique_together={('project', 'event_id'), ('issue', 'ingest_order')},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -147,7 +147,7 @@ class Event(models.Model):
|
||||
class Meta:
|
||||
unique_together = [
|
||||
("project", "event_id"),
|
||||
("project", "ingest_order"),
|
||||
("issue", "ingest_order"),
|
||||
]
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
Reference in New Issue
Block a user