mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-20 02:59:20 +01:00
26 lines
699 B
SQL
26 lines
699 B
SQL
create table chats(
|
|
id uuid primary key,
|
|
created timestamp with time zone not null default now()
|
|
);
|
|
|
|
create table chat_messages(
|
|
id uuid primary key,
|
|
chat uuid not null,
|
|
sender uuid not null references users(id),
|
|
timestamp timestamp with time zone not null default now(),
|
|
text text not null,
|
|
extra jsonb
|
|
);
|
|
|
|
create index chat_messages_chat_index on chat_messages(chat);
|
|
|
|
create table chat_members(
|
|
chat uuid not null,
|
|
"user" uuid not null,
|
|
read_until uuid references chat_messages(id),
|
|
primary key(chat, "user")
|
|
);
|
|
|
|
create index chat_members_user_index on chat_members("user");
|
|
create index chat_members_chat_user_index ON chat_members(chat, "user");
|