1 | -- fixme: include template-ish ACL?
|
---|
2 | CREATE TABLE groups (
|
---|
3 | group_id SERIAL UNIQUE,
|
---|
4 | parent_group_id int NOT NULL DEFAULT '1',
|
---|
5 | name varchar(255) NOT NULL DEFAULT ''
|
---|
6 | );
|
---|
7 | -- gotta have a default group to attach some further default data to...
|
---|
8 | INSERT INTO groups (name) VALUES ('default');
|
---|
9 |
|
---|
10 | -- use ON DELETE (CASCADE|RESTRICT|NO ACTION) on FKs
|
---|
11 |
|
---|
12 | CREATE TABLE domains (
|
---|
13 | domain_id SERIAL UNIQUE,
|
---|
14 | domain varchar(80) NOT NULL PRIMARY KEY,
|
---|
15 | group_id int NOT NULL DEFAULT 1 REFERENCES groups (group_id),
|
---|
16 | description varchar(255) NOT NULL DEFAULT '',
|
---|
17 | status int NOT NULL DEFAULT 1
|
---|
18 | );
|
---|
19 |
|
---|
20 | CREATE TABLE default_records (
|
---|
21 | record_id SERIAL PRIMARY KEY,
|
---|
22 | group_id int NOT NULL DEFAULT 1 REFERENCES groups (group_id),
|
---|
23 | host varchar(100) NOT NULL DEFAULT '',
|
---|
24 | type int NOT NULL DEFAULT 1,
|
---|
25 | val varchar(100) NOT NULL DEFAULT '',
|
---|
26 | distance int NOT NULL DEFAULT 0,
|
---|
27 | weight int NOT NULL DEFAULT 0,
|
---|
28 | port int NOT NULL DEFAULT 0,
|
---|
29 | ttl int NOT NULL DEFAULT 86400,
|
---|
30 | description varchar(255)
|
---|
31 | );
|
---|
32 |
|
---|
33 | -- let's take pity on the poor sod installing things and include some default data that's halfway sane
|
---|
34 | INSERT INTO default_records (group_id,host,type,val,ttl) VALUES (1,'ns1.example.com:hostmaster.DOMAIN',6,'10800:3600:604800:10800',86400);
|
---|
35 |
|
---|
36 | CREATE TABLE records (
|
---|
37 | domain_id int NOT NULL REFERENCES domains (domain_id),
|
---|
38 | record_id SERIAL PRIMARY KEY,
|
---|
39 | host varchar(100) NOT NULL DEFAULT '',
|
---|
40 | type int NOT NULL DEFAULT 1,
|
---|
41 | val varchar(100) NOT NULL DEFAULT '',
|
---|
42 | distance int NOT NULL DEFAULT 0,
|
---|
43 | weight int NOT NULL DEFAULT 0,
|
---|
44 | port int NOT NULL DEFAULT 0,
|
---|
45 | ttl int NOT NULL DEFAULT 86400,
|
---|
46 | description varchar(255)
|
---|
47 | );
|
---|
48 |
|
---|
49 | -- oooo! oooo! allow staff/unwashed-masses parallel users?
|
---|
50 | -- - multitable, or just another column in the database...?
|
---|
51 | -- - go with column for now (could even overload groups...)
|
---|
52 | CREATE TABLE users (
|
---|
53 | user_id SERIAL PRIMARY KEY,
|
---|
54 | group_id int NOT NULL DEFAULT 1 REFERENCES groups (group_id),
|
---|
55 | email varchar(60) NOT NULL,
|
---|
56 | password varchar(34) NOT NULL,
|
---|
57 | firstname varchar(30),
|
---|
58 | lastname varchar(30),
|
---|
59 | phone varchar(15),
|
---|
60 | type char NOT NULL DEFAULT 'S',
|
---|
61 | status int NOT NULL DEFAULT 1,
|
---|
62 | acl varchar(40) NOT NULL DEFAULT 'b'
|
---|
63 | );
|
---|
64 |
|
---|
65 | -- include a default user, so we don't break on install. not happy with this, but...
|
---|
66 | -- default password is 'test'
|
---|
67 | INSERT INTO users (group_id,email,password,type,status,acl) VALUES (1,'test@test','$1$BByge8u2$48AaGX3YeHplfErX5Tlqa1','S',1,'A');
|
---|
68 |
|
---|
69 | -- these could be stuffed in a hash, but that gets tedious
|
---|
70 | CREATE TABLE rectypes (
|
---|
71 | val int NOT NULL,
|
---|
72 | name varchar(12) NOT NULL,
|
---|
73 | stdflag int NOT NULL DEFAULT 1,
|
---|
74 | listorder int NOT NULL DEFAULT 255,
|
---|
75 | PRIMARY KEY (val,name)
|
---|
76 | );
|
---|
77 | -- data from http://www.iana.org/assignments/dns-parameters
|
---|
78 | COPY rectypes (val, name, stdflag, listorder) FROM stdin;
|
---|
79 | 1 A 1 1
|
---|
80 | 2 NS 1 2
|
---|
81 | 3 MD 2 255
|
---|
82 | 4 MF 2 255
|
---|
83 | 5 CNAME 1 6
|
---|
84 | 6 SOA 0 8
|
---|
85 | 7 MB 3 255
|
---|
86 | 8 MG 3 255
|
---|
87 | 9 MR 3 255
|
---|
88 | 10 NULL 3 255
|
---|
89 | 11 WKS 3 255
|
---|
90 | 12 PTR 2 4
|
---|
91 | 13 HINFO 3 255
|
---|
92 | 14 MINFO 3 255
|
---|
93 | 15 MX 1 3
|
---|
94 | 16 TXT 1 5
|
---|
95 | 17 RP 2 255
|
---|
96 | 18 AFSDB 3 255
|
---|
97 | 19 X25 3 255
|
---|
98 | 20 ISDN 3 255
|
---|
99 | 21 RT 3 255
|
---|
100 | 22 NSAP 3 255
|
---|
101 | 23 NSAP-PTR 3 255
|
---|
102 | 24 SIG 3 255
|
---|
103 | 25 KEY 3 255
|
---|
104 | 26 PX 3 255
|
---|
105 | 27 GPOS 3 255
|
---|
106 | 28 AAAA 2 2
|
---|
107 | 29 LOC 3 255
|
---|
108 | 30 NXT 3 255
|
---|
109 | 31 EID 3 255
|
---|
110 | 32 NIMLOC 3 255
|
---|
111 | 33 SRV 1 7
|
---|
112 | 34 ATMA 3 255
|
---|
113 | 35 NAPTR 3 255
|
---|
114 | 36 KX 3 255
|
---|
115 | 37 CERT 3 255
|
---|
116 | 38 A6 3 3
|
---|
117 | 39 DNAME 3 255
|
---|
118 | 40 SINK 3 255
|
---|
119 | 41 OPT 3 255
|
---|
120 | 42 APL 3 255
|
---|
121 | 43 DS 3 255
|
---|
122 | 44 SSHFP 3 255
|
---|
123 | 45 IPSECKEY 3 255
|
---|
124 | 46 RRSIG 3 255
|
---|
125 | 47 NSEC 3 255
|
---|
126 | 48 DNSKEY 3 255
|
---|
127 | 49 DHCID 3 255
|
---|
128 | 50 NSEC3 3 255
|
---|
129 | 51 NSEC3PARAM 3 255
|
---|
130 | 55 HIP 3 255
|
---|
131 | 99 SPF 3 255
|
---|
132 | 100 UINFO 3 255
|
---|
133 | 101 UID 3 255
|
---|
134 | 102 GID 3 255
|
---|
135 | 103 UNSPEC 3 255
|
---|
136 | 249 TKEY 3 255
|
---|
137 | 250 TSIG 3 255
|
---|
138 | 251 IXFR 3 255
|
---|
139 | 252 AXFR 3 255
|
---|
140 | 253 MAILB 3 255
|
---|
141 | 254 MAILA 3 255
|
---|
142 | 32768 TA 3 255
|
---|
143 | 32769 DLV 3 255
|
---|
144 | \.
|
---|