Update DB structure

#267
This commit is contained in:
Artur Beljajev 2016-12-27 21:50:59 +02:00
parent e5519e486a
commit 3c4cba93f4
3 changed files with 269 additions and 45 deletions

View file

@ -167,12 +167,12 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
exclude_filter varchar := '';
tmp_var text;
ret text;
BEGIN
BEGIN
-- define filters
include_filter = '%.' || i_origin;
-- for %.%.%
IF i_origin ~ '\.' THEN
IF i_origin ~ '.' THEN
exclude_filter := '';
-- for %.%
ELSE
@ -207,7 +207,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
FROM domains d
JOIN nameservers ns ON ns.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
ORDER BY d.name
),
chr(10)
@ -222,14 +222,14 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
-- a glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN A ', ns.ipv4)
SELECT concat(ns.hostname, '. IN A ', unnest(ns.ipv4))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '{}'
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
@ -242,14 +242,14 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
-- aaaa glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN AAAA ', ns.ipv6)
SELECT concat(ns.hostname, '. IN AAAA ', unnest(ns.ipv6))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '{}'
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
@ -265,7 +265,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
FROM domains d
JOIN dnskeys dk ON dk.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND dk.flags = 257
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
),
chr(10)
) INTO tmp_var;
@ -744,11 +744,13 @@ CREATE TABLE contacts (
country_code character varying,
state character varying,
legacy_id integer,
statuses character varying[],
statuses character varying[] DEFAULT '{}'::character varying[],
status_notes hstore,
legacy_history_id integer,
copy_from_id integer,
ident_updated_at timestamp without time zone
ident_updated_at timestamp without time zone,
upid integer,
up_date timestamp without time zone
);
@ -887,7 +889,8 @@ CREATE TABLE directos (
response json,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
invoice_number character varying
invoice_number character varying,
request text
);
@ -1098,7 +1101,9 @@ CREATE TABLE domains (
statuses character varying[],
reserved boolean DEFAULT false,
status_notes hstore,
statuses_backup character varying[] DEFAULT '{}'::character varying[]
statuses_backup character varying[] DEFAULT '{}'::character varying[],
upid integer,
up_date timestamp without time zone
);
@ -1353,7 +1358,8 @@ CREATE TABLE log_account_activities (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1390,7 +1396,8 @@ CREATE TABLE log_accounts (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1427,7 +1434,8 @@ CREATE TABLE log_addresses (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1464,7 +1472,8 @@ CREATE TABLE log_api_users (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1501,7 +1510,8 @@ CREATE TABLE log_bank_statements (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1538,7 +1548,8 @@ CREATE TABLE log_bank_transactions (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1575,7 +1586,8 @@ CREATE TABLE log_blocked_domains (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1612,7 +1624,8 @@ CREATE TABLE log_certificates (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1649,7 +1662,8 @@ CREATE TABLE log_contact_statuses (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1687,7 +1701,8 @@ CREATE TABLE log_contacts (
created_at timestamp without time zone,
session character varying,
children json,
ident_updated_at timestamp without time zone
ident_updated_at timestamp without time zone,
uuid character varying
);
@ -1724,7 +1739,8 @@ CREATE TABLE log_countries (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1761,7 +1777,8 @@ CREATE TABLE log_dnskeys (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1798,7 +1815,8 @@ CREATE TABLE log_domain_contacts (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1835,7 +1853,8 @@ CREATE TABLE log_domain_statuses (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1872,7 +1891,8 @@ CREATE TABLE log_domain_transfers (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1912,7 +1932,8 @@ CREATE TABLE log_domains (
tech_contact_ids text[] DEFAULT '{}'::text[],
admin_contact_ids text[] DEFAULT '{}'::text[],
session character varying,
children json
children json,
uuid character varying
);
@ -1949,7 +1970,8 @@ CREATE TABLE log_invoice_items (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -1986,7 +2008,8 @@ CREATE TABLE log_invoices (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2023,7 +2046,8 @@ CREATE TABLE log_keyrelays (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2060,7 +2084,8 @@ CREATE TABLE log_messages (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2097,7 +2122,8 @@ CREATE TABLE log_nameservers (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2133,7 +2159,8 @@ CREATE TABLE log_pricelists (
object json,
object_changes json,
created_at timestamp without time zone,
session character varying
session character varying,
uuid character varying
);
@ -2170,7 +2197,8 @@ CREATE TABLE log_registrars (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2207,7 +2235,8 @@ CREATE TABLE log_reserved_domains (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2244,7 +2273,8 @@ CREATE TABLE log_settings (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2281,7 +2311,8 @@ CREATE TABLE log_users (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2318,7 +2349,8 @@ CREATE TABLE log_white_ips (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2355,7 +2387,8 @@ CREATE TABLE log_zonefile_settings (
object_changes json,
created_at timestamp without time zone,
session character varying,
children json
children json,
uuid character varying
);
@ -2466,7 +2499,8 @@ CREATE TABLE nameservers (
domain_id integer,
creator_str character varying,
updator_str character varying,
legacy_domain_id integer
legacy_domain_id integer,
hostname_puny character varying
);
@ -2673,7 +2707,8 @@ CREATE TABLE registrars (
directo_handle character varying,
vat boolean,
legacy_id integer,
reference_no character varying
reference_no character varying,
test_registrar boolean DEFAULT false
);
@ -5214,5 +5249,31 @@ INSERT INTO schema_migrations (version) VALUES ('20160118092454');
INSERT INTO schema_migrations (version) VALUES ('20160218102355');
INSERT INTO schema_migrations (version) VALUES ('20160225113801');
INSERT INTO schema_migrations (version) VALUES ('20160225113812');
INSERT INTO schema_migrations (version) VALUES ('20160226132045');
INSERT INTO schema_migrations (version) VALUES ('20160226132056');
INSERT INTO schema_migrations (version) VALUES ('20160304125933');
INSERT INTO schema_migrations (version) VALUES ('20160311085957');
INSERT INTO schema_migrations (version) VALUES ('20160405131315');
INSERT INTO schema_migrations (version) VALUES ('20160411140719');
INSERT INTO schema_migrations (version) VALUES ('20160414110443');
INSERT INTO schema_migrations (version) VALUES ('20160421074023');
INSERT INTO schema_migrations (version) VALUES ('20160429114732');
INSERT INTO schema_migrations (version) VALUES ('20160527110738');
INSERT INTO schema_migrations (version) VALUES ('20161004101419');
INSERT INTO schema_migrations (version) VALUES ('20161227193500');