From 40c125b12a7ea7048cdb14c0bba0507a7da07567 Mon Sep 17 00:00:00 2001
From: Cristiano Urban <cristiano.urban@inaf.it>
Date: Wed, 27 Jan 2021 14:25:50 +0100
Subject: [PATCH] Added 'storage_type' + added initializations for 'location'
 table.

Signed-off-by: Cristiano Urban <cristiano.urban@inaf.it>
---
 00-init.sql | 6 ++++--
 05-data.sql | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/00-init.sql b/00-init.sql
index 0f8e43d..6292d85 100644
--- a/00-init.sql
+++ b/00-init.sql
@@ -30,7 +30,8 @@
 CREATE EXTENSION IF NOT EXISTS ltree;
 
 CREATE TYPE NodeType AS ENUM ('container', 'data', 'link', 'structured');
-CREATE TYPE LocationType AS ENUM ('async', 'user', 'portal');
+CREATE TYPE LocationType AS ENUM ('async', 'portal', 'user');
+CREATE TYPE StorageType AS ENUM ('cold', 'hot');
 
 CREATE TABLE node (
     node_id                BIGSERIAL     NOT NULL,
@@ -112,7 +113,8 @@ CREATE TABLE deleted_node (
 
 CREATE TABLE location (
     location_id       SMALLSERIAL   NOT NULL,
-    location_type     LocationType  default NULL,
+    location_type     LocationType  NOT NULL,
+    storage_type      StorageType   NOT NULL,
     base_path         VARCHAR       NOT NULL,
     hostname          VARCHAR       NOT NULL,
     PRIMARY KEY (location_id)
diff --git a/05-data.sql b/05-data.sql
index 85a8d1e..7463eee 100644
--- a/05-data.sql
+++ b/05-data.sql
@@ -13,6 +13,13 @@ INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creat
 INSERT INTO node (parent_path, parent_relative_path, name, os_name, type, owner_id, creator_id) VALUES ('5.6', '6', 'f2_renamed', 'f2', 'container', '2386', '2386');                                                 -- /test/f1/f2_renamed (rel: /f1/f2)
 INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('5.6.7', '6.7', 'f3', 'data', '2386', '2386');                                                                         -- /test/f1/f2_renamed/f3 (rel: /f1/f2/f3)
 
+/*
+   Initialization test for location table
+*/
+
+INSERT INTO location (location_type, storage_type, base_path, hostname) VALUES ('async', 'cold', '/ia2_tape_stb_01/users', 'tape-fe.ia2.inaf.it');
+INSERT INTO location (location_type, storage_type, base_path, hostname) VALUES ('async', 'hot', '/home/users', 'server');
+
 /*
    Initialization test for vospace users table
 */
-- 
GitLab