]> git.ipfire.org Git - dbl.git/commitdiff
reports: Use a UUID as primary key
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Dec 2025 12:10:31 +0000 (12:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Dec 2025 12:10:31 +0000 (12:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.sql
src/dnsbl/api/reports.py
src/dnsbl/reports.py

index 1e9aff782365d975cef47ba848b0db03b9ff9c2a..979d86927986a95a87fa919fc92774f1d3302133 100644 (file)
@@ -2,7 +2,7 @@
 -- PostgreSQL database dump
 --
 
-\restrict delNzbfbaFwfjowYSA0Hv8h5YKH5ddoC9grkkzzBvFQDPYVsiqb0QZFyQzEzwfL
+\restrict Hq2I33CNLRM7K7kcCycXF0u7UASfMPt7lX7HhX0lOG4SePHngyo8IfElIz9I44O
 
 -- Dumped from database version 17.6 (Debian 17.6-0+deb13u1)
 -- Dumped by pg_dump version 17.6 (Debian 17.6-0+deb13u1)
@@ -144,7 +144,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id;
 --
 
 CREATE TABLE public.reports (
-    id integer NOT NULL,
+    id uuid DEFAULT gen_random_uuid() NOT NULL,
     list_id integer NOT NULL,
     name text NOT NULL,
     reported_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
@@ -157,26 +157,6 @@ CREATE TABLE public.reports (
 );
 
 
---
--- Name: reports_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.reports_id_seq
-    AS integer
-    START WITH 1
-    INCREMENT BY 1
-    NO MINVALUE
-    NO MAXVALUE
-    CACHE 1;
-
-
---
--- Name: reports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.reports_id_seq OWNED BY public.reports.id;
-
-
 --
 -- Name: source_domains; Type: TABLE; Schema: public; Owner: -
 --
@@ -274,13 +254,6 @@ ALTER TABLE ONLY public.lists ALTER COLUMN id SET DEFAULT nextval('public.lists_
 ALTER TABLE ONLY public.nameservers ALTER COLUMN id SET DEFAULT nextval('public.nameservers_id_seq'::regclass);
 
 
---
--- Name: reports id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.reports ALTER COLUMN id SET DEFAULT nextval('public.reports_id_seq'::regclass);
-
-
 --
 -- Name: source_domains id; Type: DEFAULT; Schema: public; Owner: -
 --
@@ -421,5 +394,5 @@ ALTER TABLE ONLY public.sources
 -- PostgreSQL database dump complete
 --
 
-\unrestrict delNzbfbaFwfjowYSA0Hv8h5YKH5ddoC9grkkzzBvFQDPYVsiqb0QZFyQzEzwfL
+\unrestrict Hq2I33CNLRM7K7kcCycXF0u7UASfMPt7lX7HhX0lOG4SePHngyo8IfElIz9I44O
 
index 84f3f0489ab8a6e14694aa758f8e5d014677d2b9..c9284719f44be1f3ca9244fb36917540a40b9464 100644 (file)
@@ -20,6 +20,7 @@
 
 import fastapi
 import typing
+import uuid
 
 from .. import reports
 
@@ -33,7 +34,7 @@ router = fastapi.APIRouter(
        tags=["Reports"],
 )
 
-def get_report_from_path(id: str = fastapi.Path(...)) -> reports.Report:
+def get_report_from_path(id: uuid.UUID = fastapi.Path(...)) -> reports.Report:
        """
                Fetches a report by its ID
        """
index 15f091093a14d019936d8e52ddf2051c4896facb..5ba44340073616423e489038a9571bc0839e60d9 100644 (file)
@@ -20,6 +20,7 @@
 
 import datetime
 import sqlmodel
+import uuid
 
 from . import database
 
@@ -71,7 +72,7 @@ class Report(sqlmodel.SQLModel, database.BackendMixin, table=True):
        __tablename__ = "reports"
 
        # ID
-       id : int = sqlmodel.Field(primary_key=True)
+       id : uuid.UUID = sqlmodel.Field(primary_key=True)
 
        # List ID
        list_id : int = sqlmodel.Field(foreign_key="lists.id", exclude=True)