mirror of
https://github.com/bugsink/bugsink.git
synced 2026-05-07 15:30:59 -05:00
DB: unique_together and PositiveIntegerField
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('events', '0014_fill_ingest_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='ingest_order',
|
||||
field=models.PositiveIntegerField(),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('projects', '0008_set_project_slugs'),
|
||||
('events', '0015_alter_event_ingest_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='event',
|
||||
unique_together={('project', 'event_id'), ('project', 'ingest_order')},
|
||||
),
|
||||
]
|
||||
+5
-3
@@ -142,11 +142,13 @@ class Event(models.Model):
|
||||
|
||||
# 1-based, because this is for human consumption only, and using 0-based internally when we don't actually do
|
||||
# anything with this value other than showing it to humans is super-confusing. Sorry Dijkstra!
|
||||
ingest_order = models.IntegerField(blank=False, null=False)
|
||||
ingest_order = models.PositiveIntegerField(blank=False, null=False)
|
||||
|
||||
class Meta:
|
||||
unique_together = (("project", "event_id"),)
|
||||
# index_together = (("group_id", "datetime"),) TODO seriously think about indexes
|
||||
unique_together = [
|
||||
("project", "event_id"),
|
||||
("project", "ingest_order"),
|
||||
]
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f"/issues/issue/{ self.issue_id }/event/{ self.id }/"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('projects', '0008_set_project_slugs'),
|
||||
('issues', '0019_set_ingest_order'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='issue',
|
||||
unique_together={('project', 'ingest_order')},
|
||||
),
|
||||
]
|
||||
@@ -104,6 +104,9 @@ class Issue(models.Model):
|
||||
return False # TODO actually implement (and then: implement in a performant manner)
|
||||
|
||||
class Meta:
|
||||
unique_together = [
|
||||
("project", "ingest_order"),
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["first_seen"]),
|
||||
models.Index(fields=["last_seen"]),
|
||||
|
||||
Reference in New Issue
Block a user