init
This commit is contained in:
commit
00eca2801f
18 changed files with 2837 additions and 0 deletions
38
identity/migrations/20240115015514_init.sql
Normal file
38
identity/migrations/20240115015514_init.sql
Normal 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)
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue