[658] | 1 | -- Baseline SQL to add necessary fields for IPDB 2.7 -> IPDB 3.0
|
---|
| 2 | -- Note some data changes must be made via script.
|
---|
| 3 |
|
---|
| 4 | -- WARNING: This SQL is backwards-compatible, but once db-update.pl
|
---|
| 5 | -- has run, IPDB v2.7 and older will NOT be able to properly manipulate
|
---|
| 6 | -- the data!
|
---|
| 7 |
|
---|
| 8 | -- Master and routed blocks now live in the allocations table.
|
---|
| 9 |
|
---|
| 10 | ALTER TABLE allocations ADD COLUMN vrf text NOT NULL DEFAULT '';
|
---|
[691] | 11 | ALTER TABLE allocations ADD COLUMN vlan text NOT NULL DEFAULT '';
|
---|
[658] | 12 | ALTER TABLE allocations ADD COLUMN rdns text NOT NULL DEFAULT '';
|
---|
| 13 | ALTER TABLE allocations ADD COLUMN parent_id integer NOT NULL DEFAULT 0;
|
---|
| 14 | ALTER TABLE allocations ADD COLUMN master_id integer NOT NULL DEFAULT 0;
|
---|
| 15 | ALTER TABLE allocations DROP CONSTRAINT allocations_pkey;
|
---|
| 16 | ALTER TABLE allocations ADD COLUMN id serial PRIMARY KEY;
|
---|
| 17 |
|
---|
| 18 | ALTER TABLE freeblocks ADD COLUMN vrf text NOT NULL DEFAULT '';
|
---|
| 19 | ALTER TABLE freeblocks ADD COLUMN parent_id integer NOT NULL DEFAULT 0;
|
---|
| 20 | ALTER TABLE freeblocks ADD COLUMN master_id integer NOT NULL DEFAULT 0;
|
---|
| 21 | ALTER TABLE freeblocks DROP CONSTRAINT freeblocks_pkey;
|
---|
| 22 | ALTER TABLE freeblocks ADD CONSTRAINT freeblocks_pkey PRIMARY KEY ("cidr","parent_id");
|
---|
| 23 | ALTER TABLE freeblocks ADD COLUMN id serial;
|
---|
| 24 |
|
---|
| 25 | ALTER TABLE poolips ADD COLUMN vrf text NOT NULL DEFAULT '';
|
---|
[691] | 26 | ALTER TABLE poolips ADD COLUMN vlan text NOT NULL DEFAULT '';
|
---|
[658] | 27 | ALTER TABLE poolips ADD COLUMN rdns text NOT NULL DEFAULT '';
|
---|
| 28 | ALTER TABLE poolips ADD COLUMN parent_id integer NOT NULL DEFAULT 0;
|
---|
| 29 | ALTER TABLE poolips ADD COLUMN master_id integer NOT NULL DEFAULT 0;
|
---|
| 30 | ALTER TABLE poolips DROP CONSTRAINT poolips_pkey;
|
---|
| 31 | ALTER TABLE poolips ADD COLUMN id serial;
|
---|
| 32 | ALTER TABLE poolips ADD CONSTRAINT poolips_pkey PRIMARY KEY ("ip", "parent_id");
|
---|
| 33 |
|
---|
| 34 | -- probably need some more indexes
|
---|
| 35 |
|
---|
[670] | 36 | -- Need some additional fields to support search output. Might arguably
|
---|
| 37 | -- move pool IPs into the allocations table; we'll see.
|
---|
| 38 | DROP VIEW searchme;
|
---|
| 39 | CREATE VIEW "searchme" AS
|
---|
| 40 | SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city,
|
---|
[691] | 41 | allocations.description, allocations.notes, allocations.circuitid, allocations.vrf,
|
---|
| 42 | allocations.vlan, allocations.id, allocations.parent_id, 'n' AS available
|
---|
[670] | 43 | FROM allocations
|
---|
| 44 | UNION
|
---|
| 45 | SELECT poolips.ip, poolips.custid, poolips.type, poolips.city,
|
---|
[691] | 46 | poolips.description, poolips.notes, poolips.circuitid, poolips.vrf,
|
---|
| 47 | poolips.vlan, poolips.id, poolips.parent_id, poolips.available
|
---|
[670] | 48 | FROM poolips;
|
---|
| 49 |
|
---|
[658] | 50 | -- Relabel a few types to match the new structure
|
---|
| 51 | UPDATE alloctypes SET listname='Routing aggregation', dispname='Routing aggregation' WHERE type='rm';
|
---|
| 52 |
|
---|
| 53 | -- Not critical but the previous definitions were too restrictive (eg, can't
|
---|
| 54 | -- handle MD5, or SHA password hashes). Plans for ACLs also require larger fields.
|
---|
| 55 | ALTER TABLE users ALTER COLUMN username TYPE varchar(256);
|
---|
| 56 | ALTER TABLE users ALTER COLUMN password TYPE varchar(256);
|
---|
| 57 | ALTER TABLE users ALTER COLUMN acl TYPE varchar(256);
|
---|