blob: bab0c356afc9743c518e373c45f3fb612cb9c882 [file] [log] [blame]
Sergiusz Bazanski1fad2e52019-08-01 20:16:27 +02001CREATE TABLE peers (
2 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3 asn STRING NOT NULL,
4 name STRING NOT NULL,
5 source STRING check (
6 source = 'from-peeringdb' or
7 source = 'manual'
8 ) NOT NULL,
9 UNIQUE (asn)
10);
11
12CREATE TABLE peer_routers (
13 peer_id UUID NOT NULL,
14 id UUID DEFAULT gen_random_uuid(),
15
16 v6 STRING,
17 v4 STRING,
18 source STRING check (
19 source = 'from-peeringdb' or
20 source = 'manual'
21 ) NOT NULL,
22
23 UNIQUE (v4),
24 UNIQUE (v6),
25 PRIMARY KEY (peer_id, id),
26 CONSTRAINT fk_peer FOREIGN KEY (peer_id) REFERENCES peers (id) ON DELETE CASCADE
27) INTERLEAVE IN PARENT peers (peer_id);