[181] | 1 | CREATE DATABASE ipdb;
|
---|
[4] | 2 |
|
---|
[176] | 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),
|
---|
| 12 | "pocode" character varying(7),
|
---|
| 13 | "phone" character varying(15),
|
---|
| 14 | "abuse" character varying(50),
|
---|
| 15 | "def_rdns" character varying(40),
|
---|
| 16 | "description" text,
|
---|
| 17 | Constraint "customers_pkey" Primary Key ("custid")
|
---|
| 18 | );
|
---|
| 19 |
|
---|
[34] | 20 | REVOKE ALL on "customers" from PUBLIC;
|
---|
[57] | 21 | GRANT ALL on "customers" to "kdeugau";
|
---|
[34] | 22 | GRANT ALL on "customers" to "ipdb";
|
---|
| 23 |
|
---|
[4] | 24 | CREATE TABLE "masterblocks" (
|
---|
[219] | 25 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
| 26 | "ctime" timestamp DEFAULT now()
|
---|
[4] | 27 | );
|
---|
| 28 |
|
---|
[34] | 29 | REVOKE ALL on "masterblocks" from PUBLIC;
|
---|
[57] | 30 | GRANT ALL on "masterblocks" to "kdeugau";
|
---|
[34] | 31 | GRANT ALL on "masterblocks" to "ipdb";
|
---|
| 32 |
|
---|
[4] | 33 | CREATE TABLE "routed" (
|
---|
[176] | 34 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[4] | 35 | "maskbits" integer DEFAULT 128,
|
---|
[219] | 36 | "city" character varying(30) DEFAULT '',
|
---|
| 37 | "ctime" timestamp DEFAULT now()
|
---|
[4] | 38 | );
|
---|
| 39 |
|
---|
[34] | 40 | REVOKE ALL on "routed" from PUBLIC;
|
---|
[57] | 41 | GRANT ALL on "routed" to "kdeugau";
|
---|
[34] | 42 | GRANT ALL on "routed" to "ipdb";
|
---|
| 43 |
|
---|
[4] | 44 | CREATE TABLE "temp" (
|
---|
| 45 | "ofs" integer
|
---|
| 46 | );
|
---|
| 47 |
|
---|
[34] | 48 | REVOKE ALL on "temp" from PUBLIC;
|
---|
[57] | 49 | GRANT ALL on "temp" to "kdeugau";
|
---|
[34] | 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 "kdeugau";
|
---|
| 61 | GRANT ALL on "freeblocks" to "ipdb";
|
---|
[34] | 62 |
|
---|
[74] | 63 | CREATE TABLE "poolips" (
|
---|
| 64 | "pool" cidr DEFAULT '255.255.255.255/32' NOT NULL,
|
---|
[176] | 65 | "ip" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[74] | 66 | "custid" character varying(16) DEFAULT '' NOT NULL,
|
---|
[175] | 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,
|
---|
[284] | 73 | "privdata" text DEFAULT '' NOT NULL,
|
---|
[175] | 74 | "newcustid" integer,
|
---|
[218] | 75 | "createstamp" timestamp DEFAULT now(),
|
---|
| 76 | "modifystamp" timestamp DEFAULT now(),
|
---|
[176] | 77 | CHECK (((available = 'y'::bpchar) OR (available = 'n'::bpchar)))
|
---|
[74] | 78 | );
|
---|
| 79 |
|
---|
| 80 | REVOKE ALL on "poolips" from PUBLIC;
|
---|
| 81 | GRANT ALL on "poolips" to "kdeugau";
|
---|
| 82 | GRANT ALL on "poolips" to "ipdb";
|
---|
| 83 |
|
---|
| 84 | CREATE TABLE "allocations" (
|
---|
[176] | 85 | "cidr" cidr DEFAULT '255.255.255.255/32' NOT NULL PRIMARY KEY,
|
---|
[74] | 86 | "custid" character varying(16) DEFAULT '',
|
---|
| 87 | "type" character(2) DEFAULT '',
|
---|
| 88 | "city" character varying(30) DEFAULT '',
|
---|
| 89 | "description" character varying(64) DEFAULT '',
|
---|
| 90 | "notes" text DEFAULT '',
|
---|
| 91 | "maskbits" integer DEFAULT 128,
|
---|
| 92 | "circuitid" character varying(128) DEFAULT '',
|
---|
[218] | 93 | "createstamp" timestamp DEFAULT now(),
|
---|
| 94 | "modifystamp" timestamp DEFAULT now(),
|
---|
[284] | 95 | "privdata" text DEFAULT '' NOT NULL,
|
---|
[176] | 96 | "newcustid" integer
|
---|
[74] | 97 | );
|
---|
| 98 |
|
---|
| 99 | REVOKE ALL on "allocations" from PUBLIC;
|
---|
| 100 | GRANT ALL on "allocations" to "kdeugau";
|
---|
| 101 | GRANT ALL on "allocations" to "ipdb";
|
---|
| 102 |
|
---|
[176] | 103 | CREATE VIEW "searchme" as SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city, allocations.description FROM allocations UNION SELECT poolips.ip, poolips.custid, poolips.type, poolips.city, poolips.description FROM poolips;
|
---|
[92] | 104 |
|
---|
[176] | 105 | REVOKE ALL on "searchme" from PUBLIC;
|
---|
| 106 | GRANT ALL on "searchme" to "kdeugau";
|
---|
| 107 | GRANT ALL on "searchme" to "ipdb";
|
---|
| 108 |
|
---|
[92] | 109 | CREATE TABLE "alloctypes" (
|
---|
[176] | 110 | "type" character(2) DEFAULT '' NOT NULL PRIMARY KEY,
|
---|
[92] | 111 | "listname" character varying(40) DEFAULT '',
|
---|
| 112 | "dispname" character varying(40) DEFAULT '',
|
---|
| 113 | "listorder" integer DEFAULT 0,
|
---|
[176] | 114 | "def_custid" character varying(16) DEFAULT ''
|
---|
[92] | 115 | );
|
---|
| 116 |
|
---|
| 117 | REVOKE ALL on "alloctypes" from PUBLIC;
|
---|
| 118 | GRANT ALL on "alloctypes" to "kdeugau";
|
---|
| 119 | GRANT ALL on "alloctypes" to "ipdb";
|
---|
| 120 |
|
---|
| 121 | CREATE TABLE "cities" (
|
---|
[257] | 122 | "id" serial NOT NULL PRIMARY KEY,
|
---|
| 123 | "city" character varying(30) DEFAULT '' NOT NULL,
|
---|
[179] | 124 | "routing" character(1) DEFAULT 'n' NOT NULL
|
---|
[92] | 125 | );
|
---|
| 126 |
|
---|
| 127 | REVOKE ALL on "cities" from PUBLIC;
|
---|
| 128 | GRANT ALL on "cities" to "kdeugau";
|
---|
| 129 | GRANT ALL on "cities" to "ipdb";
|
---|
| 130 |
|
---|
[189] | 131 | CREATE TABLE "alloctypes" (
|
---|
| 132 | "type" character(2) DEFAULT '' NOT NULL,
|
---|
| 133 | "listname" character varying(40) DEFAULT '',
|
---|
| 134 | "dispname" character varying(40) DEFAULT '',
|
---|
| 135 | "listorder" integer DEFAULT 0,
|
---|
| 136 | "def_custid" character varying(16) DEFAULT '',
|
---|
| 137 | Constraint "alloctypes_pkey" Primary Key ("type")
|
---|
| 138 | );
|
---|
| 139 |
|
---|
| 140 | REVOKE ALL on "alloctypes" from PUBLIC;
|
---|
| 141 | GRANT ALL on "alloctypes" to "kdeugau";
|
---|
| 142 | GRANT ALL on "alloctypes" to "ipdb";
|
---|
| 143 |
|
---|
[182] | 144 | COPY "alloctypes" FROM stdin;
|
---|
| 145 | cd Static Pool - Cable Cable pool 41 CBL-BUS
|
---|
| 146 | dp Static Pool - DSL DSL pool 42 DSL-BUS
|
---|
| 147 | mp Static Pool - Dialup Static dialup pool 43 DIAL-BUS
|
---|
| 148 | wp Static Pool - Wireless Static wireless pool 44 WL-BUS
|
---|
| 149 | mm Master block Master block 999 6750400
|
---|
| 150 | in Internal netblock Internal netblock 990 6750400
|
---|
| 151 | sd Static Pool - Servers Server pool 40 6750400
|
---|
| 152 | cn Customer netblock Customer netblock 0
|
---|
| 153 | ci Static IP - Cable Static cable IP 21
|
---|
| 154 | di Static IP - DSL Static DSL IP 22
|
---|
| 155 | mi Static IP - Dialup Static dialup IP 23
|
---|
| 156 | wi Static IP - Wireless Static wireless IP 24
|
---|
| 157 | si Static IP - Server pool Server pool IP 20 6750400
|
---|
[187] | 158 | wc Reserve for WAN blocks WAN IP blocks 200 6750400
|
---|
[189] | 159 | en End-use netblock End-use netblock 100 6750400
|
---|
| 160 | me Dialup netblock Dialup netblock 101 DIAL-RES
|
---|
| 161 | de Dynamic DSL block Dynamic DSL block 102 DSL-RES
|
---|
| 162 | ce Dynamic cable block Dynamic cable block 103 CBL-RES
|
---|
| 163 | we Dynamic WiFi block Dynamic WiFi block 104 WL-RES
|
---|
| 164 | rm Routing Routed netblock 500 6750400
|
---|
[257] | 165 | pc Reserve for dynamic-route DSL netblocks Dynamic-route netblocks 201 6750400
|
---|
| 166 | pr Dynamic-route DSL netblock Dynamic-route DSL 221
|
---|
| 167 | wr WAN block WAN block 220 6750400
|
---|
[182] | 168 | \.
|
---|
[218] | 169 |
|
---|
| 170 | --
|
---|
| 171 | -- Trigger and matching function to update modifystamp on allocations, poolips
|
---|
| 172 | --
|
---|
| 173 | CREATE FUNCTION up_modtime () RETURNS OPAQUE AS '
|
---|
| 174 | BEGIN
|
---|
| 175 | NEW.modifystamp := ''now'';
|
---|
| 176 | RETURN NEW;
|
---|
| 177 | END;
|
---|
| 178 | ' LANGUAGE 'plpgsql';
|
---|
| 179 |
|
---|
| 180 | CREATE TRIGGER up_modtime BEFORE UPDATE ON allocations
|
---|
| 181 | FOR EACH ROW EXECUTE PROCEDURE up_modtime();
|
---|
| 182 |
|
---|
| 183 | CREATE TRIGGER up_modtime BEFORE UPDATE ON poolips
|
---|
| 184 | FOR EACH ROW EXECUTE PROCEDURE up_modtime();
|
---|
[233] | 185 |
|
---|
| 186 | --
|
---|
| 187 | -- User data table - required for proper ACLs
|
---|
| 188 | --
|
---|
| 189 |
|
---|
| 190 | CREATE TABLE "users" (
|
---|
[237] | 191 | "username" varchar(16) NOT NULL PRIMARY KEY,
|
---|
[233] | 192 | "password" varchar(16) DEFAULT '',
|
---|
| 193 | "acl" varchar(16) DEFAULT 'b'
|
---|
| 194 | );
|
---|
[257] | 195 |
|
---|
| 196 | CREATE TABLE "dns" (
|
---|
| 197 | "ip" inet NOT NULL PRIMARY KEY,
|
---|
| 198 | "hostname" character varying(128),
|
---|
| 199 | "auto" character(1) DEFAULT 'y'
|
---|
| 200 | );
|
---|