From 45c0fc8b54f56069b7ddf75c315f87f3ff5e8905 Mon Sep 17 00:00:00 2001 From: Sonia Zorba <sonia.zorba@inaf.it> Date: Wed, 27 Jan 2021 16:00:43 +0100 Subject: [PATCH] Added storage and location tables --- 00-init.sql | 34 +++++++++++++++++++++++----------- 05-data.sql | 13 ++++++++----- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/00-init.sql b/00-init.sql index 6292d85..625f710 100644 --- a/00-init.sql +++ b/00-init.sql @@ -33,6 +33,27 @@ CREATE TYPE NodeType AS ENUM ('container', 'data', 'link', 'structured'); CREATE TYPE LocationType AS ENUM ('async', 'portal', 'user'); CREATE TYPE StorageType AS ENUM ('cold', 'hot'); + +CREATE TABLE storage ( + storage_id SMALLSERIAL NOT NULL, + storage_type StorageType NOT NULL, + base_path VARCHAR NOT NULL, + hostname VARCHAR NOT NULL, + PRIMARY KEY (storage_id) +); + + +CREATE TABLE location ( + location_id SMALLSERIAL NOT NULL, + location_type LocationType NOT NULL, + storage_src_id SMALLINT default NULL, + storage_dest_id SMALLINT default NULL, + PRIMARY KEY (location_id), + FOREIGN KEY (storage_src_id) REFERENCES storage (storage_id), + FOREIGN KEY (storage_dest_id) REFERENCES storage (storage_id) +); + + CREATE TABLE node ( node_id BIGSERIAL NOT NULL, parent_path LTREE default NULL, @@ -67,7 +88,8 @@ CREATE TABLE node ( -- storage service mapping used to access the content of this node -- storage_id VARCHAR, protocols TEXT[] default NULL, - PRIMARY KEY (node_id) + PRIMARY KEY (node_id), + FOREIGN KEY (location_id) REFERENCES location (location_id) ); @@ -111,16 +133,6 @@ CREATE TABLE deleted_node ( ); -CREATE TABLE location ( - location_id SMALLSERIAL NOT NULL, - location_type LocationType NOT NULL, - storage_type StorageType 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, diff --git a/05-data.sql b/05-data.sql index 7463eee..0bbfe54 100644 --- a/05-data.sql +++ b/05-data.sql @@ -2,6 +2,12 @@ Initialization test for vospace node table; for now owner_id and group_id are set equal to the rap_id */ +INSERT INTO storage (storage_type, base_path, hostname) VALUES ('cold', '/ia2_tape_stb_01/users', 'tape-fe.ia2.inaf.it'); +INSERT INTO storage (storage_type, base_path, hostname) VALUES ('hot', '/home/users', 'server'); +INSERT INTO storage (storage_type, base_path, hostname) VALUES ('hot', '/home', 'localhost'); + +INSERT INTO location (location_type, storage_src_id, storage_dest_id) VALUES ('async', 1, 3); + -- parent_path = parent_relative_path INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES (NULL, NULL, '', 'container', '0', '0'); -- / INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('', '', 'curban', 'container', '3354', '3354'); -- /curban @@ -10,16 +16,13 @@ INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creat -- parent_path <> parent_relative_path INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, group_read, group_write) VALUES ('', NULL, 'test', 'container', '2386', '2386', '{"VOSpace.test1"}','{"VOSpace.test1"}'); -- /test INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id) VALUES ('5', '', 'f1', 'container', '2386', '2386'); -- /test/f1 (rel: /f1) -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) +INSERT INTO node (parent_path, parent_relative_path, name, os_name, type, owner_id, creator_id, location_id) VALUES ('5.6', '6', 'f2_renamed', 'f2', 'container', '2386', '2386', 1); -- /test/f1/f2_renamed (rel: /f1/f2) +INSERT INTO node (parent_path, parent_relative_path, name, type, owner_id, creator_id, location_id) VALUES ('5.6.7', '6.7', 'f3', 'data', '2386', '2386', 1); -- /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