From b7ae347f7efce7470dcdb1eadd8504ad50e4f6c6 Mon Sep 17 00:00:00 2001
From: Henrik Thostrup Jensen <htj@nordu.net>
Date: Thu, 18 Apr 2013 11:04:36 +0200
Subject: [PATCH] add db schema (postgres, because it is the right one)

---
 datafiles/schema.sql | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 datafiles/schema.sql

diff --git a/datafiles/schema.sql b/datafiles/schema.sql
new file mode 100644
index 00000000..bbcf000d
--- /dev/null
+++ b/datafiles/schema.sql
@@ -0,0 +1,43 @@
+-- OpenNSA SQL Schema (PostgreSQL)
+
+CREATE TYPE label AS (
+    label_type      text,
+    label_value     text
+);
+
+
+CREATE TABLE connections (
+    id                      serial                      PRIMARY KEY,
+    connection_id           text                        NOT NULL UNIQUE,
+    revision                integer                     NOT NULL,
+    global_reservation_id   text,
+    description             text,
+    state                   text                        NOT NULL,
+    nsa                     text                        NOT NULL,
+    source_network          text                        NOT NULL,
+    source_port             text                        NOT NULL,
+    source_labels           label[],
+    dest_network            text                        NOT NULL,
+    dest_port               text                        NOT NULL,
+    dest_labels             label[],
+    start_time              timestamp with time zone    NOT NULL,
+    end_time                timestamp with time zone    NOT NULL,
+    bandwidth               integer                     NOT NULL -- mbps
+);
+
+
+CREATE TABLE subconnections (
+    id                      serial                      PRIMARY KEY,
+    provider_nsa            text                        NOT NULL,
+    connection_id           integer                     NOT NULL ,
+    revision                integer                     NOT NULL,
+    parent_connection_id    integer                     NOT NULL REFERENCES connections(id),
+    source_network          text                        NOT NULL,
+    source_port             text                        NOT NULL,
+    source_labels           label[],
+    dest_network            text                        NOT NULL,
+    dest_port               text                        NOT NULL,
+    dest_labels             label[],
+    UNIQUE (provider_nsa, connection_id)
+);
+
-- 
GitLab