1 | CREATE DATABASE ipdb;
|
---|
2 |
|
---|
3 | \connect ipdb ipdb
|
---|
4 |
|
---|
5 | CREATE 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 |
|
---|
22 | REVOKE ALL on "customers" from PUBLIC;
|
---|
23 | GRANT ALL on "customers" to "ipdb";
|
---|
24 |
|
---|
25 | CREATE 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 |
|
---|
31 | REVOKE ALL on "masterblocks" from PUBLIC;
|
---|
32 | GRANT ALL on "masterblocks" to "ipdb";
|
---|
33 |
|
---|
34 | CREATE 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 |
|
---|
41 | REVOKE ALL on "routed" from PUBLIC;
|
---|
42 | GRANT ALL on "routed" to "ipdb";
|
---|
43 | GRANT SELECT on "routed" to "ipdb";
|
---|
44 |
|
---|
45 | CREATE TABLE "temp" (
|
---|
46 | "ofs" integer
|
---|
47 | );
|
---|
48 |
|
---|
49 | REVOKE ALL on "temp" from PUBLIC;
|
---|
50 | GRANT ALL on "temp" to "ipdb";
|
---|
51 |
|
---|
52 | CREATE 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 |
|
---|
59 | REVOKE ALL on "freeblocks" from PUBLIC;
|
---|
60 | GRANT ALL on "freeblocks" to "ipdb";
|
---|
61 |
|
---|
62 | CREATE 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 |
|
---|
79 | REVOKE ALL on "poolips" from PUBLIC;
|
---|
80 | GRANT ALL on "poolips" to "ipdb";
|
---|
81 |
|
---|
82 | CREATE 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 |
|
---|
98 | REVOKE ALL on "allocations" from PUBLIC;
|
---|
99 | GRANT ALL on "allocations" to "ipdb";
|
---|
100 |
|
---|
101 | CREATE 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 |
|
---|
103 | REVOKE ALL on "searchme" from PUBLIC;
|
---|
104 | GRANT ALL on "searchme" to "ipdb";
|
---|
105 |
|
---|
106 | CREATE 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 |
|
---|
119 | COPY "alloctypes" FROM stdin;
|
---|
120 | cn Customer netblock Customer netblock 0 ISPCUST
|
---|
121 | si Static IP - Server pool Server pool IP 20 6750400 ISP
|
---|
122 | ci Static IP - Cable Static cable IP 21 ISP
|
---|
123 | di Static IP - DSL Static DSL IP 22 ISP
|
---|
124 | mi Static IP - Dialup Static dialup IP 23 ISP
|
---|
125 | wi Static IP - Wireless Static wireless IP 24 ISP
|
---|
126 | sd Static Pool - Servers Server pool 40 6750400 ISP
|
---|
127 | cd Static Pool - Cable Cable pool 41 CBL-BUS ISP-STATIC-CABLE
|
---|
128 | dp Static Pool - DSL DSL pool 42 DSL-BUS ISP-STATIC-DSL
|
---|
129 | mp Static Pool - Dialup Static dialup pool 43 DIAL-BUS ISP-STATIC-DIAL
|
---|
130 | wp Static Pool - Wireless Static wireless pool 44 WL-BUS ISP-STATIC-WIFI
|
---|
131 | en End-use netblock End-use netblock 100 6750400 ISP
|
---|
132 | me Dialup netblock Dialup netblock 101 DIAL-RES ISP-DIAL
|
---|
133 | de Dynamic DSL block Dynamic DSL block 102 DSL-RES ISP-DSL
|
---|
134 | ce Dynamic cable block Dynamic cable block 103 CBL-RES ISP-CABLE
|
---|
135 | we Dynamic WiFi block Dynamic WiFi block 104 WL-RES ISP-WIFI
|
---|
136 | ve Dynamic VoIP block Dynamic VoIP block 105 DYN-VOIP ISP
|
---|
137 | li Static IP - LAN/POP Static LAN/POP IP 190 6750400 ISP
|
---|
138 | ld Static Pool - LAN/POP LAN pool 191 6750400 ISP
|
---|
139 | wc Reserve for CORE/WAN blocks CORE/WAN blocks 200 6750400 ISP
|
---|
140 | pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 6750400 ISP-STATIC-DSL
|
---|
141 | ac Reserve for ATM ATM blocks 202 6750400 ISP
|
---|
142 | wr CORE/WAN block CORE/WAN block 220 6750400 ISP
|
---|
143 | pr Dynamic-route DSL netblock Dynamic-route DSL 221 ISP
|
---|
144 | ar ATM block ATM block 222 ISP
|
---|
145 | rm Routing Routed netblock 500 6750400 ISP
|
---|
146 | in Internal netblock Internal netblock 990 6750400 ISP
|
---|
147 | mm Master block Master block 999 6750400 ISP
|
---|
148 | \.
|
---|
149 |
|
---|
150 | REVOKE ALL on "alloctypes" from PUBLIC;
|
---|
151 | GRANT ALL on "alloctypes" to "ipdb";
|
---|
152 |
|
---|
153 | CREATE 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 |
|
---|
159 | REVOKE ALL on "cities" from PUBLIC;
|
---|
160 | GRANT ALL on "cities" to "ipdb";
|
---|
161 |
|
---|
162 | --
|
---|
163 | -- Trigger and matching function to update modifystamp on allocations, poolips
|
---|
164 | --
|
---|
165 | CREATE FUNCTION up_modtime () RETURNS OPAQUE AS '
|
---|
166 | BEGIN
|
---|
167 | NEW.modifystamp := ''now'';
|
---|
168 | RETURN NEW;
|
---|
169 | END;
|
---|
170 | ' LANGUAGE 'plpgsql';
|
---|
171 |
|
---|
172 | CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations
|
---|
173 | FOR EACH ROW EXECUTE PROCEDURE up_modtime();
|
---|
174 |
|
---|
175 | CREATE 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 |
|
---|
182 | CREATE TABLE "users" (
|
---|
183 | "username" varchar(16) NOT NULL PRIMARY KEY,
|
---|
184 | "password" varchar(16) DEFAULT '',
|
---|
185 | "acl" varchar(16) DEFAULT 'b'
|
---|
186 | );
|
---|
187 |
|
---|
188 | CREATE TABLE "dns" (
|
---|
189 | "ip" inet NOT NULL PRIMARY KEY,
|
---|
190 | "hostname" character varying(128),
|
---|
191 | "auto" character(1) DEFAULT 'y'
|
---|
192 | );
|
---|