2020-08-25 17:17:16 +00:00
|
|
|
|
-- SCHEMA VERSION 9: 2020-08-25 --
|
2020-07-07 17:45:26 +00:00
|
|
|
|
-- Adds support for member groups.
|
2020-06-29 21:51:12 +00:00
|
|
|
|
|
|
|
|
|
create table groups (
|
|
|
|
|
id int primary key generated always as identity,
|
|
|
|
|
hid char(5) unique not null,
|
|
|
|
|
system int not null references systems(id) on delete cascade,
|
2020-07-07 17:45:26 +00:00
|
|
|
|
|
2020-06-29 21:51:12 +00:00
|
|
|
|
name text not null,
|
2020-08-20 19:43:17 +00:00
|
|
|
|
display_name text,
|
2020-06-29 21:51:12 +00:00
|
|
|
|
description text,
|
2020-07-07 17:45:26 +00:00
|
|
|
|
icon text,
|
|
|
|
|
|
|
|
|
|
-- Description columns follow the same pattern as usual: 1 = public, 2 = private
|
|
|
|
|
description_privacy integer check (description_privacy in (1, 2)) not null default 1,
|
|
|
|
|
icon_privacy integer check (icon_privacy in (1, 2)) not null default 1,
|
2020-08-20 19:43:17 +00:00
|
|
|
|
list_privacy integer check (list_privacy in (1, 2)) not null default 1,
|
2020-07-07 17:45:26 +00:00
|
|
|
|
visibility integer check (visibility in (1, 2)) not null default 1,
|
|
|
|
|
|
2020-06-29 21:51:12 +00:00
|
|
|
|
created timestamp with time zone not null default (current_timestamp at time zone 'utc')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create table group_members (
|
|
|
|
|
group_id int not null references groups(id) on delete cascade,
|
2020-08-16 10:10:54 +00:00
|
|
|
|
member_id int not null references members(id) on delete cascade,
|
|
|
|
|
primary key (group_id, member_id)
|
2020-06-29 21:51:12 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-08-21 15:08:49 +00:00
|
|
|
|
alter table systems add column group_list_privacy integer check (group_list_privacy in (1, 2)) not null default 1;
|
|
|
|
|
update systems set group_list_privacy = member_list_privacy;
|
2020-08-20 19:43:17 +00:00
|
|
|
|
|
2020-06-29 21:51:12 +00:00
|
|
|
|
update info set schema_version = 9;
|