Skip to content
Snippets Groups Projects
Commit 41af4c2f authored by Sara Bertocco's avatar Sara Bertocco
Browse files

Database init updated

parent 4d4ed668
No related branches found
No related tags found
No related merge requests found
/**_____________________________________________________________________________
*
* OATS - INAF
* Osservatorio Astronomico di Tireste - Istituto Nazionale di Astrofisica
* Astronomical Observatory of Trieste - National Institute for Astrophysics
* ____________________________________________________________________________
*
* Copyright (C) 2020 Istituto Nazionale di Astrofisica
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* _____________________________________________________________________________
**/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: bertocco
* Created: Sep 17, 2020
VOSpace front-end
*/
CREATE EXTENSION IF NOT EXISTS ltree;
CREATE TABLE node (
id BIGSERIAL PRIMARY KEY,
ivo_id text NOT NULL,
name text NOT NULL,
type text NOT NULL,
format text NOT NULL,
/* format e` per distinguere unstuctured (format=NULL da structured che hanno
un formato noto)
*/
asyncTrans boolean NOT NULL,
/* asyncTransf serve per indicare se il nodo e` ospitato da un cold storage e
deve essere necessariamente trasferito con un trasferimento asincrono */
busyState CHAR(1) NOT NULL,
ownerID INT NOT NULL,
creatorID INT NOT NULL,
groupRead text default NULL,
groupWrite text default NULL,
isPublic CHAR(1) NOT NULL default 'Y',
CREATE TYPE NodeType AS ENUM ('container', 'data', 'link');
CREATE TYPE LocationType AS ENUM ('virtual', 'tape', 'user', 'LBT');
CREATE TABLE Node (
node_id BIGSERIAL NOT NULL,
parent_path LTREE default NULL,
parent_relative_path LTREE default NULL,
name VARCHAR NOT NULL,
os_name VARCHAR default NULL,
tstamp_wrapper_dir VARCHAR default NULL,
type NodeType NOT NULL,
location_type LocationType default NULL,
format VARCHAR default NULL,
-- format serve per distinguere unstuctured (format=NULL) da structured che hanno un formato noto
async_trans BOOLEAN default NULL,
-- async_trans serve per indicare se il nodo e` ospitato da un cold storage e deve essere necessariamente
-- trasferito con un trasferimento asincrono
busy_state BOOLEAN default NULL,
owner_id VARCHAR default NULL,
creator_id VARCHAR default NULL,
group_read VARCHAR[] default NULL,
group_write VARCHAR[] default NULL,
is_public BOOLEAN default NULL,
delta BIGINT default NULL,
/* potrebbe essere un delta di dati trasferito durante un trasferimento asincrono.
Dovrebbe stare sul servizio che fa il trasferimento (es. redis) */
contentType VARCHAR(100) default NULL,
contentEncoding VARCHAR(50) default NULL,
contentLength BIGINT default NULL,
contentMD5 VARCHAR(256) default NULL,
creationDate timestamp NOT NULL DEFAULT NOW(),
lastModification timestamp NOT NULL DEFAULT NOW(),
/*
link TEXT default NULL,
*/
acceptViews TEXT[],
provideViews TEXT[],
/*
storageID VARCHAR(256),
serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo */
protocols TEXT[],
path ltree NOT NULL
/*
is_leaf boolean,
*/
content_type VARCHAR default NULL,
content_encoding VARCHAR default NULL,
content_length BIGINT default NULL,
content_md5 TEXT default NULL,
created_on TIMESTAMP default CURRENT_TIMESTAMP,
last_modified TIMESTAMP default NULL,
-- link TEXT default NULL,
accept_views TEXT[] default NULL,
provide_views TEXT[] default NULL,
-- serve per mappare il nome del servizio di storage da interrogare per accedere al contenuto di questo nodo
-- storage_id VARCHAR,
protocols TEXT[] default NULL,
PRIMARY KEY (node_id)
);
CONSTRAINT ivo_id_unique UNIQUE (ivo_id)
CREATE TABLE NodeProperty (
node_id BIGSERIAL,
property_uri VARCHAR NOT NULL,
property_value VARCHAR default NULL,
last_modified TIMESTAMP default CURRENT_TIMESTAMP,
-- support replication with a fake primary key
-- _rep_support BIGINT NOT NULL PRIMARY KEY,
foreign key (node_id) references Node (node_id)
);
CREATE TABLE DeletedNode (
node_id BIGSERIAL NOT NULL,
name VARCHAR NOT NULL,
owner_id VARCHAR NOT NULL,
last_modified TIMESTAMP default CURRENT_TIMESTAMP,
PRIMARY KEY (node_id)
);
CREATE TABLE Users (
rap_id VARCHAR NOT NULL,
user_name VARCHAR NOT NULL,
e_mail VARCHAR NOT NULL,
PRIMARY KEY (rap_id)
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment