Index: trunk/dns.sql
===================================================================
--- trunk/dns.sql	(revision 215)
+++ trunk/dns.sql	(revision 224)
@@ -41,7 +41,32 @@
 \.
 
+CREATE TABLE default_rev_records (
+    record_id serial NOT NULL,
+    group_id integer DEFAULT 1 NOT NULL,
+    host text DEFAULT '' NOT NULL,
+    "type" integer DEFAULT 1 NOT NULL,
+    val text DEFAULT '' NOT NULL,
+    ttl integer DEFAULT 86400 NOT NULL,
+    description text
+);
+
+COPY default_rev_records (record_id, group_id, host, "type", ip, ttl, description) FROM stdin;
+1	1	hostmaster.ADMINDOMAIN:ns1.ADMINDOMAIN	6	3600:900:1048576:2560	3600	
+2	1	unused-%r.ADMINDOMAIN	65283	ZONE	3600	
+\.
+
 CREATE TABLE domains (
     domain_id serial NOT NULL,
     "domain" character varying(80) NOT NULL,
+    group_id integer DEFAULT 1 NOT NULL,
+    description character varying(255) DEFAULT ''::character varying NOT NULL,
+    status integer DEFAULT 1 NOT NULL,
+    zserial integer,
+    sertype character(1) DEFAULT 'D'::bpchar
+);
+
+CREATE TABLE revzones (
+    rdns_id serial NOT NULL,
+    revnet cidr NOT NULL,
     group_id integer DEFAULT 1 NOT NULL,
     description character varying(255) DEFAULT ''::character varying NOT NULL,
@@ -69,4 +94,5 @@
     log_id serial NOT NULL,
     domain_id integer,
+    rdns_id integer,
     user_id integer,
     group_id integer,
@@ -103,7 +129,8 @@
 \.
 
--- fixme:  need to handle looooong records (eg, SPF)
+-- rdns_id defaults to 0 since many records will not have an associated rDNS entry.
 CREATE TABLE records (
-    domain_id integer NOT NULL,
+    domain_id integer NOT NULL DEFAULT 0,
+    rdns_id integer NOT NULL DEFAULT 0,
     record_id serial NOT NULL,
     host text DEFAULT '' NOT NULL,
@@ -119,5 +146,5 @@
 CREATE TABLE rectypes (
     val integer NOT NULL,
-    name character varying(12) NOT NULL,
+    name character varying(20) NOT NULL,
     stdflag integer DEFAULT 1 NOT NULL,
     listorder integer DEFAULT 255 NOT NULL,
@@ -129,68 +156,77 @@
 COPY rectypes (val, name, stdflag, listorder, alphaorder) FROM stdin;
 1	A	1	1	1
-2	NS	1	2	37
-3	MD	2	255	29
-4	MF	2	255	30
-5	CNAME	1	6	9
-6	SOA	0	8	53
-7	MB	3	255	28
-8	MG	3	255	31
-9	MR	3	255	33
-10	NULL	3	255	43
-11	WKS	3	255	64
-12	PTR	2	4	46
-13	HINFO	3	255	18
-14	MINFO	3	255	32
-15	MX	1	3	34
-16	TXT	1	5	60
-17	RP	2	255	48
-18	AFSDB	3	255	4
-19	X25	3	255	65
-20	ISDN	3	255	21
-21	RT	3	255	50
-22	NSAP	3	255	38
-23	NSAP-PTR	3	255	39
-24	SIG	3	255	51
-25	KEY	3	255	23
-26	PX	3	255	47
-27	GPOS	3	255	17
-28	AAAA	1	2	3
-29	LOC	3	255	25
-30	NXT	3	255	44
-31	EID	3	255	15
-32	NIMLOC	3	255	36
-33	SRV	1	7	55
-34	ATMA	3	255	6
-35	NAPTR	3	255	35
-36	KX	3	255	24
-37	CERT	3	255	8
-38	A6	3	3	2
-39	DNAME	3	255	12
-40	SINK	3	255	52
-41	OPT	3	255	45
-42	APL	3	255	5
-43	DS	3	255	14
-44	SSHFP	3	255	56
-45	IPSECKEY	3	255	20
-46	RRSIG	3	255	49
-47	NSEC	3	255	40
-48	DNSKEY	3	255	13
-49	DHCID	3	255	10
-50	NSEC3	3	255	41
-51	NSEC3PARAM	3	255	42
-55	HIP	3	255	19
-99	SPF	3	255	54
-100	UINFO	3	255	62
-101	UID	3	255	61
-102	GID	3	255	16
-103	UNSPEC	3	255	63
-249	TKEY	3	255	58
-250	TSIG	3	255	59
-251	IXFR	3	255	22
-252	AXFR	3	255	7
-253	MAILB	3	255	27
-254	MAILA	3	255	26
-32768	TA	3	255	57
-32769	DLV	3	255	11
+2	NS	1	5	37
+3	MD	5	255	29
+4	MF	5	255	30
+5	CNAME	1	7	9
+6	SOA	0	0	53
+7	MB	5	255	28
+8	MG	5	255	31
+9	MR	5	255	33
+10	NULL	5	255	43
+11	WKS	5	255	64
+12	PTR	3	10	46
+13	HINFO	5	255	18
+14	MINFO	5	255	32
+15	MX	1	6	34
+16	TXT	1	8	60
+17	RP	4	255	48
+18	AFSDB	5	255	4
+19	X25	5	255	65
+20	ISDN	5	255	21
+21	RT	5	255	50
+22	NSAP	5	255	38
+23	NSAP-PTR	5	255	39
+24	SIG	5	255	51
+25	KEY	5	255	23
+26	PX	5	255	47
+27	GPOS	5	255	17
+28	AAAA	1	3	3
+29	LOC	5	255	25
+30	NXT	5	255	44
+31	EID	5	255	15
+32	NIMLOC	5	255	36
+33	SRV	1	9	55
+34	ATMA	5	255	6
+35	NAPTR	5	255	35
+36	KX	5	255	24
+37	CERT	5	255	8
+38	A6	5	3	2
+39	DNAME	5	255	12
+40	SINK	5	255	52
+41	OPT	5	255	45
+42	APL	5	255	5
+43	DS	5	255	14
+44	SSHFP	5	255	56
+45	IPSECKEY	5	255	20
+46	RRSIG	5	255	49
+47	NSEC	5	255	40
+48	DNSKEY	5	255	13
+49	DHCID	5	255	10
+50	NSEC3	5	255	41
+51	NSEC3PARAM	5	255	42
+55	HIP	5	255	19
+99	SPF	5	255	54
+100	UINFO	5	255	62
+101	UID	5	255	61
+102	GID	5	255	16
+103	UNSPEC	5	255	63
+249	TKEY	5	255	58
+250	TSIG	5	255	59
+251	IXFR	5	255	22
+252	AXFR	5	255	7
+253	MAILB	5	255	27
+254	MAILA	5	255	26
+32768	TA	5	255	57
+32769	DLV	5	255	11
+\.
+
+-- Custom types (ab)using the "Private use" range from 65280 to 65534
+COPY rectypes (val, name, stdflag, listorder, alphaorder) FROM stdin;
+65280	A+PTR	2	2	2
+65281	AAAA+PTR	2	4	4
+65282	PTR template	3	11	2
+65283	A+PTR template	3	12	2
+65284	AAAA+PTR template	3	13	2
 \.
 
@@ -254,7 +290,4 @@
     ADD CONSTRAINT "$1" FOREIGN KEY (group_id) REFERENCES groups(group_id);
 
-ALTER TABLE ONLY records
-    ADD CONSTRAINT "$1" FOREIGN KEY (domain_id) REFERENCES domains(domain_id);
-
 ALTER TABLE ONLY users
     ADD CONSTRAINT "$1" FOREIGN KEY (group_id) REFERENCES groups(group_id);
@@ -264,9 +297,10 @@
 
 -- set starting sequence numbers, since we've inserted data before they're active
-SELECT pg_catalog.setval('misc_misc_id_seq', 1, true);
-SELECT pg_catalog.setval('default_records_record_id_seq', 8, true);
+SELECT pg_catalog.setval('misc_misc_id_seq', 2, false);
+SELECT pg_catalog.setval('default_records_record_id_seq', 8, false);
+SELECT pg_catalog.setval('default_rev_records_record_id_seq', 3, false);
 SELECT pg_catalog.setval('domains_domain_id_seq', 1, false);
-SELECT pg_catalog.setval('groups_group_id_seq', 1, true);
-SELECT pg_catalog.setval('permissions_permission_id_seq', 2, true);
+SELECT pg_catalog.setval('groups_group_id_seq', 2, false);
+SELECT pg_catalog.setval('permissions_permission_id_seq', 3, false);
 SELECT pg_catalog.setval('records_record_id_seq', 1, false);
 SELECT pg_catalog.setval('users_user_id_seq', 2, false);
