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

Last change on this file since 592 was 592, checked in by Kris Deugau, 11 years ago

/branches/stable

Merge /trunk changes up to r516

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