partial implementation

This commit is contained in:
Michele Artini 2024-09-25 15:51:20 +02:00
parent 8b7cc375fe
commit f4f3ed1d24
2 changed files with 32 additions and 16 deletions

View File

@ -0,0 +1,13 @@
-- ADD FIELDS
-- parent text REFERENCES communities(id) ON DELETE CASCADE, -- NULL for the main community
-- claimable boolean NOT NULL DEFAULT false, -- spcefici for sub-communities
-- ...
-- MISSING CASCADE
community_projects
community_datasources
community_support_orgs
community_orgs
CREATE INDEX community_parent ON communities(parent);

View File

@ -7,6 +7,10 @@ DROP TABLE IF EXISTS communities;
CREATE TABLE communities (
id text PRIMARY KEY,
parent text REFERENCES communities(id) ON DELETE CASCADE, -- NULL for the main community
claimable boolean NOT NULL DEFAULT false, -- spceficic for sub-communities
name text NOT NULL,
shortname text NOT NULL, -- in the profile is label
displayname text,
@ -31,7 +35,7 @@ CREATE TABLE communities (
);
CREATE TABLE community_projects (
community text NOT NULL REFERENCES communities(id),
community text NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
project_id text NOT NULL,
project_code text NOT NULL,
project_name text NOT NULL,
@ -42,7 +46,7 @@ CREATE TABLE community_projects (
);
CREATE TABLE community_datasources (
community text NOT NULL REFERENCES communities(id),
community text NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
ds_id text NOT NULL,
ds_name text NOT NULL,
ds_officialname text NOT NULL,
@ -54,7 +58,7 @@ CREATE TABLE community_datasources (
);
CREATE TABLE community_support_orgs (
community text NOT NULL REFERENCES communities(id),
community text NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
org_name text NOT NULL,
org_url text NOT NULL,
org_logourl text NOT NULL,
@ -62,26 +66,25 @@ CREATE TABLE community_support_orgs (
);
CREATE TABLE community_orgs (
community text NOT NULL REFERENCES communities(id),
community text NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
org_id text NOT NULL,
PRIMARY KEY (community, org_id)
);
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,
claim boolean NOT NULL DEFAULT false,
browsable boolean NOT NULL DEFAULT false,
params jsonb,
parent text REFERENCES community_subs(sub_id) -- NULL for the first level
);
--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,
-- claim boolean NOT NULL DEFAULT false,
-- browsable boolean NOT NULL DEFAULT false,
-- params jsonb,
-- parent text REFERENCES community_subs(sub_id) -- NULL for the first level
--);
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);
CREATE INDEX community_subs_community ON community_subs(community);
CREATE INDEX community_subs_parent ON community_subs(parent);
CREATE INDEX community_parent ON communities(parent);