Schema - SilentNN/Affinity GitHub Wiki
Postgres Database Schema
users
column name | datatype | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed |
discriminator |
integer | not null |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
[:username, :discriminator], unique: true
- index on
email, unique: true
- index on
session_token, unique: true
servers
column name | datatype | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null |
owner_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
owner_id
referencesusers
- index on
owner_id
channels
column name | datatype | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null |
description |
text | |
server_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
server_id
referencesservers
- index on
server_id
messages
column name | datatype | details |
---|---|---|
id |
integer | not null, primary key |
body |
text | not null |
channel_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
channel_id
referenceschannels
- index on
channel_id, unique: true
server_members
column name | datatype | details |
---|---|---|
id |
integer | not null, primary key |
server_id |
integer | not null, indexed, foreign key |
user_id |
integer | not null, indexed, foreign key |
alias |
string | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
server_id
referencesservers
user_id
referencesusers
- index on
[:server_id, :user_id], unique: true