]> git.ipfire.org Git - dbl.git/commitdiff
domains: Store a report for adding and removing a domain
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Dec 2025 11:30:54 +0000 (11:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Dec 2025 11:30:54 +0000 (11:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.sql
src/dnsbl/domains.py

index fbd0c0bffb452a0fffd583b6422391abb26e948e..43998da6e4503e416f084f00ded9461597984372 100644 (file)
@@ -2,7 +2,7 @@
 -- PostgreSQL database dump
 --
 
-\restrict EeYKZnslrxGmNaeqO4o6gPUM6JSs7wWdVd6NvcQqHzBRusgbfSbKjYZDw8t1hjq
+\restrict CceG0LqeHWTFqDb6DQrSpNSpqyV7f4lvN0FfZf1Vzji48NH0WT6mIEhc9x3L4V9
 
 -- Dumped from database version 17.6 (Debian 17.6-0+deb13u1)
 -- Dumped by pg_dump version 17.6 (Debian 17.6-0+deb13u1)
@@ -83,8 +83,9 @@ CREATE TABLE public.domains (
     removed_at timestamp with time zone,
     removed_by text,
     updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
-    report_id uuid,
-    block boolean DEFAULT true
+    block boolean DEFAULT true,
+    report_add_id uuid,
+    report_remove_id uuid
 );
 
 
@@ -402,11 +403,19 @@ ALTER TABLE ONLY public.domains
 
 
 --
--- Name: domains domains_report_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+-- Name: domains domains_report_add_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.domains
+    ADD CONSTRAINT domains_report_add_id FOREIGN KEY (report_add_id) REFERENCES public.reports(id);
+
+
+--
+-- Name: domains domains_report_remove_id; Type: FK CONSTRAINT; Schema: public; Owner: -
 --
 
 ALTER TABLE ONLY public.domains
-    ADD CONSTRAINT domains_report_id FOREIGN KEY (report_id) REFERENCES public.reports(id);
+    ADD CONSTRAINT domains_report_remove_id FOREIGN KEY (report_remove_id) REFERENCES public.reports(id);
 
 
 --
@@ -437,5 +446,5 @@ ALTER TABLE ONLY public.sources
 -- PostgreSQL database dump complete
 --
 
-\unrestrict EeYKZnslrxGmNaeqO4o6gPUM6JSs7wWdVd6NvcQqHzBRusgbfSbKjYZDw8t1hjq
+\unrestrict CceG0LqeHWTFqDb6DQrSpNSpqyV7f4lvN0FfZf1Vzji48NH0WT6mIEhc9x3L4V9
 
index 50e7d2ddf713662c6d5d93f2022d951a58e75701..577142975901a974c2df79795e0146f983081f41 100644 (file)
@@ -67,11 +67,21 @@ class Domain(sqlmodel.SQLModel, database.BackendMixin, table=True):
                sa_column_kwargs = {"server_default" : sqlmodel.text("CURRENT_TIMESTAMP")}
        )
 
-       # Report ID
-       report_id: uuid.UUID | None = sqlmodel.Field(foreign_key="reports.id", default=None)
-
-       # Report
-       report: "Report" = sqlmodel.Relationship()
-
        # Block?
        block: bool = True
+
+       # Report Add ID
+       report_add_id: uuid.UUID | None = sqlmodel.Field(foreign_key="reports.id", default=None)
+
+       # Report Add
+       report_add: "Report" = sqlmodel.Relationship(sa_relationship_kwargs={
+               "foreign_keys" : "[Domain.report_add_id]",
+       })
+
+       # Report Remove ID
+       report_remove_id: uuid.UUID | None = sqlmodel.Field(foreign_key="reports.id", default=None)
+
+       # Report Remove
+       report_remove: "Report" = sqlmodel.Relationship(sa_relationship_kwargs={
+               "foreign_keys" : "[Domain.report_remove_id]",
+       })