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