[181] | 1 | CREATE DATABASE ipdb;
|
---|
[4] | 2 |
|
---|
[176] | 3 | \connect ipdb ipdb
|
---|
[4] | 4 |
|
---|
| 5 | CREATE TABLE "customers" (
|
---|
[329] | 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 ''
|
---|
[4] | 20 | );
|
---|
| 21 |
|
---|
[34] | 22 | REVOKE ALL on "customers" from PUBLIC;
|
---|
| 23 | GRANT ALL on "customers" to "ipdb";
|
---|
| 24 |
|
---|
[4] | 25 | CREATE TABLE "masterblocks" (
|
---|
[219] | 26 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[324] | 27 | "ctime" timestamp DEFAULT now(),
|
---|
| 28 | "mtime" timestamp DEFAULT now()
|
---|
[4] | 29 | );
|
---|
| 30 |
|
---|
[34] | 31 | REVOKE ALL on "masterblocks" from PUBLIC;
|
---|
| 32 | GRANT ALL on "masterblocks" to "ipdb";
|
---|
| 33 |
|
---|
[4] | 34 | CREATE TABLE "routed" (
|
---|
[176] | 35 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[4] | 36 | "maskbits" integer DEFAULT 128,
|
---|
[219] | 37 | "city" character varying(30) DEFAULT '',
|
---|
| 38 | "ctime" timestamp DEFAULT now()
|
---|
[4] | 39 | );
|
---|
| 40 |
|
---|
[34] | 41 | REVOKE ALL on "routed" from PUBLIC;
|
---|
| 42 | GRANT ALL on "routed" to "ipdb";
|
---|
[316] | 43 | GRANT SELECT on "routed" to "ipdb";
|
---|
[34] | 44 |
|
---|
[4] | 45 | CREATE TABLE "temp" (
|
---|
| 46 | "ofs" integer
|
---|
| 47 | );
|
---|
| 48 |
|
---|
[34] | 49 | REVOKE ALL on "temp" from PUBLIC;
|
---|
| 50 | GRANT ALL on "temp" to "ipdb";
|
---|
| 51 |
|
---|
[57] | 52 | CREATE TABLE "freeblocks" (
|
---|
[180] | 53 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[57] | 54 | "maskbits" integer DEFAULT 128,
|
---|
| 55 | "city" character varying(30) DEFAULT '',
|
---|
[176] | 56 | "routed" character(1) DEFAULT 'n'
|
---|
[34] | 57 | );
|
---|
| 58 |
|
---|
[57] | 59 | REVOKE ALL on "freeblocks" from PUBLIC;
|
---|
| 60 | GRANT ALL on "freeblocks" to "ipdb";
|
---|
[34] | 61 |
|
---|
[74] | 62 | CREATE TABLE "poolips" (
|
---|
| 63 | "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
|
---|
[176] | 64 | "ip" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[74] | 65 | "custid" character varying(16) DEFAULT '' NOT NULL,
|
---|
[175] | 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,
|
---|
[284] | 72 | "privdata" text DEFAULT '' NOT NULL,
|
---|
[316] | 73 | "newcustid" character varying(16) DEFAULT '',
|
---|
[218] | 74 | "createstamp" timestamp DEFAULT now(),
|
---|
| 75 | "modifystamp" timestamp DEFAULT now(),
|
---|
[176] | 76 | CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
|
---|
[74] | 77 | );
|
---|
| 78 |
|
---|
| 79 | REVOKE ALL on "poolips" from PUBLIC;
|
---|
| 80 | GRANT ALL on "poolips" to "ipdb";
|
---|
| 81 |
|
---|
| 82 | CREATE TABLE "allocations" (
|
---|
[176] | 83 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[74] | 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 '',
|
---|
[218] | 91 | "createstamp" timestamp DEFAULT now(),
|
---|
| 92 | "modifystamp" timestamp DEFAULT now(),
|
---|
[284] | 93 | "privdata" text DEFAULT '' NOT NULL,
|
---|
[316] | 94 | "newcustid" character varying(16) DEFAULT '',
|
---|
| 95 | swip character(1) DEFAULT 'n'
|
---|
[74] | 96 | );
|
---|
| 97 |
|
---|
| 98 | REVOKE ALL on "allocations" from PUBLIC;
|
---|
| 99 | GRANT ALL on "allocations" to "ipdb";
|
---|
| 100 |
|
---|
[285] | 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;
|
---|
[92] | 102 |
|
---|
[176] | 103 | REVOKE ALL on "searchme" from PUBLIC;
|
---|
| 104 | GRANT ALL on "searchme" to "ipdb";
|
---|
| 105 |
|
---|
[92] | 106 | CREATE TABLE "alloctypes" (
|
---|
[176] | 107 | "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
|
---|
[92] | 108 | "listname" character varying(40) DEFAULT '',
|
---|
| 109 | "dispname" character varying(40) DEFAULT '',
|
---|
| 110 | "listorder" integer DEFAULT 0,
|
---|
[324] | 111 | "def_custid" character varying(16) DEFAULT '',
|
---|
| 112 | "arin_netname" character varying(20) DEFAILT 'ISP'
|
---|
[92] | 113 | );
|
---|
| 114 |
|
---|
[321] | 115 | --
|
---|
| 116 | -- Name: alloctypes; Type: TABLE DATA; Schema: public; Owner: ipdb
|
---|
| 117 | --
|
---|
| 118 |
|
---|
[324] | 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
|
---|
[182] | 148 | \.
|
---|
[218] | 149 |
|
---|
[316] | 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 |
|
---|
[218] | 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();
|
---|
[233] | 177 |
|
---|
| 178 | --
|
---|
| 179 | -- User data table - required for proper ACLs
|
---|
| 180 | --
|
---|
| 181 |
|
---|
| 182 | CREATE TABLE "users" (
|
---|
[237] | 183 | "username" varchar(16) NOT NULL PRIMARY KEY,
|
---|
[233] | 184 | "password" varchar(16) DEFAULT '',
|
---|
| 185 | "acl" varchar(16) DEFAULT 'b'
|
---|
| 186 | );
|
---|
[257] | 187 |
|
---|
| 188 | CREATE TABLE "dns" (
|
---|
| 189 | "ip" inet NOT NULL PRIMARY KEY,
|
---|
| 190 | "hostname" character varying(128),
|
---|
| 191 | "auto" character(1) DEFAULT 'y'
|
---|
| 192 | );
|
---|