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

Last change on this file since 332 was 329, checked in by Kris Deugau, 19 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
RevLine 
[181]1CREATE DATABASE ipdb;
[4]2
[176]3\connect ipdb ipdb
[4]4
5CREATE TABLE "customers" (
[329]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 ''
[4]20);
21
[34]22REVOKE ALL on "customers" from PUBLIC;
23GRANT ALL on "customers" to "ipdb";
24
[4]25CREATE TABLE "masterblocks" (
[219]26 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[324]27 "ctime" timestamp DEFAULT now(),
28 "mtime" timestamp DEFAULT now()
[4]29);
30
[34]31REVOKE ALL on "masterblocks" from PUBLIC;
32GRANT ALL on "masterblocks" to "ipdb";
33
[4]34CREATE TABLE "routed" (
[176]35 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[4]36 "maskbits" integer DEFAULT 128,
[219]37 "city" character varying(30) DEFAULT '',
38 "ctime" timestamp DEFAULT now()
[4]39);
40
[34]41REVOKE ALL on "routed" from PUBLIC;
42GRANT ALL on "routed" to "ipdb";
[316]43GRANT SELECT on "routed" to "ipdb";
[34]44
[4]45CREATE TABLE "temp" (
46 "ofs" integer
47);
48
[34]49REVOKE ALL on "temp" from PUBLIC;
50GRANT ALL on "temp" to "ipdb";
51
[57]52CREATE TABLE "freeblocks" (
[180]53 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[57]54 "maskbits" integer DEFAULT 128,
55 "city" character varying(30) DEFAULT '',
[176]56 "routed" character(1) DEFAULT 'n'
[34]57);
58
[57]59REVOKE ALL on "freeblocks" from PUBLIC;
60GRANT ALL on "freeblocks" to "ipdb";
[34]61
[74]62CREATE TABLE "poolips" (
63 "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
[176]64 "ip" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[74]65 "custid" character varying(16) DEFAULT '' NOT NULL,
[175]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,
[284]72 "privdata" text DEFAULT '' NOT NULL,
[316]73 "newcustid" character varying(16) DEFAULT '',
[218]74 "createstamp" timestamp DEFAULT now(),
75 "modifystamp" timestamp DEFAULT now(),
[176]76 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
[74]77);
78
79REVOKE ALL on "poolips" from PUBLIC;
80GRANT ALL on "poolips" to "ipdb";
81
82CREATE TABLE "allocations" (
[176]83 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[74]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 '',
[218]91 "createstamp" timestamp DEFAULT now(),
92 "modifystamp" timestamp DEFAULT now(),
[284]93 "privdata" text DEFAULT '' NOT NULL,
[316]94 "newcustid" character varying(16) DEFAULT '',
95 swip character(1) DEFAULT 'n'
[74]96);
97
98REVOKE ALL on "allocations" from PUBLIC;
99GRANT ALL on "allocations" to "ipdb";
100
[285]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;
[92]102
[176]103REVOKE ALL on "searchme" from PUBLIC;
104GRANT ALL on "searchme" to "ipdb";
105
[92]106CREATE TABLE "alloctypes" (
[176]107 "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
[92]108 "listname" character varying(40) DEFAULT '',
109 "dispname" character varying(40) DEFAULT '',
110 "listorder" integer DEFAULT 0,
[324]111 "def_custid" character varying(16) DEFAULT '',
112 "arin_netname" character varying(20) DEFAILT 'ISP'
[92]113);
114
[321]115--
116-- Name: alloctypes; Type: TABLE DATA; Schema: public; Owner: ipdb
117--
118
[324]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
[182]148\.
[218]149
[316]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
[218]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();
[233]177
178--
179-- User data table - required for proper ACLs
180--
181
182CREATE TABLE "users" (
[237]183 "username" varchar(16) NOT NULL PRIMARY KEY,
[233]184 "password" varchar(16) DEFAULT '',
185 "acl" varchar(16) DEFAULT 'b'
186);
[257]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.