source: trunk/dns-1.0-1.2.sql@ 366

Last change on this file since 366 was 366, checked in by Kris Deugau, 12 years ago

/trunk

Update initial tabledef and 1.0 -> 1.2 conversion SQL to add "changed"
flag intended to help speed up export of large datasets by not actually
actively exporting all zones each time. Note for tinydns this will
require a static cache directory for a workspace so that unchanged
zones can have their data streamed into the main tinydns data file.

File size: 3.9 KB
Line 
1-- SQL table/record type upgrade file for dnsadmin 1.0 to 1.2 migration
2
3-- Minor buglet; domains must be unique
4-- ALTER TABLE domains ADD PRIMARY KEY (domain);
5
6CREATE TABLE default_rev_records (
7 record_id serial NOT NULL,
8 group_id integer DEFAULT 1 NOT NULL,
9 host text DEFAULT '' NOT NULL,
10 "type" integer DEFAULT 1 NOT NULL,
11 val text DEFAULT '' NOT NULL,
12 ttl integer DEFAULT 86400 NOT NULL,
13 description text
14);
15
16COPY default_rev_records (record_id, group_id, host, "type", val, ttl, description) FROM stdin;
171 1 hostmaster.ADMINDOMAIN:ns1.ADMINDOMAIN 6 3600:900:1048576:2560 3600
182 1 unused-%r.ADMINDOMAIN 65283 ZONE 3600
193 1 ns2.example.com 2 ZONE 7200 \N
204 1 ns1.example.com 2 ZONE 7200 \N
21\.
22
23SELECT pg_catalog.setval('default_rev_records_record_id_seq', 5, false);
24
25ALTER TABLE domains ADD COLUMN changed boolean;
26UPDATE domains SET changed=false;
27ALTER TABLE domains ALTER COLUMN changed SET DEFAULT true;
28ALTER TABLE domains ALTER COLUMN changed SET NOT NULL;
29
30CREATE TABLE revzones (
31 rdns_id serial NOT NULL,
32 revnet cidr NOT NULL PRIMARY KEY,
33 group_id integer DEFAULT 1 NOT NULL,
34 description character varying(255) DEFAULT ''::character varying NOT NULL,
35 status integer DEFAULT 1 NOT NULL,
36 zserial integer,
37 sertype character(1) DEFAULT 'D'::bpchar,
38 changed boolean DEFAULT true NOT NULL
39);
40
41ALTER TABLE log ADD COLUMN rdns_id INTEGER;
42
43-- Since records are now parented by one or both of a forward or reverse zone,
44-- we can't enforce FK relations on domain_id (or the new rdns_id) since many
45-- records won't have one or the other.
46ALTER TABLE records DROP CONSTRAINT "$1";
47ALTER TABLE records ALTER COLUMN domain_id SET DEFAULT 0;
48ALTER TABLE records ADD COLUMN rdns_id INTEGER DEFAULT 0;
49UPDATE records SET rdns_id=0;
50ALTER TABLE records ALTER COLUMN rdns_id SET NOT NULL;
51
52-- May as well drop and recreate; this is nominally static and loaded from the
53-- DB mainly for subset grouping and sorting convenience. Most of the entries
54-- have also been updated with new subset grouping and sorting data.
55DROP TABLE rectypes;
56CREATE TABLE rectypes (
57 val integer NOT NULL,
58 name character varying(20) NOT NULL,
59 stdflag integer DEFAULT 1 NOT NULL,
60 listorder integer DEFAULT 255 NOT NULL,
61 alphaorder integer DEFAULT 32768 NOT NULL
62);
63
64-- Types are required. NB: these are vaguely read-only too
65-- data from http://www.iana.org/assignments/dns-parameters
66COPY rectypes (val, name, stdflag, listorder, alphaorder) FROM stdin;
671 A 1 1 1
682 NS 2 9 37
693 MD 5 255 29
704 MF 5 255 30
715 CNAME 2 11 9
726 SOA 0 0 53
737 MB 5 255 28
748 MG 5 255 31
759 MR 5 255 33
7610 NULL 5 255 43
7711 WKS 5 255 64
7812 PTR 3 5 46
7913 HINFO 5 255 18
8014 MINFO 5 255 32
8115 MX 1 10 34
8216 TXT 2 12 60
8317 RP 4 255 48
8418 AFSDB 5 255 4
8519 X25 5 255 65
8620 ISDN 5 255 21
8721 RT 5 255 50
8822 NSAP 5 255 38
8923 NSAP-PTR 5 255 39
9024 SIG 5 255 51
9125 KEY 5 255 23
9226 PX 5 255 47
9327 GPOS 5 255 17
9428 AAAA 1 3 3
9529 LOC 5 255 25
9630 NXT 5 255 44
9731 EID 5 255 15
9832 NIMLOC 5 255 36
9933 SRV 1 13 55
10034 ATMA 5 255 6
10135 NAPTR 5 255 35
10236 KX 5 255 24
10337 CERT 5 255 8
10438 A6 5 3 2
10539 DNAME 5 255 12
10640 SINK 5 255 52
10741 OPT 5 255 45
10842 APL 5 255 5
10943 DS 5 255 14
11044 SSHFP 5 255 56
11145 IPSECKEY 5 255 20
11246 RRSIG 5 255 49
11347 NSEC 5 255 40
11448 DNSKEY 5 255 13
11549 DHCID 5 255 10
11650 NSEC3 5 255 41
11751 NSEC3PARAM 5 255 42
11855 HIP 5 255 19
11999 SPF 5 255 54
120100 UINFO 5 255 62
121101 UID 5 255 61
122102 GID 5 255 16
123103 UNSPEC 5 255 63
124249 TKEY 5 255 58
125250 TSIG 5 255 59
126251 IXFR 5 255 22
127252 AXFR 5 255 7
128253 MAILB 5 255 27
129254 MAILA 5 255 26
13032768 TA 5 255 57
13132769 DLV 5 255 11
132\.
133
134-- Custom types (ab)using the "Private use" range from 65280 to 65534
135COPY rectypes (val, name, stdflag, listorder, alphaorder) FROM stdin;
13665280 A+PTR 2 2 2
13765281 AAAA+PTR 2 4 4
13865282 PTR template 3 6 2
13965283 A+PTR template 2 7 2
14065284 AAAA+PTR template 8 13 2
14165285 Delegation 2 8 2
142\.
143
144-- Update dbversion
145UPDATE misc SET value='1.2' WHERE key='dbversion';
Note: See TracBrowser for help on using the repository browser.