dnet-applications/apps/dnet-exporter-api/src/main/resources/sql/community-schema.sql

77 lines
2.7 KiB
MySQL
Raw Normal View History

2023-06-12 10:59:20 +02:00
DROP TABLE IF EXISTS community_projects;
DROP TABLE IF EXISTS community_datasources;
DROP TABLE IF EXISTS community_support_orgs;
DROP TABLE IF EXISTS community_orgs;
DROP TABLE IF EXISTS communities;
2023-06-09 15:31:30 +02:00
CREATE TABLE communities (
id text PRIMARY KEY,
2023-06-19 15:47:48 +02:00
name text NOT NULL,
shortname text NOT NULL, -- in the profile is label
2023-06-12 10:59:20 +02:00
description text NOT NULL DEFAULT '',
2023-06-14 11:14:24 +02:00
status text NOT NULL DEFAULT 'hidden', -- all, manager, hidden, members
2023-06-14 11:20:28 +02:00
membership text NOT NULL DEFAULT 'by-invitation', -- open, by-invitation
2023-06-09 15:31:30 +02:00
type text NOT NULL, -- community, ri
2023-06-14 11:14:24 +02:00
claim text, -- managers-only, members-only, all
2023-06-09 15:31:30 +02:00
subjects text[],
fos text[],
sdg text[],
2023-06-12 14:30:42 +02:00
adv_constraints jsonb,
remove_constraints jsonb,
2023-06-09 15:31:30 +02:00
main_zenodo_community text,
other_zenodo_communities text[],
creation_date timestamp NOT NULL DEFAULT now(),
2023-06-19 15:47:48 +02:00
last_update timestamp NOT NULL DEFAULT now(),
2023-06-09 15:31:30 +02:00
logo_url text
);
CREATE TABLE community_projects (
community text NOT NULL REFERENCES communities(id),
project_id text NOT NULL,
project_code text NOT NULL,
project_name text NOT NULL,
project_acronym text,
project_funder text NOT NULL,
PRIMARY KEY (community, project_id)
);
CREATE TABLE community_datasources (
2023-06-19 15:47:48 +02:00
community text NOT NULL REFERENCES communities(id),
ds_id text NOT NULL,
ds_name text NOT NULL,
ds_officialname text NOT NULL,
constraints jsonb,
2023-06-09 15:31:30 +02:00
PRIMARY KEY (community, ds_id)
);
CREATE TABLE community_support_orgs (
2023-06-14 11:23:04 +02:00
community text NOT NULL REFERENCES communities(id),
2023-06-09 15:31:30 +02:00
org_name text NOT NULL,
org_url text NOT NULL,
org_logourl text NOT NULL,
PRIMARY KEY (community, org_name)
);
CREATE TABLE community_orgs (
2023-06-14 11:23:04 +02:00
community text NOT NULL REFERENCES communities(id),
2023-06-09 15:31:30 +02:00
org_id text NOT NULL,
PRIMARY KEY (community, org_id)
);
2023-06-15 14:10:39 +02:00
2023-06-19 15:47:48 +02:00
CREATE TABLE community_subs (
sub_id text NOT NULL PRIMARY KEY,
community text NOT NULL REFERENCES communities(id),
label text NOT NULL,
category text NOT NULL,
params jsonb,
parent text REFERENCES community_subs(sub_id) -- NULL for the first level
);
2023-06-15 14:10:39 +02:00
CREATE INDEX community_projects_community ON community_projects(community);
CREATE INDEX community_datasources_community ON community_datasources(community);
CREATE INDEX community_support_orgs_community ON community_support_orgs(community);
CREATE INDEX community_orgs_community ON community_orgs(community);
2023-06-20 10:48:53 +02:00
CREATE INDEX community_subs_community ON community_subs(community);
CREATE INDEX community_subs_parent ON community_subs(parent);