From: Frank Brehm Date: Tue, 9 Jun 2020 07:39:17 +0000 (+0200) Subject: Adding creation of views to db/create-pdns-db-postgresql.sql X-Git-Tag: 0.1.4~1^2~2^2 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=4ef02d34b05e2aa5262c8733ffdee4bb14180c2b;p=pixelpark%2Fadmin-tools.git Adding creation of views to db/create-pdns-db-postgresql.sql --- diff --git a/db/create-pdns-db-postgresql.sql b/db/create-pdns-db-postgresql.sql index 1aa40b6..19d3022 100644 --- a/db/create-pdns-db-postgresql.sql +++ b/db/create-pdns-db-postgresql.sql @@ -169,6 +169,53 @@ ALTER SEQUENCE IF EXISTS tsigkeys_id_seq OWNER TO pdns; COMMIT; +CREATE VIEW v_domainmetadata AS + SELECT md.id AS metadata_id, + md.domain_id, + d.name AS domain_name, + md.kind AS metadata_kind, + md.content AS metadata_content, + d.master AS domain_master, + d.last_check AS domain_last_check, + d.type AS domain_type, + d.notified_serial AS domain_serial, + d.account AS domain_account + FROM domainmetadata md + LEFT JOIN domains d ON md.domain_id = d.id + ORDER BY d.name, md.kind; +ALTER VIEW IF EXISTS v_domainmetadata OWNER TO pdns; + +CREATE VIEW v_records AS + SELECT r.id AS record_id, + r.domain_id, + r.name AS record_name, + r.type AS record_type, + r.content AS record_content, + r.ttl AS record_ttl, + r.prio AS record_prio, + r.change_date AS record_change_date, + r.disabled AS record_disabled, + r.ordername AS record_ordername, + r.auth AS record_auth, + d.name AS domain_name, + d.master AS domain_master, + d.last_check AS domain_last_check, + d.type AS domain_type, + d.notified_serial AS domain_notified_serial, + d.account AS domain_account, + c.id AS comment_id, + c.name AS comment_name, + c.type AS comment_type, + c.modified_at AS comment_modified_at, + c.account AS comment_account, + c.comment + FROM records r + LEFT JOIN domains d ON d.id = r.domain_id + LEFT JOIN comments c ON r.name::text = c.name::text AND r.type::text = c.type::text + ORDER BY d.name, r.name; +ALTER VIEW IF EXISTS v_records OWNER TO pdns; + + -- Enabling automatic SOA serial update after importing all data