]> git.ipfire.org Git - dbl.git/commitdiff
domains: Prevent SQLModel from throwing away my rows
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 9 Jan 2026 17:48:56 +0000 (17:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 9 Jan 2026 17:48:56 +0000 (17:48 +0000)
The ID is not necessarily unique, so we have to add more attributes to
the primary key of the VIEW.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/domains.py

index 05a45002c2b28131bf080d81f9f647fc345aa494..efdbfb9261f173b0acb6f6e72a5c458bb6c6e70c 100644 (file)
@@ -173,7 +173,7 @@ class DomainEvent(sqlmodel.SQLModel, table=True):
                        return self.list.slug
 
        # Name
-       name: str
+       name: str = sqlmodel.Field(primary_key=True)
 
        # Source ID
        source_id: int | None = sqlmodel.Field(foreign_key="sources.id", exclude=True)
@@ -189,10 +189,10 @@ class DomainEvent(sqlmodel.SQLModel, table=True):
                        return self.source.name
 
        # Timestamp
-       timestamp: datetime.datetime
+       timestamp: datetime.datetime = sqlmodel.Field(primary_key=True)
 
        # Type
-       type: str
+       type: str = sqlmodel.Field(primary_key=True)
 
        # Block?
        block: bool