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

Last change on this file since 327 was 325, checked in by Kris Deugau, 19 years ago

/branches/stable

Merge rWHOIS update from /trunk r324.

File size: 6.3 KB
RevLine 
[185]1CREATE DATABASE ipdb;
[4]2
[177]3\connect ipdb ipdb
[4]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),
[325]12 "country" character(2),
[4]13 "pocode" character varying(7),
14 "phone" character varying(15),
[325]15 "tech_handle" character varying(50),
16 "abuse_handle" character varying(50),
17 "admin_handle" character varying(50),
[4]18 "def_rdns" character varying(40),
[325]19 "special" text,
[4]20 Constraint "customers_pkey" Primary Key ("custid")
21);
22
[59]23REVOKE ALL on "customers" from PUBLIC;
24GRANT ALL on "customers" to "ipdb";
[4]25
26CREATE TABLE "masterblocks" (
[325]27 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
28 "ctime" timestamp DEFAULT now(),
29 "mtime" timestamp DEFAULT now()
[4]30);
31
[59]32REVOKE ALL on "masterblocks" from PUBLIC;
33GRANT ALL on "masterblocks" to "ipdb";
34
[4]35CREATE TABLE "routed" (
[177]36 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[4]37 "maskbits" integer DEFAULT 128,
[325]38 "city" character varying(30) DEFAULT '',
39 "ctime" timestamp DEFAULT now()
[4]40);
41
[59]42REVOKE ALL on "routed" from PUBLIC;
43GRANT ALL on "routed" to "ipdb";
[325]44GRANT SELECT on "routed" to "ipdb";
[59]45
[4]46CREATE TABLE "temp" (
47 "ofs" integer
48);
49
[59]50REVOKE ALL on "temp" from PUBLIC;
51GRANT ALL on "temp" to "ipdb";
52
53CREATE TABLE "freeblocks" (
[185]54 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[59]55 "maskbits" integer DEFAULT 128,
56 "city" character varying(30) DEFAULT '',
[177]57 "routed" character(1) DEFAULT 'n'
[59]58);
59
60REVOKE ALL on "freeblocks" from PUBLIC;
61GRANT ALL on "freeblocks" to "ipdb";
62
[75]63CREATE TABLE "poolips" (
64 "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
[177]65 "ip" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[75]66 "custid" character varying(16) DEFAULT '' NOT NULL,
[177]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,
[286]73 "privdata" text DEFAULT '' NOT NULL,
[325]74 "newcustid" character varying(16) DEFAULT '',
75 "createstamp" timestamp DEFAULT now(),
76 "modifystamp" timestamp DEFAULT now(),
[177]77 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
[75]78);
79
80REVOKE ALL on "poolips" from PUBLIC;
81GRANT ALL on "poolips" to "ipdb";
82
83CREATE TABLE "allocations" (
[177]84 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[75]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 '',
[325]92 "createstamp" timestamp DEFAULT now(),
93 "modifystamp" timestamp DEFAULT now(),
[286]94 "privdata" text DEFAULT '' NOT NULL,
[325]95 "newcustid" character varying(16) DEFAULT '',
96 swip character(1) DEFAULT 'n'
[75]97);
98
99REVOKE ALL on "allocations" from PUBLIC;
100GRANT ALL on "allocations" to "ipdb";
101
[325]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;
[91]103
[177]104REVOKE ALL on "searchme" from PUBLIC;
105GRANT ALL on "searchme" to "ipdb";
106
[91]107CREATE TABLE "alloctypes" (
[177]108 "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
[91]109 "listname" character varying(40) DEFAULT '',
110 "dispname" character varying(40) DEFAULT '',
111 "listorder" integer DEFAULT 0,
[325]112 "def_custid" character varying(16) DEFAULT '',
113 "arin_netname" character varying(20) DEFAILT 'ISP'
[91]114);
115
[325]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
143wr CORE/WAN block CORE/WAN block 220 6750400 ISP
144pr Dynamic-route DSL netblock Dynamic-route DSL 221 ISP
145ar ATM block ATM block 222 ISP
146rm Routing Routed netblock 500 6750400 ISP
147in Internal netblock Internal netblock 990 6750400 ISP
148mm Master block Master block 999 6750400 ISP
149\.
150
[91]151REVOKE ALL on "alloctypes" from PUBLIC;
152GRANT ALL on "alloctypes" to "ipdb";
153
154CREATE TABLE "cities" (
[325]155 "id" serial NOT NULL PRIMARY KEY,
156 "city" character varying(30) DEFAULT '' NOT NULL,
[178]157 "routing" character(1) DEFAULT 'n' NOT NULL
[91]158);
159
160REVOKE ALL on "cities" from PUBLIC;
161GRANT ALL on "cities" to "ipdb";
162
[192]163--
[325]164-- Trigger and matching function to update modifystamp on allocations, poolips
[192]165--
[325]166CREATE FUNCTION up_modtime () RETURNS OPAQUE AS '
167 BEGIN
168 NEW.modifystamp := ''now'';
169 RETURN NEW;
170 END;
171' LANGUAGE 'plpgsql';
[192]172
[325]173CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations
174 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
[192]175
[325]176CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips
177 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
[192]178
179--
[242]180-- User data table - required for proper ACLs
181--
182
183CREATE TABLE "users" (
184 "username" varchar(16) NOT NULL PRIMARY KEY,
185 "password" varchar(16) DEFAULT '',
186 "acl" varchar(16) DEFAULT 'b'
187);
[325]188
189CREATE TABLE "dns" (
190 "ip" inet NOT NULL PRIMARY KEY,
191 "hostname" character varying(128),
192 "auto" character(1) DEFAULT 'y'
193);
Note: See TracBrowser for help on using the repository browser.