2023-06-10 22:43:27 +00:00
|
|
|
create type public.thread_kind as enum
|
|
|
|
( 'feed'
|
|
|
|
, 'message_feed'
|
|
|
|
, 'message'
|
|
|
|
, 'post_feed'
|
|
|
|
, 'post'
|
|
|
|
, 'comment'
|
|
|
|
, 'symbolic'
|
|
|
|
);
|
|
|
|
|
|
|
|
create table public.thread
|
|
|
|
( id int not null primary key generated always as identity
|
2023-07-16 02:03:16 +00:00
|
|
|
, uid human_uuid.huid not null unique default human_uuid.huid()
|
2023-06-10 22:43:27 +00:00
|
|
|
, deleted boolean not null default false
|
|
|
|
, kind public.thread_kind not null
|
|
|
|
);
|
|
|
|
|
2023-06-11 16:26:39 +00:00
|
|
|
select audit('public', 'thread', array[] :: audited_column[], soft_delete => true);
|
|
|
|
select immutable('public', 'thread', array['id', 'uid', 'kind']);
|
2023-06-10 22:43:27 +00:00
|
|
|
|
|
|
|
create table public.thread_feed
|
2023-07-16 02:03:16 +00:00
|
|
|
( id int not null primary key generated always as identity
|
|
|
|
, uid human_uuid.huid not null unique default human_uuid.huid()
|
|
|
|
, deleted boolean not null default false
|
|
|
|
, thread int not null references public.thread(id)
|
|
|
|
-- , community int not null references public.community(id)
|
2023-06-10 22:43:27 +00:00
|
|
|
);
|
|
|
|
|
2023-06-11 16:26:39 +00:00
|
|
|
select audit('public', 'thread_feed', array[] :: audited_column[], soft_delete => true);
|
|
|
|
select immutable('public', 'thread_feed', array['id', 'uid', 'thread', 'community']);
|
2023-06-10 22:43:27 +00:00
|
|
|
|
|
|
|
create type public.thread_attachment_kind as enum
|
|
|
|
( 'vote'
|
|
|
|
, 'emoji'
|
|
|
|
);
|
|
|
|
|
|
|
|
create type public.thread_attachment_vote_direction as enum
|
|
|
|
( 'up'
|
|
|
|
, 'down'
|
|
|
|
);
|
|
|
|
|
|
|
|
create table public.thread_attachment
|
|
|
|
( id int not null primary key generated always as identity
|
2023-07-16 02:03:16 +00:00
|
|
|
, uid human_uuid.huid not null unique default human_uuid.huid()
|
2023-06-10 22:43:27 +00:00
|
|
|
, thread int not null references public.thread(id)
|
|
|
|
, kind public.thread_attachment_kind not null
|
|
|
|
);
|
|
|
|
|
2023-06-11 16:26:39 +00:00
|
|
|
select audit('public', 'thread_attachment', array[] :: audited_column[], soft_delete => true);
|
|
|
|
select immutable('public', 'thread_attachment', array['id', 'uid', 'thread', 'kind']);
|
2023-06-10 22:43:27 +00:00
|
|
|
|
|
|
|
create table public.thread_attachment_emoji
|
2023-07-16 02:03:16 +00:00
|
|
|
( id int not null primary key generated always as identity
|
|
|
|
, uid human_uuid.huid not null unique default human_uuid.huid()
|
|
|
|
, thread_attachment int not null references public.thread_attachment(id)
|
|
|
|
, emoji text not null
|
2023-06-10 22:43:27 +00:00
|
|
|
);
|
|
|
|
|
2023-06-11 16:26:39 +00:00
|
|
|
select audit('public', 'thread_attachment_emoji', array[] :: audited_column[], soft_delete => true);
|
|
|
|
select immutable('public', 'thread_attachment_emoji', array['id', 'uid', 'thread_attachment', 'emoji']);
|
2023-06-10 22:43:27 +00:00
|
|
|
|
|
|
|
create table public.thread_attachment_vote
|
|
|
|
( id int not null primary key generated always as identity
|
2023-07-16 02:03:16 +00:00
|
|
|
, uid human_uuid.huid not null unique default human_uuid.huid()
|
2023-06-10 22:43:27 +00:00
|
|
|
, thread_attachment int not null references public.thread_attachment(id)
|
|
|
|
, direction public.thread_attachment_vote_direction not null
|
|
|
|
);
|
|
|
|
|
2023-06-11 16:26:39 +00:00
|
|
|
select audit('public', 'thread_attachment_vote', array[] :: audited_column[], soft_delete => true);
|
|
|
|
select immutable('public', 'thread_attachment_vote', array['id', 'uid', 'thread_attachment', 'direction']);
|