Index: branches/stable/dns.sql
===================================================================
--- branches/stable/dns.sql	(revision 544)
+++ branches/stable/dns.sql	(revision 545)
@@ -14,6 +14,15 @@
 
 COPY misc (misc_id, key, value) FROM stdin;
-1	dbversion	1.0
-\.
+1	dbversion	1.2
+\.
+
+CREATE TABLE locations (
+    location character varying (4) PRIMARY KEY,
+    loc_id serial UNIQUE,
+    group_id integer NOT NULL DEFAULT 1,
+    iplist text NOT NULL DEFAULT '',
+    description character varying(40) NOT NULL DEFAULT '',
+    comments text NOT NULL DEFAULT ''
+);
 
 CREATE TABLE default_records (
@@ -54,24 +63,30 @@
 1	1	hostmaster.ADMINDOMAIN:ns1.ADMINDOMAIN	6	3600:900:1048576:2560	3600	
 2	1	unused-%r.ADMINDOMAIN	65283	ZONE	3600	
+3	1	ns2.example.com	2	ZONE	7200	\N
+4	1	ns1.example.com	2	ZONE	7200	\N
 \.
 
 CREATE TABLE domains (
     domain_id serial NOT NULL,
-    "domain" character varying(80) NOT NULL,
+    "domain" character varying(80) NOT NULL PRIMARY KEY,
     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
+    sertype character(1) DEFAULT 'D'::bpchar,
+    changed boolean DEFAULT true NOT NULL,
+    default_location character varying (4) DEFAULT '' NOT NULL
 );
 
 CREATE TABLE revzones (
     rdns_id serial NOT NULL,
-    revnet cidr NOT NULL,
+    revnet cidr NOT NULL PRIMARY KEY,
     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
+    sertype character(1) DEFAULT 'D'::bpchar,
+    changed boolean DEFAULT true NOT NULL,
+    default_location character varying (4) DEFAULT '' NOT NULL
 );
 
@@ -119,4 +134,9 @@
     record_edit boolean DEFAULT false NOT NULL,
     record_delete boolean DEFAULT false NOT NULL,
+    record_locchg boolean DEFAULT false NOT NULL,
+    location_create boolean DEFAULT false NOT NULL,
+    location_edit boolean DEFAULT false NOT NULL,
+    location_delete boolean DEFAULT false NOT NULL,
+    location_view boolean DEFAULT false NOT NULL,
     user_id integer UNIQUE,
     group_id integer UNIQUE
@@ -124,7 +144,7 @@
 
 -- Need *two* basic permissions;  one for the initial group, one for the default admin user
-COPY permissions (permission_id, admin, self_edit, group_create, group_edit, group_delete, user_create, user_edit, user_delete, domain_create, domain_edit, domain_delete, record_create, record_edit, record_delete, user_id, group_id) FROM stdin;
-1	f	f	f	f	f	f	f	f	t	t	t	t	t	t	\N	1
-2	t	f	f	f	f	f	f	f	f	f	f	f	f	f	1	\N
+COPY permissions (permission_id, "admin", self_edit, group_create, group_edit, group_delete, user_create, user_edit, user_delete, domain_create, domain_edit, domain_delete, record_create, record_edit, record_delete, record_locchg, location_create, location_edit, location_delete, location_view, user_id, group_id) FROM stdin;
+1	f	f	f	f	f	f	f	f	t	t	t	t	t	t	f	f	f	f	f	\N	1
+2	t	f	f	f	f	f	f	f	f	f	f	f	f	f	f	f	f	f	f	1	\N
 \.
 
@@ -141,5 +161,6 @@
     port integer DEFAULT 0 NOT NULL,
     ttl integer DEFAULT 7200 NOT NULL,
-    description text
+    description text,
+    location character varying (4) DEFAULT '' NOT NULL
 );
 
@@ -156,8 +177,8 @@
 COPY rectypes (val, name, stdflag, listorder, alphaorder) FROM stdin;
 1	A	1	1	1
-2	NS	1	5	37
+2	NS	2	9	37
 3	MD	5	255	29
 4	MF	5	255	30
-5	CNAME	1	7	9
+5	CNAME	2	11	9
 6	SOA	0	0	53
 7	MB	5	255	28
@@ -166,9 +187,9 @@
 10	NULL	5	255	43
 11	WKS	5	255	64
-12	PTR	3	10	46
+12	PTR	3	5	46
 13	HINFO	5	255	18
 14	MINFO	5	255	32
-15	MX	1	6	34
-16	TXT	1	8	60
+15	MX	1	10	34
+16	TXT	2	12	60
 17	RP	4	255	48
 18	AFSDB	5	255	4
@@ -187,5 +208,5 @@
 31	EID	5	255	15
 32	NIMLOC	5	255	36
-33	SRV	1	9	55
+33	SRV	1	13	55
 34	ATMA	5	255	6
 35	NAPTR	5	255	35
@@ -226,7 +247,8 @@
 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
+65282	PTR template	3	6	2
+65283	A+PTR template	2	7	2
+65284	AAAA+PTR template	8	13	2
+65285	Delegation	2	8	2
 \.
 
@@ -262,7 +284,4 @@
 
 ALTER TABLE ONLY domains
-    ADD CONSTRAINT domains_pkey PRIMARY KEY ("domain");
-
-ALTER TABLE ONLY domains
     ADD CONSTRAINT domains_domain_id_key UNIQUE (domain_id);
 
@@ -284,5 +303,11 @@
 -- foreign keys
 -- fixme: permissions FK refs
+ALTER TABLE ONLY locations
+    ADD CONSTRAINT "locations_group_id_fkey" FOREIGN KEY (group_id) REFERENCES groups(group_id);
+
 ALTER TABLE ONLY domains
+    ADD CONSTRAINT "$1" FOREIGN KEY (group_id) REFERENCES groups(group_id);
+
+ALTER TABLE ONLY revzones
     ADD CONSTRAINT "$1" FOREIGN KEY (group_id) REFERENCES groups(group_id);
 
@@ -299,5 +324,5 @@
 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('default_rev_records_record_id_seq', 5, false);
 SELECT pg_catalog.setval('domains_domain_id_seq', 1, false);
 SELECT pg_catalog.setval('groups_group_id_seq', 2, false);
