From: Frank Brehm Date: Thu, 2 Nov 2017 17:52:33 +0000 (+0100) Subject: Jede Menge neue Views X-Git-Tag: 0.1.2~124^2~4 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=4cd8f32e7711c15d9bfe1bb7196428b1a00909f2;p=pixelpark%2Fadmin-tools.git Jede Menge neue Views --- diff --git a/dns/schema.pgsql.sql b/dns/schema.pgsql.sql index f77a545..bebba86 100644 --- a/dns/schema.pgsql.sql +++ b/dns/schema.pgsql.sql @@ -171,3 +171,116 @@ ALTER SEQUENCE IF EXISTS tsigkeys_id_seq OWNER TO pdns; GRANT SELECT ON TABLE tsigkeys TO dns; COMMIT; + +-- ---------------------------------------------------------------------- + +BEGIN WORK; + +-- ---------------- + +CREATE or REPLACE VIEW v_records AS +SELECT r.id AS record_id, + r.domain_id AS 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 AS comment + FROM records AS r + LEFT join domains AS d ON d.id = r.domain_id + LEFT join comments AS c ON r.name = c.name AND r.type = c.type + ORDER BY d.name, r.name; + +ALTER TABLE IF EXISTS v_records OWNER TO pdns; + +GRANT SELECT ON TABLE v_records TO dns; + +COMMIT; + +-- ---------------------------------------------------------------------- + +\connect pdns_local + +BEGIN WORK; + +CREATE EXTENSION IF NOT EXISTS postgres_fdw; + +CREATE SERVER pdns_master FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'systemshare.pixelpark.com', dbname 'pdns'); +ALTER SERVER pdns_master OWNER TO pdns_local; +CREATE USER MAPPING FOR pdns_local SERVER pdns_master OPTIONS (user 'pdns_local', password 'Neingeichee(ghahn7ah'); + +CREATE SCHEMA IF NOT EXISTS pdns; +ALTER SCHEMA pdns OWNER TO pdns_local; +IMPORT FOREIGN SCHEMA public FROM SERVER pdns_master INTO pdns; + +COMMIT; + +-- ---------------- + +BEGIN WORK; + +CREATE or REPLACE VIEW public.domains AS +SELECT id, name, master, last_check, type, notified_serial, account + FROM pdns.domains + ORDER BY name; + +ALTER TABLE IF EXISTS public.domains OWNER TO pdns_local; + +COMMIT; + +-- ---------------- + +BEGIN WORK; + +CREATE or REPLACE VIEW public.records AS +SELECT id, domain_id, name, type, content, ttl, prio, change_date, disabled, ordername, auth + FROM pdns.records + WHERE name NOT in ( SELECT name FROM pdns.comments WHERE comment ~* '.*public.*'); + +ALTER TABLE IF EXISTS public.records OWNER TO pdns_local; + +COMMIT; + +-- ---------------- + +BEGIN WORK; + +CREATE or REPLACE VIEW public.supermasters AS +SELECT ip, nameserver, account + FROM pdns.supermasters + ORDER BY nameserver; + +ALTER TABLE IF EXISTS public.supermasters OWNER TO pdns_local; + +COMMIT; + +-- ---------------- + +BEGIN WORK; + +CREATE or REPLACE VIEW public.comments AS +SELECT id, domain_id, name, type, modified_at, account, comment + FROM pdns.comments + WHERE comment IS NULL OR comment !~* '.*public.*'; + +ALTER TABLE IF EXISTS public.comments OWNER TO pdns_local; + +COMMIT; + +