From 862a66e7d0e1e15a8d18088b9fe1b7c6cfa0f202 Mon Sep 17 00:00:00 2001
From: Cristiano Urban <cristiano.urban@inaf.it>
Date: Wed, 27 Jan 2021 11:33:16 +0100
Subject: [PATCH] Removed 'location_type', added 'location_id' which points to
 'location' + modified 'LocationType' enum.

Signed-off-by: Cristiano Urban <cristiano.urban@inaf.it>
---
 00-init.sql | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/00-init.sql b/00-init.sql
index f429509..c1f3964 100644
--- a/00-init.sql
+++ b/00-init.sql
@@ -30,7 +30,7 @@
 CREATE EXTENSION IF NOT EXISTS ltree;
 
 CREATE TYPE NodeType AS ENUM ('container', 'data', 'link', 'structured');
-CREATE TYPE LocationType AS ENUM ('virtual', 'tape', 'user', 'LBT');
+CREATE TYPE LocationType AS ENUM ('async', 'user', 'portal');
 
 CREATE TABLE node (
     node_id                BIGSERIAL     NOT NULL,
@@ -40,7 +40,7 @@ CREATE TABLE node (
     os_name                VARCHAR       default NULL,
     tstamp_wrapper_dir     VARCHAR       default NULL,
     type                   NodeType      NOT NULL,
-    location_type          LocationType  default 'virtual',
+    location_id            SMALLINT      NOT NULL,
     format                 VARCHAR       default NULL,
     -- format is used to distinguish between unstuctured (format=NULL) and structured nodes having a well defined format
     async_trans            BOOLEAN       default false,
@@ -78,7 +78,7 @@ CREATE TABLE deleted_node (
     os_name                VARCHAR       default NULL,
     tstamp_wrapper_dir     VARCHAR       default NULL,
     type                   NodeType      NOT NULL,
-    location_type          LocationType  default NULL,
+    location_id            SMALLINT      NOT NULL,
     format                 VARCHAR       default NULL,
     -- format is used to distinguish between unstuctured (format=NULL) and structured nodes having a well defined format
     async_trans            BOOLEAN       default NULL,
@@ -110,6 +110,15 @@ CREATE TABLE deleted_node (
 );
 
 
+CREATE TABLE location (
+    location_id       SMALLSERIAL   NOT NULL,
+    location_type     LocationType  NOT NULL,
+    base_path         VARCHAR       NOT NULL,
+    hostname          VARCHAR       NOT NULL,
+    PRIMARY KEY (location_id)
+);
+
+
 CREATE TABLE users (
     rap_id            VARCHAR       NOT NULL,
     user_name         VARCHAR       NOT NULL,
-- 
GitLab