source: trunk/cgi-bin/ipdb.psql@ 329

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

/trunk

Update SQL tabledefs with defaults on the customers table

(province/country/tech handle)

First iteration of cust data handling for rWHOIS - allow display

of existing data, entry of complete fresh new data.

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