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

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

/branches/stable

Merge /trunk changes up to r516

File size: 6.4 KB
RevLine 
[507]1-- Initial table setup for IP Database
[342]2
[4]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),
[325]10 "country" character(2),
[4]11 "pocode" character varying(7),
12 "phone" character varying(15),
[325]13 "tech_handle" character varying(50),
14 "abuse_handle" character varying(50),
15 "admin_handle" character varying(50),
[4]16 "def_rdns" character varying(40),
[325]17 "special" text,
[4]18 Constraint "customers_pkey" Primary Key ("custid")
19);
20
21CREATE TABLE "masterblocks" (
[325]22 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
23 "ctime" timestamp DEFAULT now(),
[364]24 "mtime" timestamp DEFAULT now(),
25 "rwhois" character(1) DEFAULT 'n' NOT NULL
[4]26);
27
28CREATE TABLE "routed" (
[177]29 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[4]30 "maskbits" integer DEFAULT 128,
[325]31 "city" character varying(30) DEFAULT '',
32 "ctime" timestamp DEFAULT now()
[4]33);
34
35CREATE TABLE "temp" (
36 "ofs" integer
37);
38
[59]39CREATE TABLE "freeblocks" (
[185]40 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[59]41 "maskbits" integer DEFAULT 128,
42 "city" character varying(30) DEFAULT '',
[177]43 "routed" character(1) DEFAULT 'n'
[59]44);
45
[75]46CREATE TABLE "poolips" (
47 "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
[177]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,
[286]55 "privdata" text DEFAULT '' NOT NULL,
[342]56 "custid" character varying(16) DEFAULT '',
[325]57 "createstamp" timestamp DEFAULT now(),
58 "modifystamp" timestamp DEFAULT now(),
[177]59 CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
[75]60);
61
62CREATE TABLE "allocations" (
[177]63 "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
[75]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 '',
[325]70 "createstamp" timestamp DEFAULT now(),
71 "modifystamp" timestamp DEFAULT now(),
[286]72 "privdata" text DEFAULT '' NOT NULL,
[342]73 "custid" character varying(16) DEFAULT '',
[325]74 swip character(1) DEFAULT 'n'
[75]75);
76
[592]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;
[91]78
79CREATE TABLE "alloctypes" (
[177]80 "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
[91]81 "listname" character varying(40) DEFAULT '',
82 "dispname" character varying(40) DEFAULT '',
83 "listorder" integer DEFAULT 0,
[325]84 "def_custid" character varying(16) DEFAULT '',
[342]85 "arin_netname" character varying(20) DEFAULT 'ISP'
[91]86);
87
[325]88--
89-- Name: alloctypes; Type: TABLE DATA; Schema: public; Owner: ipdb
90--
91
[410]92COPY alloctypes ("type", listname, dispname, listorder, def_custid, arin_netname) FROM stdin;
[325]93cn Customer netblock Customer netblock 0 ISPCUST
[410]94si Static IP - Server pool Server pool IP 20 ISP
[325]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
[445]99sd Static Pool - Servers Server pool 40 5554242 ISP
[325]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
[445]104en End-use netblock End-use netblock 100 5554242 ISP
[325]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
[353]110li Static IP - LAN/POP Static LAN/POP IP 190 NOC-VPN ISP
[410]111ai Static IP - Management Static management IP 192 NOC-VPN ISP
112bi Static IP - Wifi CPE Wifi CPE IP 193 ISP
[353]113ld Static Pool - LAN/POP LAN pool 195 NOC-VPN ISP
[363]114ad Static Pool - Management Management pool 196 NOC-VPN ISP
[410]115bd Static pool - Wifi CPE Wifi CPE pool 197 ISP
[445]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
[377]122pr Dynamic-route DSL netblock (cust) Dynamic-route DSL (cust) 221 ISPCUST
[325]123ar ATM block ATM block 222 ISP
[410]124fr Fibre Fibre 223 ISP
[445]125rm Routing Routed netblock 500 5554242 ISP
126mm Master block Master block 999 5554242 ISP
[325]127\.
128
[91]129CREATE TABLE "cities" (
[325]130 "id" serial NOT NULL PRIMARY KEY,
131 "city" character varying(30) DEFAULT '' NOT NULL,
[178]132 "routing" character(1) DEFAULT 'n' NOT NULL
[91]133);
134
[192]135--
[325]136-- Trigger and matching function to update modifystamp on allocations, poolips
[192]137--
[325]138CREATE FUNCTION up_modtime () RETURNS OPAQUE AS '
139 BEGIN
140 NEW.modifystamp := ''now'';
141 RETURN NEW;
142 END;
143' LANGUAGE 'plpgsql';
[192]144
[325]145CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations
146 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
[192]147
[325]148CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips
149 FOR EACH ROW EXECUTE PROCEDURE up_modtime();
[192]150
151--
[242]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);
[325]160
[342]161-- Default password is admin
162INSERT INTO users VALUES ('admin','luef5C4XumqIs','bacdsA');
163
[325]164CREATE TABLE "dns" (
165 "ip" inet NOT NULL PRIMARY KEY,
166 "hostname" character varying(128),
167 "auto" character(1) DEFAULT 'y'
168);
[372]169
[394]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);
[445]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.