source: branches/stable/cgi-bin/ipdb.psql@ 334

Last change on this file since 334 was 334, checked in by Kris Deugau, 18 years ago

/branches/stable

Update SQL tabledef with new alloctypes: fr and fc for fibre reserve
container and fibre block respectively

File size: 6.3 KB
Line 
1CREATE DATABASE ipdb;
2
3\connect ipdb ipdb
4
5CREATE TABLE "customers" (
6 "custid" character varying(16) DEFAULT '' NOT NULL,
7 "name" character varying(64),
8 "street" character varying(25),
9 "street2" character varying(25),
10 "city" character varying(30),
11 "province" character(2),
12 "country" character(2),
13 "pocode" character varying(7),
14 "phone" character varying(15),
15 "tech_handle" character varying(50),
16 "abuse_handle" character varying(50),
17 "admin_handle" character varying(50),
18 "def_rdns" character varying(40),
19 "special" text,
20 Constraint "customers_pkey" Primary Key ("custid")
21);
22
23REVOKE ALL on "customers" from PUBLIC;
24GRANT ALL on "customers" to "ipdb";
25
26CREATE TABLE "masterblocks" (
27 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
28 "ctime" timestamp DEFAULT now(),
29 "mtime" timestamp DEFAULT now()
30);
31
32REVOKE ALL on "masterblocks" from PUBLIC;
33GRANT ALL on "masterblocks" to "ipdb";
34
35CREATE TABLE "routed" (
36 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
37 "maskbits" integer DEFAULT 128,
38 "city" character varying(30) DEFAULT '',
39 "ctime" timestamp DEFAULT now()
40);
41
42REVOKE ALL on "routed" from PUBLIC;
43GRANT ALL on "routed" to "ipdb";
44GRANT SELECT on "routed" to "ipdb";
45
46CREATE TABLE "temp" (
47 "ofs" integer
48);
49
50REVOKE ALL on "temp" from PUBLIC;
51GRANT ALL on "temp" to "ipdb";
52
53CREATE TABLE "freeblocks" (
54 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
55 "maskbits" integer DEFAULT 128,
56 "city" character varying(30) DEFAULT '',
57 "routed" character(1) DEFAULT 'n'
58);
59
60REVOKE ALL on "freeblocks" from PUBLIC;
61GRANT ALL on "freeblocks" to "ipdb";
62
63CREATE TABLE "poolips" (
64 "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
65 "ip" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
66 "custid" character varying(16) DEFAULT '' NOT NULL,
67 "city" character varying(30) DEFAULT '' NOT NULL,
68 "type" character(2) DEFAULT '' NOT NULL,
69 "available" character(1) DEFAULT 'y' NOT NULL,
70 "notes" text DEFAULT '' NOT NULL,
71 "description" character varying(64) DEFAULT '' NOT NULL,
72 "circuitid" character varying(128) DEFAULT '' NOT NULL,
73 "privdata" text DEFAULT '' NOT NULL,
74 "newcustid" character varying(16) DEFAULT '',
75 "createstamp" timestamp DEFAULT now(),
76 "modifystamp" timestamp DEFAULT now(),
77 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
78);
79
80REVOKE ALL on "poolips" from PUBLIC;
81GRANT ALL on "poolips" to "ipdb";
82
83CREATE TABLE "allocations" (
84 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
85 "custid" character varying(16) DEFAULT '',
86 "type" character(2) DEFAULT '',
87 "city" character varying(30) DEFAULT '',
88 "description" character varying(64) DEFAULT '',
89 "notes" text DEFAULT '',
90 "maskbits" integer DEFAULT 128,
91 "circuitid" character varying(128) DEFAULT '',
92 "createstamp" timestamp DEFAULT now(),
93 "modifystamp" timestamp DEFAULT now(),
94 "privdata" text DEFAULT '' NOT NULL,
95 "newcustid" character varying(16) DEFAULT '',
96 swip character(1) DEFAULT 'n'
97);
98
99REVOKE ALL on "allocations" from PUBLIC;
100GRANT ALL on "allocations" to "ipdb";
101
102CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description, allocations.notes FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.type, poolips.city, poolips.description, poolips.notes FROM poolips;
103
104REVOKE ALL on "searchme" from PUBLIC;
105GRANT ALL on "searchme" to "ipdb";
106
107CREATE TABLE "alloctypes" (
108 "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
109 "listname" character varying(40) DEFAULT '',
110 "dispname" character varying(40) DEFAULT '',
111 "listorder" integer DEFAULT 0,
112 "def_custid" character varying(16) DEFAULT '',
113 "arin_netname" character varying(20) DEFAILT 'ISP'
114);
115
116--
117-- Name: alloctypes; Type: TABLE DATA; Schema: public; Owner: ipdb
118--
119
120COPY "alloctypes" FROM stdin;
121cn Customer netblock Customer netblock 0 ISPCUST
122si Static IP - Server pool Server pool IP 20 6750400 ISP
123ci Static IP - Cable Static cable IP 21 ISP
124di Static IP - DSL Static DSL IP 22 ISP
125mi Static IP - Dialup Static dialup IP 23 ISP
126wi Static IP - Wireless Static wireless IP 24 ISP
127sd Static Pool - Servers Server pool 40 6750400 ISP
128cd Static Pool - Cable Cable pool 41 CBL-BUS ISP-STATIC-CABLE
129dp Static Pool - DSL DSL pool 42 DSL-BUS ISP-STATIC-DSL
130mp Static Pool - Dialup Static dialup pool 43 DIAL-BUS ISP-STATIC-DIAL
131wp Static Pool - Wireless Static wireless pool 44 WL-BUS ISP-STATIC-WIFI
132en End-use netblock End-use netblock 100 6750400 ISP
133me Dialup netblock Dialup netblock 101 DIAL-RES ISP-DIAL
134de Dynamic DSL block Dynamic DSL block 102 DSL-RES ISP-DSL
135ce Dynamic cable block Dynamic cable block 103 CBL-RES ISP-CABLE
136we Dynamic WiFi block Dynamic WiFi block 104 WL-RES ISP-WIFI
137ve Dynamic VoIP block Dynamic VoIP block 105 DYN-VOIP ISP
138li Static IP - LAN/POP Static LAN/POP IP 190 6750400 ISP
139ld Static Pool - LAN/POP LAN pool 191 6750400 ISP
140wc Reserve for CORE/WAN blocks CORE/WAN blocks 200 6750400 ISP
141pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 6750400 ISP-STATIC-DSL
142ac Reserve for ATM ATM blocks 202 6750400 ISP
143fc Reserve for fibre 203 6750400 ISP
144wr CORE/WAN block CORE/WAN block 220 6750400 ISP
145pr Dynamic-route DSL netblock Dynamic-route DSL 221 ISP
146ar ATM block ATM block 222 ISP
147fr Fibre Fibre 223 ISP
148rm Routing Routed netblock 500 6750400 ISP
149in Internal netblock Internal netblock 990 6750400 ISP
150mm Master block Master block 999 6750400 ISP
151\.
152
153REVOKE ALL on "alloctypes" from PUBLIC;
154GRANT ALL on "alloctypes" to "ipdb";
155
156CREATE TABLE "cities" (
157 "id" serial NOT NULL PRIMARY KEY,
158 "city" character varying(30) DEFAULT '' NOT NULL,
159 "routing" character(1) DEFAULT 'n' NOT NULL
160);
161
162REVOKE ALL on "cities" from PUBLIC;
163GRANT ALL on "cities" to "ipdb";
164
165--
166-- Trigger and matching function to update modifystamp on allocations, poolips
167--
168CREATE FUNCTION up_modtime () RETURNS OPAQUE AS '
169 BEGIN
170 NEW.modifystamp := ''now'';
171 RETURN NEW;
172 END;
173' LANGUAGE 'plpgsql';
174
175CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations
176 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
177
178CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips
179 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
180
181--
182-- User data table - required for proper ACLs
183--
184
185CREATE TABLE "users" (
186 "username" varchar(16) NOT NULL PRIMARY KEY,
187 "password" varchar(16) DEFAULT '',
188 "acl" varchar(16) DEFAULT 'b'
189);
190
191CREATE TABLE "dns" (
192 "ip" inet NOT NULL PRIMARY KEY,
193 "hostname" character varying(128),
194 "auto" character(1) DEFAULT 'y'
195);
Note: See TracBrowser for help on using the repository browser.