This commit is contained in:
sam 2024-01-15 16:39:31 +01:00
commit 00eca2801f
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
18 changed files with 2837 additions and 0 deletions

View file

@ -0,0 +1,38 @@
create type account_role as enum ('user', 'admin');
create table accounts (
id text primary key,
username text not null,
email text not null,
password text not null, -- Hashed + salted password
role account_role not null default 'user',
avatar text null -- Avatar hash
);
create unique index users_username_idx on accounts (lower(username));
create type instance_status as enum ('active', 'suspended');
create table chat_instances (
id text primary key,
domain text not null unique,
public_key text not null,
status instance_status not null default 'active',
reason text
);
create table chat_instance_accounts (
account_id text not null references accounts (id) on delete cascade,
chat_instance_id text not null references chat_instances (id) on delete cascade,
primary key (account_id, chat_instance_id)
);
create table instance (
id integer not null primary key default 1,
public_key text not null,
private_key text not null,
constraint singleton check (id = 1)
);