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