From: Michael Tremer Date: Wed, 31 Dec 2025 11:30:54 +0000 (+0000) Subject: domains: Store a report for adding and removing a domain X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3727e49ad8ba1766a98ef9d4f75a2975bf97b58;p=dbl.git domains: Store a report for adding and removing a domain Signed-off-by: Michael Tremer --- diff --git a/src/database.sql b/src/database.sql index fbd0c0b..43998da 100644 --- a/src/database.sql +++ b/src/database.sql @@ -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 diff --git a/src/dnsbl/domains.py b/src/dnsbl/domains.py index 50e7d2d..5771429 100644 --- a/src/dnsbl/domains.py +++ b/src/dnsbl/domains.py @@ -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]", + })