-
Notifications
You must be signed in to change notification settings - Fork 8
schema
Phillip edited this page Dec 16, 2019
·
9 revisions
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
string | username | not null |
integer | tag | not null |
string | not null | |
string | password_digest | not null |
string | session_token | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
- index on
[username, tag], unique: true
- index on
email, unique: true
- index on
session_token, unique: true
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | owner_id | not null, foreign key |
string | name | not null |
text | description | not null |
boolean | is_private | not null, default: false |
string | invite_token | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
owner_id
referencesusers
- index on
owner_id
-
invite_token
is used for a permanent invitation link - index on
invite_token, unique: true
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
integer | user_id | not null, foreign key |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
-
user_id
referencesusers
- index on
[user_id, server_id], unique: true
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
string | name | not null |
text | description | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
- index on
server_id
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | author_id | not null, foreign key |
integer | thread_id | not null, foreign key |
string | thread_type | not null |
text | body | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
author_id
referencesusers
-
thread
represents a polymorphic association between messages andchannels
/dm_threads
- index on
author_id
- index on
[thread_id, thread_type]
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
datetime | created_at | not null |
datetime | updated_at | not null |
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | dm_thread_id | not null, foreign key |
integer | member_id | not null, foreign key |
datetime | created_at | not null |
datetime | updated_at | not null |
-
member_id
referencesusers
-
dm_thread_id
referencesdm_threads
- index on
member_id
- index on
dm_thread_id
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
integer | invitee_id | foreign key |
string | token | not null |
datetime | expiry | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
-
invitee_id
referencesusers
- index on
[invitee_id, server_id], unique: true
- index on
token, unique: true
- used for temporary invitations
- invitee_id used for private invitations; allow null for general invitations
-
servers#is_private
won't come into play until private servers are introduced - DMs will require more thought, since they are very similar to channels, but don't belong to a normal server
- Note the distinction between
servers#invite_token
andinvitations#token
. They are for permanent and temporary invitation, respectively